raw materials fix

This commit is contained in:
Michał Zieliński
2025-09-08 14:57:40 +02:00
parent 64a63d5748
commit f9b7c2462b
2 changed files with 6 additions and 6 deletions

View File

@@ -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("<td><a target=\"_blank\" href=\"index.php?module=EcmSales&action=DetailView&record=" + el.orderId + "\">" + el.orderNo + "</a></td>");
tr.append("<td>" + el.orderType + "</td>");
tr.append("<td>" + el.orderStatus + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.mainProductId + "\">" + el.mainProductCode + "</a></td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.mainProductId + "\">" + el.mainProductCode + "</a><input type=\"hidden\" value=" + el.mainProductId + " id=\"mainProductId-" + el.productId + "\"/></td>");
tr.append("<td>" + el.orderParent + "</td>");
tr.append("<td>" + el.productShape + "</td>");
tr.append("<td>" + el.productBrand + "</td>");
@@ -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;
if (el === mainId) {
tmp.push(prod);
}
});
ids = tmp;
}

View File

@@ -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;
}