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

index 3c52596c349d6a85d9b18d777a9865eeaa92fcd8..bdcb251fa2743bd049424a6f84470438c98c1403 100644 (file)
@@ -141,6 +141,7 @@ class AutoPlannogrammaController extends BaseController
                     'product_id' => $productId,
                     'name' => $productName,
                     'values' => [],
+                    'title' => [],
                 ];
             }
 
@@ -151,6 +152,26 @@ class AutoPlannogrammaController extends BaseController
             ];
         }
 
+        $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year']);
+
+        foreach ($result as $productId => &$productData) {
+            $guid = $productIdToGuid[$productId] ?? null;
+            if (!$guid) continue;
+
+            foreach ($productData['values'] as $value) {
+                $storeId = $value['store_id'];
+
+                if (!isset($forecast[$storeId][$guid])) continue;
+                $forecastData = $forecast[$storeId][$guid];
+
+                foreach ($forecastData as $type => $groups) {
+                    foreach ($groups as $group => $amount) {
+                        $productData['title'][$type][$group] = $amount;
+                    }
+                }
+            }
+        }
+
         return array_values($result);
     }
 
index 15d9c773fd2fe2d40d1f563fc2e82a71234c9551..ad28f695cb736ae1d808ae1fd0b14b04252c8575 100644 (file)
@@ -2786,7 +2786,7 @@ class AutoPlannogrammaService
         return $pricesMap;
     }
 
-    public function getWeeklyBouquetProductsForecast($month, $year, $storeId)
+    public function getWeeklyBouquetProductsForecast($month, $year, $storeId = null)
     {
         $matrixGroups = ArrayHelper::map(
             MatrixBouquetForecast::find()->select(['group'])->distinct()->asArray()->all(),
@@ -2797,6 +2797,7 @@ class AutoPlannogrammaService
         $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId, $matrixGroups);
         $weekShares = $this->getHistoricalSpeciesShareByWeek($date);
         $flatData = $result['flatData'];
+
         $weekIndex = [];
         foreach ($weekShares as $shareRow) {
             $key = implode('|', [
index 1ddaed688b4359613ed26408c6d4a1ba09cff7ec..725ae3dda8aa446926a79d225ca6311ae38c04b2 100644 (file)
@@ -57,6 +57,7 @@ $('.subcategory .list-group-item').on('click', function (e) {
     const subcategory = $link.data('subcategory');
     const $row = $link.closest('tr');
     const filters = getFilterData();
+    filters['month'] = getMonthByWeek(filters['week'], filters['year'], true)
     filters.category = category;
     filters.subcategory = subcategory;
 
@@ -227,33 +228,6 @@ function applyStoreFilter() {
     });
 }
 
-$(document).on('click', '.input', function () {
-    const $el = $(this);
-
-    if ($el.data('tooltip-loaded')) return;
-
-    const storeId = $el.data('store_id');
-    const year = $('#year').val();
-    const week = $('#week').val();
-    const month = getMonthByWeek(week, year, true);
-
-    const data = {
-        storeId: storeId,
-        year: year,
-        week: week,
-        month: month
-    };
-
-    $.get('/auto-plannogramma/weekly-bouquet-products-forecast', data, (response) => {
-        const titleText = typeof response === 'object' ? JSON.stringify(response) : response;
-        $el.attr('title', titleText).data('tooltip-loaded', true);
-
-        if ($el.tooltip) {
-            $el.tooltip('dispose').tooltip();
-        }
-    });
-});
-
 $('.btn-save').on('click', function () {
     const changedValues = [];
     let hasErrors = false;
@@ -375,27 +349,6 @@ function getMonthNumberByWeek(week, year) {
     return startMonth;
 }
 
-document.addEventListener("DOMContentLoaded", async () => {
-    const week = '23';
-    const month = 6;
-    const storeId = '';
-    const year = new Date().getFullYear();
-
-    if (!week) return;
-
-    try {
-        const response = await fetch(`/auto-plannogramma/weekly-bouquet-products-forecast?month=${month}&year=${year}&week=${week}&storeId=${storeId}`);
-        const json = await response.json();
-        if (json.success && json.data) {
-            Object.assign(forecastCache, json.data);
-        }
-        console.log(json);
-        console.log(forecastCache);
-    } catch (e) {
-        console.error("Ошибка загрузки прогнозов:", e);
-    }
-});
-
 function buildForecastTooltip(week, storeId, guid) {
     console.log(week, storeId, guid);
     const weekData = forecastCache[week];