/** * 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 buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates) { $map = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'); $definition = $schedule->getDefinition(); $has_open_slot = false; foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $slots = array(); if (isset($definition[$map[$date_info['isoday'] - 1]])) { $slots = array(); foreach ($definition[$map[$date_info['isoday'] - 1]] as $slot) { $slot = explode('-', $slot); $slots[] = array('from' => str_replace(':', '', $slot[0]), 'to' => str_replace(':', '', $slot[1])); } } $last = array_pop(array_keys($hours)); $slot_captions = array(); foreach ($hours as $hour => $period) { $dates[$hour][0] = $period; $period = explode("-", $period); if (sizeof($period) == 1) { $period_from = (int) substr($period[0], 0, 2) . "00"; $period_to = (int) substr($period[0], 0, 2) . "59"; } else { $period_from = (int) substr($period[0], 0, 2) . "00"; $period_to = (int) substr($period[1], 0, 2) . "59"; } $column = $date_info['isoday']; if (!$week_start) { if ($column < 7) { $column++; } else { $column = 1; } } if (sizeof($slots)) { $in = false; foreach ($slots as $slot) { $slot_from = mktime(substr($slot['from'], 0, 2), substr($slot['from'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]); $slot_to = mktime(substr($slot['to'], 0, 2), substr($slot['to'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]); // check deadline if ($slot_from < time() + $schedule->getDeadline() * 60 * 60 || !ilBookingReservation::getAvailableObject($object_ids, $slot_from, $slot_to - 1)) { continue; } // is slot active in current hour? if ((int) $slot['from'] < $period_to && (int) $slot['to'] > $period_from) { $from = ilDatePresentation::formatDate(new ilDateTime($slot_from, IL_CAL_UNIX)); $from = array_pop(explode(' ', $from)); $to = ilDatePresentation::formatDate(new ilDateTime($slot_to, IL_CAL_UNIX)); $to = array_pop(explode(' ', $to)); // show caption (first hour) of slot $id = $slot_from . '_' . $slot_to; if (!in_array($id, $slot_captions)) { $dates[$hour][$column]['captions'][$id] = $from . '-' . $to; $slot_captions[] = $id; } $in = true; } } // (any) active slot if ($in) { $has_open_slot = true; $dates[$hour][$column]['in_slot'] = $in; } } } } return $has_open_slot; }
protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates) { global $ilUser; include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $map = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'); $definition = $schedule->getDefinition(); $has_open_slot = false; foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $slots = array(); if (isset($definition[$map[$date_info['isoday'] - 1]])) { $slots = array(); foreach ($definition[$map[$date_info['isoday'] - 1]] as $slot) { $slot = explode('-', $slot); $slots[] = array('from' => str_replace(':', '', $slot[0]), 'to' => str_replace(':', '', $slot[1])); } } $last = array_pop(array_keys($hours)); $slot_captions = array(); foreach ($hours as $hour => $period) { $dates[$hour][0] = $period; $period = explode("-", $period); // #13738 if ($user_settings->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_12) { if (stristr($period[0], "pm")) { $period[0] = (int) $period[0] + 12; } else { $period[0] = (int) $period[0]; if ($period[0] == 12) { $period[0] = 0; } } if (sizeof($period) == 2) { if (stristr($period[1], "pm")) { $period[1] = (int) $period[1] + 12; } else { $period[1] = (int) $period[1]; if ($period[1] == 12) { $period[1] = 0; } } } } if (sizeof($period) == 1) { $period_from = (int) substr($period[0], 0, 2) . "00"; $period_to = (int) substr($period[0], 0, 2) . "59"; } else { $period_from = (int) substr($period[0], 0, 2) . "00"; $period_to = (int) substr($period[1], 0, 2) . "59"; } $column = $date_info['isoday']; if (!$week_start) { if ($column < 7) { $column++; } else { $column = 1; } } if (sizeof($slots)) { $in = false; foreach ($slots as $slot) { $slot_from = mktime(substr($slot['from'], 0, 2), substr($slot['from'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]); $slot_to = mktime(substr($slot['to'], 0, 2), substr($slot['to'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]); // always single object, we can sum up $nr_available = (array) ilBookingReservation::getAvailableObject($object_ids, $slot_from, $slot_to - 1, false, true); // check deadline if ($slot_from < time() + $schedule->getDeadline() * 60 * 60 || !array_sum($nr_available)) { continue; } // is slot active in current hour? if ((int) $slot['from'] < $period_to && (int) $slot['to'] > $period_from) { $from = ilDatePresentation::formatDate(new ilDateTime($slot_from, IL_CAL_UNIX)); $from = array_pop(explode(' ', $from)); $to = ilDatePresentation::formatDate(new ilDateTime($slot_to, IL_CAL_UNIX)); $to = array_pop(explode(' ', $to)); // show caption (first hour) of slot $id = $slot_from . '_' . $slot_to; if (!in_array($id, $slot_captions)) { $dates[$hour][$column]['captions'][$id] = $from . '-' . $to; $dates[$hour][$column]['available'][$id] = array_sum($nr_available); $slot_captions[] = $id; } $in = true; } } // (any) active slot if ($in) { $has_open_slot = true; $dates[$hour][$column]['in_slot'] = $in; } } } } return $has_open_slot; }