]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 06:08:52 +0000 (09:08 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 06:08:52 +0000 (09:08 +0300)
erp24/web/js/autoplannogramma/autoplannogramma.js

index f8df96891d6c88e55544e093da2f314f0447a13d..08b4908307c18085cc4708a21f2a12b7d05dbbf9 100644 (file)
@@ -373,4 +373,49 @@ function getMonthNumberByWeek(week, year) {
         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;
+}