From f9b7c2462b6c745d8c2380b03555bffcdb6354a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Mon, 8 Sep 2025 14:57:40 +0200 Subject: [PATCH] raw materials fix --- .../BimIT-Reports/productsBySales/productsBySales.js | 10 +++++----- .../BimIT-Reports/productsBySales/productsBySales.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js index ac27f53d..6b5e7f8d 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js @@ -162,7 +162,6 @@ function SetTab(tab_name) { } function getComnponents() { - console.log("getComnponents"); var ids = []; $('input.allCheck:checkbox:checked').each(function () { // check if this element is visible on site @@ -184,9 +183,7 @@ function getComnponents() { ids }, success: function (data) { - console.log(data); var result = JSON.parse(data); - console.log(result); Components = result; drawComponents(result); updateComponentsPositions(); @@ -219,7 +216,7 @@ function drawComponents(data) { tr.append("" + el.orderNo + ""); tr.append("" + el.orderType + ""); tr.append("" + el.orderStatus + ""); - tr.append("" + el.mainProductCode + ""); + tr.append("" + el.mainProductCode + ""); tr.append("" + el.orderParent + ""); tr.append("" + el.productShape + ""); tr.append("" + el.productBrand + ""); @@ -283,10 +280,13 @@ function getRawMaterials(previousTab) { var tmp = []; ids.forEach(el => { var qty = parseFloat($("#qty-" + el).html().trim()); + var mainId = $("#mainProductId-" + el).val(); var prod = {}; prod.ecmproduct_id = el; prod.quantity = qty; - tmp.push(prod); + if (el === mainId) { + tmp.push(prod); + } }); ids = tmp; } diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php index dc8cb921..629bf3c3 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php @@ -324,7 +324,7 @@ function getRawMaterials2($ids, $type) $grouppedRawMaterials = array_reduce($rawMaterialsData, function ($carry, $item) { if (isset($carry[$item['ecmproduct_id']])) { - $carry[$item['ecmproduct_id']]['productQty'] += $item['quantity']; + $carry[$item['ecmproduct_id']]['quantity'] += $item['quantity']; } else { $carry[$item['ecmproduct_id']] = $item; }