grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026cal = $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(); $weekdays = array(); for ($i = 0; $i < 7; $i++) { $j = $i + $this->startday; if ($j >= 7) { $j = $j - 7; } $weekdays[$i] = $GLOBALS['app_list_strings']['dom_cal_day_short'][$j+1]; } $this->weekdays = $weekdays; $this->scrollable = false; if (!($this->cal->isPrint() && $this->cal->view == 'day')) { 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(); $this->style = $this->cal->style; } /** 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."
"; $cell_number = 0; $first_cell = $this->cal->scroll_slot; $last_cell = $first_cell + $this->cal->celcount - 1; 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 || ($cell_number >= $first_cell && $cell_number <= $last_cell)) { $str .= "
".$innerText."
"; } $cell_number++; } } $str .= "
"; return $str; } /** * Get html of day slots column * @param integer $start timestamp * @param integer $day number of day in week * @param string $suffix suffix for id of time slot used in shared view * @return string */ protected function get_day_column($start, $day = 0, $suffix = "") { $curr_time = $start; $str = ""; $str .= "
"; //$str .= $this->get_day_head($start,$day); $cell_number = 0; $first_cell = $this->cal->scroll_slot; $last_cell = $first_cell + $this->cal->celcount - 1; 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 || ($cell_number >= $first_cell && $cell_number <= $last_cell)) { $str .= "
fromTimestamp($curr_time)->format($this->date_time_format)."'>
"; } $cell_number++; $curr_time += $this->time_step*60; } } $str .= "
"; return $str; } public function display_mobile() { global $mod_strings; $str = "
"; foreach ($this->cal->items as $cal_item) { if (date("Y-m-d", $cal_item['ts_start']) >= date("Y-m-d", $this->today_ts)) { $agenda_array[$cal_item['ts_start']][] = $cal_item; ksort($agenda_array); } } $days = array_keys($agenda_array); if ($days) { foreach ($days as $day) { $agenda_array[$day] = $this->mobile_sort_items($agenda_array[$day]); if ($day == $this->today_ts) { $str .= "
Today " . date("D dS, M Y", $agenda_array[$day][0]['ts_start']) . "
"; } else { $str .= "
" . date("D dS, M Y", $agenda_array[$day][0]['ts_start']) . "
"; } $i = 0; while ($i < count($agenda_array[$day])) { $day_item = $agenda_array[$day][$i]; $str .= $this->mobile_display_items($day_item); $i++; } } } else { $str .= "
" . $mod_strings['LBL_NO_ITEMS_MOBILE'] . "
"; } $str .= "
"; return $str; } public function mobile_display_items($day_item) { $end_time = $this->mobile_get_end_time($day_item); $status_color = $this->mobile_get_status_colour($day_item['status']); $type_color = $this->mobile_get_type_colour($day_item['type']); $display = ""; $display .= "
"; $display .= "
"; $display .= "
"; $display .= ucfirst($day_item['type']); $display .= "
"; $display .= "
"; $display .= "
" . $day_item['time_start'] . "
"; $display .= "
" . $end_time . "
"; $display .= "
"; $display .= "
"; $display .= $day_item['status']; $display .= "
"; $display .= "
"; $display .= "
"; $display .= "

" . $day_item['name'] . "

"; $display .= "

" . $day_item['description'] . "

"; $display .= "
"; if ($day_item['type'] == "task") { $display .= "
"; $display .= "Edit"; $display .= "
"; $display .= "
"; } else { $display .= "
"; $display .= "Edit"; $display .= "
"; $display .= ""; } return $display; } public function mobile_get_end_time($day_item) { $start_time = DateTime::createFromFormat("h:ia", $day_item['time_start']); $start_time->modify('+' . $day_item['duration_minutes'] .'minutes'); return $start_time->format("h:ia"); } public function mobile_get_type_colour($type) { switch ($type) { case "meeting": $colour = "#D2E5FC"; break; case "call": $colour = "#FCDCDC"; break; case "task": $colour = "#B1F5AE"; break; default: $colour = "#777777"; break; } return $colour; } public function mobile_get_status_colour($type) { switch ($type) { case "Held": case "Completed": $colour = "green"; break; case "Planned": case "Not Started": case "In Progress": $colour = "#1B4B94"; break; case "Not Held": case "Deferred": $colour = "red"; break; default: $colour = "#777777"; break; } return $colour; } public function mobile_sort_items($agenda_array) { $times = ""; foreach ($agenda_array as $key => $row) { $times[$key] = $row['timestamp']; } array_multisort($times, SORT_ASC, $agenda_array); return $agenda_array; } /** * Get html of basic cell * @param integer $start timestamp * @param integer $height slot height * @param string $prefix prefix for id of slot used in shared view * @return string */ protected function get_basic_cell($start, $height = 80, $suffix = "") { $str = ""; $dt = $GLOBALS['timedate']->fromTimestamp($start)->get("+8 hours"); $str .= "
"; $str .= "
"; $str .= "
"; return $str; } /** * Get html of basic week grid * @param integer $start timestamp * @param string $prefix prefix for id of slot used in shared view * @return string */ protected function get_basic_row($start, $cols = 7, $suffix = "") { $height = 20; $str = ""; $head_content = " "; if ($this->cal->view == 'month' || $this->cal->style == "basic") { $wf = 0; if ($this->startday == 0) { $wf = 1; } $head_content = $GLOBALS['timedate']->fromTimestamp($start + $wf*3600*24)->format('W'); $head_content = "fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$head_content.""; } $left_col = ($this->style != 'basic' || $this->cal->view == 'month'); $attr = ""; if ($this->cal->style != "basic") { $attr = " id='cal-multiday-bar'"; } $str .= "
"; if ($cols > 1) { $str .= "
"; if ($left_col) { $str .= "
"; $str .= "
".$head_content."
"; $str .= "
"; } $str .= "
"; for ($d = 0; $d < $cols; $d++) { $curr_time = $start + $d * 86400; $str .= "
"; $str .= $this->get_day_head($curr_time, $d, true); $str .= "
"; } $str .= "
"; $str .= "
"; $str .= "
"; } $str .= "
"; if ($left_col) { $str .= "
"; $str .= "
 
"; $str .= "
"; } $str .= "
"; for ($d = 0; $d < $cols; $d++) { $curr_time = $start + $d*86400; $str .= $this->get_basic_cell($curr_time, $height, $suffix); } $str .= "
"; $str .= "
"; $str .= "
"; $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 ($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->weekdays[$day]." ".$GLOBALS['timedate']->fromTimestamp($start)->format('d')."
"; } return $str; } /** * Get html of week calendar grid * @return string */ protected function display_week() { $basic = $this->style == "basic"; $week_start_ts = $this->cal->grid_start_ts; $str = ""; $str .= ""; return $str; } /** * Get html of day calendar grid * @return string */ protected function display_day() { $basic = $this->style == "basic"; $day_start_ts = $this->cal->grid_start_ts; $str = ""; $str .= ""; return $str; } /** * Get html of month calendar grid * @return string */ protected function display_month() { $basic = $this->style == "basic"; $week_start_ts = $this->cal->grid_start_ts; $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); $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() { $basic = $this->style == "basic"; $week_start_ts = $this->cal->grid_start_ts; $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->weekdays[$d].'
"; } else { $str .= ""; } $str .= $monC; $str .= "
'; $str .= '
"; return $str; } }