From fa5121a0725f1f766ebaea9c39a9bbdf42cc30ec Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 10:20:12 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../AutoPlannogrammaController.php | 21 ++++++++ erp24/services/AutoPlannogrammaService.php | 3 +- .../js/autoplannogramma/autoplannogramma.js | 49 +------------------ 3 files changed, 24 insertions(+), 49 deletions(-) diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index 3c52596c..bdcb251f 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -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); } diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index 15d9c773..ad28f695 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -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('|', [ diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index 1ddaed68..725ae3dd 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -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]; -- 2.39.5