From f0e56f7915bcb9d629fd4bc85a616152403ce31f Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Mon, 3 Jun 2013 18:11:16 +0100 Subject: [PATCH] Implements get_allowed_quantity hook. --- hooks.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hooks.php b/hooks.php index 8a177c4..af125eb 100644 --- a/hooks.php +++ b/hooks.php @@ -64,5 +64,20 @@ class hooks_order_line_extra extends hooks { return $this->update_databases($company, $updates, $check_only); } + + function get_allowed_quantity($detail_id, $opts) { + $location = array_shift($opts); + $date = array_shift($opts); + $qoh = array_shift($opts); + + $sql = "select quantity_before from ".TB_PREF."denorm_order_details_queue where id = $detail_id"; + $result = db_query($sql); + $quantity_before = 0; + if($row=db_fetch($result)) { + $quantity_before = $row['quantity_before']; + } + + return max($qoh - $quantity_before, 0); + } } ?> -- 2.30.2