X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Forder_xtra_config.inc;h=bd7fa4d61189e1d7049f2378803c08774de1fb9a;hb=HEAD;hp=6ef484b062e52e6445088b69f1f908445b919441;hpb=a73cdbbda185c9a43ef3870f5ab95d3e861b9f87;p=order_line_extra.git diff --git a/includes/order_xtra_config.inc b/includes/order_xtra_config.inc index 6ef484b..bd7fa4d 100644 --- a/includes/order_xtra_config.inc +++ b/includes/order_xtra_config.inc @@ -1,12 +1,18 @@ { delivery, parent } // Location not listed are excluded static $locations= array(); + // control how many days before are holded item 'visible' + static $pre_hold_offset=7; + // Return delivery date for a give location static function delivery($location) { if(isset(self::$locations[$location])) { $parameters = self::$locations[$location]; @@ -16,5 +22,17 @@ class OrderXtraConfig { return null; } } + + // True if the date before hold_until_date + static function early($hold_until_date, $date=null) { + if(!$date) $date = Today(); + return date_diff2($hold_until_date, $date, 'd') > OrderXtraConfig::$pre_hold_offset; + } + + static function sql_held_condition($date=null) { + if(!$date) $date = Today(); + $sql_date = date2sql(add_days($date, + OrderXtraConfig::$pre_hold_offset)); + return 'hold_until_date > '.db_escape($sql_date); + } } ?>