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);
128 global $ilUser,
$lng;
130 $this->tpl =
new ilTemplate(
'tpl.week_view.html',
true,
true,
'Services/Calendar');
132 include_once(
'./Services/YUI/classes/class.ilYuiUtil.php');
138 $this->tpl->setVariable(
'NAVIGATION',$navigation->getHTML());
140 if(isset(
$_GET[
"bkid"]))
142 $user_id =
$_GET[
"bkid"];
143 $disable_empty =
true;
146 elseif($ilUser->getId() == ANONYMOUS_USER_ID)
148 $user_id = $ilUser->getId();
149 $disable_empty =
false;
154 $user_id = $ilUser->getId();
155 $disable_empty =
false;
158 include_once(
'Services/Calendar/classes/class.ilCalendarSchedule.php');
160 $this->scheduler->addSubitemCalendars(
true);
161 $this->scheduler->calculate();
165 $all_fullday = array();
168 $daily_apps = $this->scheduler->getByDay($date,$this->timezone);
169 $hours = $this->
parseHourInfo($daily_apps,$date,$counter,$hours,
170 $this->user_settings->getDayStart(),
171 $this->user_settings->getDayEnd()
173 $this->weekdays[] = $date;
175 $num_apps[$date->get(
IL_CAL_DATE)] = count($daily_apps);
177 $all_fullday[] = $daily_apps;
183 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
191 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$date->get(
IL_CAL_DATE));
192 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$date->get(
IL_CAL_DATE));
193 $this->ctrl->setParameterByClass(
'ilcalendardaygui',
'seed',$date->get(
IL_CAL_DATE));
197 if ($settings->getEnableGroupMilestones())
199 $this->tpl->setCurrentBlock(
"new_ms");
201 $this->tpl->setVariable(
'H_NEW_MS_ALT', $this->lng->txt(
'cal_new_ms'));
202 $this->tpl->setVariable(
'NEW_MS_LINK', $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'addMilestone'));
203 $this->tpl->parseCurrentBlock();
207 $this->tpl->setCurrentBlock(
"new_app");
208 $this->tpl->setVariable(
'NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
209 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
211 $this->tpl->setVariable(
'NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
212 $this->tpl->parseCurrentBlock();
218 if(!$disable_empty || $num_apps[$date->get(
IL_CAL_DATE)] > 0)
220 $link = $this->ctrl->getLinkTargetByClass(
'ilcalendardaygui',
'');
221 $this->ctrl->clearParametersByClass(
'ilcalendardaygui');
223 $this->tpl->setCurrentBlock(
"day_view1_link");
224 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
225 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
226 $this->tpl->parseCurrentBlock();
228 $this->tpl->setCurrentBlock(
"day_view2_link");
229 $this->tpl->setVariable(
'DAYNAME',$dayname);
230 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
231 $this->tpl->parseCurrentBlock();
235 $this->tpl->setCurrentBlock(
"day_view1_no_link");
236 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
237 $this->tpl->parseCurrentBlock();
239 $this->tpl->setCurrentBlock(
"day_view2_no_link");
240 $this->tpl->setVariable(
'DAYNAME',$dayname);
241 $this->tpl->parseCurrentBlock();
244 $this->tpl->setCurrentBlock(
'day_header_row');
245 $this->tpl->setVariable(
'DAY_COLSPAN',max($colspans[$counter],1));
246 $this->tpl->parseCurrentBlock();
253 foreach($all_fullday as $daily_apps)
255 foreach($daily_apps as $event)
257 if($event[
'fullday'])
262 $this->tpl->setCurrentBlock(
'f_day_row');
263 $this->tpl->setVariable(
'COLSPAN',max($colspans[$counter],1));
264 $this->tpl->parseCurrentBlock();
267 $this->tpl->setCurrentBlock(
'fullday_apps');
268 $this->tpl->setVariable(
'TXT_F_DAY', $lng->txt(
"cal_all_day"));
269 $this->tpl->parseCurrentBlock();
271 $new_link_counter = 0;
272 foreach($hours as $num_hour => $hours_per_day)
274 foreach($hours_per_day as $num_day => $hour)
276 foreach($hour[
'apps_start'] as $app)
282 if ($ilUser->prefs[
"screen_reader_optimization"])
284 $this->tpl->setCurrentBlock(
'scrd_day_cell');
285 $this->tpl->setVariable(
'TD_CLASS',
'calstd');
286 $this->tpl->parseCurrentBlock();
290 #echo "NUMDAY: ".$num_day;
291 #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
292 $num_apps = $hour[
'apps_num'];
293 $colspan = max($colspans[$num_day],1);
297 if(!$hour[
'apps_num'] && !$ilUser->prefs[
"screen_reader_optimization"] && !$no_add)
299 $this->tpl->setCurrentBlock(
'new_app_link');
300 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$this->weekdays[$num_day]->
get(
IL_CAL_DATE));
301 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$this->seed->get(
IL_CAL_DATE));
302 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour',$num_hour);
303 $this->tpl->setVariable(
'DAY_NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
304 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
307 $this->tpl->setVariable(
'DAY_NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
308 $this->tpl->setVariable(
'DAY_NEW_ID',++$new_link_counter);
309 $this->tpl->parseCurrentBlock();
312 for($i = $colspan;$i > $hour[
'apps_num'];$i--)
314 if ($ilUser->prefs[
"screen_reader_optimization"])
318 $this->tpl->setCurrentBlock(
'day_cell');
320 if($i == ($hour[
'apps_num'] + 1))
322 $this->tpl->setVariable(
'TD_CLASS',
'calempty calrightborder');
323 #$this->tpl->setVariable('TD_STYLE',$add_style);
327 $this->tpl->setVariable(
'TD_CLASS',
'calempty');
328 #$this->tpl->setVariable('TD_STYLE',$add_style);
331 if(!$hour[
'apps_num'])
333 $this->tpl->setVariable(
'DAY_ID',$new_link_counter);
335 $this->tpl->setVariable(
'TD_ROWSPAN',1);
336 $this->tpl->parseCurrentBlock();
340 $this->tpl->setCurrentBlock(
'time_row');
341 $this->tpl->setVariable(
'TIME',$hour[
'txt']);
342 $this->tpl->parseCurrentBlock();
345 $this->tpl->setVariable(
"TXT_TIME", $lng->txt(
"time"));
357 $this->tpl->setCurrentBlock(
'panel_code');
358 $this->tpl->setVariable(
'NUM',$this->num_appointments);
359 $this->tpl->parseCurrentBlock();
362 if ($a_app[
'event']->isMilestone())
364 $this->tpl->setCurrentBlock(
'fullday_ms_icon');
365 $this->tpl->setVariable(
'ALT_FD_MS', $this->lng->txt(
"cal_milestone"));
367 $this->tpl->parseCurrentBlock();
370 $this->tpl->setCurrentBlock(
'fullday_app');
372 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
374 $this->tpl->setVariable(
'F_DAY_ID',$this->num_appointments);
376 $compl = ($a_app[
'event']->isMilestone() && $a_app[
'event']->getCompletion() > 0)
377 ?
" (".$a_app[
'event']->getCompletion().
"%)"
380 $this->tpl->setVariable(
'F_APP_TITLE',$a_app[
'event']->getPresentationTitle().$compl);
382 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
383 $this->tpl->setVariable(
'F_APP_BGCOLOR',$color);
386 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
387 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
388 $this->tpl->setVariable(
'F_APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
390 $this->tpl->parseCurrentBlock();
392 $this->num_appointments++;
405 $this->tpl->setCurrentBlock(
'panel_code');
406 $this->tpl->setVariable(
'NUM',$this->num_appointments);
407 $this->tpl->parseCurrentBlock();
409 if (!$ilUser->prefs[
"screen_reader_optimization"])
411 $this->tpl->setCurrentBLock(
'not_empty');
415 $this->tpl->setCurrentBLock(
'scrd_not_empty');
418 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
421 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
422 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
423 $this->tpl->setVariable(
'APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
425 if($a_app[
'event']->isFullDay())
427 $title = $a_app[
'event']->getPresentationTitle();
431 switch($this->user_settings->getTimeFormat())
442 if ($ilUser->prefs[
"screen_reader_optimization"])
444 switch($this->user_settings->getTimeFormat())
459 include_once
'Services/Booking/classes/class.ilBookingEntry.php';
463 $title .=
' '.$a_app[
'event']->getTitle();
464 if($entry->isOwner())
466 $max = (int)$entry->getNumberOfBookings();
467 $current = (int)$entry->getCurrentNumberOfBookings($a_app[
'event']->getEntryId());
470 $title .=
' ('.$current.
'/'.$max.
')';
472 else if($current == $max)
474 $title .=
' ('.$this->lng->txt(
'cal_booked_out').
')';
478 $title .=
' ('.$this->lng->txt(
'cal_book_free').
')';
481 else if($entry->hasBooked($a_app[
'event']->getEntryId()))
483 $title .=
' ('.$this->lng->txt(
'cal_date_booked').
')';
489 $title .= (
' '.$a_app[
'event']->getPresentationTitle());
493 $this->tpl->setVariable(
'APP_TITLE',
$title);
495 $this->tpl->setVariable(
'LINK_NUM',$this->num_appointments);
497 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
498 $style =
'background-color: '.$color.
';';
499 $style .= (
'color:'.ilCalendarUtil::calculateFontColor($color));
500 $this->tpl->setVariable(
'LINK_STYLE',$style);
502 if (!$ilUser->prefs[
"screen_reader_optimization"])
505 $this->tpl->parseCurrentBlock();
507 $this->tpl->setCurrentBlock(
'day_cell');
509 $this->tpl->setVariable(
'DAY_CELL_NUM',$this->num_appointments);
510 $this->tpl->setVariable(
'TD_ROWSPAN',$a_app[
'rowspan']);
511 $this->tpl->setVariable(
'TD_STYLE',$style);
512 $this->tpl->setVariable(
'TD_CLASS',
'calevent');
514 $this->tpl->parseCurrentBlock();
519 $this->tpl->setVariable(
'DIV_STYLE',$style);
520 $this->tpl->parseCurrentBlock();
523 $this->num_appointments++;
536 $morning_aggr = 7, $evening_aggr = 20)
540 for($i = $morning_aggr;$i <= $evening_aggr;$i++)
542 $hours[$i][$num_day][
'apps_start'] = array();
543 $hours[$i][$num_day][
'apps_num'] = 0;
544 switch($this->user_settings->getTimeFormat())
547 if ($morning_aggr > 0 && $i == $morning_aggr)
549 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:00',0).
"-";
551 $hours[$i][$num_day][
'txt'].= sprintf(
'%02d:00',$i);
552 if ($evening_aggr < 23 && $i == $evening_aggr)
554 $hours[$i][$num_day][
'txt'].=
"-".sprintf(
'%02d:00',23);
559 if ($morning_aggr > 0 && $i == $morning_aggr)
561 $hours[$i][$num_day][
'txt'] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
563 $hours[$i][$num_day][
'txt'].= date(
'h a',mktime($i,0,0,1,1,2000));
564 if ($evening_aggr < 23 && $i == $evening_aggr)
566 $hours[$i][$num_day][
'txt'].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
575 foreach($daily_apps as $app)
583 if($app[
'start_info'][
'mday'] != $date_info[
'mday'])
589 $start = $app[
'start_info'][
'hours'];
592 if($app[
'end_info'][
'mday'] != $date_info[
'mday'])
596 elseif($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours'])
603 $end = $app[
'end_info'][
'hours'];
607 if ($ilUser->prefs[
"screen_reader_optimization"])
612 if ($start < $morning_aggr)
614 $start = $morning_aggr;
616 if ($end <= $morning_aggr)
618 $end = $morning_aggr+1;
620 if ($start > $evening_aggr)
622 $start = $evening_aggr;
624 if ($end > $evening_aggr+1)
626 $end = $evening_aggr+1;
634 for($i = $start;$i < $end;$i++)
638 if (!$ilUser->prefs[
"screen_reader_optimization"])
640 $app[
'rowspan'] = $end - $start;
646 $hours[$i][$num_day][
'apps_start'][] = $app;
649 $hours[$i][$num_day][
'apps_num']++;
666 foreach($hours as $hour_num => $hours_per_day)
668 foreach($hours_per_day as $num_day => $hour)
670 $colspans[$num_day] = max($colspans[$num_day],$hour[
'apps_num']);
673 if ($ilUser->prefs[
"screen_reader_optimization"])
675 $colspans[$num_day] = 1;