cal = &$cal; $today = $GLOBALS['timedate']->getNow(true)->get_day_begin(); $this->today_ts = $today->format('U') + $today->getOffset(); $this->startday = $current_user->get_first_day_of_week(); $weekday_names = array(); for($i = 0; $i < 7; $i++){ $j = $i + $this->startday; if($j >= 7) $j = $j - 7; $weekday_names[$i] = $GLOBALS['app_list_strings']['dom_cal_day_short'][$j+1]; } $this->weekday_names = $weekday_names; $this->scrollable = false; if(in_array($this->cal->view,array('day','week'))){ $this->scrollable = true; if($this->cal->time_step < 30) $this->scroll_height = 480; else $this->scroll_height = $this->cal->celcount * 15 + 1; } $this->time_step = $this->cal->time_step; $this->time_format = $GLOBALS['timedate']->get_time_format(); $this->date_time_format = $GLOBALS['timedate']->get_date_time_format(); } /** Get html of calendar grid * @return string */ public function display(){ $action = "display_".strtolower($this->cal->view); return $this->$action(); } /** Get html of time column * @param integer $start timestamp * @return string */ protected function get_time_column($start){ $str = ""; $head_content = " "; if($this->cal->view == 'month'){ if($this->startday == 0) $wf = 1; else $wf = 0; $head_content = "fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$GLOBALS['timedate']->fromTimestamp($start + $wf*3600*24)->format('W').""; } $str .= "
"; if(!$this->scrollable) $str .= "
".$head_content."
"; for($i = 0; $i < 24; $i++){ for($j = 0; $j < 60; $j += $this->time_step){ if($j == 0){ $innerText = $GLOBALS['timedate']->fromTimestamp($start + $i * 3600)->format($this->time_format); }else{ $innerText = " "; } if($j == 60 - $this->time_step && $this->time_step < 60){ $class = " odd_border"; }else{ $class = ""; } if($this->scrollable || !$this->check_owt($i,$j,$this->cal->d_start_minutes,$this->cal->d_end_minutes)) $str .= "
".$innerText."
"; } } $str .= "
"; return $str; } /** * Get html of day slots column * @param integer $start timestamp * @param integer $day number of day in week * @param string $prefix prefix for id of timeslot used in shared view * @return string */ protected function get_day_column($start,$day = 0,$prefix = ""){ $curr_time = $start; $str = ""; $str .= "
"; $str .= $this->get_day_head($start,$day); for($i = 0; $i < 24; $i++){ for($j = 0; $j < 60; $j += $this->time_step){ $timestr = $GLOBALS['timedate']->fromTimestamp($curr_time)->format($this->time_format); if($j == 60 - $this->time_step && $this->time_step < 60){ $class = " odd_border"; }else{ $class = ""; } if($this->scrollable || !$this->check_owt($i,$j,$this->cal->d_start_minutes,$this->cal->d_end_minutes)) $str .= "
fromTimestamp($curr_time)->format($this->date_time_format)."'>
"; $curr_time += $this->time_step*60; } } $str .= "
"; return $str; } /** * Get html of day head * @param integer $start timestamp * @param integer $day number of day in week * @param bulean $force force display header * @return string */ protected function get_day_head($start,$day = 0,$force = false){ $str = ""; if(!$this->scrollable || $force){ $headstyle = ""; if($this->today_ts == $start) $headstyle = " today"; $str .= "
fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$this->weekday_names[$day]." ".$GLOBALS['timedate']->fromTimestamp($start)->format('d')."
"; } return $str; } /** * Get true if out of working day * @param integer $i hours * @param integer $j minutes * @param integer $r_start start of working day in minutes * @param integer $r_end end of working day in minutes * @return boolean */ protected function check_owt($i,$j,$r_start,$r_end){ if($i*60+$j < $r_start || $i*60+$j >= $r_end) return true; } /** * Get html of week calendar grid * @return string */ protected function display_week(){ $current_date = $this->cal->date_time; $week_start = CalendarUtils::get_first_day_of_week($current_date); $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz $str = ""; $str .= ""; return $str; } /** * Get html of day calendar grid * @return string */ protected function display_day(){ $current_date = $this->cal->date_time; $day_start_ts = $current_date->format('U') + $current_date->getOffset(); // convert to timestamp, ignore tz $str = ""; $str .= ""; return $str; } /** * Get html of month calendar grid * @return string */ protected function display_month(){ $current_date = $this->cal->date_time; $month_start = $current_date->get_day_by_index_this_month(0); $month_end = $month_start->get("+".$month_start->format('t')." days"); $week_start = CalendarUtils::get_first_day_of_week($month_start); $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz $month_end_ts = $month_end->format('U') + $month_end->getOffset(); $str = ""; $str .= ""; return $str; } /** * Get html of week shared grid * @return string */ protected function display_shared(){ $current_date = $this->cal->date_time; $week_start = CalendarUtils::get_first_day_of_week($current_date); $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz $str = ""; $str .= ""; return $str; } /** * Get html of year calendar * @return string */ protected function display_year(){ $weekEnd1 = 0 - $this->startday; $weekEnd2 = -1 - $this->startday; if($weekEnd1 < 0) $weekEnd1 += 7; if($weekEnd2 < 0) $weekEnd2 += 7; $year_start = $GLOBALS['timedate']->fromString($this->cal->date_time->year.'-01-01'); $str = ""; $str .= ''; for($m = 0; $m < 12; $m++){ $month_start = $year_start->get("+".$m." months"); $month_start_ts = $month_start->format('U') + $month_start->getOffset(); $month_end = $month_start->get("+".$month_start->format('t')." days"); $week_start = CalendarUtils::get_first_day_of_week($month_start); $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz $month_end_ts = $month_end->format('U') + $month_end->getOffset(); $table_id = "daily_cal_table".$m; //bug 47471 if($m % 3 == 0) $str .= ""; $str .= ''; if(($m - 2) % 3 == 0) $str .= ""; } $str .= "
'; $str .= ''.$GLOBALS['app_list_strings']['dom_cal_month_long'][$m+1].''; $str .= ''; $str .= ''; for($d = 0; $d < 7; $d++) $str .= ''; $str .= ''; $curr_time_global = $week_start_ts; $w = 0; while($curr_time_global < $month_end_ts){ $str .= ''; for($d = 0; $d < 7; $d++){ $curr_time = $week_start_ts + $d*86400 + $w*60*60*24*7; if($curr_time < $month_start_ts || $curr_time >= $month_end_ts) $monC = ""; else $monC = ''.$GLOBALS['timedate']->fromTimestamp($curr_time)->format('j').''; if($d == $weekEnd1 || $d == $weekEnd2) $str .= ""; } $str .= ""; $curr_time_global += 60*60*24*7; $w++; } $str .= '
'.$this->weekday_names[$d].'
"; else $str .= ""; $str .= $monC; $str .= "
'; $str .= '
"; return $str; } } ?>