From 6b9a8269143539161e38420721e97c02397aaf80 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Tue, 22 Jul 2025 18:08:18 +0300 Subject: [PATCH] =?utf8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=BF=D0=BE?= =?utf8?q?=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronController.php | 2 +- .../AutoPlannogrammaController.php | 1 + .../js/autoplannogramma/autoplannogramma.js | 55 ++++++++++--------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index 0b836543..bc6275a3 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -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; diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index fc7531f1..1b86be89 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -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'], diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index a699101f..3e049c99 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -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 = $('
').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 -- 2.39.5