X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb_order_lines.inc;h=a0675f47b62f928e18567817e7f3ee29116afb83;hb=ee3469d3ffd74d2a6be87d3dd0a9541a14bcdfde;hp=0719ef461a8f91c94b0913fac9334c3fadcb44bc;hpb=88d189f48b92fc89ae9b98362926756937c0f7ad;p=order_line_extra.git diff --git a/includes/db_order_lines.inc b/includes/db_order_lines.inc index 0719ef4..a0675f4 100644 --- a/includes/db_order_lines.inc +++ b/includes/db_order_lines.inc @@ -117,10 +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"; - return db_query($sql); + 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); } ?>