Production improvements

This commit is contained in:
Michał Zieliński
2025-08-13 22:35:40 +02:00
parent b9e2d6d869
commit e7f76c94d6
6 changed files with 113 additions and 100 deletions

View File

@@ -57,26 +57,33 @@ function loadSchedulers($dateFrom = null, $dateTo = null, $ids = null)
$db = $GLOBALS['db'];
global $app_list_strings;
$query = "SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type,
p.code, p.name, ps.ecmproduct_id, ps.description,
si.quantity, p.vendor_part_no as kind, p.brand, p.part_no as size, p.shape,
p.ems_qty_in_stock as stockState, si.id as item_id, s.shipping_address_name, ps.production_date,
ps.quantity as scheduledQuantity, ps.id as id,
ps.main_id,
ps_main.ecmproduct_id as main_product_id,
p_main.code as main_product_code
FROM productionScheduler AS ps
LEFT JOIN ecmsaleitems AS si
ON ps.ecmsaleitem_id = si.id
LEFT JOIN ecmsales AS s
ON ps.ecmsale_id = s.id
INNER JOIN ecmproducts AS p
ON ps.ecmproduct_id = p.id
LEFT JOIN productionScheduler AS ps_main
ON ps.main_id = ps_main.id
LEFT JOIN ecmproducts AS p_main
ON ps_main.ecmproduct_id = p_main.id
WHERE ps.deleted = 0 ";
$query = "
SELECT s.id as orderId, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type,
p.code, p.name, ps.ecmproduct_id, ps.description,
si.quantity, p.vendor_part_no as kind, p.brand, p.part_no as size, p.shape,
p.ems_qty_in_stock as stockState, si.id as item_id, s.shipping_address_name, ps.production_date,
ps.quantity as scheduledQuantity, ps.id as id,
ps.main_id,
ps_main.ecmproduct_id as main_product_id,
p_main.code as main_product_code,
GROUP_CONCAT(a.name SEPARATOR ', ') as actions
FROM productionScheduler AS ps
LEFT JOIN ecmsaleitems AS si
ON ps.ecmsaleitem_id = si.id
LEFT JOIN ecmsales AS s
ON ps.ecmsale_id = s.id
INNER JOIN ecmproducts AS p
ON ps.ecmproduct_id = p.id
LEFT JOIN productionScheduler AS ps_main
ON ps.main_id = ps_main.id
LEFT JOIN ecmproducts AS p_main
ON ps_main.ecmproduct_id = p_main.id
LEFT JOIN ecmproductactions pa
ON p.id = pa.ecmproduct_id
LEFT JOIN ecmactions a
ON pa.ecmaction_id = a.id
WHERE ps.deleted = 0
GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id";
if ($dateFrom != null && $dateTo != null) {
$query .= " AND (
@@ -123,8 +130,9 @@ function loadSchedulers($dateFrom = null, $dateTo = null, $ids = null)
$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'];
$row['mainProductCode'] = strlen($r['main_product_code']) > 20 ? substr($r['main_product_code'], 0, 20) . "..." : $r['main_product_code'];
$row['mainProductFullCode'] = $r['main_product_code'];
$row['actions'] = $r['actions'];
$data[] = $row;
}
return $data;