Call hooks on split.
[order_line_extra.git] / includes / db_order_lines.inc
index ffb30e4b5db169af064ae70b68b615b15e2ae8bf..a0675f47b62f928e18567817e7f3ee29116afb83 100644 (file)
@@ -117,15 +117,27 @@ function clear_qoh_for_item($stock_id=null) {
 }
 
 function update_order_detail_defaults() {
+       // Set priority to current time.
        $sql  = "UPDATE ".TB_PREF."sales_order_details
                                        SET priority = now()
                                        WHERE priority is null";
        db_query($sql);
+       // Set hold_until_date to delivery_date 
        $sql  = "UPDATE ".TB_PREF."sales_order_details
                                                NATURAL JOIN  0_sales_orders 
                                        SET hold_until_date = delivery_date
                                        WHERE hold_until_date is null";
        db_query($sql);
+
+       // Set expiry date to 6 weeks + delivery date
+       // or 2 weeks + required date. Stuff with an 
+       // explicit required date should expire quickly the 
+       // required date has been missed.
+       $sql  = "UPDATE ".TB_PREF."sales_order_details
+                                       SET expiry_date = if(required_date is null, hold_until_date + INTERVAL 6 WEEK,
+                                                                                                                                                                                       required_date + INTERVAL 2 WEEK)
+                                       WHERE expiry_date is null";
+       db_query($sql);
 }
 
 ?>