]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 10:02:05 +0000 (13:02 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 10:02:05 +0000 (13:02 +0300)
erp24/controllers/AutoPlannogrammaController.php

index bf947d5b505c16b62788c132af35146dc8333f12..e90bc0bd14af622ce7adc0c03765c062c44d8a37 100644 (file)
@@ -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 ?: [];
                 }
             }
         }