Split: add original detail_id in reference.
authorMaxime Bourget <bmx007@gmail.com>
Sun, 16 Jun 2013 12:22:08 +0000 (13:22 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sun, 16 Jun 2013 12:43:34 +0000 (13:43 +0100)
Allow splits to be grouped back.

includes/db_order_lines.inc
includes/order_lines.inc
includes/splitter.inc
order_lines_view.php

index 944a3f2f09ae0fe6d0a3ad762a0c7f19814a3ccf..ebf401441a1ab8e77213e747f7490dfad4d2f4df 100644 (file)
@@ -148,6 +148,13 @@ function update_order_detail_defaults($use_order_date=false) {
                                        WHERE expiry_date is null";
        $ok &= db_query($sql, $sql);
 
+       // Set ref to ref order. Usefull to track detail history (if move from orders)
+       $sql  = "UPDATE ".TB_PREF."sales_order_details
+                                               NATURAL JOIN  ".TB_PREF."sales_orders 
+                                       SET ref = reference
+                                       WHERE ref is null";
+       $ok &= db_query($sql);
+
        return $ok;
 }
 
index d961b8926fc955c4742b29b96097d336a3003d53..1759c886bfeabd40a12c9dedf936cac5c76c0e2a 100644 (file)
@@ -253,7 +253,8 @@ function get_order_details_extra($customer_id, $location, $item_like, $order_id)
        , hold_until_date
        , required_date
        , expiry_date
-       ,comment";
+       ,comment
+       ,ref";
        $from =  TB_PREF."sales_order_details sod
        JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no
                AND so.trans_type = sod.trans_type
index f8090ac1ddd7e2caf790345e28afb1a3d9c01101..782e77d89eb907c8db05a5e2a6cf58165636da03 100644 (file)
@@ -152,7 +152,9 @@ class Splitter extends OrderAction {
                                ->add($detail['stk_code'], 'stk_code')
                                ->add($detail['description'], 'description')
                                ->add($detail['unit_price'], 'unit_price', false)
-                               ->add($detail['discount_percent'], 'discount_percent', false);
+                               ->add($detail['discount_percent'], 'discount_percent', false)
+                               ->add($detail['ref'].":split:".$detail['id'], 'ref')
+                       ;
 
                foreach($splits as $split) {
                        $set = new SqlSet($common_set);
index 1dc12976d0ae0ce7e8b79cb1bec8155acbe40fd0..ea8b128ca5a725b060fc2917ccf5b96746a899ee 100644 (file)
@@ -132,6 +132,7 @@ if($customer_id) {
                ,_("Require By") => array('fun' => 'input_required_date_details', 'ord' => '')
                ,_("Expiry Date") => array('fun' => 'input_expiry_date_details', 'ord' => '')
                ,_("Comment") => array('fun' => 'input_comment_details', 'ord' => '')
+               ,_("Reference") => array( 'ord' => '')
                ,'<input id="checkAll" type="checkbox">' => array('fun' => 'input_check_details')
        );
 }