From: Maxime Bourget Date: Sat, 8 Jun 2013 15:25:41 +0000 (+0100) Subject: Call hooks on split. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=cac7335b5528b1eca9cc02ca7bc9760a080b676f;p=order_line_extra.git Call hooks on split. --- diff --git a/hooks.php b/hooks.php index 818fe7a..1df1ef5 100644 --- a/hooks.php +++ b/hooks.php @@ -83,7 +83,7 @@ class hooks_order_line_extra extends hooks { } function db_postwrite($cart, $trans_type) { - if(!is_a($cart, "Cart") ) return; + if(is_a($cart, "Cart")) { // It's a cart. Find all the stock_id and update the cache table foreach($cart->line_items as $line_no => $item) { @@ -91,10 +91,11 @@ class hooks_order_line_extra extends hooks { update_queue_quantity_for_item($stock_id); update_qoh_for_item($stock_id); } + } // update null fields of new entered orders. // - $types = array(ST_SALESORDER); + $types = array(ST_SALESORDER, 'order_xtra'); if(in_array($trans_type, $types)) update_order_detail_defaults(); } diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 9366ecb..cbaedc1 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -71,7 +71,10 @@ function split_order_details() { if(!isset($_POST['Split']) || $_POST['Split'] != 'Split') return; $splitter = new Splitter($_POST); begin_transaction(); + $cart = null; + hook_db_prewrite($cart, 'order_xtra'); if($splitter->splitAll()) display_warning("Items have been split."); + hook_db_postwrite($cart, 'order_xtra'); commit_transaction(); }