schedule[0]=array('start_time'=>0,'target_day'=>3); $this->schedule[1]=array('start_time'=>13,'target_day'=>4); $this->schedule[2]=array('start_time'=>13,'target_day'=>5); $this->schedule[3]=array('start_time'=>13,'target_day'=>6); $this->schedule[4]=array('start_time'=>15,'target_day'=>2); $this->schedule[5]=array('start_time'=>0,'target_day'=>2); $this->schedule[6]=array('start_time'=>14,'target_day'=>3); } function EarliestArrival(){ $current_day=date('w'); $current_time=date('G'); //any time of the hour will be considered past the hour $prev_day=($current_day!=0) ? $current_day-1 : 6; $target=($current_time>=$this->schedule[$current_day]['start_time']) ? $this->schedule[$current_day]['target_day'] : $this->schedule[$prev_day]['target_day']; $days_needed=($current_day<=$target) ? $target-$current_day : (7-$current_day)+$target; $this->earliest_date=mktime(0,0,0,date('m'),date('d')+$days_needed,date('Y')); } function DateStillValid($shipdate){ if(!isset($this->earliest_date))$this->EarliestArrival(); $result=($this->earliest_date>$shipdate) ? false : true; return $result; } function DateInfo($datestamp){ //This functions returns an array containing info about whether a date is valid for delivery //and the CSS class for the calendar. The classes are defined in calendar.css //Currently Sunday is considered invalid and Saturday is a different class, //although for now its class is defined the same as other valid days. //special days (holidays) construct an array of timestamps valid for a special day to appear "valid" //2007: these dates must be modified each year (format JJJJ-MM-TT) and according to your country! // First decide whether you want use special days $this->use_special_dates = false; // set to true if you want to use the special days $xmas06 = '2006-12-25'; $boxing06 = '2006-12-26'; $newyear = '2007-01-01'; $goodfriday = '2007-04-06'; $easter = '2007-04-09'; $mayday = '2007-05-07'; $pentecost = '2007-05-28'; $augustbh = '2007-08-28'; $xmas = '2007-12-25'; $boxingday = '2007-12-26'; //Ende eintragen //change date to timestamp $xmas06_stamp = strtotime ($xmas06); $boxing06_stamp = strtotime ($boxing06); $newyear_stamp = strtotime ($newyear); $goodfriday = strtotime ($goodfriday); $easter_stamp = strtotime ($easter); $mayday_stamp = strtotime ($mayday); $pentecost_stamp = strtotime ($pentecost); $augustbh_stamp = strtotime ($augustbh); $xmas_stamp = strtotime ($xmas); $boxingday = strtotime ($boxingday); //construct an array of timestamps $special_date = array ("$xmas06_stamp", "$boxing06_stamp", "$newyear_stamp", "$goodfriday", "$easter_stamp", "$mayday_stamp", "$pentecost_stamp", "$augustbh_stamp", "$xmas_stamp", "$boxingday"); //now check if the day selected in the calender belongs to the array of special dates and make it vaild (true) or non-valid (false), according to your needs if(!isset($this->earliest_date))$this->EarliestArrival(); if($datestamp>=$this->earliest_date){ if ( ($this->use_special_dates == true) && (in_array ("$datestamp", $special_date)) ) { $result['valid']=false; $result['class']='invalid'; } elseif(date('w',$datestamp)==6){ $result['valid']=true; $result['class']='s_valid'; }elseif(date('w',$datestamp)==0){ $result['valid']=false; $result['class']='invalid'; }else{ $result['valid']=true; $result['class']='valid'; } }else{ $result['valid']=false; $result['class']='invalid'; } return $result; } } ?>