raw materials fix
This commit is contained in:
@@ -162,7 +162,6 @@ function SetTab(tab_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getComnponents() {
|
function getComnponents() {
|
||||||
console.log("getComnponents");
|
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$('input.allCheck:checkbox:checked').each(function () {
|
$('input.allCheck:checkbox:checked').each(function () {
|
||||||
// check if this element is visible on site
|
// check if this element is visible on site
|
||||||
@@ -184,9 +183,7 @@ function getComnponents() {
|
|||||||
ids
|
ids
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log(data);
|
|
||||||
var result = JSON.parse(data);
|
var result = JSON.parse(data);
|
||||||
console.log(result);
|
|
||||||
Components = result;
|
Components = result;
|
||||||
drawComponents(result);
|
drawComponents(result);
|
||||||
updateComponentsPositions();
|
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><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.orderType + "</td>");
|
||||||
tr.append("<td>" + el.orderStatus + "</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.orderParent + "</td>");
|
||||||
tr.append("<td>" + el.productShape + "</td>");
|
tr.append("<td>" + el.productShape + "</td>");
|
||||||
tr.append("<td>" + el.productBrand + "</td>");
|
tr.append("<td>" + el.productBrand + "</td>");
|
||||||
@@ -283,10 +280,13 @@ function getRawMaterials(previousTab) {
|
|||||||
var tmp = [];
|
var tmp = [];
|
||||||
ids.forEach(el => {
|
ids.forEach(el => {
|
||||||
var qty = parseFloat($("#qty-" + el).html().trim());
|
var qty = parseFloat($("#qty-" + el).html().trim());
|
||||||
|
var mainId = $("#mainProductId-" + el).val();
|
||||||
var prod = {};
|
var prod = {};
|
||||||
prod.ecmproduct_id = el;
|
prod.ecmproduct_id = el;
|
||||||
prod.quantity = qty;
|
prod.quantity = qty;
|
||||||
tmp.push(prod);
|
if (el === mainId) {
|
||||||
|
tmp.push(prod);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ids = tmp;
|
ids = tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ function getRawMaterials2($ids, $type)
|
|||||||
|
|
||||||
$grouppedRawMaterials = array_reduce($rawMaterialsData, function ($carry, $item) {
|
$grouppedRawMaterials = array_reduce($rawMaterialsData, function ($carry, $item) {
|
||||||
if (isset($carry[$item['ecmproduct_id']])) {
|
if (isset($carry[$item['ecmproduct_id']])) {
|
||||||
$carry[$item['ecmproduct_id']]['productQty'] += $item['quantity'];
|
$carry[$item['ecmproduct_id']]['quantity'] += $item['quantity'];
|
||||||
} else {
|
} else {
|
||||||
$carry[$item['ecmproduct_id']] = $item;
|
$carry[$item['ecmproduct_id']] = $item;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user