From 01ad361fbaeb2aa6f34d710d0e8f33745386745c Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Tue, 18 Jun 2013 20:43:05 +0100 Subject: [PATCH] Fix quantity and color wrong on dispatch --- hooks.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hooks.php b/hooks.php index 6922792..3f146c7 100644 --- a/hooks.php +++ b/hooks.php @@ -95,10 +95,15 @@ class hooks_order_line_extra extends hooks { * 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); @@ -107,7 +112,7 @@ class hooks_order_line_extra extends hooks { $row = db_fetch($result); if($row) { $available = $row['quantity']; - return array($available, 'picked'); + return array($available, 'picked limited'); } else { return array(0, ''); @@ -115,14 +120,14 @@ class hooks_order_line_extra extends hooks { } 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; @@ -133,7 +138,7 @@ class hooks_order_line_extra extends hooks { 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) { -- 2.30.2