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

index fc8b48ec0718dadb36d5f3713d74ced0f855e20b..addc9b76082c174627b3933bbc76942beabc552d 100644 (file)
@@ -213,14 +213,22 @@ class AutoPlannogrammaController extends BaseController
                 $quantity = $value['quantity'];
                 $value['title'] = [];
 
-                if (!isset($forecast[$storeId])) {
+                if (!isset($forecast[$storeId]) || !isset($forecast[$storeId][$productId])) {
                     continue;
                 }
 
                 foreach (['offline', 'marketplace', 'online'] as $channel) {
-                    if (isset($forecast[$storeId][$channel]['share']) && is_numeric($forecast[$storeId][$channel]['share'])) {
-                        $coef = $forecast[$storeId][$channel]['share'];
-                        $value['title'][$channel] = round($quantity * $coef, 2);
+                    if (isset($forecast[$storeId][$productId][$channel]) && is_array($forecast[$storeId][$productId][$channel])) {
+                        // Суммируем все коэффициенты по группам для данного канала
+                        $coefSum = 0;
+                        foreach ($forecast[$storeId][$productId][$channel] as $coef) {
+                            if (is_numeric($coef)) {
+                                $coefSum += $coef;
+                            }
+                        }
+                        if ($coefSum > 0) {
+                            $value['title'][$channel] = round($quantity * $coefSum, 2);
+                        }
                     }
                 }
             }