New way components in production planing
This commit is contained in:
@@ -206,19 +206,14 @@ function drawComponents(data) {
|
|||||||
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.productId + "\">" + el.productCode + "</a></td>");
|
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.productId + "\">" + el.productCode + "</a></td>");
|
||||||
tr.append("<td title=\"" + el.productFullName +"\">" + el.productName + "</td>");
|
tr.append("<td title=\"" + el.productFullName +"\">" + el.productName + "</td>");
|
||||||
tr.append("<td id=\"qty-" + el.productId + "\">" + el.productQty + "</td>");
|
tr.append("<td id=\"qty-" + el.productId + "\">" + el.productQty + "</td>");
|
||||||
tr.append("<td>" + el.productUnit + "</td>");
|
|
||||||
tr.append("<td id=\"state-" + el.productId + "\">" + el.productStockState + "</td>");
|
tr.append("<td id=\"state-" + el.productId + "\">" + el.productStockState + "</td>");
|
||||||
tr.append("<td id=\"ordered-" + el.productId + "\">" + el.productOrdered + "</td>");
|
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=Accounts&action=DetailView&record=" + el.productVendorId + "\">" + el.productVendorName + "</a></td>");
|
tr.append("<td>" + el.orderType + "</td>");
|
||||||
var orders = "<td>";
|
tr.append("<td>" + el.orderStatus + "</td>");
|
||||||
el.orders.forEach((o) => {
|
tr.append("<td><a target=\"_blank\" href=\"index.php?module=Accounts&action=DetailView&record=" + el.orderParentId + "\">" + el.orderParent + "</a></td>");
|
||||||
orders += "<a target=\"_blank\" href=\"index.php?module=EcmPurchaseOrders&action=DetailView&record=" + o.orderId + "\">" + o.orderNr + "</a>";
|
tr.append("<td>" + el.productKind + "</td>");
|
||||||
if (o.orderDeliveryDate.length) {
|
tr.append("<td>" + el.productBrand + "</td>");
|
||||||
orders += " (" + o.orderDeliveryDate + ") ";
|
tr.append("<td>" + el.orderSendDate + "</td>");
|
||||||
}
|
|
||||||
});
|
|
||||||
orders += "</td>";
|
|
||||||
tr.append(orders);
|
|
||||||
$("#componentsTable > tbody").append(tr);
|
$("#componentsTable > tbody").append(tr);
|
||||||
});
|
});
|
||||||
$("#componentsTable").tablesorter({
|
$("#componentsTable").tablesorter({
|
||||||
@@ -484,7 +479,7 @@ function updateRawMaterialsPositions() {
|
|||||||
$("#rawMaterialsTableSum").html(Math.ceil(sum));
|
$("#rawMaterialsTableSum").html(Math.ceil(sum));
|
||||||
}
|
}
|
||||||
function componentsTablePrototype() {
|
function componentsTablePrototype() {
|
||||||
return '<table id="componentsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllComponents" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Zamówiono</th><th>Dostawca</th><th>Zamówienie</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="componentsTableSum">0</td><td colspan="5"></td></tr></tfoot></table>'
|
return '<table id="componentsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllComponents" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>Stan</th><th>ZS E5</th><th>Typ</th><th>Status</th><th>Odbiorca</th><th>Forma</th><th>Marka</th><th>Data wysyłki</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="componentsTableSum">0</td><td colspan="8"></td></tr></tfoot></table>'
|
||||||
}
|
}
|
||||||
function rawMaterialsTablePrototype() {
|
function rawMaterialsTablePrototype() {
|
||||||
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Zamówiono</th><th>Dostawca</th><th>Zamówienie</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="rawMaterialsTableSum">0</td><td colspan="5"></td></tr></tfoot></table>'
|
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Zamówiono</th><th>Dostawca</th><th>Zamówienie</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="rawMaterialsTableSum">0</td><td colspan="5"></td></tr></tfoot></table>'
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ if (!isset($_GET['ajaxAction'])) {
|
|||||||
} else {
|
} else {
|
||||||
switch ($_GET['ajaxAction']) {
|
switch ($_GET['ajaxAction']) {
|
||||||
case 'getComponents':
|
case 'getComponents':
|
||||||
echo getComponents($_POST['ids'], $dateFrom, $dateTo);
|
echo getComponents2($_POST['ids']);
|
||||||
break;
|
break;
|
||||||
case 'getRawMaterials':
|
case 'getRawMaterials':
|
||||||
echo getRawMaterials($_POST['ids'], $_POST['cids']);
|
echo getRawMaterials($_POST['ids'], $_POST['cids']);
|
||||||
@@ -343,7 +343,6 @@ function getProductRawMaterials($productId, $quantity)
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToProductionScheduler($orderItemId) {
|
function addToProductionScheduler($orderItemId) {
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
global $current_user;
|
global $current_user;
|
||||||
@@ -378,6 +377,84 @@ function addComponentToProductionScheduler($productId, $qty) {
|
|||||||
generateUuidV4(), $qty, $current_user->id, $current_user->id, $productId);
|
generateUuidV4(), $qty, $current_user->id, $current_user->id, $productId);
|
||||||
$db->query($query);
|
$db->query($query);
|
||||||
}
|
}
|
||||||
|
function getComponents2($ids) {
|
||||||
|
$db = $GLOBALS['db'];
|
||||||
|
global $app_list_strings;
|
||||||
|
$idsString = join("','", $ids);
|
||||||
|
$productsQuery = "SELECT si.ecmproduct_id, SUM(si.quantity) as quantity, s.document_no, s.parent_id, s.parent_name,
|
||||||
|
s.id, s.type, s.status, s.send_date
|
||||||
|
FROM ecmsaleitems AS si
|
||||||
|
INNER JOIN ecmsales AS s
|
||||||
|
ON s.id = si.ecmsale_id
|
||||||
|
WHERE si.id IN ('" . $idsString . "')
|
||||||
|
GROUP BY si.ecmproduct_id";
|
||||||
|
$rows = $db->query($productsQuery);
|
||||||
|
|
||||||
|
$componentsData = array();
|
||||||
|
while ($r = $db->fetchByAssoc($rows)) {
|
||||||
|
$products = getProductComponents($r['ecmproduct_id'], $r['quantity']);
|
||||||
|
foreach ($products as $product) {
|
||||||
|
$prodQuery = sprintf("SELECT p.id, p.code, p.name, p.shape, p.brand, p.ems_qty_in_stock,
|
||||||
|
p.vendor_part_no as kind
|
||||||
|
FROM ecmproducts AS p WHERE p.id = '%s' AND p.deleted = 0", $product['ecmproduct_id']);
|
||||||
|
$p = $db->fetchByAssoc($db->query($prodQuery));
|
||||||
|
$row = array();
|
||||||
|
$row['productId'] = $p['id'];
|
||||||
|
$row['productName'] = strlen($p['name']) > 55 ? substr($p['name'], 0, 55) . "..." : $p['name'];
|
||||||
|
$row['productFullName'] = $p['name'];
|
||||||
|
$row['productCode'] = strlen($p['code']) > 20 ? substr($p['code'], 0, 20) . "..." : $p['code'];
|
||||||
|
$row['productFullCode'] = $p['code'];
|
||||||
|
$row['productKind'] = $p['kind'] != null ? $p['kind'] : "";
|
||||||
|
$row['productSize'] = $p['size'];
|
||||||
|
$row['productShape'] = $app_list_strings['ecmproducts_shape_dom'][$p['shape']];
|
||||||
|
$row['productBrand'] = $app_list_strings['ecmproducts_brand_dom'][$p['brand']];
|
||||||
|
$row['productQty'] = $product['quantity'];
|
||||||
|
$row['productStockState'] = $p['ems_qty_in_stock'] | 0;
|
||||||
|
$row['orderNo'] = $r['document_no'];
|
||||||
|
$row['orderId'] = $r['id'];
|
||||||
|
$row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
|
||||||
|
$row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']];
|
||||||
|
$row['orderParent'] = $r['parent_name'];
|
||||||
|
$row['orderParentId'] = $r['parent_id'];
|
||||||
|
$row['orderSendDate'] = $r['send_date'];
|
||||||
|
$componentsData[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($componentsData);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $row['position'] = $i;
|
||||||
|
$row['id'] = $r['id'];
|
||||||
|
$row['productName'] = strlen($r['name']) > 55 ? substr($r['name'], 0, 55) . "..." : $r['name'];
|
||||||
|
$row['productFullName'] = $r['name'];
|
||||||
|
$row['productCode'] = strlen($r['code']) > 20 ? substr($r['code'], 0, 20) . "..." : $r['code'];
|
||||||
|
$row['productFullCode'] = $r['code'];
|
||||||
|
$row['productId'] = $r['ecmproduct_id'];
|
||||||
|
$row['productQty'] = $r['quantity'];
|
||||||
|
$row['qty'] = $r['scheduledQuantity'];
|
||||||
|
$row['productKind'] = $r['kind'];
|
||||||
|
$row['productSize'] = $r['size'];
|
||||||
|
$row['productShape'] = $app_list_strings['ecmproducts_shape_dom'][$r['shape']];
|
||||||
|
$row['productBrand'] = $app_list_strings['ecmproducts_brand_dom'][$r['brand']];
|
||||||
|
$row['orderNo'] = $r['document_no'];
|
||||||
|
$row['orderId'] = $r['orderId'];
|
||||||
|
$row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
|
||||||
|
$row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']];
|
||||||
|
$row['orderParent'] = $r['parent_name'];
|
||||||
|
$row['orderParentId'] = $r['parent_id'];
|
||||||
|
$row['orderSendDate'] = $r['send_date'];
|
||||||
|
$row['orderItemId'] = $r['item_id'];
|
||||||
|
$row['description'] = strlen($r['description']) > 0 ? substr($r['description'], 0, 30) : '';
|
||||||
|
$row['fullDescription'] = $r['description'];
|
||||||
|
$row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
|
||||||
|
$row['productionDate'] = $r['production_date'] == '0000-00-00' ? '' : $r['production_date'];
|
||||||
|
$row['productStockState'] = $r['stockState'] | 0;
|
||||||
|
$row['mainProductId'] = $r['main_product_id'];
|
||||||
|
$row['mainProductCode'] = $r['main_product_code'];
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
}
|
||||||
function getProductComponents($productId, $quantity) {
|
function getProductComponents($productId, $quantity) {
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
$response = array();
|
$response = array();
|
||||||
|
|||||||
Reference in New Issue
Block a user