From: Alexander Smirnov Date: Mon, 17 Feb 2025 09:44:16 +0000 (+0300) Subject: [ERP-305] редактируемые проценты X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7bba08cfd2f81cfeaf4687b3ccfbfdf1ec6d78f4;p=erp24_rep%2Fyii-erp24%2F.git [ERP-305] редактируемые проценты --- 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,