From 26513f71995aae1b384e8ceb5a011bb36a506c0a Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 13:06:27 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../AutoPlannogrammaController.php | 2 +- .../js/autoplannogramma/autoplannogramma.js | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index 1e9668e1..309a9825 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -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); diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index 37df4449..9cfff0f6 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -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); -- 2.39.5