X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=hooks.php;h=019b6affb13cdeefce212cc0373f2968d6bf59c2;hb=e83dd263203cb4f16aec72e084825198b5e12259;hp=dfac38971f41cab922b85bfecf2a96e186695f08;hpb=b3f0a14d9b3cdf8d029d02989031ecb4667fbcd0;p=order_line_extra.git diff --git a/hooks.php b/hooks.php index dfac389..019b6af 100644 --- a/hooks.php +++ b/hooks.php @@ -8,6 +8,8 @@ // ---------------------------------------------------------------- define ('SS_ORDERLINEX', 100<<8); +include_once('includes/db_order_lines.inc'); + class hooks_order_line_extra extends hooks { var $module_name = 'order_line_extra'; @@ -42,12 +44,15 @@ class hooks_order_line_extra extends hooks { global $db_connections; $updates = array( - 'alter_sales_order_details.sql' => array('sales_order_details', 'required_date'), + 'alter_sales_order_details.sql' => array('sales_order_details','required_date'), 'create_denorm_order_details_queue.sql' => array('denorm_order_details_queue'), - + 'create_denorm_qoh.sql' => array('denorm_qoh'), + 'create_order_summary_view.sql' => array('order_summary_view'), ); - return $this->update_databases($company, $updates, $check_only); + return $this->update_databases($company, $updates, $check_only) + && update_queue_quantities() + && update_qoh_for_item();; } function deactivate_extension($company, $check_only=true) @@ -60,5 +65,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); + } } ?>