* If an order has been selected to be picked up, only the items and the quantity picked up
* needs to be available.
*/
- $sql = "SELECT count(*)
- FROM 0_sales_order_details
+
+ /* We don't only need to check if the detail has been pick but check
+ * that any item in the same order have or not
+ */
+ $sql = "SELECT *
+ FROM ".TB_PREF."sales_order_details sod
+ JOIN ".TB_PREF."topick p ON (sod.id = p.detail_id)
WHERE order_no IN (SELECT distinct order_no
- FROM 0_sales_order_details
+ FROM ".TB_PREF."sales_order_details
WHERE id = $detail_id)";
$result = db_query($sql);
$row = db_fetch($result);
if($row) {
$available = $row['quantity'];
- return array($available, 'picked');
+ return array($available, 'picked limited');
}
else {
return array(0, '');
}
else {
- return get_allowed_quantity_from_priority($detail_id, $location, $date, $qoh);
+ return $this->get_allowed_quantity_from_priority($detail_id, $location, $date, $qoh);
}
}
function get_allowed_quantity_from_priority($detail_id, $location, $date, $qoh) {
$sql = "SELECT quantity_before, hold_until_date
FROM ".TB_PREF."denorm_order_details_queue
- NATURAL JOIN ".TB_PREF."sales_order_details
+ JOIN ".TB_PREF."sales_order_details USING (id)
WHERE id = $detail_id";
$result = db_query($sql);
$quantity_before = 0;
if(OrderXtraConfig::early($hold_until, $date)) return array(0, 'early');
}
- return array(max($qoh - $quantity_before, 0), '');
+ return array(max($qoh - $quantity_before, 0), 'limited');
}
function db_postwrite($cart, $trans_type) {