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;
148 $user_id = $ilUser->getId();
149 $disable_empty =
false;
152 include_once(
'Services/Calendar/classes/class.ilCalendarSchedule.php');
154 $this->scheduler->addSubitemCalendars(
true);
155 $this->scheduler->calculate();
159 $all_fullday = array();
162 $daily_apps = $this->scheduler->getByDay($date,$this->timezone);
163 $hours = $this->
parseHourInfo($daily_apps,$date,$counter,$hours,
164 $this->user_settings->getDayStart(),
165 $this->user_settings->getDayEnd()
167 $this->weekdays[] = $date;
169 $num_apps[$date->get(
IL_CAL_DATE)] = count($daily_apps);
171 $all_fullday[] = $daily_apps;
177 include_once(
'Services/Calendar/classes/class.ilCalendarSettings.php');
185 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$date->get(
IL_CAL_DATE));
186 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$date->get(
IL_CAL_DATE));
187 $this->ctrl->setParameterByClass(
'ilcalendardaygui',
'seed',$date->get(
IL_CAL_DATE));
191 if ($settings->getEnableGroupMilestones())
193 $this->tpl->setCurrentBlock(
"new_ms");
195 $this->tpl->setVariable(
'H_NEW_MS_ALT', $this->lng->txt(
'cal_new_ms'));
196 $this->tpl->setVariable(
'NEW_MS_LINK', $this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'addMilestone'));
197 $this->tpl->parseCurrentBlock();
201 $this->tpl->setCurrentBlock(
"new_app");
202 $this->tpl->setVariable(
'NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
203 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
205 $this->tpl->setVariable(
'NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
206 $this->tpl->parseCurrentBlock();
212 if(!$disable_empty || $num_apps[$date->get(
IL_CAL_DATE)] > 0)
214 $link = $this->ctrl->getLinkTargetByClass(
'ilcalendardaygui',
'');
215 $this->ctrl->clearParametersByClass(
'ilcalendardaygui');
217 $this->tpl->setCurrentBlock(
"day_view1_link");
218 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
219 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
220 $this->tpl->parseCurrentBlock();
222 $this->tpl->setCurrentBlock(
"day_view2_link");
223 $this->tpl->setVariable(
'DAYNAME',$dayname);
224 $this->tpl->setVariable(
'DAY_VIEW_LINK',$link);
225 $this->tpl->parseCurrentBlock();
229 $this->tpl->setCurrentBlock(
"day_view1_no_link");
230 $this->tpl->setVariable(
'HEADER_DATE',$daydate);
231 $this->tpl->parseCurrentBlock();
233 $this->tpl->setCurrentBlock(
"day_view2_no_link");
234 $this->tpl->setVariable(
'DAYNAME',$dayname);
235 $this->tpl->parseCurrentBlock();
238 $this->tpl->setCurrentBlock(
'day_header_row');
239 $this->tpl->setVariable(
'DAY_COLSPAN',max($colspans[$counter],1));
240 $this->tpl->parseCurrentBlock();
247 foreach($all_fullday as $daily_apps)
249 foreach($daily_apps as $event)
251 if($event[
'fullday'])
256 $this->tpl->setCurrentBlock(
'f_day_row');
257 $this->tpl->setVariable(
'COLSPAN',max($colspans[$counter],1));
258 $this->tpl->parseCurrentBlock();
261 $this->tpl->setCurrentBlock(
'fullday_apps');
262 $this->tpl->setVariable(
'TXT_F_DAY', $lng->txt(
"cal_all_day"));
263 $this->tpl->parseCurrentBlock();
265 $new_link_counter = 0;
266 foreach($hours as $num_hour => $hours_per_day)
268 foreach($hours_per_day as $num_day => $hour)
270 foreach($hour[
'apps_start'] as $app)
276 if ($ilUser->prefs[
"screen_reader_optimization"])
278 $this->tpl->setCurrentBlock(
'scrd_day_cell');
279 $this->tpl->setVariable(
'TD_CLASS',
'calstd');
280 $this->tpl->parseCurrentBlock();
284 #echo "NUMDAY: ".$num_day;
285 #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
286 $num_apps = $hour[
'apps_num'];
287 $colspan = max($colspans[$num_day],1);
291 if(!$hour[
'apps_num'] && !$ilUser->prefs[
"screen_reader_optimization"] && !$no_add)
293 $this->tpl->setCurrentBlock(
'new_app_link');
294 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'idate',$this->weekdays[$num_day]->
get(
IL_CAL_DATE));
295 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'seed',$this->seed->get(
IL_CAL_DATE));
296 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'hour',$num_hour);
297 $this->tpl->setVariable(
'DAY_NEW_APP_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'add'));
298 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
301 $this->tpl->setVariable(
'DAY_NEW_APP_ALT',$this->lng->txt(
'cal_new_app'));
302 $this->tpl->setVariable(
'DAY_NEW_ID',++$new_link_counter);
303 $this->tpl->parseCurrentBlock();
306 for($i = $colspan;$i > $hour[
'apps_num'];$i--)
308 if ($ilUser->prefs[
"screen_reader_optimization"])
312 $this->tpl->setCurrentBlock(
'day_cell');
314 if($i == ($hour[
'apps_num'] + 1))
316 $this->tpl->setVariable(
'TD_CLASS',
'calempty calrightborder');
317 #$this->tpl->setVariable('TD_STYLE',$add_style);
321 $this->tpl->setVariable(
'TD_CLASS',
'calempty');
322 #$this->tpl->setVariable('TD_STYLE',$add_style);
325 if(!$hour[
'apps_num'])
327 $this->tpl->setVariable(
'DAY_ID',$new_link_counter);
329 $this->tpl->setVariable(
'TD_ROWSPAN',1);
330 $this->tpl->parseCurrentBlock();
334 $this->tpl->setCurrentBlock(
'time_row');
335 $this->tpl->setVariable(
'TIME',$hour[
'txt']);
336 $this->tpl->parseCurrentBlock();
339 $this->tpl->setVariable(
"TXT_TIME", $lng->txt(
"time"));
351 $this->tpl->setCurrentBlock(
'panel_code');
352 $this->tpl->setVariable(
'NUM',$this->num_appointments);
353 $this->tpl->parseCurrentBlock();
356 if ($a_app[
'event']->isMilestone())
358 $this->tpl->setCurrentBlock(
'fullday_ms_icon');
359 $this->tpl->setVariable(
'ALT_FD_MS', $this->lng->txt(
"cal_milestone"));
361 $this->tpl->parseCurrentBlock();
364 $this->tpl->setCurrentBlock(
'fullday_app');
366 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
368 $this->tpl->setVariable(
'F_DAY_ID',$this->num_appointments);
370 $compl = ($a_app[
'event']->isMilestone() && $a_app[
'event']->getCompletion() > 0)
371 ?
" (".$a_app[
'event']->getCompletion().
"%)"
374 $this->tpl->setVariable(
'F_APP_TITLE',$a_app[
'event']->getPresentationTitle().$compl);
376 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
377 $this->tpl->setVariable(
'F_APP_BGCOLOR',$color);
380 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
381 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
382 $this->tpl->setVariable(
'F_APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
384 $this->tpl->parseCurrentBlock();
386 $this->num_appointments++;
399 $this->tpl->setCurrentBlock(
'panel_code');
400 $this->tpl->setVariable(
'NUM',$this->num_appointments);
401 $this->tpl->parseCurrentBlock();
403 if (!$ilUser->prefs[
"screen_reader_optimization"])
405 $this->tpl->setCurrentBLock(
'not_empty');
409 $this->tpl->setCurrentBLock(
'scrd_not_empty');
412 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
415 $this->ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
416 $this->ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id',$a_app[
'event']->getEntryId());
417 $this->tpl->setVariable(
'APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'edit'));
419 if($a_app[
'event']->isFullDay())
421 $title = $a_app[
'event']->getPresentationTitle();
425 switch($this->user_settings->getTimeFormat())
436 if ($ilUser->prefs[
"screen_reader_optimization"])
438 switch($this->user_settings->getTimeFormat())
453 include_once
'Services/Booking/classes/class.ilBookingEntry.php';
457 $title .=
' '.$a_app[
'event']->getTitle();
458 if($entry->isOwner())
460 $max = (int)$entry->getNumberOfBookings();
461 $current = (int)$entry->getCurrentNumberOfBookings($a_app[
'event']->getEntryId());
464 $title .=
' ('.$current.
'/'.$max.
')';
466 else if($current == $max)
468 $title .=
' ('.$this->lng->txt(
'cal_booked_out').
')';
472 $title .=
' ('.$this->lng->txt(
'cal_book_free').
')';
475 else if($entry->hasBooked($a_app[
'event']->getEntryId()))
477 $title .=
' ('.$this->lng->txt(
'cal_date_booked').
')';
483 $title .= (
' '.$a_app[
'event']->getPresentationTitle());
487 $this->tpl->setVariable(
'APP_TITLE',
$title);
489 $this->tpl->setVariable(
'LINK_NUM',$this->num_appointments);
491 $color = $this->app_colors->getColorByAppointment($a_app[
'event']->getEntryId());
492 $style =
'background-color: '.$color.
';';
493 $style .= (
'color:'.ilCalendarUtil::calculateFontColor($color));
494 $this->tpl->setVariable(
'LINK_STYLE',$style);
496 if (!$ilUser->prefs[
"screen_reader_optimization"])
499 $this->tpl->parseCurrentBlock();
501 $this->tpl->setCurrentBlock(
'day_cell');
503 $this->tpl->setVariable(
'DAY_CELL_NUM',$this->num_appointments);
504 $this->tpl->setVariable(
'TD_ROWSPAN',$a_app[
'rowspan']);
505 $this->tpl->setVariable(
'TD_STYLE',$style);
506 $this->tpl->setVariable(
'TD_CLASS',
'calevent');
508 $this->tpl->parseCurrentBlock();
513 $this->tpl->setVariable(
'DIV_STYLE',$style);
514 $this->tpl->parseCurrentBlock();
517 $this->num_appointments++;
530 $morning_aggr = 7, $evening_aggr = 20)
534 for($i = $morning_aggr;$i <= $evening_aggr;$i++)
536 $hours[$i][$num_day][
'apps_start'] = array();
537 $hours[$i][$num_day][
'apps_num'] = 0;
538 switch($this->user_settings->getTimeFormat())
541 if ($morning_aggr > 0 && $i == $morning_aggr)
543 $hours[$i][$num_day][
'txt'] = sprintf(
'%02d:00',0).
"-";
545 $hours[$i][$num_day][
'txt'].= sprintf(
'%02d:00',$i);
546 if ($evening_aggr < 23 && $i == $evening_aggr)
548 $hours[$i][$num_day][
'txt'].=
"-".sprintf(
'%02d:00',23);
553 if ($morning_aggr > 0 && $i == $morning_aggr)
555 $hours[$i][$num_day][
'txt'] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
557 $hours[$i][$num_day][
'txt'].= date(
'h a',mktime($i,0,0,1,1,2000));
558 if ($evening_aggr < 23 && $i == $evening_aggr)
560 $hours[$i][$num_day][
'txt'].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
569 foreach($daily_apps as $app)
577 if($app[
'start_info'][
'mday'] != $date_info[
'mday'])
583 $start = $app[
'start_info'][
'hours'];
586 if($app[
'end_info'][
'mday'] != $date_info[
'mday'])
590 elseif($app[
'start_info'][
'hours'] == $app[
'end_info'][
'hours'])
597 $end = $app[
'end_info'][
'hours'];
601 if ($ilUser->prefs[
"screen_reader_optimization"])
606 if ($start < $morning_aggr)
608 $start = $morning_aggr;
610 if ($end <= $morning_aggr)
612 $end = $morning_aggr+1;
614 if ($start > $evening_aggr)
616 $start = $evening_aggr;
618 if ($end > $evening_aggr+1)
620 $end = $evening_aggr+1;
628 for($i = $start;$i < $end;$i++)
632 if (!$ilUser->prefs[
"screen_reader_optimization"])
634 $app[
'rowspan'] = $end - $start;
640 $hours[$i][$num_day][
'apps_start'][] = $app;
643 $hours[$i][$num_day][
'apps_num']++;
660 foreach($hours as $hour_num => $hours_per_day)
662 foreach($hours_per_day as $num_day => $hour)
664 $colspans[$num_day] = max($colspans[$num_day],$hour[
'apps_num']);
667 if ($ilUser->prefs[
"screen_reader_optimization"])
669 $colspans[$num_day] = 1;