ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilBookingReservationsTableGUI.php
Go to the documentation of this file.
1<?php
2
24
30{
36 protected \ILIAS\BookingManager\Access\AccessManager $access;
38 protected ilObjUser $user;
39 protected int $ref_id;
40 protected array $filter;
41 protected int $pool_id;
42 protected bool $show_all;
43 protected bool $has_schedule;
44 protected array $objects;
45 protected ?int $group_id;
46 protected array $advmd;
47 protected bool $has_items_with_host_context = false;
48 protected ilTree $tree;
50 protected ?array $context_obj_ids;
52
53 public function __construct(
54 object $a_parent_obj,
55 string $a_parent_cmd,
56 int $a_ref_id,
58 bool $a_show_all,
59 ?array $a_filter_pre = null,
60 ?int $a_group_id = null,
61 ?array $context_obj_ids = null
62 ) {
63 global $DIC;
64
65 $service = $DIC->bookingManager()->internal();
66 $this->gui = $service->gui();
67 $this->domain = $service->domain();
68 $this->pool = $pool;
69 $a_pool_id = $pool->getId();
71 $this->ctrl = $DIC->ctrl();
72 $this->lng = $DIC->language();
73 $this->user = $DIC->user();
74 $this->access = $DIC->bookingManager()->internal()->domain()->access();
75 $ilCtrl = $DIC->ctrl();
76 $lng = $DIC->language();
77 $ilUser = $DIC->user();
78 $this->tree = $DIC->repositoryTree();
79 $this->reservation_repo = $DIC->bookingManager()
80 ->internal()
81 ->repo()
82 ->reservation();
83 $this->schedule_manager = $DIC
84 ->bookingManager()
85 ->internal()
86 ->domain()
87 ->schedules($a_pool_id);
88
89 $this->context_obj_ids = $context_obj_ids;
90 $this->pool_id = $a_pool_id;
91 $this->ref_id = $a_ref_id;
92 $this->show_all = $a_show_all;
93 $this->has_schedule = $a_has_schedule;
94 $this->group_id = $a_group_id;
95
96 $this->table_repo = $DIC->bookingManager()
97 ->internal()
98 ->repo()
99 ->reservationTable();
100
101 $this->advmd = ilObjBookingPool::getAdvancedMDFields($a_ref_id);
102
103 $this->setId("bkrsv" . $a_ref_id);
104
105 parent::__construct($a_parent_obj, $a_parent_cmd);
106
107 $this->setTitle($lng->txt("book_reservations_list"));
108
109 $this->addColumn("", "", 1);
110 $this->addColumn($this->lng->txt("title"), "title");
111
112 $this->lng->loadLanguageModule("crs");
113
114 $selected = $this->getSelectedColumns();
115 $cols = $this->getSelectableColumns();
116
117 if ($this->has_schedule) {
118 $this->lng->loadLanguageModule("dateplaner");
119
120 $this->addColumn($this->lng->txt("date"), "date");
121 if (in_array("week", $selected, true)) {
122 $this->addColumn($this->lng->txt("wk_short"), "week");
123 unset($cols["week"]);
124 }
125 if (in_array("weekday", $selected, true)) {
126 $this->addColumn($this->lng->txt("cal_weekday"), "weekday");
127 unset($cols["weekday"]);
128 }
129 $this->addColumn($this->lng->txt("book_schedule_slot"), "slot");
130 $this->addColumn($this->lng->txt("book_no_of_objects"), "counter");
131
132 $this->setDefaultOrderField("date");
133 } else {
134 $this->addColumn($this->lng->txt("status"), "status");
135
136 $this->setDefaultOrderField("title");
137 }
138 if ($this->showMessages()) {
139 $this->addColumn($this->lng->txt("book_message"));
140 }
141
142 $this->setDefaultOrderDirection("asc");
143
144 // non-user columns
145 $user_cols = $this->getSelectableUserColumns();
146 foreach ($this->getSelectedColumns() as $col) {
147 if (array_key_exists($col, $cols)) {
148 if (!isset($user_cols[$col])) {
149 $this->addColumn($cols[$col]["txt"], $col);
150 }
151 }
152 }
153
154 $this->initFilter($a_filter_pre);
155 if ($this->group_id) {
156 $this->setLimit(9999);
157 $this->disable("numinfo");
158 $this->filters = array();
159 } else {
160 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
161 }
162 $this->getItems($this->getCurrentFilter());
163
164 if ($this->has_items_with_host_context) {
165 $this->addColumn($this->lng->txt("book_booked_in"), "context_obj_title");
166 }
167
168 $this->addColumn($this->lng->txt("user"), "user_name");
169
170 // user columns
171 foreach ($this->getSelectedColumns() as $col) {
172 if (isset($cols[$col]["txt"], $user_cols[$col])) {
173 $this->addColumn($cols[$col]["txt"], $col);
174 }
175 }
176
177 $this->addColumn($this->lng->txt("actions"));
178
179 $this->setEnableHeader(true);
180 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
181 $this->setRowTemplate("tpl.booking_reservation_row.html", "components/ILIAS/BookingManager/Reservations");
182 $this->setResetCommand("resetLogFilter");
183 $this->setFilterCommand("applyLogFilter");
184 $this->setDisableFilterHiding(true);
185
186 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
187 if ($this->access->canManageAllReservations($this->ref_id) ||
188 $this->access->canManageOwnReservations($this->ref_id)) {
189 $this->addMultiCommand('rsvConfirmCancel', $lng->txt('book_set_cancel'));
190 }
191 if ($this->access->canManageAllReservations($this->ref_id)) {
192 $this->addMultiCommand('rsvConfirmDelete', $lng->txt('delete'));
193 }
194 }
196 }
197
198 protected function showMessages(): bool
199 {
200 return $this->pool->usesMessages() && $this->access->canManageAllReservations($this->ref_id);
201 }
202
203 public function getSelectableColumns(): array
204 {
205 $cols = [];
206
207 if ($this->has_schedule) {
208 $this->lng->loadLanguageModule('dateplaner');
209
210 $cols['week'] = ['txt' => $this->lng->txt('wk_short'), 'default' => true];
211 $cols['weekday'] = ['txt' => $this->lng->txt('cal_weekday'), 'default' => true];
212 }
213
214 foreach ($this->advmd as $field) {
215 $cols["advmd{$field['id']}"] = ['txt' => $field['title'], 'default' => false];
216 }
217
218 return array_merge($cols, $this->getSelectableUserColumns());
219 }
220
224 protected function getSelectableUserColumns(): array
225 {
226 $cols = [];
227 // additional user fields
228 if ($this->access->canManageMembersOfParent($this->ref_id)) {
229 $parent = $this->access->getParentGroupCourse($this->ref_id);
230 $ef = ilExportFieldsInfo::_getInstanceByType($parent["type"]);
231 foreach ($ef->getSelectableFieldsInfo(ilObject::_lookupObjectId($parent["ref_id"])) as $k => $v) {
232 if ($k !== "login") {
233 $cols[$k] = $v;
234 }
235 }
236 }
237 return $cols;
238 }
239
240 protected function getSelectedUserColumns(): array
241 {
242 $user_cols = $this->getSelectableUserColumns();
243 $sel = [];
244 foreach ($this->getSelectedColumns() as $col) {
245 if (isset($user_cols[$col])) {
246 $sel[] = $col;
247 }
248 }
249 return $sel;
250 }
251
252 public function initFilter(
253 ?array $a_filter_pre = null
254 ): void {
255 if (is_array($a_filter_pre) &&
256 isset($a_filter_pre["object"])) {
257 $this->table_repo->setObjectFilter(
258 $this->getId(),
259 serialize($a_filter_pre["object"])
260 );
261 }
262
263 $this->objects = array();
264 foreach (ilBookingObject::getList($this->pool_id) as $item) {
265 $this->objects[$item["booking_object_id"]] = $item["title"];
266 }
267 $item = $this->addFilterItemByMetaType("object", ilTable2GUI::FILTER_SELECT);
268 if ($item !== null) {
269 $item->setOptions(array("" => $this->lng->txt('book_all')) + $this->objects);
270 $this->filter["object"] = $item->getValue();
272 "title",
274 false,
275 $this->lng->txt("object") . " " . $this->lng->txt("title") . "/" . $this->lng->txt("description")
276 );
277 if ($title !== null) {
278 $this->filter["title"] = $title->getValue();
279 }
280
281 if ($this->has_schedule) {
282 // default period: from:today [ to:(today + n days) ]
283 if (!$this->table_repo->hasFromToFilter($this->getId())) {
284 $from = new ilDateTime(date("Y-m-d"), IL_CAL_DATE); // today
285 $to = null;
286
287 // add period end from pool settings?
288 $bpool = new ilObjBookingPool($this->pool_id, false);
289 $period = $bpool->getReservationFilterPeriod();
290 if ($period !== null) {
291 $to = clone $from;
292 if ($period) {
293 $to->increment(ilDateTime::DAY, $period);
294 }
295 $to = serialize($to);
296 }
297
298 $this->table_repo->setFromToFilter(
299 $this->getId(),
300 serialize(array(
301 "from" => serialize($from),
302 "to" => $to
303 ))
304 );
305 }
306 $item = $this->addFilterItemByMetaType(
307 "fromto",
309 false,
310 $this->lng->txt('book_fromto')
311 );
312 $this->filter["fromto"] = $item->getDate();
313
314 // only needed for full log
315 if ($this->show_all) {
316 // see ilObjBookingPoolGUI::buildDatesBySchedule()
317 $map = array_flip(array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'));
318
319 $options = array("" => $this->lng->txt('book_all'));
320
321 // schedule to slot
322 foreach ($this->schedule_manager->getScheduleList() as $id => $title) {
323 $schedule = new ilBookingSchedule($id);
324 foreach ($schedule->getDefinition() as $day => $slots) {
325 $day_caption = ilCalendarUtil::_numericDayToString((int) $map[$day], false);
326
327 foreach ($slots as $slot) {
328 $slot = $slot === ilBookingSchedule::ALL_DAY_SLOT
329 ? $this->lng->txt('book_all_day')
330 : $slot;
331
332 $options["{$map[$day]}_{$slot}"] = "{$day_caption}, {$slot}";
333 }
334 }
335 }
336
337 ksort($options);
338
339 $item = $this->addFilterItemByMetaType("book_schedule_slot", ilTable2GUI::FILTER_SELECT);
340 $item->setOptions($options);
341 $this->filter["slot"] = $item->getValue();
342 }
343 }
344
345 $item = new ilCheckboxInputGUI($this->lng->txt("book_filter_past_reservations"), "past");
346 $this->addFilterItem($item);
347 $item->readFromSession();
348
349 // if period starts in the past we have to include past reservations
350 // :TODO: to be discussed
351 if (isset($this->filter["fromto"]["from"]) &&
352 $this->filter["fromto"]["from"]->get(IL_CAL_DATE) < date("Y-m-d")) {
353 $item->setChecked(true);
354 }
355
356 $this->filter["past"] = $item->getChecked();
357
358 // status
359 $valid_status = array(-ilBookingReservation::STATUS_CANCELLED,
361 );
362 if (!$this->has_schedule) {
363 $options = array("" => $this->lng->txt('book_all'));
364 } else {
365 $options = array();
366 }
367 foreach ($valid_status as $loop) {
368 if ($loop > 0) {
369 $options[$loop] = $this->lng->txt('book_reservation_status_' . $loop);
370 } else {
371 $options[$loop] = $this->lng->txt('book_not') . ' ' . $this->lng->txt('book_reservation_status_' . -$loop);
372 }
373 }
374 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT);
375 $item->setOptions($options);
376 $this->filter["status"] = $item->getValue();
377
378 // only needed for full log
379 if ($this->show_all) {
380 $options = array("" => $this->lng->txt('book_all')) +
381 ilBookingReservation::getUserFilter(array_keys($this->objects));
383 $item->setOptions($options);
384 if (is_array($a_filter_pre) && isset($a_filter_pre["user"])) {
385 $item->setValue($a_filter_pre["user"]);
386 $this->filter["user_id"] = $a_filter_pre["user"];
387 } else {
388 $this->filter["user_id"] = $item->getValue();
389 }
390 }
391 }
392 }
393
397 public function getCurrentFilter(): array
398 {
399 $filter = array();
400 if ($this->filter["object"]) {
401 $filter["object"] = $this->filter["object"];
402 }
403 if ($this->filter["title"]) {
404 $filter["title"] = $this->filter["title"];
405 }
406 if ($this->filter["status"]) {
407 $filter["status"] = $this->filter["status"];
408 }
409 if (isset($this->filter["user_id"])) {
410 $filter["user_id"] = $this->filter["user_id"];
411 }
412 if (!is_null($this->context_obj_ids)) {
413 $filter["context_obj_ids"] = $this->context_obj_ids;
414 }
415
416 if ($this->has_schedule) {
417 if (!isset($filter["status"])) {
418 // needs distinct status because of aggregation
419 $filter["status"] = -ilBookingReservation::STATUS_CANCELLED;
420 }
421 if (isset($this->filter["slot"])) {
422 $filter["slot"] = $this->filter["slot"];
423 }
424
425 if ($this->filter["fromto"]["from"] || $this->filter["fromto"]["to"]) {
426 if ($this->filter["fromto"]["from"]) {
427 $filter["from"] = $this->filter["fromto"]["from"]->get(IL_CAL_UNIX);
428 }
429 if ($this->filter["fromto"]["to"]) {
430 $day_end = new ilDateTime(
431 $this->filter["fromto"]["to"]->get(IL_CAL_DATE) . " 23:59:59",
433 );
434 $filter["to"] = $day_end->get(IL_CAL_UNIX);
435 }
436 }
437
438 $filter["past"] = (bool) $this->filter["past"];
439 }
440 return $filter;
441 }
442
443 public function numericOrdering(string $a_field): bool
444 {
445 return in_array($a_field, array("counter", "date", "week", "weekday"));
446 }
447
451 public function getItems(array $filter): void
452 {
453 $ilUser = $this->user;
454
455 $this->has_items_with_host_context = false;
456
457 if (!isset($filter["object"])) {
458 $ids = array_keys($this->objects);
459 } else {
460 $ids = array($filter["object"]);
461 }
462
463 if (!$this->show_all) {
464 $filter["user_id"] = $ilUser->getId();
465 }
466
467 $repo = $this->reservation_repo;
468 $data = $repo->getListByDate($this->has_schedule, $ids, $filter);
469
470 if ($this->advmd) {
471 // advanced metadata
472 $this->record_gui = new ilAdvancedMDRecordGUI(
474 "book",
475 $this->pool_id,
476 "bobj"
477 );
478 $this->record_gui->setTableGUI($this);
479 $this->record_gui->parse();
480
481 foreach (array_keys($data) as $idx) {
482 $data[$idx]["pool_id"] = $this->pool_id;
483 }
484
486 $this->ref_id,
487 "book",
488 "bobj",
489 [$this->pool_id],
490 "bobj",
491 $data,
492 "pool_id",
493 "object_id",
494 $this->record_gui->getFilterElements()
495 );
496 }
497
498 if (count($this->getSelectedUserColumns()) > 0) {
499 // get additional user data
500 $user_ids = array_unique(array_map(static function ($d) {
501 return $d['user_id'];
502 }, $data));
503
504 $user_columns = [];
505 $odf_ids = [];
506 foreach ($this->getSelectedUserColumns() as $field) {
507 if (str_starts_with($field, 'odf')) {
508 $odf_ids[] = (int) substr($field, 4);
509 continue;
510 }
511
512 $user_columns[] = $field;
513 }
514
515 // see ilCourseParticipantsTableGUI
516 $user_columns = array_diff(
517 $user_columns,
518 ['consultation_hour', 'prtf', 'roles', 'org_units']
519 );
520
521 // user data fields
522 $query = new ilUserQuery();
523 $query->setLimit(9999);
524 $query->setAdditionalFields($user_columns);
525 $query->setUserFilter($user_ids);
526 $ud = $query->query();
527 $usr_data = [];
528 foreach ($ud["set"] as $v) {
529 foreach ($user_columns as $c) {
530 $usr_data[$v["usr_id"]][$c] = $v[$c];
531 }
532 }
533 foreach ($data as $key => $v) {
534 if (isset($usr_data[$v["user_id"]])) {
535 $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
536 }
537 }
538
539 // object specific user data fields of parent course or group
540 if ($odf_ids !== []) {
541 $parent = $this->access->getParentGroupCourse($this->ref_id);
542 $parent_obj_id = ilObject::_lookupObjectId($parent['ref_id']);
543 $parent_obj_type = ilObject::_lookupType($parent_obj_id);
544
545 $privacy_settings = ilPrivacySettings::getInstance();
546 $confirmation_required = $parent_obj_type === 'crs'
547 ? $privacy_settings->courseConfirmationRequired()
548 : $privacy_settings->groupConfirmationRequired();
549 if ($confirmation_required) {
550 $user_ids = array_diff($user_ids, ilMemberAgreement::lookupAcceptedAgreements($parent_obj_id));
551 }
552 $odf_data = ilCourseUserData::_getValuesByObjId($parent_obj_id);
553 $usr_data = [];
554 foreach ($odf_data as $usr_id => $fields) {
555 if (in_array($usr_id, $user_ids, true)) {
556 foreach ($fields as $field_id => $value) {
557 if (in_array($field_id, $odf_ids, true)) {
558 $usr_data[$usr_id]["odf_{$field_id}"] = $value;
559 }
560 }
561 }
562 }
563
564 foreach ($data as $key => $v) {
565 if (isset($usr_data[$v['user_id']])) {
566 $data[$key] = array_merge($v, $usr_data[$v['user_id']]);
567 }
568 }
569 }
570 }
571
572 foreach ($data as $k => $d) {
573 if ($d["context_obj_id"] > 0) {
574 $this->has_items_with_host_context = true;
575 $data[$k]["context_obj_title"] = ilObject::_lookupTitle($d["context_obj_id"]);
576 }
577 }
578
579 $this->setData($data);
580 }
581
583 {
584 return $this->record_gui;
585 }
586
587 public function getOrderField(): string
588 {
589 $field = parent::getOrderField();
590
591 // #16560 - this will enable matchting slot sorting to date/week
592 if (in_array($field, array("date", "week"))) {
593 $field = "_sortdate";
594 }
595
596 return $field;
597 }
598
599 protected function fillRow(array $a_set): void
600 {
602 $ilAccess = $this->access;
603 $ilCtrl = $this->ctrl;
604 $ilUser = $this->user;
605 $f = $this->gui->ui()->factory();
606
607 $selected = $this->getSelectedColumns();
608
609 $dd_items = [];
610
611 if ($this->has_items_with_host_context) {
612 $this->tpl->setCurrentBlock("context");
613 $this->tpl->setVariable("VALUE_CONTEXT_TITLE", ($a_set["context_obj_title"] ?? "") . " ");
614 $this->tpl->parseCurrentBlock();
615 }
616
617 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
618
619 $can_be_cancelled = ($this->access->canManageReservationForUser($this->ref_id, $a_set['user_id']) &&
620 $a_set["can_be_cancelled"]);
621
622 if ($can_be_cancelled) {
623 $this->tpl->setVariable("MULTI_ID", $a_set["booking_reservation_id"]);
624 }
625
626 // #11995
627 $profile = $this->domain->profile();
628 $user_id = (int) $a_set['user_id'];
629 if (!$profile->exists($user_id)) {
630 $uname = $profile->getDeletedUserNamePresentation();
631 } else {
632 $uname = ilUserUtil::getNamePresentation($a_set['user_id'], false, true, "", true);
633 }
634 $this->tpl->setVariable("TXT_CURRENT_USER", $uname);
635 if ($this->has_schedule) {
636 $this->tpl->setVariable(
637 "VALUE_DATE",
639 );
640 if (in_array("week", $selected, true)) {
641 $this->tpl->setVariable("VALUE_WEEK", $a_set["week"]);
642 }
643 if (in_array("weekday", $selected, true)) {
644 $this->tpl->setVariable(
645 "VALUE_WEEKDAY",
646 ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false)
647 );
648 }
649 $this->tpl->setVariable(
650 "VALUE_SLOT",
651 in_array($a_set["slot"], [ilBookingSchedule::ALL_DAY_SLOT, "00:00 - 00:00"], true)
652 ? $this->lng->txt('book_all_day')
653 : $a_set["slot"]
654 );
655 $this->tpl->setVariable("VALUE_COUNTER", $a_set["counter"]);
656 } elseif (in_array(
657 $a_set['status'],
659 )) {
660 $this->tpl->setVariable("TXT_STATUS", $lng->txt('book_reservation_status_' . $a_set['status']));
661 } else {
662 $this->tpl->setVariable("TXT_STATUS", "&nbsp;");
663 }
664 if ($this->showMessages()) {
665 $this->tpl->setCurrentBlock("message");
666 $this->tpl->setVariable("MESSAGE", ilStr::shortenTextExtended($a_set["message"] . " ", 20, true));
667 $this->tpl->parseCurrentBlock();
668 }
669
670 if ($this->advmd) {
671 foreach ($this->advmd as $item) {
672 $advmd_id = (int) $item["id"];
673
674 if (!in_array("advmd" . $advmd_id, $selected, true)) {
675 continue;
676 }
677
678 $val = " ";
679 $key = "md_" . $advmd_id . "_presentation";
680 if (isset($a_set[$key])) {
681 $pb = $a_set[$key]->getList();
682 if ($pb) {
683 $val = $pb;
684 }
685 }
686
687 $this->tpl->setCurrentBlock("advmd_bl");
688 $this->tpl->setVariable("VALUE_ADVMD", $val);
689 $this->tpl->parseCurrentBlock();
690 }
691 }
692
693 // additional user fields
694 $user_cols = $this->getSelectableUserColumns();
695 foreach ($this->getSelectedColumns() as $col) {
696 if (isset($user_cols[$col])) {
697 $this->tpl->setCurrentBlock("user_col");
698 $this->tpl->setVariable("VALUE_USER_COL", ($a_set[$col] ?? "") . " ");
699 $this->tpl->parseCurrentBlock();
700 }
701 }
702
703 // reservation information
704 if ($a_set['user_id'] == $ilUser->getId() || $ilAccess->canManageAllReservations($this->ref_id)) {
705 if ($a_set['post_text'] !== "" || $a_set['post_file'] !== "") {
706 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
707 $ilCtrl->setParameter($this->parent_obj, 'object_id', $a_set['object_id']);
708 $dd_items[] = $f->button()->shy(
709 $lng->txt('book_post_booking_information'),
710 $ilCtrl->getLinkTarget($this->parent_obj, 'displayPostInfo')
711 );
712 $ilCtrl->setParameter($this->parent_obj, 'object_id', null);
713 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
714 }
715 }
716
717 if ($can_be_cancelled) {
718 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
719 $dd_items[] = $f->button()->shy(
720 $lng->txt('book_set_cancel'),
721 $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmCancel')
722 );
723 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
724 }
725
726 if ($this->access->canManageAllReservations($this->ref_id)) {
727 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
728 $dd_items[] = $f->button()->shy(
729 $lng->txt('delete'),
730 $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmDelete')
731 );
732 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
733 }
734
735 $render_items = [];
736 if ($this->showMessages() && $a_set["message"] !== "") {
737 $c = $this->gui->modal(
738 $this->lng->txt("book_message"),
739 $this->lng->txt("close")
740 )
741 ->legacy(nl2br($a_set["message"]))
742 ->getTriggerButtonComponents(
743 $this->lng->txt("book_show_message"),
744 true
745 );
746 $dd_items[] = $c["button"];
747 $render_items[] = $c["modal"];
748 }
749
750 if (count($dd_items) > 0) {
751 $render_items[] = $f->dropdown()->standard($dd_items);
752 $this->tpl->setVariable("ACTIONS", $this->gui->ui()->renderer()->render($render_items));
753 }
754 }
755
756 protected function getAdditionalExportCols(): array
757 {
758 $add_cols = [];
759 $cols = $this->getSelectableColumns();
760
761 unset($cols["week"], $cols["weekday"]);
762
763 // non-user columns
764 $user_cols = $this->getSelectableUserColumns();
765 foreach ($this->getSelectedColumns() as $col) {
766 if (array_key_exists($col, $cols)) {
767 if (!isset($user_cols[$col])) {
768 $add_cols[$col] = $cols[$col]["txt"];
769 }
770 }
771 }
772
773 $add_cols["user_name"] = $this->lng->txt("user");
774 $add_cols["login"] = $this->lng->txt("login");
775
776 // user columns
777 foreach ($this->getSelectedColumns() as $col) {
778 if (isset($cols[$col]["txt"], $user_cols[$col])) {
779 $add_cols[$col] = $cols[$col]["txt"];
780 }
781 }
782
783 return $add_cols;
784 }
785
786 protected function fillHeaderExcel(
787 ilExcel $a_excel,
788 int &$a_row
789 ): void {
790 $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
791 $col = 0;
792 if ($this->has_schedule) {
793 $a_excel->setCell($a_row, ++$col, $this->lng->txt("date"));
794 $a_excel->setCell($a_row, ++$col, $this->lng->txt("wk_short"));
795 $a_excel->setCell($a_row, ++$col, $this->lng->txt("cal_weekday"));
796 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_schedule_slot"));
797 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_no_of_objects"));
798 } else {
799 $a_excel->setCell($a_row, ++$col, $this->lng->txt("status"));
800 }
801 if ($this->showMessages()) {
802 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_message"));
803 }
804
805 foreach ($this->getAdditionalExportCols() as $txt) {
806 $a_excel->setCell($a_row, ++$col, $txt);
807 }
808
809 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col) . $a_row);
810 }
811
812 protected function fillRowExcel(
813 ilExcel $a_excel,
814 int &$a_row,
815 array $a_set
816 ): void {
817 $a_excel->setCell($a_row, 0, $a_set["title"]);
818 $col = 0;
819 if ($this->has_schedule) {
820 $a_excel->setCell($a_row, ++$col, new ilDate($a_set["date"], IL_CAL_DATE));
821 $a_excel->setCell($a_row, ++$col, $a_set["week"]);
822 $a_excel->setCell($a_row, ++$col, ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
823 $a_excel->setCell($a_row, ++$col, $a_set["slot"]);
824 $a_excel->setCell($a_row, ++$col, $a_set["counter"]);
825 } else {
826 $status = "";
827 if (in_array(
828 $a_set['status'],
830 )) {
831 $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
832 }
833 $a_excel->setCell($a_row, ++$col, $status);
834 }
835 if ($this->showMessages()) {
836 $a_excel->setCell($a_row, ++$col, $a_set["message"]);
837 }
838
839 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
840 if (str_starts_with($colid, "advmd")) {
841 $val = " ";
842 $key = "md_" . (int) substr($colid, 5) . "_presentation";
843 if (isset($a_set[$key])) {
844 $pb = $a_set[$key]->getList();
845 if ($pb) {
846 $val = $pb;
847 }
848 }
849 $a_excel->setCell($a_row, ++$col, $val);
850 } else {
851 $a_excel->setCell($a_row, ++$col, $a_set[$colid] ?? "");
852 }
853 }
854 }
855
856 protected function fillHeaderCSV(
857 ilCSVWriter $a_csv
858 ): void {
859 $a_csv->addColumn($this->lng->txt("title"));
860 if ($this->has_schedule) {
861 $a_csv->addColumn($this->lng->txt("date"));
862 $a_csv->addColumn($this->lng->txt("wk_short"));
863 $a_csv->addColumn($this->lng->txt("cal_weekday"));
864 $a_csv->addColumn($this->lng->txt("book_schedule_slot"));
865 $a_csv->addColumn($this->lng->txt("book_no_of_objects"));
866 } else {
867 $a_csv->addColumn($this->lng->txt("status"));
868 }
869 if ($this->showMessages()) {
870 $a_csv->addColumn($this->lng->txt("book_message"));
871 }
872
873 foreach ($this->getAdditionalExportCols() as $txt) {
874 $a_csv->addColumn($txt);
875 }
876
877 $a_csv->addRow();
878 }
879
880 protected function fillRowCSV(
881 ilCSVWriter $a_csv,
882 array $a_set
883 ): void {
884 $a_csv->addColumn($a_set["title"]);
885 if ($this->has_schedule) {
886 $a_csv->addColumn(ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
887 $a_csv->addColumn($a_set["week"]);
888 $a_csv->addColumn(ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
889 $a_csv->addColumn($a_set["slot"]);
890 $a_csv->addColumn($a_set["counter"]);
891 } else {
892 $status = "";
893 if (in_array(
894 $a_set['status'],
896 )) {
897 $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
898 }
899 $a_csv->addColumn($status);
900 }
901 if ($this->showMessages()) {
902 $a_csv->addColumn($a_set["message"]);
903 }
904
905 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
906 if (str_starts_with($colid, "advmd")) {
907 $val = " ";
908 $key = "md_" . (int) substr($colid, 5) . "_presentation";
909 if (isset($a_set[$key])) {
910 $pb = $a_set[$key]->getList();
911 if ($pb) {
912 $val = $pb;
913 }
914 }
915 $a_csv->addColumn($val);
916 } else {
917 $a_csv->addColumn($a_set[$colid] ?? "");
918 }
919 }
920
921 $a_csv->addRow();
922 }
923}
Author: Alexander Killing killing@leifos.de
Repo class for reservations Acts on tables booking_reservation (rw), booking_reservation_group (rw) a...
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
static queryForRecords(int $adv_rec_obj_ref_id, string $adv_rec_obj_type, string $adv_rec_obj_subtype, array $a_obj_id, string $a_subtype, array $a_records, string $a_obj_id_key, string $a_obj_subid_key, ?array $a_amet_filter=null)
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
static getUserFilter(array $a_object_ids)
Get all users who have reservations for object(s)
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
ILIAS BookingManager Access AccessManager $access
ReservationTableSessionRepository $table_repo
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
fillRow(array $a_set)
Standard Version of Fill Row.
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
getItems(array $filter)
Gather data and build rows.
numericOrdering(string $a_field)
Should this field be sorted numeric?
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_ref_id, ilObjBookingPool $pool, bool $a_show_all, ?array $a_filter_pre=null, ?int $a_group_id=null, ?array $context_obj_ids=null)
getSelectableUserColumns()
Get selectable user fields.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_col)
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
This class represents a checkbox property in a property form.
static _getValuesByObjId(int $a_obj_id)
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Class for single dates.
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell(int $a_row, int $col, $value, CellType|string|null $datatype=null)
Set cell value.
static _getInstanceByType(string $a_type)
Get Singleton Instance.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static lookupAcceptedAgreements(int $a_obj_id)
Lookup users who have accepted the agreement.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAdvancedMDFields(int $a_ref_id)
User class.
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFilterCommand(string $a_val, string $a_caption="")
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setExportFormats(array $formats)
Set available export formats.
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
addMultiCommand(string $a_cmd, string $a_text)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setDisableFilterHiding(bool $a_val=true)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
ilLanguage $lng
disable(string $a_module_name)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
User query class.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
const ANONYMOUS_USER_ID
Definition: constants.php:27
$service
Definition: ltiresult.php:44
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $lng
Definition: privfeed.php:26
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$data
Definition: storeScorm.php:45