34 include_once(
'Services/Calendar/classes/class.ilDate.php');
35 include_once(
'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php');
36 include_once(
'Services/Calendar/classes/class.ilCalendarUserSettings.php');
37 include_once(
'Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
66 $this->seed = $seed_date;
72 $this->tabs_gui = $ilTabs;
77 $this->timezone = $ilUser->getTimeZone();
90 $this->ctrl->saveParameter($this,
'seed');
93 $next_class = $ilCtrl->getNextClass();
96 case 'ilcalendarappointmentgui':
97 $this->ctrl->setReturn($this,
'');
98 $this->tabs_gui->setSubTabActive(
$_SESSION[
'cal_last_tab']);
103 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
105 $this->ctrl->forwardCommand($app);
109 $time = microtime(
true);
110 $cmd = $this->ctrl->getCmd(
"show");
112 $tpl->setContent($this->tpl->get());
113 #echo "Zeit: ".(microtime(true) - $time);
133 if($this->user_settings->getDayStart())
136 $morning_aggr = ($this->user_settings->getDayStart()-1)*60+(60-$raster);
142 $evening_aggr = $this->user_settings->getDayEnd()*60;
145 $this->tpl =
new ilTemplate(
'tpl.week_view.html',
true,
true,
'Services/Calendar');
147 include_once(
'./Services/YUI/classes/class.ilYuiUtil.php');
153 $this->tpl->setVariable(
'NAVIGATION',$navigation->getHTML());
155 if(isset(
$_GET[
"bkid"]))
157 $user_id =
$_GET[
"bkid"];
158 $disable_empty =
true;
161 elseif($ilUser->getId() == ANONYMOUS_USER_ID)
163 $user_id = $ilUser->getId();
164 $disable_empty =
false;
169 $user_id = $ilUser->getId();
170 $disable_empty =
false;
173 include_once(
'Services/Calendar/classes/class.ilCalendarSchedule.php');
175 $this->scheduler->addSubitemCalendars(
true);
176 $this->scheduler->calculate();
180 $all_fullday = array();
183 $daily_apps = $this->scheduler->getByDay($date,$this->timezone);
184 $hours = $this->
parseHourInfo($daily_apps,$date,$counter,$hours,
189 $this->weekdays[] = $date;
191 $num_apps[$date->get(
IL_CAL_DATE)] = count($daily_apps);
193 $all_fullday[] = $daily_apps;
199 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
207 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$date->get(
IL_CAL_DATE));
208 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$date->get(
IL_CAL_DATE));
209 $this->ctrl->setParameterByClass(
'ilcalendardaygui',
'seed',$date->get(
IL_CAL_DATE));
213 if ($settings->getEnableGroupMilestones())
215 $this->tpl->setCurrentBlock(
"new_ms");
217 $this->tpl->setVariable(
'H_NEW_MS_ALT', $this->lng->txt(
'cal_new_ms'));
218 $this->tpl->setVariable(
'NEW_MS_LINK', $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'addMilestone'));
219 $this->tpl->parseCurrentBlock();
223 $this->tpl->setCurrentBlock(
"new_app");
224 $this->tpl->setVariable(
'NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
225 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
227 $this->tpl->setVariable(
'NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
228 $this->tpl->parseCurrentBlock();
234 if(!$disable_empty || $num_apps[$date->get(
IL_CAL_DATE)] > 0)
236 $link = $this->ctrl->getLinkTargetByClass(
'ilcalendardaygui',
'');
237 $this->ctrl->clearParametersByClass(
'ilcalendardaygui');
239 $this->tpl->setCurrentBlock(
"day_view1_link");
240 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
241 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
242 $this->tpl->parseCurrentBlock();
244 $this->tpl->setCurrentBlock(
"day_view2_link");
245 $this->tpl->setVariable(
'DAYNAME',$dayname);
246 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
247 $this->tpl->parseCurrentBlock();
251 $this->tpl->setCurrentBlock(
"day_view1_no_link");
252 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
253 $this->tpl->parseCurrentBlock();
255 $this->tpl->setCurrentBlock(
"day_view2_no_link");
256 $this->tpl->setVariable(
'DAYNAME',$dayname);
257 $this->tpl->parseCurrentBlock();
260 $this->tpl->setCurrentBlock(
'day_header_row');
261 $this->tpl->setVariable(
'DAY_COLSPAN',max($colspans[$counter],1));
262 $this->tpl->parseCurrentBlock();
269 foreach($all_fullday as $daily_apps)
271 foreach($daily_apps as $event)
273 if($event[
'fullday'])
278 $this->tpl->setCurrentBlock(
'f_day_row');
279 $this->tpl->setVariable(
'COLSPAN',max($colspans[$counter],1));
280 $this->tpl->parseCurrentBlock();
283 $this->tpl->setCurrentBlock(
'fullday_apps');
284 $this->tpl->setVariable(
'TXT_F_DAY', $lng->txt(
"cal_all_day"));
285 $this->tpl->parseCurrentBlock();
287 $new_link_counter = 0;
288 foreach($hours as $num_hour => $hours_per_day)
291 foreach($hours_per_day as $num_day => $hour)
295 if(!($num_hour%60) || ($num_hour == $morning_aggr && $morning_aggr) ||
296 ($num_hour == $evening_aggr && $evening_aggr))
301 if(($num_hour == $morning_aggr && $morning_aggr) ||
302 ($num_hour == $evening_aggr && $evening_aggr))
304 $this->tpl->setVariable(
'TIME_ROWSPAN', 1);
309 $this->tpl->setVariable(
'TIME_ROWSPAN', 60/$raster);
312 $this->tpl->setCurrentBlock(
'time_txt');
314 $this->tpl->setVariable(
'TIME',$hour[
'txt']);
315 $this->tpl->parseCurrentBlock();
319 foreach($hour[
'apps_start'] as $app)
325 if ($ilUser->prefs[
"screen_reader_optimization"])
327 $this->tpl->setCurrentBlock(
'scrd_day_cell');
328 $this->tpl->setVariable(
'TD_CLASS',
'calstd');
329 $this->tpl->parseCurrentBlock();
333 #echo "NUMDAY: ".$num_day;
334 #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
335 $num_apps = $hour[
'apps_num'];
336 $colspan = max($colspans[$num_day],1);
340 if(!$hour[
'apps_num'] && !$ilUser->prefs[
"screen_reader_optimization"] && !$no_add)
342 $this->tpl->setCurrentBlock(
'new_app_link');
343 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$this->weekdays[$num_day]->
get(
IL_CAL_DATE));
344 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$this->seed->get(
IL_CAL_DATE));
345 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour',floor($num_hour/60));
346 $this->tpl->setVariable(
'DAY_NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
347 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
350 $this->tpl->setVariable(
'DAY_NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
351 $this->tpl->setVariable(
'DAY_NEW_ID',++$new_link_counter);
352 $this->tpl->parseCurrentBlock();
355 for($i = $colspan;$i > $hour[
'apps_num'];$i--)
357 if ($ilUser->prefs[
"screen_reader_optimization"])
361 $this->tpl->setCurrentBlock(
'day_cell');
365 if($num_hour%60 == 60-$raster ||
366 ($num_hour == $morning_aggr && $morning_aggr) ||
367 ($num_hour == $evening_aggr && $evening_aggr))
369 $empty_border =
' calempty_border';
372 if($i == ($hour[
'apps_num'] + 1))
374 $this->tpl->setVariable(
'TD_CLASS',
'calempty calrightborder'.$empty_border);
375 #$this->tpl->setVariable('TD_STYLE',$add_style);
379 $this->tpl->setVariable(
'TD_CLASS',
'calempty'.$empty_border);
380 #$this->tpl->setVariable('TD_STYLE',$add_style);
383 if(!$hour[
'apps_num'])
385 $this->tpl->setVariable(
'DAY_ID',$new_link_counter);
387 $this->tpl->setVariable(
'TD_ROWSPAN',1);
388 $this->tpl->parseCurrentBlock();
392 $this->tpl->touchBlock(
'time_row');
395 $this->tpl->setVariable(
"TXT_TIME", $lng->txt(
"time"));
407 $this->tpl->setCurrentBlock(
'panel_code');
408 $this->tpl->setVariable(
'NUM',$this->num_appointments);
409 $this->tpl->parseCurrentBlock();
412 if ($a_app[
'event']->isMilestone())
414 $this->tpl->setCurrentBlock(
'fullday_ms_icon');
415 $this->tpl->setVariable(
'ALT_FD_MS', $this->lng->txt(
"cal_milestone"));
417 $this->tpl->parseCurrentBlock();
420 $this->tpl->setCurrentBlock(
'fullday_app');
422 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
424 $this->tpl->setVariable(
'F_DAY_ID',$this->num_appointments);
426 $compl = ($a_app[
'event']->isMilestone() && $a_app[
'event']->getCompletion() > 0)
427 ?
" (".$a_app[
'event']->getCompletion().
"%)"
430 $this->tpl->setVariable(
'F_APP_TITLE',$a_app[
'event']->getPresentationTitle().$compl);
432 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
433 $this->tpl->setVariable(
'F_APP_BGCOLOR',$color);
436 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
437 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
438 $this->tpl->setVariable(
'F_APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
440 $this->tpl->parseCurrentBlock();
442 $this->num_appointments++;
455 $this->tpl->setCurrentBlock(
'panel_code');
456 $this->tpl->setVariable(
'NUM',$this->num_appointments);
457 $this->tpl->parseCurrentBlock();
459 if (!$ilUser->prefs[
"screen_reader_optimization"])
461 $this->tpl->setCurrentBLock(
'not_empty');
465 $this->tpl->setCurrentBLock(
'scrd_not_empty');
468 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
471 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
472 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
473 $this->tpl->setVariable(
'APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
475 if($a_app[
'event']->isFullDay())
477 $title = $a_app[
'event']->getPresentationTitle();
481 switch($this->user_settings->getTimeFormat())
492 if ($ilUser->prefs[
"screen_reader_optimization"])
494 switch($this->user_settings->getTimeFormat())
509 include_once
'Services/Booking/classes/class.ilBookingEntry.php';
513 $title .=
' '.$a_app[
'event']->getTitle();
514 if($entry->isOwner())
516 $max = (int)$entry->getNumberOfBookings();
517 $current = (int)$entry->getCurrentNumberOfBookings($a_app[
'event']->getEntryId());
520 $title .=
' ('.$current.
'/'.$max.
')';
522 else if($current == $max)
524 $title .=
' ('.$this->lng->txt(
'cal_booked_out').
')';
528 $title .=
' ('.$this->lng->txt(
'cal_book_free').
')';
531 else if($entry->hasBooked($a_app[
'event']->getEntryId()))
533 $title .=
' ('.$this->lng->txt(
'cal_date_booked').
')';
539 $title .= (
' '.$a_app[
'event']->getPresentationTitle());
543 $this->tpl->setVariable(
'APP_TITLE',
$title);
545 $this->tpl->setVariable(
'LINK_NUM',$this->num_appointments);
547 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
548 $style =
'background-color: '.$color.
';';
549 $style .= (
'color:'.ilCalendarUtil::calculateFontColor($color));
550 $this->tpl->setVariable(
'LINK_STYLE',$style);
552 if (!$ilUser->prefs[
"screen_reader_optimization"])
555 $this->tpl->parseCurrentBlock();
557 $this->tpl->setCurrentBlock(
'day_cell');
559 $this->tpl->setVariable(
'DAY_CELL_NUM',$this->num_appointments);
560 $this->tpl->setVariable(
'TD_ROWSPAN',$a_app[
'rowspan']);
561 $this->tpl->setVariable(
'TD_STYLE',$style);
562 $this->tpl->setVariable(
'TD_CLASS',
'calevent');
564 $this->tpl->parseCurrentBlock();
569 $this->tpl->setVariable(
'DIV_STYLE',$style);
570 $this->tpl->parseCurrentBlock();
573 $this->num_appointments++;
586 $morning_aggr, $evening_aggr, $raster)
590 for($i = $morning_aggr;$i <= $evening_aggr;$i+=$raster)
592 $hours[$i][$num_day][
'apps_start'] = array();
593 $hours[$i][$num_day][
'apps_num'] = 0;
594 switch($this->user_settings->getTimeFormat())
597 if ($morning_aggr > 0 && $i == $morning_aggr)
599 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:00',0).
"-".
600 sprintf(
'%02d:00',ceil(($i+1)/60));
604 $hours[$i][$num_day][
'txt'].= sprintf(
'%02d:%02d',floor($i/60),$i%60);
606 if ($evening_aggr < 23*60 && $i == $evening_aggr)
608 $hours[$i][$num_day][
'txt'].=
"-".sprintf(
'%02d:00',23);
613 if ($morning_aggr > 0 && $i == $morning_aggr)
615 $hours[$i][$num_day][
'txt'] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
617 $hours[$i][$num_day][
'txt'].= date(
'h a',mktime(floor($i/60),$i%60,0,1,1,2000));
618 if ($evening_aggr < 23 && $i == $evening_aggr)
620 $hours[$i][$num_day][
'txt'].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
629 foreach($daily_apps as $app)
637 if($app[
'start_info'][
'mday'] != $date_info[
'mday'])
643 $start = $app[
'start_info'][
'hours']*60+$app[
'start_info'][
'minutes'];
646 if($app[
'end_info'][
'mday'] != $date_info[
'mday'])
650 elseif($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours'])
652 $end = $start+$raster;
657 $end = $app[
'end_info'][
'hours']*60+$app[
'end_info'][
'minutes'];
661 if ($ilUser->prefs[
"screen_reader_optimization"])
663 $end = $start+$raster;
666 if ($start < $morning_aggr)
668 $start = $morning_aggr;
670 if ($end <= $morning_aggr)
672 $end = $morning_aggr+$raster;
674 if ($start > $evening_aggr)
676 $start = $evening_aggr;
678 if ($end > $evening_aggr+$raster)
680 $end = $evening_aggr+$raster;
684 $end = $start+$raster;
688 $start = floor($start/$raster)*$raster;
689 $end = ceil($end/$raster)*$raster;
692 for($i = $start;$i < $end;$i+=$raster)
696 if (!$ilUser->prefs[
"screen_reader_optimization"])
698 $app[
'rowspan'] = ceil(($end - $start)/$raster);
704 $hours[$i][$num_day][
'apps_start'][] = $app;
707 $hours[$i][$num_day][
'apps_num']++;
724 foreach($hours as $hour_num => $hours_per_day)
726 foreach($hours_per_day as $num_day => $hour)
728 $colspans[$num_day] = max($colspans[$num_day],$hour[
'apps_num']);
731 if ($ilUser->prefs[
"screen_reader_optimization"])
733 $colspans[$num_day] = 1;