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

index a43f89c3a579ec172df0cdede93a1e18b9825810..0be4834db004308f0ac293859be186cad329d4ee 100644 (file)
@@ -150,7 +150,7 @@ class AutoPlannogrammaController extends BaseController
             ];
         }
 
-        $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year']);
+        $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year'], null, $filters['week']);
 var_dump($forecast);die();
 
         foreach ($result as $productId => &$productData) {
index ad28f695cb736ae1d808ae1fd0b14b04252c8575..17eff12bc781d88530da17eb7f74a91cdd4c6255 100644 (file)
@@ -2786,14 +2786,16 @@ class AutoPlannogrammaService
         return $pricesMap;
     }
 
-    public function getWeeklyBouquetProductsForecast($month, $year, $storeId = null)
+    public function getWeeklyBouquetProductsForecast($month, $year, $storeId = null, $weekNumber = null)
     {
         $matrixGroups = ArrayHelper::map(
             MatrixBouquetForecast::find()->select(['group'])->distinct()->asArray()->all(),
             'group',
             'group'
         );
+
         $date = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01';
+
         $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId, $matrixGroups);
         $weekShares = $this->getHistoricalSpeciesShareByWeek($date);
         $flatData = $result['flatData'];
@@ -2824,6 +2826,10 @@ class AutoPlannogrammaService
             }
 
             foreach ($weekIndex[$key] as $weekShare) {
+                if ($weekNumber !== null && (int)$weekShare['week'] !== (int)$weekNumber) {
+                    continue; // фильтрация по неделе
+                }
+
                 $weeklyForecasts[] = [
                     'store_id'       => $item['store_id'],
                     'category'       => $item['category'],
@@ -2840,8 +2846,7 @@ class AutoPlannogrammaService
                 ];
             }
         }
-        return $weeklyForecasts;
 
+        return $weeklyForecasts;
     }
-
 }
\ No newline at end of file