From: Maxime Bourget Date: Tue, 4 Jun 2013 21:06:52 +0000 (+0100) Subject: Add hook to update cache on db write. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=ee3ba0c774916a4a2cf3c1fdd56c1cc9328137fe;p=order_line_extra.git Add hook to update cache on db write. --- diff --git a/hooks.php b/hooks.php index 019b6af..0bf5ad1 100644 --- a/hooks.php +++ b/hooks.php @@ -80,5 +80,17 @@ 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); + } + + } } ?> diff --git a/item_schedule.php b/item_schedule.php index 5e47ec5..accb8da 100644 --- a/item_schedule.php +++ b/item_schedule.php @@ -51,7 +51,7 @@ else { } if (list_updated('stock_id') || in_ajax()) $Ajax->activate('item_schedule') ; -else update_queue_quantities() && update_qoh_for_item(); +//else update_queue_quantities() && update_qoh_for_item(); //if (!@$_GET['popup'])