Implements get_allowed_quantity hook.
authorMaxime Bourget <bmx007@gmail.com>
Mon, 3 Jun 2013 17:11:16 +0000 (18:11 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Mon, 3 Jun 2013 17:11:16 +0000 (18:11 +0100)
hooks.php

index 8a177c4128d06eac7c9af95ccf0fe092d20c796a..af125eb867198a322dbdca3069bfd274d8205f79 100644 (file)
--- 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);
     }
 
         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);
+               }
 }
 ?>
 }
 ?>