From: marina Date: Tue, 17 Jun 2025 10:02:05 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=6527e88f2c5655e1e6a7a2a4c1942415125ba13d;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- 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 ?: []; } } }