19declare(strict_types=1);
51 public function initialize(
int $a_calendar_presentation_type): void
53 parent::initialize($a_calendar_presentation_type);
57 if ($this->
user->getTimeZone()) {
58 $this->timezone = $this->
user->getTimeZone();
64 $this->
ctrl->saveParameter($this,
'seed');
65 $next_class = $this->
ctrl->getNextClass();
66 switch ($next_class) {
67 case "ilcalendarappointmentpresentationgui":
68 $this->
ctrl->setReturn($this,
"");
70 $this->
ctrl->forwardCommand($gui);
72 case 'ilcalendarappointmentgui':
73 $this->
ctrl->setReturn($this,
'');
74 $this->tabs_gui->setSubTabActive((
string)
ilSession::get(
'cal_last_tab'));
79 $this->
ctrl->forwardCommand($app);
83 $time = microtime(
true);
84 $cmd = $this->
ctrl->getCmd(
"show");
86 $this->main_tpl->setContent($this->tpl->get());
91 public function show(): void
95 $evening_aggr = $this->user_settings->getDayEnd() * 60;
97 $this->tpl =
new ilTemplate(
'tpl.week_view.html',
true,
true,
'components/ILIAS/Calendar');
100 $this->tpl->setVariable(
'NAVIGATION', $navigation->getHTML());
106 $this->
user->getId(),
109 $scheduler->addSubitemCalendars(
true);
110 $scheduler->calculate();
114 $all_fullday = array();
116 $daily_apps = $scheduler->getByDay($date, $this->timezone);
117 if (!$this->view_with_appointments && count($daily_apps)) {
118 $this->view_with_appointments =
true;
128 $this->weekdays[] = $date;
130 $num_apps[$date->get(
IL_CAL_DATE)] = count($daily_apps);
132 $all_fullday[] = $daily_apps;
143 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $date->get(
IL_CAL_DATE));
144 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate', $date->get(
IL_CAL_DATE));
145 $this->
ctrl->setParameterByClass(
'ilcalendardaygui',
'seed', $date->get(
IL_CAL_DATE));
147 if (!$this->no_add) {
153 $this->tpl->setCurrentBlock(
'day_header_row');
154 $this->tpl->setVariable(
'DAY_COLSPAN', max($this->colspans[
$counter], 1));
155 $this->tpl->parseCurrentBlock();
166 $this->tpl->setVariable(
"TXT_TIME", $this->
lng->txt(
"time"));
171 $event_tpl =
new ilTemplate(
'tpl.day_event_view.html',
true,
true,
'components/ILIAS/Calendar');
172 $event_tpl->setCurrentBlock(
'fullday_app');
176 $event_tpl->setVariable(
'EVENT_CONTENT', $title);
178 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
181 $event_tpl->setVariable(
'F_APP_BGCOLOR', $color);
182 $event_tpl->setVariable(
'F_APP_FONTCOLOR', $font_color);
184 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
185 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
186 $event_tpl->setVariable(
188 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit')
191 if ($event_html_by_plugin = $this->
getContentByPlugins($a_app[
'event'], $a_app[
'dstart'], $title, $event_tpl)) {
192 $event_html = $event_html_by_plugin;
194 $event_tpl->parseCurrentBlock();
195 $event_html = $event_tpl->get();
198 $this->tpl->setCurrentBlock(
"content_fd");
199 $this->tpl->setVariable(
"CONTENT_EVENT_FD", $event_html);
200 $this->tpl->parseCurrentBlock();
202 $this->num_appointments++;
208 $event_tpl =
new ilTemplate(
'tpl.week_event_view.html',
true,
true,
'components/ILIAS/Calendar');
212 $this->tpl->setCurrentBlock(
'not_empty');
214 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
215 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
217 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
218 $style =
'background-color: ' . $color .
';';
222 if (!$a_app[
'event']->isFullDay()) {
225 $td_style .= $a_app[
'event']->getPresentationStyle();
230 $title = ($time !=
"") ? $time .
" " . $shy : $shy;
232 $event_tpl->setCurrentBlock(
'event_cell_content');
233 $event_tpl->setVariable(
"STYLE", $style);
234 $event_tpl->setVariable(
'EVENT_CONTENT', $title);
236 if ($event_html_by_plugin = $this->
getContentByPlugins($a_app[
'event'], $a_app[
'dstart'], $title, $event_tpl)) {
237 $event_html = $event_html_by_plugin;
239 $event_tpl->parseCurrentBlock();
240 $event_html = $event_tpl->get();
243 $this->tpl->setVariable(
'GRID_CONTENT', $event_html);
246 $this->tpl->parseCurrentBlock();
248 $this->tpl->setCurrentBlock(
'day_cell');
250 $this->tpl->setVariable(
'DAY_ID',
'a' . $this->num_appointments);
251 $this->tpl->setVariable(
'TD_ROWSPAN', $a_app[
'rowspan']);
252 $this->tpl->setVariable(
'TD_STYLE', $a_app[
'event']->getPresentationStyle());
253 $this->tpl->setVariable(
'TD_CLASS',
'calevent il_calevent');
255 $this->tpl->parseCurrentBlock();
257 $this->num_appointments++;
269 ?array $hours =
null,
270 int $morning_aggr = 0,
271 int $evening_aggr = 0
273 for ($i = $morning_aggr; $i <= $evening_aggr; $i +=
$this->raster) {
274 $hours[$i][$num_day][
'apps_start'] = array();
275 $hours[$i][$num_day][
'apps_num'] = 0;
276 switch ($this->user_settings->getTimeFormat()) {
278 if ($morning_aggr > 0 && $i == $morning_aggr) {
279 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:00', 0) .
' - ' .
280 sprintf(
'%02d:00', ceil(($i + 1) / 60));
282 if (!isset($hours[$i][$num_day][
'txt'])) {
283 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
285 $hours[$i][$num_day][
'txt'] .= sprintf(
'%02d:%02d', floor($i / 60), $i % 60);
288 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
289 if (!isset($hours[$i][$num_day][
'txt'])) {
290 $hours[$i][$num_day][
'txt'] =
' - ' . sprintf(
'%02d:00', 0);
292 $hours[$i][$num_day][
'txt'] .=
' - ' . sprintf(
'%02d:00', 0);
298 if ($morning_aggr > 0 && $i == $morning_aggr) {
299 $hours[$i][$num_day][
'txt'] =
300 date(
'h a', mktime(0, 0, 0, 1, 1, 2000)) .
' - ' .
301 date(
'h a', mktime($this->user_settings->getDayStart(), 0, 0, 1, 1, 2000));
303 if (!isset($hours[$i][$num_day][
'txt'])) {
304 $hours[$i][$num_day][
'txt'] = date(
'h a', mktime((
int) floor($i / 60), $i % 60, 0, 1, 1, 2000));
306 $hours[$i][$num_day][
'txt'] .= date(
'h a', mktime((
int) floor($i / 60), $i % 60, 0, 1, 1, 2000));
309 if ($evening_aggr < 23 * 60 && $i == $evening_aggr) {
310 $hours[$i][$num_day][
'txt'] =
311 date(
'h a', mktime($this->user_settings->getDayEnd(), 0, 0, 1, 1, 2000)) .
' - ' .
312 date(
'h a', mktime(0, 0, 0, 1, 1, 2000));
320 foreach ($daily_apps as $app) {
322 if ($app[
'fullday']) {
327 if ($app[
'start_info'][
'mday'] != $date_info[
'mday']) {
330 $start = $app[
'start_info'][
'hours'] * 60 + $app[
'start_info'][
'minutes'];
336 if ($app[
'end_info'][
'mday'] != $date_info[
'mday']) {
338 } elseif ($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours']) {
341 $end = $app[
'end_info'][
'hours'] * 60 + $app[
'end_info'][
'minutes'];
346 if ($start < $morning_aggr) {
347 $start = $morning_aggr;
349 if ($end <= $morning_aggr) {
352 if ($start > $evening_aggr) {
353 $start = $evening_aggr;
355 if ($end > $evening_aggr + $this->raster) {
358 if ($end <= $start) {
369 $app[
'rowspan'] = ceil(($end - $start) / $this->raster);
370 $hours[$i][$num_day][
'apps_start'][] = $app;
373 $hours[$i][$num_day][
'apps_num']++;
381 foreach ($hours as $hour_num => $hours_per_day) {
382 foreach ($hours_per_day as $num_day => $hour) {
383 $this->colspans[$num_day] = max($this->colspans[$num_day] ?? 0, $hour[
'apps_num'] ?? 0);
390 if ($this->user_settings->getDayStart()) {
392 $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $this->raster);
397 return $morning_aggr;
402 $new_app_url = $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add');
404 $this->tpl->setCurrentBlock(
"new_app");
406 $this->tpl->setVariable(
'NEW_APP_GLYPH', $this->ui_renderer->render(
407 $this->ui_factory->symbol()->glyph()->add($new_app_url)
410 $this->tpl->parseCurrentBlock();
414 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
419 $bkid = $this->initBookingUserFromQuery();
421 $this->user_id = $bkid;
422 $this->disable_empty =
true;
423 $this->no_add =
true;
425 $this->disable_empty =
false;
426 $this->no_add =
true;
428 $this->disable_empty =
false;
429 $this->no_add =
false;
437 $daydate = $dayname .
' ' . $date_info[
'mday'] .
'.';
439 if (!$this->disable_empty || $num_apps[$date->
get(
IL_CAL_DATE)] > 0) {
440 $link = $this->
ctrl->getLinkTargetByClass(
'ilcalendardaygui',
'');
441 $this->
ctrl->clearParametersByClass(
'ilcalendardaygui');
443 $this->tpl->setCurrentBlock(
"day_view_link");
444 $this->tpl->setVariable(
'HEADER_DATE', $daydate);
445 $this->tpl->setVariable(
'DAY_VIEW_LINK', $link);
446 $this->tpl->parseCurrentBlock();
448 $this->tpl->setCurrentBlock(
"day_view_no_link");
449 $this->tpl->setVariable(
'HEADER_DATE', $daydate);
450 $this->tpl->parseCurrentBlock();
457 foreach ($all_fullday as $daily_apps) {
458 foreach ($daily_apps as $event) {
459 if ($event[
'fullday']) {
460 $this->showFulldayAppointment($event);
463 $this->tpl->setCurrentBlock(
'f_day_row');
464 $this->tpl->setVariable(
'COLSPAN', max($this->colspans[
$counter], 1));
465 $this->tpl->parseCurrentBlock();
468 $this->tpl->setCurrentBlock(
'fullday_apps');
469 $this->tpl->setVariable(
'TXT_F_DAY', $this->
lng->txt(
"cal_all_day"));
470 $this->tpl->parseCurrentBlock();
473 protected function addTimedEvents(array $hours,
int $morning_aggr,
int $evening_aggr): void
475 $new_link_counter = 0;
477 foreach ($hours as $num_hour => $hours_per_day) {
479 foreach ($hours_per_day as $num_day => $hour) {
480 #ADD the hours in the left side of the grid.
482 if (!($num_hour % 60) || ($num_hour == $morning_aggr && $morning_aggr) ||
483 ($num_hour == $evening_aggr && $evening_aggr)) {
487 if (($num_hour == $morning_aggr && $morning_aggr) ||
488 ($num_hour == $evening_aggr && $evening_aggr)) {
489 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
492 $this->tpl->setVariable(
'TIME_ROWSPAN', 60 / $this->raster);
495 $this->tpl->setCurrentBlock(
'time_txt');
497 $this->tpl->setVariable(
'TIME', $hour[
'txt']);
498 $this->tpl->parseCurrentBlock();
502 foreach ($hour[
'apps_start'] as $app) {
503 $this->showAppointment($app);
505 $num_apps = $hour[
'apps_num'];
506 $colspan = max($this->colspans[$num_day], 1);
509 if (!$hour[
'apps_num'] && !$this->no_add) {
510 $this->tpl->setCurrentBlock(
'new_app_link');
512 $this->
ctrl->clearParameterByClass(
'ilcalendarappointmentgui',
'app_id');
514 $this->
ctrl->setParameterByClass(
515 'ilcalendarappointmentgui',
519 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed', $this->seed->get(
IL_CAL_DATE));
520 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour', floor($num_hour / 60));
523 $new_app_url = $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add');
524 $this->tpl->setVariable(
526 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->add($new_app_url))
528 $this->tpl->setVariable(
'DAY_NEW_ID', ++$new_link_counter);
529 $this->tpl->parseCurrentBlock();
532 for ($i = $colspan; $i > $hour[
'apps_num']; $i--) {
533 $this->tpl->setCurrentBlock(
'day_cell');
537 if ($num_hour % 60 == 60 - $this->raster ||
538 ($num_hour == $morning_aggr && $morning_aggr) ||
539 ($num_hour == $evening_aggr && $evening_aggr)) {
540 $empty_border =
' calempty_border';
543 $this->tpl->setVariable(
'TD_CLASS',
'calempty createhover' . $empty_border);
545 $this->tpl->setVariable(
'DAY_ID', ++$day_id_counter);
546 $this->tpl->setVariable(
'TD_ROWSPAN', 1);
547 $this->tpl->parseCurrentBlock();
550 $this->tpl->touchBlock(
'time_row');
561 switch ($this->user_settings->getTimeFormat()) {
Administrate calendar appointments.
static _getInstance(ilDate $seed, array $a_app)
get singleton instance
Model for a calendar entry.
getStart()
Get start of date period.
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
Stores all calendar relevant settings.
static _getInstanceByUserId(int $a_user_id)
static calculateFontColor(string $a_html_color_code)
Calculate best font color from html hex color code.
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
static _buildWeekDayList(ilDate $a_day, int $a_weekstart)
build week day list @access public
getAppointmentShyButton(ilCalendarEntry $a_calendar_entry, string $a_dstart, string $a_title_forced="")
const CAL_PRESENTATION_WEEK
initInitialDateFromQuery()
initAppointmentIdFromQuery()
getContentByPlugins(ilCalendarEntry $a_cal_entry, int $a_start_date, string $a_content, ilTemplate $a_tpl)
addAppointmentLink(ilDateTime $date)
ilCalendarAppointmentColors $app_colors
getAppointmentTimeString(ilCalendarEntry $a_event)
addTimedEvents(array $hours, int $morning_aggr, int $evening_aggr)
ilCalendarSettings $cal_settings
initialize(int $a_calendar_presentation_type)
showAppointment(array $a_app)
__construct(ilDate $seed_date)
parseHourInfo(array $daily_apps, ilDateTime $date, int $num_day, ?array $hours=null, int $morning_aggr=0, int $evening_aggr=0)
calculate overlapping hours @access protected
addHeaderDate($date, $num_apps)
showFulldayAppointment(array $a_app)
calculateColspans(array $hours)
ilCalendarUserSettings $user_settings
addFullDayEvents($all_fullday)
@classDescription Date and time handling
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
static get(string $a_var)
special template class to simplify handling of ITX/PEAR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc