return startMonth;
}
return startMonth;
-}
\ No newline at end of file
+}
+
+document.addEventListener("DOMContentLoaded", async () => {
+ const week = '23';
+ const month = 6;
+ const storeId = 6;
+ 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];
+ if (!weekData) return null;
+
+ const storeData = weekData[storeId];
+ if (!storeData) return null;
+
+ const productData = storeData[guid];
+ if (!productData) return null;
+
+ let tooltip = `<div><strong>Прогноз:</strong><br>`;
+ for (const [type, groups] of Object.entries(productData)) {
+ tooltip += `<div><em>${type}</em><ul>`;
+ for (const [group, value] of Object.entries(groups)) {
+ tooltip += `<li>${group}: ${value}</li>`;
+ }
+ tooltip += `</ul></div>`;
+ }
+ tooltip += `</div>`;
+
+ return tooltip;
+}