19 declare(strict_types=1);
44 $this->
lng = $DIC->language();
45 $this->
ctrl = $DIC->ctrl();
46 $this->tree = $DIC->repositoryTree();
47 $this->
user = $DIC->user();
57 if (!self::$instance instanceof
self) {
58 self::$instance =
new self(
$seed);
60 return self::$instance;
74 $this->tpl =
new ilTemplate(
'tpl.appointment_panel.html',
true,
true,
'components/ILIAS/Calendar');
77 $this->tpl->setVariable(
'PANEL_NUM', self::$counter);
78 $this->tpl->setVariable(
'PANEL_TITLE', str_replace(
' ()',
'', $a_app[
'event']->getPresentationTitle(
false)));
79 $this->tpl->setVariable(
'PANEL_DETAILS', $this->
lng->txt(
'cal_details'));
80 $this->tpl->setVariable(
'PANEL_TXT_DATE', $this->
lng->txt(
'date'));
82 if ($a_app[
'fullday']) {
93 if ($a_app[
'event']->getLocation()) {
94 $this->tpl->setVariable(
'PANEL_TXT_WHERE', $this->
lng->txt(
'cal_where'));
97 if ($a_app[
'event']->getDescription()) {
98 $this->tpl->setVariable(
'PANEL_TXT_DESC', $this->
lng->txt(
'description'));
99 $this->tpl->setVariable(
'PANEL_DESC',
ilUtil::makeClickable(nl2br($a_app[
'event']->getDescription())));
104 $entry_obj_id = $cat_info[
'subitem_obj_ids'][$cat_id] ?? $cat_info[
'obj_id'];
106 $this->tpl->setVariable(
'PANEL_TXT_CAL_TYPE', $this->
lng->txt(
'cal_cal_type'));
107 switch ($cat_info[
'type']) {
109 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_type_system'));
113 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_type_personal'));
118 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_type_' . $type));
121 if ($this->
settings->isCGRegistrationEnabled() and $type ==
'crs' or $type ==
'grp') {
122 if (!$a_app[
'event']->isAutoGenerated()) {
125 if ($reg->isRegistered(
126 $this->user->getId(),
130 $this->tpl->setCurrentBlock(
'panel_cancel_book_link');
131 $this->
ctrl->setParameterByClass(
132 'ilcalendarappointmentgui',
136 $this->
ctrl->setParameterByClass(
137 'ilcalendarappointmentgui',
139 $a_app[
'event']->getEntryId()
141 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dstart', $a_app[
'dstart']);
142 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dend', $a_app[
'dend']);
144 $this->tpl->setVariable(
'TXT_PANEL_CANCELBOOK', $this->
lng->txt(
'cal_reg_unregister'));
145 $this->tpl->setVariable(
146 'PANEL_CANCELBOOK_HREF',
147 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'confirmUnregister')
149 $this->tpl->parseCurrentBlock();
151 $this->tpl->setCurrentBlock(
'panel_book_link');
152 $this->
ctrl->setParameterByClass(
153 'ilcalendarappointmentgui',
157 $this->
ctrl->setParameterByClass(
158 'ilcalendarappointmentgui',
160 $a_app[
'event']->getEntryId()
162 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dstart', $a_app[
'dstart']);
163 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dend', $a_app[
'dend']);
164 $this->tpl->setVariable(
'TXT_PANEL_BOOK', $this->
lng->txt(
'cal_reg_register'));
165 $this->tpl->setVariable(
167 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'confirmRegister')
169 $this->tpl->parseCurrentBlock();
172 $registrations = array();
173 foreach ($reg->getRegisteredUsers(
178 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user', $usr_id);
179 $registrations[] =
'<a href="' . $this->
ctrl->getLinkTargetByClass(
180 'ilconsultationhoursgui',
183 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user',
'');
185 if (count($registrations)) {
186 $this->tpl->setCurrentBlock(
'panel_current_booking');
187 $this->tpl->setVariable(
188 'PANEL_TXT_CURRENT_BOOKING',
189 $this->
lng->txt(
'cal_reg_registered_users')
191 $this->tpl->setVariable(
'PANEL_CURRENT_BOOKING', implode(
'<br />', $registrations));
192 $this->tpl->parseCurrentBlock();
199 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_ch_ch'));
203 $is_owner = $entry->isOwner();
204 $user_entry = ($cat_info[
'obj_id'] == $this->
user->getId());
206 if ($user_entry && !$is_owner) {
210 $a_app[
'event']->getContextId(),
211 $a_app[
'event']->getStart()
213 $ref_event = $apps[0];
215 $ref_event = $a_app[
'event']->getEntryId();
218 $this->tpl->setCurrentBlock(
'panel_booking_owner');
219 $this->tpl->setVariable(
'PANEL_TXT_BOOKING_OWNER', $this->
lng->txt(
'cal_ch_booking_owner'));
221 $this->tpl->parseCurrentBlock();
223 $this->tpl->setCurrentBlock(
'panel_max_booking');
224 $this->tpl->setVariable(
'PANEL_TXT_MAX_BOOKING', $this->
lng->txt(
'cal_ch_num_bookings'));
225 $this->tpl->setVariable(
'PANEL_MAX_BOOKING', $entry->getNumberOfBookings());
226 $this->tpl->parseCurrentBlock();
229 if ($entry->hasBooked($ref_event)) {
231 $this->tpl->setCurrentBlock(
'panel_cancel_book_link');
232 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $ref_event);
233 $this->
ctrl->setParameterByClass(
234 'ilcalendarappointmentgui',
238 $this->tpl->setVariable(
'TXT_PANEL_CANCELBOOK', $this->
lng->txt(
'cal_ch_cancel_booking'));
239 $this->tpl->setVariable(
240 'PANEL_CANCELBOOK_HREF',
241 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'cancelBooking')
243 $this->tpl->parseCurrentBlock();
245 } #
else if(!$entry->isBookedOut($ref_event))
246 elseif ($entry->isAppointmentBookableForUser($ref_event,
$GLOBALS[
'DIC'][
'ilUser']->getId())) {
247 $this->tpl->setCurrentBlock(
'panel_book_link');
248 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $ref_event);
249 $this->
ctrl->setParameterByClass(
250 'ilcalendarappointmentgui',
254 $this->tpl->setVariable(
'TXT_PANEL_BOOK', $this->
lng->txt(
'cal_ch_book'));
255 $this->tpl->setVariable(
257 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'book')
259 $this->tpl->parseCurrentBlock();
262 $this->tpl->setCurrentBlock(
'panel_current_booking');
263 $this->tpl->setVariable(
'PANEL_TXT_CURRENT_BOOKING', $this->
lng->txt(
'cal_ch_current_bookings'));
264 $this->tpl->setVariable(
'PANEL_CURRENT_BOOKING', $entry->getCurrentNumberOfBookings($ref_event));
265 $this->tpl->parseCurrentBlock();
267 $obj_ids = $entry->getTargetObjIds();
268 foreach ($obj_ids as $obj_id) {
271 $this->tpl->setCurrentBlock(
'panel_booking_target_row');
272 $this->tpl->setVariable(
'PANEL_BOOKING_TARGET_TITLE', $title);
273 $this->tpl->setVariable(
'PANEL_BOOKING_TARGET', ilLink::_getLink(end($refs)));
274 $this->tpl->parseCurrentBlock();
277 $this->tpl->setCurrentBlock(
'panel_booking_target');
278 $this->tpl->setVariable(
'PANEL_TXT_BOOKING_TARGET', $this->
lng->txt(
'cal_ch_target_object'));
279 $this->tpl->parseCurrentBlock();
288 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'panel', 1);
289 foreach ($entry->getCurrentBookings($a_app[
'event']->getEntryId()) as
$user_id) {
291 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user', $user_id);
292 $bookings[] =
'<a href="' . $this->
ctrl->getLinkTargetByClass(
293 'ilconsultationhoursgui',
297 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'user',
'');
302 $this->
ctrl->setParameterByClass(
'ilconsultationhoursgui',
'panel',
'');
303 $this->tpl->setCurrentBlock(
'panel_current_booking');
304 $this->tpl->setVariable(
'PANEL_TXT_CURRENT_BOOKING', $this->
lng->txt(
'cal_ch_current_bookings'));
305 $this->tpl->setVariable(
'PANEL_CURRENT_BOOKING', implode(
'<br />', $bookings));
306 $this->tpl->parseCurrentBlock();
311 $this->tpl->setVariable(
'PANEL_CAL_TYPE', $this->
lng->txt(
'cal_ch_booking'));
313 $this->tpl->setCurrentBlock(
'panel_cancel_book_link');
314 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
315 $this->
ctrl->setParameterByClass(
316 'ilcalendarappointmentgui',
320 $this->tpl->setVariable(
'TXT_PANEL_CANCELBOOK', $this->
lng->txt(
'cal_ch_cancel_booking'));
321 $this->tpl->setVariable(
322 'PANEL_CANCELBOOK_HREF',
323 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'cancelBooking')
325 $this->tpl->parseCurrentBlock();
329 $this->tpl->setVariable(
'PANEL_TXT_CAL_NAME', $this->
lng->txt(
'cal_calendar_name'));
330 $this->tpl->setVariable(
'PANEL_CAL_NAME', $cat_info[
'title']);
332 if ($cat_info[
'editable'] and !$a_app[
'event']->isAutoGenerated()) {
333 $this->tpl->setCurrentBlock(
'panel_edit_link');
334 $this->tpl->setVariable(
'TXT_PANEL_EDIT', $this->
lng->txt(
'edit'));
336 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
338 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
339 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dt', $a_app[
'dstart']);
340 $this->tpl->setVariable(
342 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'askEdit')
345 $this->tpl->setCurrentBlock(
'panel_delete_link');
346 $this->tpl->setVariable(
'TXT_PANEL_DELETE', $this->
lng->txt(
'delete'));
348 $this->
ctrl->clearParametersByClass(
'ilcalendarappointmentgui');
350 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'app_id', $a_app[
'event']->getEntryId());
351 $this->
ctrl->setParameterByClass(
'ilcalendarappointmentgui',
'dt', $a_app[
'dstart']);
352 $this->tpl->setVariable(
354 $this->
ctrl->getLinkTargetByClass(
'ilcalendarappointmentgui',
'askdelete')
356 $this->tpl->parseCurrentBlock();
363 $this->
lng->txt(
'obj_' . $type);
366 $parent = $this->tree->getParentId(current($refs));
368 $this->tpl->setVariable(
'PANEL_TXT_LINK', $this->
lng->txt(
'ext_link'));
369 $this->tpl->setVariable(
'PANEL_LINK_HREF', $href);
370 $this->tpl->setVariable(
'PANEL_LINK_NAME', $title);
371 $this->tpl->setVariable(
'PANEL_PARENT', $parent_title);
374 return $this->tpl->get();
__construct(?ilDate $seed=null)
static _lookupCategory(int $a_cal_id)
static _lookupFullname(int $a_user_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 _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 _getInstance(ilDate $seed)
get singleton instance
static _lookupType(int $id, bool $reference=false)
static makeClickable(string $a_text, bool $detectGotoLinks=false)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.