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

index 1e9668e1d2eb1abe9ee722d870b9835d2912ca3b..309a9825c9e02d878ae7f849213551973bbc0794 100644 (file)
@@ -223,7 +223,7 @@ class AutoPlannogrammaController extends BaseController
                     if (isset($channelData['share']) && is_numeric($channelData['share'])) {
                         $titleData = [round($quantity * $channelData['share'], 2)];
                     }
-                    
+
                     if (isset($productData['product_id']) && isset($forecast[$storeId][$productData['product_id']][$channel])) {
                         $details = $forecast[$storeId][$productData['product_id']][$channel];
                         $total = array_sum($details);
index 37df44499539915791d2a785a726699a41651176..9cfff0f67bdf2df25742fb97deb10b839e7f077f 100644 (file)
@@ -386,21 +386,30 @@ const generateTitleString = (titleObj) => {
     if (!titleObj || typeof titleObj !== 'object') return '';
 
     const typeTitles = {
-        offline: 'Оффлайн',
-        online: 'Онлайн',
-        marketplace: 'Маркетплейс'
+        offline: '📦 Оффлайн',
+        online: '🌐 Онлайн',
+        marketplace: '🛒 Маркетплейс'
     };
 
     const parts = Object.entries(titleObj)
         .map(([typeKey, typeValue]) => {
             const title = typeTitles[typeKey] || typeKey;
+
+            // Handle case where typeValue is an array [numeric_value, {details: {...}}]
+            if (Array.isArray(typeValue) && typeValue.length >= 1) {
+                const numericValue = parseFloat(typeValue[0]);
+                const details = typeValue[1]?.details || {};
+                const lines = Object.entries(details)
+                    .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`);
+                return `${title}: ${numericValue.toFixed(2)}${lines.length ? '\n' + lines.join('\n') : ''}`;
+            }
+
+            // Handle case where typeValue is a number (for share-only, if applicable)
             if (typeof typeValue === 'number') {
                 return `${title}: ${typeValue.toFixed(2)}`;
             }
-            if (!typeValue || typeof typeValue !== 'object' || !typeValue[0]) return '';
-            const lines = Object.entries(typeValue[1]?.details || {})
-                .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`);
-            return `${title}: ${parseFloat(typeValue[0]).toFixed(2)}\n${lines.join('\n')}`;
+
+            return ''; // Skip invalid or empty values
         })
         .filter(Boolean);