X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=hooks.php;h=818fe7a3fc2ac3219151eb0efba5f05e8012fbfa;hb=514ad9dfb6f8ea147b9cb9ee9b89d2b0b485b607;hp=af125eb867198a322dbdca3069bfd274d8205f79;hpb=f0e56f7915bcb9d629fd4bc85a616152403ce31f;p=order_line_extra.git diff --git a/hooks.php b/hooks.php index af125eb..818fe7a 100644 --- a/hooks.php +++ b/hooks.php @@ -45,8 +45,10 @@ class hooks_order_line_extra extends hooks { $updates = array( 'alter_sales_order_details.sql' => array('sales_order_details','required_date'), + 'alter_sales_order_details_2.sql' => array('sales_order_details','expiry_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) @@ -79,5 +81,33 @@ class hooks_order_line_extra extends hooks { return max($qoh - $quantity_before, 0); } + + function db_postwrite($cart, $trans_type) { + if(!is_a($cart, "Cart") ) return; + + // It's a cart. Find all the stock_id and update the cache table + foreach($cart->line_items as $line_no => $item) { + $stock_id = $item->stock_id; + update_queue_quantity_for_item($stock_id); + update_qoh_for_item($stock_id); + } + + // update null fields of new entered orders. + // + $types = array(ST_SALESORDER); + if(in_array($trans_type, $types)) update_order_detail_defaults(); + + } + + + function db_prevoid($cart, $trans_type) { + // Simple version, rebuild everything + $types = array(ST_CUSTCREDIT, ST_CUSTDELIVERY, ST_INVADJUST, ST_PURCHORDER, ST_WORKORDER, ST_MANUISSUE, + ST_SALESORDER, ST_SALESQUOTE, ST_MANURECEIVE); + if(in_array($trans_type, $types)) { + update_queue_quantities(); + update_qoh_for_item(); + } + } } ?>