Style held quantity in order view.
[order_line_extra.git] / includes / order_xtra_config.inc
1 <?php
2 require_once($path_to_root.'/'.'includes/date_functions.inc');
3
4 class OrderXtraConfig {
5         // Location code of the default or main location
6         static $default_location = "";
7         
8         // Array location => { delivery, parent }
9         // Location not listed are excluded
10         static $locations= array();
11         //  control how many days before are holded item 'visible'
12         static $pre_hold_offset=7;
13
14         // Return delivery date for a give location
15         static function delivery($location) {
16                         if(isset(self::$locations[$location])) {
17                         $parameters = self::$locations[$location];
18                                 return @$parameters['delivery'];
19                         }
20                         else {
21                                 return null;
22                         }
23                 }
24
25         // True if the date before hold_until_date
26         static function early($hold_until_date, $date=null) {
27                 if(!$date) $date = Today();
28                 return date_diff2($hold_until_date, $date, 'd') > OrderXtraConfig::$pre_hold_offset;
29         }
30
31         static function sql_held_condition($date=null) {
32                 if(!$date) $date = Today();
33                 $sql_date = date2sql(add_days($date, + OrderXtraConfig::$pre_hold_offset));
34                 return 'hold_until_date > '.db_escape($sql_date);
35         }
36 }
37 ?>