3 declare(strict_types=1);
50 $this->
lng = $DIC->language();
51 $this->
ctrl = $DIC->ctrl();
52 $this->tree = $DIC->repositoryTree();
53 $this->
user = $DIC->user();
63 if (!self::$instance instanceof
self) {
64 self::$instance =
new self(
$seed);
66 return self::$instance;
80 $this->tpl =
new ilTemplate(
'tpl.appointment_panel.html',
true,
true,
'Services/Calendar');
83 $this->tpl->setVariable(
'PANEL_NUM', self::$counter);
84 $this->tpl->setVariable(
'PANEL_TITLE', str_replace(
' ()',
'', $a_app[
'event']->getPresentationTitle(
false)));
85 $this->tpl->setVariable(
'PANEL_DETAILS', $this->
lng->txt(
'cal_details'));
86 $this->tpl->setVariable(
'PANEL_TXT_DATE', $this->
lng->txt(
'date'));
88 if ($a_app[
'fullday']) {
99 if ($a_app[
'event']->getLocation()) {
100 $this->tpl->setVariable(
'PANEL_TXT_WHERE', $this->
lng->txt(
'cal_where'));
103 if ($a_app[
'event']->getDescription()) {
104 $this->tpl->setVariable(
'PANEL_TXT_DESC', $this->
lng->txt(
'description'));
105 $this->tpl->setVariable(
'PANEL_DESC',
ilUtil::makeClickable(nl2br($a_app[
'event']->getDescription())));
110 $entry_obj_id = $cat_info[
'subitem_obj_ids'][$cat_id] ?? $cat_info[
'obj_id'];
112 $this->tpl->setVariable(
'PANEL_TXT_CAL_TYPE', $this->
lng->txt(
'cal_cal_type'));
113 switch ($cat_info[
'type']) {
115 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_type_system'));
119 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_type_personal'));
124 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_type_' . $type));
127 if ($this->
settings->isCGRegistrationEnabled() and $type ==
'crs' or $type ==
'grp') {
128 if (!$a_app[
'event']->isAutoGenerated()) {
131 if ($reg->isRegistered(
132 $this->user->getId(),
136 $this->tpl->setCurrentBlock(
'panel_cancel_book_link');
137 $this->
ctrl->setParameterByClass(
138 'ilcalendarappointmentgui',
142 $this->
ctrl->setParameterByClass(
143 'ilcalendarappointmentgui',
145 $a_app[
'event']->getEntryId()
147 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dstart', $a_app[
'dstart']);
148 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dend', $a_app[
'dend']);
150 $this->tpl->setVariable(
'TXT_PANEL_CANCELBOOK', $this->
lng->txt(
'cal_reg_unregister'));
151 $this->tpl->setVariable(
152 'PANEL_CANCELBOOK_HREF',
153 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'confirmUnregister')
155 $this->tpl->parseCurrentBlock();
157 $this->tpl->setCurrentBlock(
'panel_book_link');
158 $this->
ctrl->setParameterByClass(
159 'ilcalendarappointmentgui',
163 $this->
ctrl->setParameterByClass(
164 'ilcalendarappointmentgui',
166 $a_app[
'event']->getEntryId()
168 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dstart', $a_app[
'dstart']);
169 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dend', $a_app[
'dend']);
170 $this->tpl->setVariable(
'TXT_PANEL_BOOK', $this->
lng->txt(
'cal_reg_register'));
171 $this->tpl->setVariable(
173 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'confirmRegister')
175 $this->tpl->parseCurrentBlock();
178 $registrations = array();
179 foreach ($reg->getRegisteredUsers(
184 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user', $usr_id);
185 $registrations[] =
'<a href="' . $this->
ctrl->getLinkTargetByClass(
186 'ilconsultationhoursgui',
189 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user',
'');
191 if (count($registrations)) {
192 $this->tpl->setCurrentBlock(
'panel_current_booking');
193 $this->tpl->setVariable(
194 'PANEL_TXT_CURRENT_BOOKING',
195 $this->
lng->txt(
'cal_reg_registered_users')
197 $this->tpl->setVariable(
'PANEL_CURRENT_BOOKING', implode(
'<br />', $registrations));
198 $this->tpl->parseCurrentBlock();
205 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_ch_ch'));
209 $is_owner = $entry->isOwner();
210 $user_entry = ($cat_info[
'obj_id'] == $this->
user->getId());
212 if ($user_entry && !$is_owner) {
216 $a_app[
'event']->getContextId(),
217 $a_app[
'event']->getStart()
219 $ref_event = $apps[0];
221 $ref_event = $a_app[
'event']->getEntryId();
224 $this->tpl->setCurrentBlock(
'panel_booking_owner');
225 $this->tpl->setVariable(
'PANEL_TXT_BOOKING_OWNER', $this->
lng->txt(
'cal_ch_booking_owner'));
227 $this->tpl->parseCurrentBlock();
229 $this->tpl->setCurrentBlock(
'panel_max_booking');
230 $this->tpl->setVariable(
'PANEL_TXT_MAX_BOOKING', $this->
lng->txt(
'cal_ch_num_bookings'));
231 $this->tpl->setVariable(
'PANEL_MAX_BOOKING', $entry->getNumberOfBookings());
232 $this->tpl->parseCurrentBlock();
235 if ($entry->hasBooked($ref_event)) {
237 $this->tpl->setCurrentBlock(
'panel_cancel_book_link');
238 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $ref_event);
239 $this->
ctrl->setParameterByClass(
240 'ilcalendarappointmentgui',
244 $this->tpl->setVariable(
'TXT_PANEL_CANCELBOOK', $this->
lng->txt(
'cal_ch_cancel_booking'));
245 $this->tpl->setVariable(
246 'PANEL_CANCELBOOK_HREF',
247 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'cancelBooking')
249 $this->tpl->parseCurrentBlock();
251 } #
else if(!$entry->isBookedOut($ref_event))
252 elseif ($entry->isAppointmentBookableForUser($ref_event,
$GLOBALS[
'DIC'][
'ilUser']->getId())) {
253 $this->tpl->setCurrentBlock(
'panel_book_link');
254 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $ref_event);
255 $this->
ctrl->setParameterByClass(
256 'ilcalendarappointmentgui',
260 $this->tpl->setVariable(
'TXT_PANEL_BOOK', $this->
lng->txt(
'cal_ch_book'));
261 $this->tpl->setVariable(
263 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'book')
265 $this->tpl->parseCurrentBlock();
268 $this->tpl->setCurrentBlock(
'panel_current_booking');
269 $this->tpl->setVariable(
'PANEL_TXT_CURRENT_BOOKING', $this->
lng->txt(
'cal_ch_current_bookings'));
270 $this->tpl->setVariable(
'PANEL_CURRENT_BOOKING', $entry->getCurrentNumberOfBookings($ref_event));
271 $this->tpl->parseCurrentBlock();
273 $obj_ids = $entry->getTargetObjIds();
274 foreach ($obj_ids as $obj_id) {
277 $this->tpl->setCurrentBlock(
'panel_booking_target_row');
278 $this->tpl->setVariable(
'PANEL_BOOKING_TARGET_TITLE', $title);
279 $this->tpl->setVariable(
'PANEL_BOOKING_TARGET', ilLink::_getLink(end($refs)));
280 $this->tpl->parseCurrentBlock();
283 $this->tpl->setCurrentBlock(
'panel_booking_target');
284 $this->tpl->setVariable(
'PANEL_TXT_BOOKING_TARGET', $this->
lng->txt(
'cal_ch_target_object'));
285 $this->tpl->parseCurrentBlock();
294 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'panel', 1);
295 foreach ($entry->getCurrentBookings($a_app[
'event']->getEntryId()) as $user_id) {
297 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user', $user_id);
298 $bookings[] =
'<a href="' . $this->
ctrl->getLinkTargetByClass(
299 'ilconsultationhoursgui',
303 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user',
'');
308 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'panel',
'');
309 $this->tpl->setCurrentBlock(
'panel_current_booking');
310 $this->tpl->setVariable(
'PANEL_TXT_CURRENT_BOOKING', $this->
lng->txt(
'cal_ch_current_bookings'));
311 $this->tpl->setVariable(
'PANEL_CURRENT_BOOKING', implode(
'<br />', $bookings));
312 $this->tpl->parseCurrentBlock();
317 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_ch_booking'));
319 $this->tpl->setCurrentBlock(
'panel_cancel_book_link');
320 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
321 $this->
ctrl->setParameterByClass(
322 'ilcalendarappointmentgui',
326 $this->tpl->setVariable(
'TXT_PANEL_CANCELBOOK', $this->
lng->txt(
'cal_ch_cancel_booking'));
327 $this->tpl->setVariable(
328 'PANEL_CANCELBOOK_HREF',
329 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'cancelBooking')
331 $this->tpl->parseCurrentBlock();
335 $this->tpl->setVariable(
'PANEL_TXT_CAL_NAME', $this->
lng->txt(
'cal_calendar_name'));
336 $this->tpl->setVariable(
'PANEL_CAL_NAME', $cat_info[
'title']);
338 if ($cat_info[
'editable'] and !$a_app[
'event']->isAutoGenerated()) {
339 $this->tpl->setCurrentBlock(
'panel_edit_link');
340 $this->tpl->setVariable(
'TXT_PANEL_EDIT', $this->
lng->txt(
'edit'));
342 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
344 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
345 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dt', $a_app[
'dstart']);
346 $this->tpl->setVariable(
348 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'askEdit')
351 $this->tpl->setCurrentBlock(
'panel_delete_link');
352 $this->tpl->setVariable(
'TXT_PANEL_DELETE', $this->
lng->txt(
'delete'));
354 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
356 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
357 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dt', $a_app[
'dstart']);
358 $this->tpl->setVariable(
360 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'askdelete')
362 $this->tpl->parseCurrentBlock();
369 $this->
lng->txt(
'obj_' . $type);
372 $parent = $this->tree->getParentId(current($refs));
374 $this->tpl->setVariable(
'PANEL_TXT_LINK', $this->
lng->txt(
'ext_link'));
375 $this->tpl->setVariable(
'PANEL_LINK_HREF', $href);
376 $this->tpl->setVariable(
'PANEL_LINK_NAME', $title);
377 $this->tpl->setVariable(
'PANEL_PARENT', $parent_title);
380 return $this->tpl->get();
static _lookupCategory(int $a_cal_id)
__construct(ilDate $seed=null)
static _lookupFullname(int $a_user_id)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
static getAppointmentIds(int $a_user_id, int $a_context_id=null, ?ilDateTime $a_start=null, ?int $a_type=null, bool $a_check_owner=true)
static _lookupTitle(int $obj_id)
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
registration for calendar appointments
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
ilCalendarSettings $settings
const MODE_PORTFOLIO_CONSULTATION
static _getInstance($a_usr_id=0)
get singleton instance
GUI class for YUI appointment panels.
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static _getInstance(ilDate $seed)
get singleton instance
static _lookupType(int $id, bool $reference=false)
static makeClickable(string $a_text, bool $detectGotoLinks=false)