]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Вывод подсказки
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 22 Jul 2025 15:08:18 +0000 (18:08 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 22 Jul 2025 15:08:18 +0000 (18:08 +0300)
erp24/commands/CronController.php
erp24/controllers/AutoPlannogrammaController.php
erp24/web/js/autoplannogramma/autoplannogramma.js

index 0b8365435525369d057d2cee34a6cf409ea795d7..bc6275a385be65e27e6ab404bfaad265ca346619 100644 (file)
@@ -1667,7 +1667,7 @@ class CronController extends Controller
                         $share = isset($salesForecast[$store->id][$type]['share']) ? (float)$salesForecast[$store->id][$type]['share'] : 0;
                         $block['share'] = $share;
                         $block['quantity'] = (float) sprintf('%.2f', round($quantity * $share, 2)); // Нормализует -0 до 0
-                        $total += $block['quantity'];
+                        //$total += $block['quantity'];
                         foreach ($data as $k => $v) {
                             $val = (float)$v;
                             $groups[$k] = $val;
index fc7531f1cf17e3cae8b1f69163314d3ec2803ccb..1b86be8957d40c2255d7e405f793bdc8fbfb7245 100644 (file)
@@ -156,6 +156,7 @@ class AutoPlannogrammaController extends BaseController
             $result[$productId]['values'][] = [
                 'id' => $model['plan_id'],
                 'quantity' => (int)$quantity,
+                'old_quantity' => (int)$model['total'],
                 'is_modify' => (int)$model['modify'] ? true : false,
                 'is_min' =>  $filters['capacity_type'] == 'min' ? true : false,
                 'store_id' => (int)$model['store_id'],
index a699101fd6515621f12981928ea271a98c06c2d0..3e049c99350c8841899533f1debaeec7d6b065da 100644 (file)
@@ -160,7 +160,7 @@ $('.subcategory .list-group-item').on('click', function (e) {
                     if (!isVisible) return;
 
                     const val = valuesMap.get(storeId) || {quantity: 0, id: '', title: {}};
-                    const tooltipTitle = generateTitleString(val.title, val.is_min, val.is_modify);
+                    const tooltipTitle = generateTitleString(val.title, val.is_min, val.is_modify, val.quantity);
                     const encodedTooltip = $('<div>').text(tooltipTitle).html();
                     const modifyClass = val.is_modify ? 'corrected-input-bg' : 'auto-input-bg';
                     const td = $(`
@@ -449,10 +449,11 @@ const safeParseJson = (str) => {
     }
 };
 
-const generateTitleString = (titleRaw, isMin, isModify) => {
+const generateTitleString = (titleRaw, isMin, isModify, modify) => {
     const titleObj = typeof titleRaw === 'string' ? safeParseJson(titleRaw) : titleRaw;
     if (!titleObj || typeof titleObj !== 'object') return '';
-    if (isModify) {return 'Изменено пользователем';}
+    if (isModify) return "Корректировка: " + modify;
+
     const modificator = isMin ? 0.3 : 1;
     const typeTitles = {
         offline: 'Оффлайн',
@@ -462,33 +463,35 @@ const generateTitleString = (titleRaw, isMin, isModify) => {
         forecast: 'Расчетный прогноз',
     };
 
-    const parts = Object.entries(titleObj)
-        .map(([typeKey, typeValue]) => {
-            const title = typeTitles[typeKey] || typeKey;
-
-            if (typeof typeValue !== 'object' || typeValue === null) {
-                return '';
-            }
+    const lines = [];
+    const groupLines = [];
 
-            const quantity = typeof typeValue.quantity === 'number'
-                ? parseFloat(typeValue.quantity * modificator).toFixed(2)
-                : '0.00';
+    for (const [typeKey, typeValue] of Object.entries(titleObj)) {
+        if (typeof typeValue !== 'object' || typeValue === null) continue;
 
-            let result = `${title}: ${quantity}`;
+        const title = typeTitles[typeKey] || typeKey;
+        const quantity = typeof typeValue.quantity === 'number'
+            ? parseFloat(typeValue.quantity * modificator).toFixed(2)
+            : '0.00';
 
-            if (typeof typeValue.groups === 'object' && typeValue.groups !== null) {
-                const groupEntries = Object.entries(typeValue.groups);
-                if (groupEntries.length > 0) {
-                    const lines = groupEntries.map(
-                        ([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`
-                    );
-                    result += `\n${lines.join('\n')}`;
+        if (typeKey === 'forecast') {
+            // forecast заменяет offline
+            lines.unshift(`Оффлайн ${quantity}`);
+        } else if (typeKey === 'writeOffs') {
+            lines.push(`${title} ${quantity}`);
+        } else {
+            // Оффлайн, Онлайн, Маркетплейс
+            if (typeKey !== 'forecast') {
+                const groups = typeValue.groups;
+                if (groups && typeof groups === 'object') {
+                    for (const [groupKey, val] of Object.entries(groups)) {
+                        const groupVal = parseFloat(val).toFixed(2);
+                        groupLines.push(`${groupKey.replace(/_/g, ' ')} (${title.toLowerCase()}) ${groupVal}`);
+                    }
                 }
             }
+        }
+    }
 
-            return result;
-        })
-        .filter(Boolean);
-
-    return parts.join('\n\n');
+    return [...lines, ...groupLines].join('\n');
 };
\ No newline at end of file