From 5546d633e88f0c4ef160eca9cf5f884d244c7d20 Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 16 Jun 2025 16:22:59 +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 | 18 ++----- .../js/autoplannogramma/autoplannogramma.js | 51 +++++++++++++++---- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index d124e048..3c52596c 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -1750,22 +1750,16 @@ class AutoPlannogrammaController extends BaseController ]); } - public function actionWeeklyBouquetProductsForecast() + public function actionWeeklyBouquetProductsForecast($storeId, $month, $year, $week) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - $request = Yii::$app->request; - $storeIdRequest = $request->get('storeId'); - $monthRequest = $request->get('month'); - $yearRequest = $request->get('year'); - $weekRequest = $request->get('week'); - - if (!$monthRequest || !$yearRequest || $weekRequest === null) { + if (!$month || !$year || $week === null) { return ['success' => false, 'message' => 'Нет параметров']; } $service = new AutoPlannogrammaService(); - $result = $service->getWeeklyBouquetProductsForecast($monthRequest, $yearRequest, $storeIdRequest); + $result = $service->getWeeklyBouquetProductsForecast($month, $year, $storeId); if (!is_array($result)) { return ['success' => false, 'message' => 'Ошибка структуры данных']; @@ -1785,8 +1779,8 @@ class AutoPlannogrammaController extends BaseController } - if ($weekRequest !== null) { - $week = (int)$weekRequest; + if ($week !== null) { + $week = (int)$week; $grouped = isset($grouped[$week]) ? [$week => $grouped[$week]] : []; } @@ -1794,8 +1788,6 @@ class AutoPlannogrammaController extends BaseController 'success' => true, 'data' => $grouped, ]; - - } public function actionGetSubcategories(string $category, int $year, int $week): array diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index e1b77ff2..f8df9689 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -99,7 +99,7 @@ $('.subcategory .list-group-item').on('click', function (e) { const isVisible = $(`table tbody tr:first td:eq(${index})`).is(':visible'); if (!isVisible) return; - const val = valuesMap[storeId] || { quantity: '', id: '' }; + const val = valuesMap[storeId] || {quantity: '', id: ''}; const td = $(` @@ -140,7 +140,7 @@ $('.category .list-group-item').on('click', function () { const year = $('#year').val(); const week = $('#week').val(); $('.loader-overlay').removeClass('d-none'); - $.get('/auto-plannogramma/get-subcategories', { category, year, week }, function (subcategories) { + $.get('/auto-plannogramma/get-subcategories', {category, year, week}, function (subcategories) { const subMap = {}; subcategories.forEach(sub => { subMap[sub.name] = sub.hasdata; @@ -227,6 +227,33 @@ 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; @@ -313,18 +340,24 @@ $('.btn-apply').on('click', function () { }); $('.btn-reset').on('click', resetStoreFilter); -function getMonthByWeek(week, year) { - if (!(week) || !(year)) { +function getMonthByWeek(week, year, returnNumber = false) { + if (!week || !year) { return; } + const start = new Date(year, 0, 4 + (week - 1) * 7 - (new Date(year, 0, 4).getDay() || 7) + 1); const end = new Date(start.getTime() + 6 * 24 * 60 * 60 * 1000); - const months = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']; - const startMonth = months[start.getMonth()]; - const endMonth = months[end.getMonth()]; - - return startMonth === endMonth ? startMonth : `${startMonth} - ${endMonth}`; + if (returnNumber) { + const startMonthNum = start.getMonth() + 1; // от 1 до 12 + const endMonthNum = end.getMonth() + 1; + return startMonthNum === endMonthNum ? startMonthNum : `${startMonthNum}-${endMonthNum}`; + } else { + const months = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']; + const startMonth = months[start.getMonth()]; + const endMonth = months[end.getMonth()]; + return startMonth === endMonth ? startMonth : `${startMonth} - ${endMonth}`; + } } function getMonthNumberByWeek(week, year) { -- 2.39.5