From 6527e88f2c5655e1e6a7a2a4c1942415125ba13d Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 13:02:05 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/AutoPlannogrammaController.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index bf947d5b..e90bc0bd 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -218,24 +218,24 @@ class AutoPlannogrammaController extends BaseController foreach (['offline', 'marketplace', 'online'] as $channel) { $channelData = $forecast[$storeId][$channel] ?? []; + $titleData = []; - // Prioritize share if it exists + // Add share-based value if it exists if (isset($channelData['share']) && is_numeric($channelData['share'])) { - $value['title'][$channel] = round($quantity * $channelData['share'], 2); - continue; // Skip product-specific data if share exists + $titleData = [round($quantity * $channelData['share'], 2)]; } - // Use product-specific forecast if available + // Add product-specific details if available if (isset($productData['product_id']) && isset($forecast[$storeId][$productData['product_id']][$channel])) { $details = $forecast[$storeId][$productData['product_id']][$channel]; $total = array_sum($details); - $value['title'][$channel] = [ - round($quantity * $total, 2), + $titleData = [ + isset($titleData[0]) ? $titleData[0] : round($quantity * $total, 2), 'details' => array_map(fn($val) => round($val, 2), $details), ]; - } else { - $value['title'][$channel] = []; // Empty if neither share nor details exist } + + $value['title'][$channel] = $titleData ?: []; } } } -- 2.39.5