protected function parseDynamicTitle($a_type) { global $lng; $title = $style = ""; switch ($a_type) { case "consultationhour": include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $entry = new ilBookingEntry($this->getContextId()); if ($entry) { if ($entry->isOwner()) { $max = (int) $entry->getNumberOfBookings(); $current = (int) $entry->getCurrentNumberOfBookings($this->getEntryId()); if (!$current) { $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: green'; $title = $lng->txt('cal_book_free'); } elseif ($current >= $max) { $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: red'; $title = $lng->txt('cal_booked_out'); } else { $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: yellow'; $title = $current . '/' . $max; } } else { /* * if($entry->hasBooked($this->getEntryId())) */ include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; $apps = ilConsultationHourAppointments::getAppointmentIds($entry->getObjId(), $this->getContextId(), $this->getStart()); $orig_event = $apps[0]; if ($entry->hasBooked($orig_event)) { $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: green'; $title = $lng->txt('cal_date_booked'); } } } break; } if ($style) { $this->presentation_style = $style; } return $title; }
/** * Add mini version of monthly overview * (Maybe extracted to another class, if used in pd calendar tab */ function addMiniMonth($a_tpl) { global $ilCtrl, $lng, $ilUser; // weekdays include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; $a_tpl->setCurrentBlock('month_header_col'); $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev")); $a_tpl->parseCurrentBlock(); for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) { $a_tpl->setCurrentBlock('month_header_col'); $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false)); $a_tpl->parseCurrentBlock(); } if (isset($_GET["bkid"])) { $user_id = $_GET["bkid"]; $disable_empty = true; } else { $user_id = $ilUser->getId(); $disable_empty = false; } include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php'; $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id); $this->scheduler->addSubitemCalendars(true); $this->scheduler->calculate(); $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++; $events = $this->scheduler->getByDay($date, $ilUser->getTimeZone()); $has_events = (bool) count($events); if ($has_events || !$disable_empty) { $a_tpl->setCurrentBlock('month_col_link'); } else { $a_tpl->setCurrentBlock('month_col_no_link'); } if ($disable_empty) { if (!$has_events) { $a_tpl->setVariable('DAY_CLASS', 'calminiinactive'); } else { $week_has_events = true; include_once 'Services/Booking/classes/class.ilBookingEntry.php'; foreach ($events as $event) { $booking = new ilBookingEntry($event['event']->getContextId()); if ($booking->hasBooked($event['event']->getEntryId())) { $a_tpl->setVariable('DAY_CLASS', 'calminiapp'); break; } } } } elseif ($has_events) { $week_has_events = true; $a_tpl->setVariable('DAY_CLASS', 'calminiapp'); } $day = $date->get(IL_CAL_FKT_DATE, 'j'); $month = $date->get(IL_CAL_FKT_DATE, 'n'); $month_day = $day; $ilCtrl->clearParametersByClass('ilcalendardaygui'); $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE)); $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', '')); $ilCtrl->clearParametersByClass('ilcalendardaygui'); $a_tpl->setVariable('MONTH_DAY', $month_day); $a_tpl->parseCurrentBlock(); $a_tpl->setCurrentBlock('month_col'); include_once './Services/Calendar/classes/class.ilCalendarUtil.php'; if (ilCalendarUtil::_isToday($date)) { $a_tpl->setVariable('TD_CLASS', 'calminitoday'); } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) { $a_tpl->setVariable('TD_CLASS', 'calministd'); } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) { $a_tpl->setVariable('TD_CLASS', 'calminiprev'); } else { $a_tpl->setVariable('TD_CLASS', 'calmininext'); } $a_tpl->parseCurrentBlock(); if ($counter and !($counter % 7)) { if (!$disable_empty || $week_has_events) { $a_tpl->setCurrentBlock('month_row_link'); $ilCtrl->clearParametersByClass('ilcalendarweekgui'); $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE)); $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui', '')); $ilCtrl->clearParametersByClass('ilcalendarweekgui'); } else { $a_tpl->setCurrentBlock('month_row_no_link'); $a_tpl->setVariable('WEEK_CLASS', 'calminiinactive'); } $a_tpl->setVariable('WEEK', $date->get(IL_CAL_FKT_DATE, 'W')); $a_tpl->parseCurrentBlock(); $a_tpl->setCurrentBlock('month_row'); $a_tpl->setVariable('TD_CLASS', 'calminiweek'); $a_tpl->parseCurrentBlock(); $week_has_events = false; } } $a_tpl->setCurrentBlock('mini_month'); $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview")); $a_tpl->setVariable('TXT_MONTH', $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y')); $myseed = clone $this->seed; $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE)); $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', '')); $myseed->increment(ilDateTime::MONTH, -1); $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE)); $a_tpl->setVariable('BL_TYPE', $this->getBlockType()); $a_tpl->setVariable('BL_ID', $this->getBlockId()); $a_tpl->setVariable('PREV_MONTH', $ilCtrl->getLinkTarget($this, "setSeed")); $a_tpl->setVariable('PREV_MONTH_ASYNC', $ilCtrl->getLinkTarget($this, "setSeed", "", true)); $myseed->increment(ilDateTime::MONTH, 2); $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE)); $a_tpl->setVariable('NEXT_MONTH', $ilCtrl->getLinkTarget($this, "setSeed")); $a_tpl->setVariable('NEXT_MONTH_ASYNC', $ilCtrl->getLinkTarget($this, "setSeed", "", true)); $ilCtrl->setParameter($this, 'seed', ""); $a_tpl->parseCurrentBlock(); }
/** * Confirmation screen to cancel consultation appointment or ressource booking * depends on calendar category */ public function cancelBooking() { global $ilUser, $tpl; $entry = (int) $_GET['app_id']; include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry($entry); $category = $this->calendarEntryToCategory($entry); if ($category->getType() == ilCalendarCategory::TYPE_CH) { include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $booking = new ilBookingEntry($entry->getContextId()); if (!$booking->hasBooked($entry->getEntryId())) { $this->ctrl->returnToParent($this); return false; } $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')'; } else { if ($category->getType() == ilCalendarCategory::TYPE_BOOK) { $entry_title = ' ' . $entry->getTitle(); } else { $this->ctrl->returnToParent($this); return false; } } $title = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()); include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php'; $conf = new ilConfirmationGUI(); $conf->setFormAction($this->ctrl->getFormAction($this)); $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info')); $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed'); $conf->setCancel($this->lng->txt('cancel'), 'cancel'); $conf->addItem('app_id', $entry->getEntryId(), $title . ' - ' . $entry_title); $tpl->setContent($conf->getHTML()); }
/** * get HTML * * @access public * @param * @return */ public function getHTML($a_app) { global $tree, $lng, $ilUser; self::$counter++; $this->tpl = new ilTemplate('tpl.appointment_panel.html', true, true, 'Services/Calendar'); // Panel variables $this->tpl->setVariable('PANEL_NUM', self::$counter); $this->tpl->setVariable('PANEL_TITLE', str_replace(' ()', '', $a_app['event']->getPresentationTitle(false))); if ($a_app["event"]->isMilestone()) { $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_ms_details')); } else { $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_details')); } $this->tpl->setVariable('PANEL_TXT_DATE', $this->lng->txt('date')); if ($a_app['fullday']) { $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(new ilDate($a_app['dstart'], IL_CAL_UNIX), new ilDate($a_app['dend'], IL_CAL_UNIX))); } else { $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX))); } if ($a_app['event']->getLocation()) { $this->tpl->setVariable('PANEL_TXT_WHERE', $this->lng->txt('cal_where')); $this->tpl->setVariable('PANEL_WHERE', ilUtil::makeClickable($a_app['event']->getLocation()), true); } if ($a_app['event']->getDescription()) { $this->tpl->setVariable('PANEL_TXT_DESC', $this->lng->txt('description')); $this->tpl->setVariable('PANEL_DESC', ilUtil::makeClickable(nl2br($a_app['event']->getDescription()))); } if ($a_app['event']->isMilestone() && $a_app['event']->getCompletion() > 0) { $this->tpl->setVariable('PANEL_TXT_COMPL', $this->lng->txt('cal_task_completion')); $this->tpl->setVariable('PANEL_COMPL', $a_app['event']->getCompletion() . " %"); } if ($a_app['event']->isMilestone()) { // users responsible $users = $a_app['event']->readResponsibleUsers(); $delim = ""; foreach ($users as $r) { $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]"; $delim = "<br />"; } if (count($users) > 0) { $this->tpl->setVariable('PANEL_TXT_RESP', $this->lng->txt('cal_responsible')); $this->tpl->setVariable('PANEL_RESP', $value); } } include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $cat_id = ilCalendarCategoryAssignments::_lookupCategory($a_app['event']->getEntryId()); $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id); $entry_obj_id = isset($cat_info['subitem_obj_ids'][$cat_id]) ? $cat_info['subitem_obj_ids'][$cat_id] : $cat_info['obj_id']; $this->tpl->setVariable('PANEL_TXT_CAL_TYPE', $this->lng->txt('cal_cal_type')); switch ($cat_info['type']) { case ilCalendarCategory::TYPE_GLOBAL: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_system')); break; case ilCalendarCategory::TYPE_USR: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_personal')); break; case ilCalendarCategory::TYPE_OBJ: $type = ilObject::_lookupType($cat_info['obj_id']); $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_' . $type)); // Course group appointment registration if ($this->settings->isCGRegistrationEnabled() and $type == 'crs' or type == 'grp') { if (!$a_app['event']->isAutoGenerated()) { include_once './Services/Calendar/classes/class.ilCalendarRegistration.php'; $reg = new ilCalendarRegistration($a_app['event']->getEntryId()); if ($reg->isRegistered($ilUser->getId(), new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX))) { $this->tpl->setCurrentBlock('panel_cancel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']); $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_reg_unregister')); $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmUnregister')); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock('panel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']); $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_reg_register')); $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmRegister')); $this->tpl->parseCurrentBlock(); } include_once './Services/Link/classes/class.ilLink.php'; $registrations = array(); foreach ($reg->getRegisteredUsers(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX)) as $usr_data) { $usr_id = $usr_data['usr_id']; $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $usr_id); $registrations[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($usr_id); $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', ''); } if (count($registrations)) { $this->tpl->setCurrentBlock('panel_current_booking'); $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_reg_registered_users')); $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $registrations)); $this->tpl->parseCurrentBlock(); } } } break; case ilCalendarCategory::TYPE_CH: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_ch')); include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $entry = new ilBookingEntry($a_app['event']->getContextId()); $is_owner = $entry->isOwner(); $user_entry = $cat_info['obj_id'] == $ilUser->getId(); if ($user_entry && !$is_owner) { // find source calendar entry in owner calendar include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; $apps = ilConsultationHourAppointments::getAppointmentIds($entry->getObjId(), $a_app['event']->getContextId(), $a_app['event']->getStart()); $ref_event = $apps[0]; } else { $ref_event = $a_app['event']->getEntryId(); } $this->tpl->setCurrentBlock('panel_booking_owner'); $this->tpl->setVariable('PANEL_TXT_BOOKING_OWNER', $this->lng->txt('cal_ch_booking_owner')); $this->tpl->setVariable('PANEL_BOOKING_OWNER', ilObjUser::_lookupFullname($entry->getObjId())); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock('panel_max_booking'); $this->tpl->setVariable('PANEL_TXT_MAX_BOOKING', $this->lng->txt('cal_ch_num_bookings')); $this->tpl->setVariable('PANEL_MAX_BOOKING', $entry->getNumberOfBookings()); $this->tpl->parseCurrentBlock(); if (!$is_owner) { if ($entry->hasBooked($ref_event)) { if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) { $this->tpl->setCurrentBlock('panel_cancel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking')); $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')); $this->tpl->parseCurrentBlock(); } } elseif ($entry->isAppointmentBookableForUser($ref_event, $GLOBALS['ilUser']->getId())) { $this->tpl->setCurrentBlock('panel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_ch_book')); $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book')); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock('panel_current_booking'); $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings')); $this->tpl->setVariable('PANEL_CURRENT_BOOKING', $entry->getCurrentNumberOfBookings($ref_event)); $this->tpl->parseCurrentBlock(); } else { $obj_ids = $entry->getTargetObjIds(); foreach ($obj_ids as $obj_id) { $title = ilObject::_lookupTitle($obj_id); $refs = ilObject::_getAllReferences($obj_id); include_once './Services/Link/classes/class.ilLink.php'; $this->tpl->setCurrentBlock('panel_booking_target_row'); $this->tpl->setVariable('PANEL_BOOKING_TARGET_TITLE', $title); $this->tpl->setVariable('PANEL_BOOKING_TARGET', ilLink::_getLink(end($refs))); $this->tpl->parseCurrentBlock(); } if ($obj_ids) { $this->tpl->setCurrentBlock('panel_booking_target'); $this->tpl->setVariable('PANEL_TXT_BOOKING_TARGET', $this->lng->txt('cal_ch_target_object')); $this->tpl->parseCurrentBlock(); } $link_users = true; if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) { $link_users = false; } include_once './Services/Link/classes/class.ilLink.php'; $bookings = array(); $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', 1); foreach ($entry->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) { if ($link_users) { $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $user_id); $bookings[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($user_id) . '</a>'; $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', ''); } else { $bookings[] = ilObjUser::_lookupFullname($user_id); } } $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', ''); $this->tpl->setCurrentBlock('panel_current_booking'); $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings')); $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $bookings)); $this->tpl->parseCurrentBlock(); } break; case ilCalendarCategory::TYPE_BOOK: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_booking')); $this->tpl->setCurrentBlock('panel_cancel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking')); $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')); $this->tpl->parseCurrentBlock(); break; } $this->tpl->setVariable('PANEL_TXT_CAL_NAME', $this->lng->txt('cal_calendar_name')); $this->tpl->setVariable('PANEL_CAL_NAME', $cat_info['title']); if ($cat_info['editable'] and !$a_app['event']->isAutoGenerated()) { $this->tpl->setCurrentBlock('panel_edit_link'); $this->tpl->setVariable('TXT_PANEL_EDIT', $this->lng->txt('edit')); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']); $this->tpl->setVariable('PANEL_EDIT_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askEdit')); $this->tpl->setCurrentBlock('panel_delete_link'); $this->tpl->setVariable('TXT_PANEL_DELETE', $this->lng->txt('delete')); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']); $this->tpl->setVariable('PANEL_DELETE_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askdelete')); $this->tpl->parseCurrentBlock(); } include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; if ($cat_info['type'] == ilCalendarCategory::TYPE_OBJ) { $refs = ilObject::_getAllReferences($entry_obj_id); $type = ilObject::_lookupType($entry_obj_id); $title = ilObject::_lookupTitle($entry_obj_id) ? ilObject::_lookupTitle($entry_obj_id) : $lng->txt('obj_' . $type); include_once './Services/Link/classes/class.ilLink.php'; $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($entry_obj_id)); $parent = $tree->getParentId(current($refs)); $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($parent)); $this->tpl->setVariable('PANEL_TXT_LINK', $this->lng->txt('ext_link')); $this->tpl->setVariable('PANEL_LINK_HREF', $href); $this->tpl->setVariable('PANEL_LINK_NAME', $title); $this->tpl->setVariable('PANEL_PARENT', $parent_title); } return $this->tpl->get(); }
/** * set appointments * * @access public * @return */ public function setAppointments($a_apps) { include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php'; include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; $cat = new ilCalendarCategory($this->cat_id); foreach ($a_apps as $cal_entry_id) { $entry = new ilCalendarEntry($cal_entry_id); $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId()); // booking if ($cat->getType() == ilCalendarCategory::TYPE_CH) { include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $book = new ilBookingEntry($entry->getContextId()); if ($book) { $title = $entry->getTitle(); if ($book->isOwner()) { $max = (int) $book->getNumberOfBookings(); $current = (int) $book->getCurrentNumberOfBookings($entry->getEntryId()); if ($max > 1) { $title .= ' (' . $current . '/' . $max . ')'; } else { if ($current == $max) { $title .= ' (' . $this->lng->txt('cal_booked_out') . ')'; } else { $title .= ' (' . $this->lng->txt('cal_book_free') . ')'; } } } else { if ($book->hasBooked($entry->getEntryId())) { $title .= ' (' . $this->lng->txt('cal_date_booked') . ')'; } } } } else { $title = $entry->getPresentationTitle(); } $tmp_arr['id'] = $entry->getEntryId(); $tmp_arr['title'] = $title; $tmp_arr['description'] = $entry->getDescription(); $tmp_arr['fullday'] = $entry->isFullday(); $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX); $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX); $tmp_arr['dt_sort'] = $entry->getStart()->get(IL_CAL_UNIX); $tmp_arr['dt'] = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()); #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24; $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin']; if ($tmp_arr['fullday']) { $tmp_arr['duration'] += 60 * 60 * 24; } if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) { $tmp_arr['duration'] = ''; } $tmp_arr['frequence'] = $rec->getFrequenceType(); $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable); $appointments[] = $tmp_arr; } $this->setData($appointments ? $appointments : array()); }
/** * show appointment * * @access protected * @param array appointment */ protected function showAppointment($a_app) { global $ilUser; $this->tpl->setCurrentBlock('panel_code'); $this->tpl->setVariable('NUM', $this->num_appointments); $this->tpl->parseCurrentBlock(); if (!$ilUser->prefs["screen_reader_optimization"]) { $this->tpl->setCurrentBlock('app'); } else { $this->tpl->setCurrentBlock('scrd_app'); } include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php'; $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app)); $this->tpl->setVariable('PANEL_NUM', $this->num_appointments); $this->tpl->setVariable('APP_ROWSPAN', $a_app['rowspan']); $this->tpl->setVariable('APP_TITLE', $a_app['event']->getPresentationTitle(false)); switch ($this->user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone); break; case ilCalendarSettings::TIME_FORMAT_12: $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone); break; } // add end time for screen readers if ($ilUser->prefs["screen_reader_optimization"]) { switch ($this->user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone); break; case ilCalendarSettings::TIME_FORMAT_12: $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone); break; } } // booking if ($a_app['category_type'] == ilCalendarCategory::TYPE_CH) { include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $entry = new ilBookingEntry($a_app['event']->getContextId()); if ($entry) { $title .= ' ' . $a_app['event']->getTitle(); if ($entry->isOwner()) { $max = (int) $entry->getNumberOfBookings(); $current = (int) $entry->getCurrentNumberOfBookings($a_app['event']->getEntryId()); if ($max > 1) { $title .= ' (' . $current . '/' . $max . ')'; } else { if ($current == $max) { $title .= ' (' . $this->lng->txt('cal_booked_out') . ')'; } else { $title .= ' (' . $this->lng->txt('cal_book_free') . ')'; } } } else { if ($entry->hasBooked($a_app['event']->getEntryId())) { $title .= ' (' . $this->lng->txt('cal_date_booked') . ')'; } } } } else { $title .= ' ' . $a_app['event']->getPresentationTitle(false); } $this->tpl->setVariable('APP_TITLE', $title); $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId()); $this->tpl->setVariable('APP_BGCOLOR', $color); $this->tpl->setVariable('APP_COLOR', ilCalendarUtil::calculateFontColor($color)); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit')); $this->tpl->parseCurrentBlock(); $this->num_appointments++; }
/** * Confirmation screen to cancel consultation appointment or ressource booking * depends on calendar category */ public function cancelBooking() { global $ilUser, $tpl; $entry = (int) $_GET['app_id']; include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry($entry); $category = $this->calendarEntryToCategory($entry); if ($category->getType() == ilCalendarCategory::TYPE_CH) { include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $booking = new ilBookingEntry($entry->getContextId()); if (!$booking->hasBooked($entry->getEntryId())) { $this->ctrl->returnToParent($this); return false; } $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')'; } else { if ($category->getType() == ilCalendarCategory::TYPE_BOOK) { $entry_title = ' ' . $entry->getTitle(); } else { $this->ctrl->returnToParent($this); return false; } } $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $timezone = $ilUser->getTimeZone(); switch ($user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: $title = $entry->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $timezone); $title .= "-" . $entry->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $timezone); break; case ilCalendarSettings::TIME_FORMAT_12: $title = $entry->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $timezone); $title .= "-" . $entry->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $timezone); break; } include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php'; $conf = new ilConfirmationGUI(); $conf->setFormAction($this->ctrl->getFormAction($this)); $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info')); $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed'); $conf->setCancel($this->lng->txt('cancel'), 'cancel'); $conf->addItem('app_id', $entry->getEntryId(), $title . ' - ' . $entry_title); $tpl->setContent($conf->getHTML()); }