";
}
-function get_order_details_extra($customer_id) {
+function get_order_details_extra($customer_id, $location) {
$sql = "SELECT sod.id
, so.order_no
, stk_code
- , quantity - qty_sent
+ , sod.quantity - qty_sent
+ , GREATEST(0, LEAST(qoh.quantity - quantity_before, sod.quantity - qty_sent))
+ , quantity_before
, required_date
,comment
FROM ".TB_PREF."sales_order_details sod
AND so.trans_type = ".ST_SALESORDER."
AND so.debtor_no = $customer_id
)
- WHERE quantity > qty_sent
+ JOIN ".TB_PREF."denorm_qoh qoh ON (stock_id = stk_code AND loc_code = '$location')
+ JOIN ".TB_PREF."denorm_order_details_queue d ON (d.id = sod.id)
+ WHERE sod.quantity > qty_sent
";
return $sql;