Set default priority on db_write hook.
authorMaxime Bourget <bmx007@gmail.com>
Thu, 6 Jun 2013 19:43:58 +0000 (20:43 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Thu, 6 Jun 2013 19:43:58 +0000 (20:43 +0100)
hooks.php
includes/db_order_lines.inc

index 1773852a2b2f4cfe15db15141e71fb906794a901..e51de866d27acbe552744c9a0298b7e62d014652 100644 (file)
--- a/hooks.php
+++ b/hooks.php
@@ -90,6 +90,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);
+               if(in_array($trans_type, $types)) update_order_detail_defaults();
        
                }
 
index f4913bf262c644acc1db814ff99b79d2df724e92..0719ef461a8f91c94b0913fac9334c3fadcb44bc 100644 (file)
@@ -116,4 +116,11 @@ function clear_qoh_for_item($stock_id=null) {
        return db_query($sql, 'Error when trying to clean ".TB_PREF."denorm_qoh');
 }
 
+function update_order_detail_defaults() {
+       $sql  = "UPDATE ".TB_PREF."sales_order_details
+                                       SET priority = now()
+                                       WHERE priority is null";
+       return db_query($sql);
+}
+
 ?>