From: marina Date: Tue, 17 Jun 2025 07:20:12 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=fa5121a0725f1f766ebaea9c39a9bbdf42cc30ec;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- 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];