From 7bba08cfd2f81cfeaf4687b3ccfbfdf1ec6d78f4 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Mon, 17 Feb 2025 12:44:16 +0300 Subject: [PATCH] =?utf8?q?[ERP-305]=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?utf8?q?=D0=B8=D1=80=D1=83=D0=B5=D0=BC=D1=8B=D0=B5=20=D0=BF=D1=80=D0=BE?= =?utf8?q?=D1=86=D0=B5=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/views/category-plan/index.php | 6 +++--- erp24/web/js/category-plan/index.js | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/erp24/views/category-plan/index.php b/erp24/views/category-plan/index.php index 24615c83..7376ad23 100644 --- a/erp24/views/category-plan/index.php +++ b/erp24/views/category-plan/index.php @@ -186,20 +186,20 @@ input[readonly] { $data = $categoryPlan[$type]['offline']; $p1 = $offline_sale <= 0 ? 0 : 1.0 * $data / $offline_sale * 100; ?> - % + 'number', 'style' => 'max-width: 80px;', 'readonly' => !$isEditable, 'onchange' => 'editProcent(this, 1);']) ?>% 'number', 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?> - % + 'number', 'style' => 'max-width: 80px;', 'readonly' => !$isEditable, 'onchange' => 'editProcent(this, 2);']) ?>% 'number', 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?> ?> - % + 'number', 'style' => 'max-width: 80px;', 'readonly' => !$isEditable, 'onchange' => 'editProcent(this, 3);']) ?>% 'number', 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?> diff --git a/erp24/web/js/category-plan/index.js b/erp24/web/js/category-plan/index.js index 4734a5db..df3c96d1 100644 --- a/erp24/web/js/category-plan/index.js +++ b/erp24/web/js/category-plan/index.js @@ -58,9 +58,9 @@ function editField(zis) { const p1 = tr.querySelector("[data-p1]"); const p2 = tr.querySelector("[data-p2]"); const p3 = tr.querySelector("[data-p3]"); - p1.textContent = (p1.dataset.offline > 0 ? Math.round(100.0 * offline / +p1.dataset.offline) : 0) + '%'; - p2.textContent = (p2.dataset.online > 0 ? Math.round(100.0 * internet_shop / +p2.dataset.online) : 0) + '%'; - p3.textContent = (p3.dataset.writeoffs > 0 ? Math.round(100.0 * write_offs / +p3.dataset.writeoffs) : 0) + '%'; + p1.querySelector('input').value = (p1.dataset.offline > 0 ? Math.round(100.0 * offline / +p1.dataset.offline) : 0); + p2.querySelector('input').value = (p2.dataset.online > 0 ? Math.round(100.0 * internet_shop / +p2.dataset.online) : 0); + p3.querySelector('input').value = (p3.dataset.writeoffs > 0 ? Math.round(100.0 * write_offs / +p3.dataset.writeoffs) : 0); $.ajax({ method: "POST", @@ -83,6 +83,19 @@ function editField(zis) { } } +function editProcent(zis, num) { + const tr = zis.parentNode.parentNode; + const p1 = tr.querySelector("[data-p1]"); + const p2 = tr.querySelector("[data-p2]"); + const p3 = tr.querySelector("[data-p3]"); + switch (num) { + case 1: tr.querySelector("input[name=offline]").value = Math.round(p1.querySelector('input').value / 100.0 * (+p1.dataset.offline)); break; + case 2: tr.querySelector("input[name=internet_shop]").value = Math.round(p2.querySelector('input').value / 100.0 * (+p2.dataset.online)); break; + case 3: tr.querySelector("input[name=write_offs]").value = Math.round(p3.querySelector('input').value / 100.0 * (+p3.dataset.writeoffs)); break; + } + editField(zis); +} + $(document).ready(() => { $('#categoryPlan').DataTable({ sorting: false, -- 2.39.5