'product_id' => $productId,
'name' => $productName,
'values' => [],
+ 'title' => [],
];
}
];
}
+ $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);
}
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(),
$result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId, $matrixGroups);
$weekShares = $this->getHistoricalSpeciesShareByWeek($date);
$flatData = $result['flatData'];
+
$weekIndex = [];
foreach ($weekShares as $shareRow) {
$key = implode('|', [
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;
});
}
-$(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;
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];