/** * fill data section * * @access protected * */ protected function show() { global $lng, $ilUser; // config $raster = 15; if ($this->user_settings->getDayStart()) { // push starting point to last "slot" of hour BEFORE morning aggregation $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster); } else { $morning_aggr = 0; } $evening_aggr = $this->user_settings->getDayEnd() * 60; $this->tpl = new ilTemplate('tpl.day_view.html', true, true, 'Services/Calendar'); include_once './Services/YUI/classes/class.ilYuiUtil.php'; ilYuiUtil::initDragDrop(); ilYuiUtil::initPanel(); if (isset($_GET["bkid"])) { $user_id = $_GET["bkid"]; $no_add = true; } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) { $user_id = $ilUser->getId(); $no_add = true; } else { $user_id = $ilUser->getId(); $no_add = false; } include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php'; $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_DAY, $user_id); $this->scheduler->addSubitemCalendars(true); $this->scheduler->calculate(); $daily_apps = $this->scheduler->getByDay($this->seed, $this->timezone); $hours = $this->parseInfoIntoRaster($daily_apps, $morning_aggr, $evening_aggr, $raster); $colspan = $this->calculateColspan($hours); $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::DAY); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); // add milestone link include_once 'Services/Calendar/classes/class.ilCalendarSettings.php'; $settings = ilCalendarSettings::_getInstance(); include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; if (!$no_add) { $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE)); $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'); if ($settings->getEnableGroupMilestones()) { $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE)); $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone'); $this->tpl->setCurrentBlock("new_ms"); $this->tpl->setVariable('DD_ID', $this->seed->get(IL_CAL_UNIX)); $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD)); $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url); $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app')); $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url); $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms')); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("new_app1"); $this->tpl->setVariable('H_NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app'))); $this->tpl->setVariable('NEW_APP_LINK', $new_app_url); $this->tpl->parseCurrentBlock(); } $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); } $this->tpl->setVariable('NAVIGATION', $navigation->getHTML()); $this->tpl->setVariable('HEADER_DATE', $this->seed_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($this->seed_info['mon'], false)); $this->tpl->setVariable('HEADER_DAY', ilCalendarUtil::_numericDayToString($this->seed_info['wday'], true)); $this->tpl->setVariable('HCOLSPAN', $colspan - 1); $this->tpl->setVariable('TXT_TIME', $lng->txt("time")); // show fullday events foreach ($daily_apps as $event) { if ($event['fullday']) { $this->showFulldayAppointment($event); } } $this->tpl->setCurrentBlock('fullday_apps'); $this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day")); $this->tpl->setVariable('COLSPAN', $colspan - 1); $this->tpl->parseCurrentBlock(); // parse the hour rows foreach ($hours as $numeric => $hour) { if (!($numeric % 60) || $numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) { if (!$no_add) { $this->tpl->setCurrentBlock("new_app2"); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'hour', floor($numeric / 60)); $this->tpl->setVariable('NEW_APP_HOUR_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add')); $this->tpl->setVariable('NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app'))); $this->tpl->parseCurrentBlock(); } // aggregation rows if ($numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) { $this->tpl->setVariable('TIME_ROWSPAN', 1); } else { $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster); } $this->tpl->setCurrentBlock('time_txt'); $this->tpl->setVariable('TIME', $hour['txt']); $this->tpl->parseCurrentBlock(); } foreach ($hour['apps_start'] as $app) { $this->showAppointment($app); } if ($ilUser->prefs["screen_reader_optimization"]) { $this->tpl->touchBlock('scrd_app_cell'); } for ($i = $colspan - 1; $i > $hour['apps_num']; $i--) { $this->tpl->setCurrentBlock('empty_cell'); $this->tpl->setVariable('EMPTY_WIDTH', 100 / (int) ($colspan - 1) . '%'); // last "slot" of hour needs border if ($numeric % 60 == 60 - $raster || $numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) { $this->tpl->setVariable('EMPTY_STYLE', ' calempty_border'); } $this->tpl->parseCurrentBlock(); } $this->tpl->touchBlock('time_row'); } }
/** * fill data section * * @access public * */ public function show() { global $ilUser, $lng; // config $raster = 15; if ($this->user_settings->getDayStart()) { // push starting point to last "slot" of hour BEFORE morning aggregation $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster); } else { $morning_aggr = 0; } $evening_aggr = $this->user_settings->getDayEnd() * 60; $this->tpl = new ilTemplate('tpl.week_view.html', true, true, 'Services/Calendar'); include_once './Services/YUI/classes/class.ilYuiUtil.php'; ilYuiUtil::initDragDrop(); ilYuiUtil::initPanel(); $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::WEEK); $this->tpl->setVariable('NAVIGATION', $navigation->getHTML()); if (isset($_GET["bkid"])) { $user_id = $_GET["bkid"]; $disable_empty = true; $no_add = true; } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) { $user_id = $ilUser->getId(); $disable_empty = false; $no_add = true; } else { $user_id = $ilUser->getId(); $disable_empty = false; $no_add = false; } include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php'; $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_WEEK, $user_id, $disable_empty); $this->scheduler->addSubitemCalendars(true); $this->scheduler->calculate(); $counter = 0; $hours = null; $all_fullday = array(); foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) { $daily_apps = $this->scheduler->getByDay($date, $this->timezone); $hours = $this->parseHourInfo($daily_apps, $date, $counter, $hours, $morning_aggr, $evening_aggr, $raster); $this->weekdays[] = $date; $num_apps[$date->get(IL_CAL_DATE)] = count($daily_apps); $all_fullday[] = $daily_apps; $counter++; } $colspans = $this->calculateColspans($hours); include_once 'Services/Calendar/classes/class.ilCalendarSettings.php'; $settings = ilCalendarSettings::_getInstance(); include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; // Table header $counter = 0; foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $date->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE)); if (!$no_add) { $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'); if ($settings->getEnableGroupMilestones()) { $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone'); $this->tpl->setCurrentBlock("new_ms"); $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX)); $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD)); $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url); $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app')); $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url); $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms')); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("new_app"); $this->tpl->setVariable('NEW_APP_LINK', $new_app_url); $this->tpl->setVariable('NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app'))); // $this->tpl->setVariable('NEW_APP_ALT',$this->lng->txt('cal_new_app')); $this->tpl->parseCurrentBlock(); } $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); } $dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE, 'w'), true); $daydate = $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'], false); if (!$disable_empty || $num_apps[$date->get(IL_CAL_DATE)] > 0) { $link = $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''); $this->ctrl->clearParametersByClass('ilcalendardaygui'); $this->tpl->setCurrentBlock("day_view1_link"); $this->tpl->setVariable('HEADER_DATE', $daydate); $this->tpl->setVariable('DAY_VIEW_LINK', $link); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("day_view2_link"); $this->tpl->setVariable('DAYNAME', $dayname); $this->tpl->setVariable('DAY_VIEW_LINK', $link); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("day_view1_no_link"); $this->tpl->setVariable('HEADER_DATE', $daydate); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("day_view2_no_link"); $this->tpl->setVariable('DAYNAME', $dayname); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock('day_header_row'); $this->tpl->setVariable('DAY_COLSPAN', max($colspans[$counter], 1)); $this->tpl->parseCurrentBlock(); $counter++; } // show fullday events $counter = 0; foreach ($all_fullday as $daily_apps) { foreach ($daily_apps as $event) { if ($event['fullday']) { $this->showFulldayAppointment($event); } } $this->tpl->setCurrentBlock('f_day_row'); $this->tpl->setVariable('COLSPAN', max($colspans[$counter], 1)); $this->tpl->parseCurrentBlock(); $counter++; } $this->tpl->setCurrentBlock('fullday_apps'); $this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day")); $this->tpl->parseCurrentBlock(); $new_link_counter = 0; foreach ($hours as $num_hour => $hours_per_day) { $first = true; foreach ($hours_per_day as $num_day => $hour) { if ($first) { if (!($num_hour % 60) || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) { $first = false; // aggregation rows if ($num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) { $this->tpl->setVariable('TIME_ROWSPAN', 1); } else { $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster); } $this->tpl->setCurrentBlock('time_txt'); $this->tpl->setVariable('TIME', $hour['txt']); $this->tpl->parseCurrentBlock(); } } foreach ($hour['apps_start'] as $app) { $this->showAppointment($app); } // screen reader: appointments are divs, now output cell if ($ilUser->prefs["screen_reader_optimization"]) { $this->tpl->setCurrentBlock('scrd_day_cell'); $this->tpl->setVariable('TD_CLASS', 'calstd'); $this->tpl->parseCurrentBlock(); } #echo "NUMDAY: ".$num_day; #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />'; $num_apps = $hour['apps_num']; $colspan = max($colspans[$num_day], 1); // Show new apointment link if (!$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add) { $this->tpl->setCurrentBlock('new_app_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->weekdays[$num_day]->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'hour', floor($num_hour / 60)); $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add')); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->tpl->setVariable('DAY_NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app'))); $this->tpl->setVariable('DAY_NEW_APP_ALT', $this->lng->txt('cal_new_app')); $this->tpl->setVariable('DAY_NEW_ID', ++$new_link_counter); $this->tpl->parseCurrentBlock(); } for ($i = $colspan; $i > $hour['apps_num']; $i--) { if ($ilUser->prefs["screen_reader_optimization"]) { continue; } $this->tpl->setCurrentBlock('day_cell'); // last "slot" of hour needs border $empty_border = ''; if ($num_hour % 60 == 60 - $raster || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) { $empty_border = ' calempty_border'; } if ($i == $hour['apps_num'] + 1) { $this->tpl->setVariable('TD_CLASS', 'calempty calrightborder' . $empty_border); #$this->tpl->setVariable('TD_STYLE',$add_style); } else { $this->tpl->setVariable('TD_CLASS', 'calempty' . $empty_border); #$this->tpl->setVariable('TD_STYLE',$add_style); } if (!$hour['apps_num']) { $this->tpl->setVariable('DAY_ID', $new_link_counter); } $this->tpl->setVariable('TD_ROWSPAN', 1); $this->tpl->parseCurrentBlock(); } } $this->tpl->touchBlock('time_row'); } $this->tpl->setVariable("TXT_TIME", $lng->txt("time")); }
/** * Fills the table with data for whole week. */ public function show($export = false) { if ($export && isset($_SESSION['weeklySeed'])) { $this->seed = $_SESSION['weeklySeed']; } else { $_SESSION['weeklySeed'] = $this->seed; } if (!$this->permission->checkPrivilege(PRIVC::SEE_BOOKINGS_OF_ROOMS)) { ilUtil::sendFailure($this->lng->txt("rep_robj_xrs_no_permission_for_action")); $this->ctrl->redirectByClass('ilinfoscreengui', 'showSummary', 'showSummary'); return false; } global $ilUser; $this->setSubTabs('weekview'); //intervalsize $raster = 15; if ($this->user_settings->getDayStart()) { // push starting point to last "slot" of hour BEFORE morning aggregation $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster); } else { $morning_aggr = 0; } $evening_aggr = $this->user_settings->getDayEnd() * 60; $this->tpl = new ilTemplate('tpl.room_week_view.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/RoomSharing'); ilYuiUtil::initDragDrop(); ilYuiUtil::initPanel(); $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::WEEK); $this->tpl->setVariable('NAVIGATION', $navigation->getHTML()); if (isset($_GET["bkid"])) { $user_id = $_GET["bkid"]; $disable_empty = true; $no_add = true; } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) { $user_id = $ilUser->getId(); $disable_empty = false; $no_add = true; } else { $user_id = $ilUser->getId(); $disable_empty = false; $no_add = false; } $room = new ilRoomSharingRoom($this->pool_id, $this->room_id); $this->tpl->setVariable('ROOM', $this->lng->txt('rep_robj_xrs_room_occupation_title') . " " . $room->getName()); $this->scheduler = new ilRoomSharingCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_WEEK, $user_id, $room); $this->scheduler->addSubitemCalendars(true); $this->scheduler->calculate(); $counter = 0; $hours = NULL; foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) { $daily_apps = $this->scheduler->getByDay($date, $this->timezone); $hours = $this->parseHourInfo($daily_apps, $date, $counter, $hours, $morning_aggr, $evening_aggr, $raster); $this->weekdays[] = $date; $num_apps[$date->get(IL_CAL_DATE)] = count($daily_apps); $counter++; } $colspans = $this->calculateColspans($hours); $settings = ilCalendarSettings::_getInstance(); $exportLink = $this->ctrl->getLinkTargetByClass("ilroomsharingcalendarweekgui", "export"); $this->tpl->setCurrentBlock("export_block"); $this->tpl->setVariable('EXPORT_LINK', $exportLink); $this->tpl->parseCurrentBlock(); // Table header $counter = 0; foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $date->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE)); $dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE, 'w'), true); $this->days[$counter] = $date; $daydate = $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'], false); if (!$disable_empty || $num_apps[$date->get(IL_CAL_DATE)] > 0) { $link = $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''); $this->ctrl->clearParametersByClass('ilcalendardaygui'); $this->tpl->setCurrentBlock("day_view1_link"); $this->tpl->setVariable('HEADER_DATE', $daydate); $this->tpl->setVariable('DAY_VIEW_LINK', $link); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("day_view2_link"); $this->tpl->setVariable('DAYNAME', $dayname); $this->tpl->setVariable('DAY_VIEW_LINK', $link); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("day_view1_no_link"); $this->tpl->setVariable('HEADER_DATE', $daydate); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("day_view2_no_link"); $this->tpl->setVariable('DAYNAME', $dayname); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock('day_header_row'); $this->tpl->setVariable('DAY_COLSPAN', max($colspans[$counter], 1)); $this->tpl->parseCurrentBlock(); $counter++; } $new_link_counter = 0; foreach ($hours as $num_hour => $hours_per_day) { $first = true; foreach ($hours_per_day as $num_day => $hour) { if ($first) { if (!($num_hour % 60) || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) { $first = false; $this->timeIntervals[] = $hours_per_day[2]; // aggregation rows if ($num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) { $this->tpl->setVariable('TIME_ROWSPAN', 1); } else { $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster); } $this->tpl->setCurrentBlock('time_txt'); $this->tpl->setVariable('TIME', $hour['txt']); $this->tpl->parseCurrentBlock(); } } foreach ($hour['apps_start'] as $app) { $this->showAppointment($app); } // screen reader: appointments are divs, now output cell if ($ilUser->prefs["screen_reader_optimization"]) { $this->tpl->setCurrentBlock('scrd_day_cell'); $this->tpl->setVariable('TD_CLASS', 'calstd'); $this->tpl->parseCurrentBlock(); } #echo "NUMDAY: ".$num_day; #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />'; $num_apps = $hour['apps_num']; $colspan = max($colspans[$num_day], 1); // Show new apointment link $userCanAddBooking = $this->permission->checkPrivilege(PRIVC::ADD_OWN_BOOKINGS); $calStuffAllowed = !$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add; if ($userCanAddBooking && $calStuffAllowed) { $this->tpl->setCurrentBlock('new_app_link'); $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->lng->txt('rep_robj_xrs_room_book')); $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'room', $room->getName()); $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'room_id', $room->getId()); $_SESSION['last_cmd'] = 'showroom'; $date = $this->weekdays[$num_day]->get(IL_CAL_DATE); //convert time into suitable format (HH:ii:ss) $hr = floor($num_hour / 60); $hr = $hr < 10 ? "0" . $hr : $hr; $hr_end = floor(($num_hour + 60) / 60); $hr_end = $hr_end < 10 ? "0" . $hr_end : $hr_end; $min = floor($num_hour % 60); $min = $min < 10 ? "0" . $min : $min; $min_end = floor(($num_hour + 60) % 60); $min_end = $min_end < 10 ? "0" . $min_end : $min_end; $time_from = $hr . ":" . $min . ":00"; $time_to = $hr_end . ":" . $min_end . ":00"; $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'date', $date); $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'time_from', $time_from); $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'time_to', $time_to); $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->ctrl->getLinkTargetByClass('ilobjroomsharinggui', 'book')); // free the parameters $this->ctrl->clearParametersByClass('ilobjroomsharinggui'); $this->tpl->setVariable('DAY_NEW_APP_SRC', ilUtil::getImagePath('date_add.png')); $this->tpl->setVariable('DAY_NEW_APP_ALT', $this->lng->txt('cal_new_app')); $this->tpl->setVariable('DAY_NEW_ID', ++$new_link_counter); $this->tpl->parseCurrentBlock(); } for ($i = $colspan; $i > $hour['apps_num']; $i--) { if ($ilUser->prefs["screen_reader_optimization"]) { continue; } $this->tpl->setCurrentBlock('day_cell'); // last "slot" of hour needs border $empty_border = ''; if ($num_hour % 60 == 60 - $raster || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) { $empty_border = ' calempty_border'; } if ($i == $hour['apps_num'] + 1) { $this->tpl->setVariable('TD_CLASS', 'calempty calrightborder' . $empty_border); #$this->tpl->setVariable('TD_STYLE',$add_style); } else { $this->tpl->setVariable('TD_CLASS', 'calempty' . $empty_border); #$this->tpl->setVariable('TD_STYLE',$add_style); } if (!$hour['apps_num']) { $this->tpl->setVariable('DAY_ID', $new_link_counter); } $this->tpl->setVariable('TD_ROWSPAN', 1); $this->tpl->parseCurrentBlock(); } } $this->tpl->touchBlock('time_row'); } $this->tpl->setVariable("TXT_TIME", $this->lng->txt("time")); if ($export) { $this->export(); } }
protected function renderSlots(ilBookingSchedule $schedule, array $object_ids, $title) { global $ilUser; // fix if (!$schedule->getRaster()) { $mytpl = new ilTemplate('tpl.booking_reservation_fix.html', true, true, 'Modules/BookingManager'); $mytpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this)); $mytpl->setVariable('TXT_TITLE', $this->lng->txt('book_reservation_title')); $mytpl->setVariable('TXT_INFO', $this->lng->txt('book_reservation_fix_info')); $mytpl->setVariable('TXT_OBJECT', $title); $mytpl->setVariable('TXT_CMD_BOOK', $this->lng->txt('book_confirm_booking')); $mytpl->setVariable('TXT_CMD_CANCEL', $this->lng->txt('cancel')); include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $morning_aggr = $user_settings->getDayStart(); $evening_aggr = $user_settings->getDayEnd(); $hours = array(); for ($i = $morning_aggr; $i <= $evening_aggr; $i++) { switch ($user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: if ($morning_aggr > 0 && $i == $morning_aggr) { $hours[$i] = sprintf('%02d:00', 0) . "-"; } $hours[$i] .= sprintf('%02d:00', $i); if ($evening_aggr < 23 && $i == $evening_aggr) { $hours[$i] .= "-" . sprintf('%02d:00', 23); } break; case ilCalendarSettings::TIME_FORMAT_12: if ($morning_aggr > 0 && $i == $morning_aggr) { $hours[$i] = date('h a', mktime(0, 0, 0, 1, 1, 2000)) . "-"; } $hours[$i] .= date('h a', mktime($i, 0, 0, 1, 1, 2000)); if ($evening_aggr < 23 && $i == $evening_aggr) { $hours[$i] .= "-" . date('h a', mktime(23, 0, 0, 1, 1, 2000)); } break; } } if (isset($_GET['seed'])) { $find_first_open = false; $seed = new ilDate($_GET['seed'], IL_CAL_DATE); } else { $find_first_open = true; $seed = new ilDate(time(), IL_CAL_UNIX); } include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $week_start = $user_settings->getWeekStart(); if (!$find_first_open) { $dates = array(); $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); } else { $dates = array(); $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); // find first open slot if (!$has_open_slot) { // 1 year is limit for search $limit = clone $seed; $limit->increment(ilDate::YEAR, 1); $limit = $limit->get(IL_CAL_UNIX); while (!$has_open_slot && $seed->get(IL_CAL_UNIX) < $limit) { $seed->increment(ilDate::WEEK, 1); $dates = array(); $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); } } } include_once 'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php'; $navigation = new ilCalendarHeaderNavigationGUI($this, $seed, ilDateTime::WEEK, 'book'); $mytpl->setVariable('NAVIGATION', $navigation->getHTML()); foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $mytpl->setCurrentBlock('weekdays'); $mytpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($date_info['wday'])); $mytpl->setVariable('TXT_DATE', $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'])); $mytpl->parseCurrentBlock(); } include_once 'Services/Calendar/classes/class.ilCalendarAppointmentColors.php'; include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; $color = array(); $all = ilCalendarAppointmentColors::_getColorsByType('crs'); for ($loop = 0; $loop < 7; $loop++) { $col = $all[$loop]; $fnt = ilCalendarUtil::calculateFontColor($col); $color[$loop + 1] = 'border-bottom: 1px solid ' . $col . '; background-color: ' . $col . '; color: ' . $fnt; } $counter = 0; foreach ($dates as $hour => $days) { $caption = $days; $caption = array_shift($caption); for ($loop = 1; $loop < 8; $loop++) { if (!isset($days[$loop])) { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ' '); $mytpl->parseCurrentBlock(); } else { if (isset($days[$loop]['captions'])) { foreach ($days[$loop]['captions'] as $slot_id => $slot_caption) { $mytpl->setCurrentBlock('choice'); $mytpl->setVariable('TXT_DATE', $slot_caption); $mytpl->setVariable('VALUE_DATE', $slot_id); $mytpl->setVariable('DATE_COLOR', $color[$loop]); $mytpl->parseCurrentBlock(); } $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ''); $mytpl->parseCurrentBlock(); } else { if (isset($days[$loop]['in_slot'])) { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DATE_COLOR', $color[$loop]); $mytpl->parseCurrentBlock(); } else { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ' '); $mytpl->parseCurrentBlock(); } } } } $mytpl->setCurrentBlock('slots'); $mytpl->setVariable('TXT_HOUR', $caption); if ($counter % 2) { $mytpl->setVariable('CSS_ROW', 'tblrow1'); } else { $mytpl->setVariable('CSS_ROW', 'tblrow2'); } $mytpl->parseCurrentBlock(); $counter++; } } else { // :TODO: inactive for now } return $mytpl->get(); }
/** * fill data section * * @access public * */ public function show() { global $tpl, $ilUser; $this->tpl = new ilTemplate('tpl.month_view.html', true, true, 'Services/Calendar'); include_once './Services/YUI/classes/class.ilYuiUtil.php'; ilYuiUtil::initDragDrop(); ilYuiUtil::initPanel(); $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::MONTH); $this->tpl->setVariable('NAVIGATION', $navigation->getHTML()); for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) { $this->tpl->setCurrentBlock('month_header_col'); $this->tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, true)); $this->tpl->parseCurrentBlock(); } if (isset($_GET["bkid"])) { $user_id = $_GET["bkid"]; $disable_empty = true; $no_add = true; } else { if ($ilUser->getId() == ANONYMOUS_USER_ID) { $user_id = $ilUser->getId(); $disable_empty = false; $no_add = true; } else { $user_id = $ilUser->getId(); $disable_empty = false; $no_add = false; } } $is_portfolio_embedded = false; if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) { $no_add = true; $is_portfolio_embedded = true; } include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php'; $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id); $this->scheduler->addSubitemCalendars(true); if (sizeof($this->schedule_filters)) { foreach ($this->schedule_filters as $filter) { $this->scheduler->addFilter($filter); } } $this->scheduler->calculate(); include_once 'Services/Calendar/classes/class.ilCalendarSettings.php'; $settings = ilCalendarSettings::_getInstance(); $counter = 0; foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) { $counter++; $has_events = (bool) $this->showEvents($date); if (!$no_add) { include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'); if ($settings->getEnableGroupMilestones()) { $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE)); $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone'); $this->tpl->setCurrentBlock("new_ms"); $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX)); $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD)); $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url); $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app')); $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url); $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms')); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("new_app"); $this->tpl->setVariable('ADD_LINK', $new_app_url); $this->tpl->setVariable('NEW_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app'))); $this->tpl->parseCurrentBlock(); } } $day = $date->get(IL_CAL_FKT_DATE, 'j'); $month = $date->get(IL_CAL_FKT_DATE, 'n'); if ($day == 1) { $month_day = '1 ' . ilCalendarUtil::_numericMonthToString($month, false); } else { $month_day = $day; } if (!$is_portfolio_embedded && (!$disable_empty || $has_events)) { $this->tpl->setCurrentBlock('month_day_link'); $this->ctrl->clearParametersByClass('ilcalendardaygui'); $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE)); $this->tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', '')); $this->ctrl->clearParametersByClass('ilcalendardaygui'); } else { $this->tpl->setCurrentBlock('month_day_no_link'); } $this->tpl->setVariable('MONTH_DAY', $month_day); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock('month_col'); include_once './Services/Calendar/classes/class.ilCalendarUtil.php'; if (ilCalendarUtil::_isToday($date)) { $this->tpl->setVariable('TD_CLASS', 'caltoday'); } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) { $this->tpl->setVariable('TD_CLASS', 'calstd'); } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) { $this->tpl->setVariable('TD_CLASS', 'calprev'); } else { $this->tpl->setVariable('TD_CLASS', 'calnext'); } $this->tpl->parseCurrentBlock(); if ($counter and !($counter % 7)) { $this->tpl->setCurrentBlock('month_row'); $this->tpl->parseCurrentBlock(); } } }