ILIAS  release_8 Revision v8.24
class.ilBookingReservationsTableGUI.php
Go to the documentation of this file.
1<?php
2
20
26{
28 protected ilObjUser $user;
30 protected int $ref_id;
31 protected array $filter;
32 protected int $pool_id;
33 protected bool $show_all;
34 protected bool $has_schedule;
35 protected array $objects;
36 protected ?int $group_id;
37 protected array $advmd;
38 protected bool $has_items_with_host_context = false;
39 protected ilTree $tree;
41 protected ?array $context_obj_ids;
43
44 public function __construct(
45 object $a_parent_obj,
46 string $a_parent_cmd,
47 int $a_ref_id,
48 int $a_pool_id,
49 bool $a_show_all,
50 bool $a_has_schedule,
51 array $a_filter_pre = null,
52 int $a_group_id = null,
53 array $context_obj_ids = null
54 ) {
55 global $DIC;
56
57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->user = $DIC->user();
60 $this->access = $DIC->access();
61 $ilCtrl = $DIC->ctrl();
62 $lng = $DIC->language();
63 $ilUser = $DIC->user();
64 $this->tree = $DIC->repositoryTree();
65
66 $this->context_obj_ids = $context_obj_ids;
67 $this->pool_id = $a_pool_id;
68 $this->ref_id = $a_ref_id;
69 $this->show_all = $a_show_all;
70 $this->has_schedule = $a_has_schedule;
71 $this->group_id = $a_group_id;
72
73 $this->table_repo = $DIC->bookingManager()
74 ->internal()
75 ->repo()
76 ->reservationTable();
77
78 $this->advmd = ilObjBookingPool::getAdvancedMDFields($a_ref_id);
79
80 $this->setId("bkrsv" . $a_ref_id);
81
82 parent::__construct($a_parent_obj, $a_parent_cmd);
83
84 $this->setTitle($lng->txt("book_reservations_list"));
85
86 $this->addColumn("", "", 1);
87 $this->addColumn($this->lng->txt("title"), "title");
88
89 $this->lng->loadLanguageModule("crs");
90
91 $selected = $this->getSelectedColumns();
92 $cols = $this->getSelectableColumns();
93
94 if ($this->has_schedule) {
95 $this->lng->loadLanguageModule("dateplaner");
96
97 $this->addColumn($this->lng->txt("date"), "date");
98 if (in_array("week", $selected, true)) {
99 $this->addColumn($this->lng->txt("wk_short"), "week");
100 unset($cols["week"]);
101 }
102 if (in_array("weekday", $selected, true)) {
103 $this->addColumn($this->lng->txt("cal_weekday"), "weekday");
104 unset($cols["weekday"]);
105 }
106 $this->addColumn($this->lng->txt("book_schedule_slot"), "slot");
107 $this->addColumn($this->lng->txt("book_no_of_objects"), "counter");
108
109 $this->setDefaultOrderField("date");
110 } else {
111 $this->addColumn($this->lng->txt("status"), "status");
112
113 $this->setDefaultOrderField("title");
114 }
115 $this->setDefaultOrderDirection("asc");
116
117 // non-user columns
118 $user_cols = $this->getSelectableUserColumns();
119 foreach ($this->getSelectedColumns() as $col) {
120 if (array_key_exists($col, $cols)) {
121 if (!isset($user_cols[$col])) {
122 $this->addColumn($cols[$col]["txt"], $col);
123 }
124 }
125 }
126
127
128
129 $this->initFilter($a_filter_pre);
130 if ($this->group_id) {
131 $this->setLimit(9999);
132 $this->disable("numinfo");
133 $this->filters = array();
134 } else {
135 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
136 }
137 $this->getItems($this->getCurrentFilter());
138
139 if ($this->has_items_with_host_context) {
140 $this->addColumn($this->lng->txt("book_booked_in"), "context_obj_title");
141 }
142
143 $this->addColumn($this->lng->txt("user"), "user_name");
144
145 // user columns
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->addColumn($this->lng->txt("actions"));
155
156 $this->setEnableHeader(true);
157 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
158 $this->setRowTemplate("tpl.booking_reservation_row.html", "Modules/BookingManager/Reservations");
159 $this->setResetCommand("resetLogFilter");
160 $this->setFilterCommand("applyLogFilter");
161 $this->setDisableFilterHiding(true);
162
163
164 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
165 $this->addMultiCommand('rsvConfirmCancel', $lng->txt('book_set_cancel'));
166 if ($this->access->checkAccess('write', '', $this->ref_id)) {
167 $this->addMultiCommand('rsvConfirmDelete', $lng->txt('delete'));
168 }
169 $this->setSelectAllCheckbox('mrsv');
170 }
171
172
174 }
175
176 public function getSelectableColumns(): array
177 {
178 $cols = array();
179
180 if ($this->has_schedule) {
181 $this->lng->loadLanguageModule("dateplaner");
182
183 $cols["week"] = array(
184 "txt" => $this->lng->txt("wk_short"),
185 "default" => true
186 );
187
188 $cols["weekday"] = array(
189 "txt" => $this->lng->txt("cal_weekday"),
190 "default" => true
191 );
192 }
193
194 foreach ($this->advmd as $field) {
195 $cols["advmd" . $field["id"]] = array(
196 "txt" => $field["title"],
197 "default" => false
198 );
199 }
200
201 $cols = array_merge($cols, $this->getSelectableUserColumns());
202
203 return $cols;
204 }
205
209 protected function getSelectableUserColumns(): array
210 {
211 $cols = [];
212 // additional user fields
213 if (($parent = $this->getParentGroupCourse()) !== null) {
214 if ($this->access->checkAccess("manage_members", "", $parent["ref_id"])) {
215 $ef = ilExportFieldsInfo::_getInstanceByType($parent["type"]);
216 foreach ($ef->getSelectableFieldsInfo(ilObject::_lookupObjectId($parent["ref_id"])) as $k => $v) {
217 if ($k !== "login") {
218 $cols[$k] = $v;
219 }
220 }
221 }
222 }
223 return $cols;
224 }
225
226 protected function getSelectedUserColumns(): array
227 {
228 $user_cols = $this->getSelectableUserColumns();
229 $sel = [];
230 foreach ($this->getSelectedColumns() as $col) {
231 if (isset($user_cols[$col])) {
232 $sel[] = $col;
233 }
234 }
235 return $sel;
236 }
237
238 protected function getParentGroupCourse(): ?array
239 {
241 if (($par_ref_id = $tree->checkForParentType($this->ref_id, "grp")) > 0) {
242 return [
243 "ref_id" => $par_ref_id,
244 "type" => "grp"
245 ];
246 }
247 if (($par_ref_id = $tree->checkForParentType($this->ref_id, "crs")) > 0) {
248 return [
249 "ref_id" => $par_ref_id,
250 "type" => "crs"
251 ];
252 }
253 return null;
254 }
255
256 public function initFilter(
257 array $a_filter_pre = null
258 ): void {
259 if (is_array($a_filter_pre) &&
260 isset($a_filter_pre["object"])) {
261 $this->table_repo->setObjectFilter(
262 $this->getId(),
263 serialize($a_filter_pre["object"])
264 );
265 }
266
267 $this->objects = array();
268 foreach (ilBookingObject::getList($this->pool_id) as $item) {
269 $this->objects[$item["booking_object_id"]] = $item["title"];
270 }
271 $item = $this->addFilterItemByMetaType("object", ilTable2GUI::FILTER_SELECT);
272 if ($item !== null) {
273 $item->setOptions(array("" => $this->lng->txt('book_all')) + $this->objects);
274 $this->filter["object"] = $item->getValue();
276 "title",
278 false,
279 $this->lng->txt("object") . " " . $this->lng->txt("title") . "/" . $this->lng->txt("description")
280 );
281 if ($title !== null) {
282 $this->filter["title"] = $title->getValue();
283 }
284
285 if ($this->has_schedule) {
286 // default period: from:today [ to:(today + n days) ]
287 if (!$this->table_repo->hasFromToFilter($this->getId())) {
288 $from = new ilDateTime(date("Y-m-d"), IL_CAL_DATE); // today
289 $to = null;
290
291 // add period end from pool settings?
292 $bpool = new ilObjBookingPool($this->pool_id, false);
293 $period = $bpool->getReservationFilterPeriod();
294 if ($period !== null) {
295 $to = clone $from;
296 if ($period) {
297 $to->increment(ilDateTime::DAY, $period);
298 }
299 $to = serialize($to);
300 }
301
302 $this->table_repo->setFromToFilter(
303 $this->getId(),
304 serialize(array(
305 "from" => serialize($from),
306 "to" => $to
307 ))
308 );
309 }
310 $item = $this->addFilterItemByMetaType("fromto", ilTable2GUI::FILTER_DATE_RANGE, false, $this->lng->txt('book_fromto'));
311 $this->filter["fromto"] = $item->getDate();
312
313 // only needed for full log
314 if ($this->show_all) {
315 // see ilObjBookingPoolGUI::buildDatesBySchedule()
316 $map = array_flip(array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'));
317
318 $options = array("" => $this->lng->txt('book_all'));
319
320 // schedule to slot
321 foreach (ilBookingSchedule::getList($this->pool_id) as $def) {
322 $schedule = new ilBookingSchedule($def["booking_schedule_id"]);
323 foreach ($schedule->getDefinition() as $day => $slots) {
324 $day_caption = ilCalendarUtil::_numericDayToString((int) $map[$day], false);
325
326 foreach ($slots as $slot) {
327 $idx = $map[$day] . "_" . $slot;
328 $options[$idx] = $day_caption . ", " . $slot;
329 }
330 }
331 }
332
333 ksort($options);
334
335 $item = $this->addFilterItemByMetaType("book_schedule_slot", ilTable2GUI::FILTER_SELECT);
336 $item->setOptions($options);
337 $this->filter["slot"] = $item->getValue();
338 }
339 }
340
341 $item = new ilCheckboxInputGUI($this->lng->txt("book_filter_past_reservations"), "past");
342 $this->addFilterItem($item);
343 $item->readFromSession();
344
345 // if period starts in the past we have to include past reservations
346 // :TODO: to be discussed
347 if (isset($this->filter["fromto"]["from"]) &&
348 $this->filter["fromto"]["from"]->get(IL_CAL_DATE) < date("Y-m-d")) {
349 $item->setChecked(true);
350 }
351
352 $this->filter["past"] = $item->getChecked();
353
354 // status
355 $valid_status = array(-ilBookingReservation::STATUS_CANCELLED,
357 if (!$this->has_schedule) {
358 $options = array("" => $this->lng->txt('book_all'));
359 } else {
360 $options = array();
361 }
362 foreach ($valid_status as $loop) {
363 if ($loop > 0) {
364 $options[$loop] = $this->lng->txt('book_reservation_status_' . $loop);
365 } else {
366 $options[$loop] = $this->lng->txt('book_not') . ' ' . $this->lng->txt('book_reservation_status_' . -$loop);
367 }
368 }
369 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT);
370 $item->setOptions($options);
371 $this->filter["status"] = $item->getValue();
372
373 // only needed for full log
374 if ($this->show_all) {
375 $options = array("" => $this->lng->txt('book_all')) +
376 ilBookingReservation::getUserFilter(array_keys($this->objects));
378 $item->setOptions($options);
379 if (is_array($a_filter_pre) && isset($a_filter_pre["user_id"])) {
380 $item->setValue($a_filter_pre["user_id"]);
381 $this->filter["user_id"] = $a_filter_pre["user_id"];
382 } else {
383 $this->filter["user_id"] = $item->getValue();
384 }
385 }
386 }
387 }
388
392 public function getCurrentFilter(): array
393 {
394 $filter = array();
395 if ($this->filter["object"]) {
396 $filter["object"] = $this->filter["object"];
397 }
398 if ($this->filter["title"]) {
399 $filter["title"] = $this->filter["title"];
400 }
401 if ($this->filter["status"]) {
402 $filter["status"] = $this->filter["status"];
403 }
404 if ($this->filter["user_id"] ?? false) {
405 $filter["user_id"] = $this->filter["user_id"];
406 }
407 if (!is_null($this->context_obj_ids)) {
408 $filter["context_obj_ids"] = $this->context_obj_ids;
409 }
410
411 if ($this->has_schedule) {
412 if (!isset($filter["status"])) {
413 // needs distinct status because of aggregation
414 $filter["status"] = -ilBookingReservation::STATUS_CANCELLED;
415 }
416 if ($this->filter["slot"] ?? false) {
417 $filter["slot"] = $this->filter["slot"];
418 }
419
420 if ($this->filter["fromto"]["from"] || $this->filter["fromto"]["to"]) {
421 if ($this->filter["fromto"]["from"]) {
422 $filter["from"] = $this->filter["fromto"]["from"]->get(IL_CAL_UNIX);
423 }
424 if ($this->filter["fromto"]["to"]) {
425 $day_end = new ilDateTime($this->filter["fromto"]["to"]->get(IL_CAL_DATE) . " 23:59:59", IL_CAL_DATETIME);
426 $filter["to"] = $day_end->get(IL_CAL_UNIX);
427 }
428 }
429
430 $filter["past"] = (bool) $this->filter["past"];
431 }
432 return $filter;
433 }
434
435 public function numericOrdering(string $a_field): bool
436 {
437 return in_array($a_field, array("counter", "date", "week", "weekday"));
438 }
439
443 public function getItems(array $filter): void
444 {
445 $ilUser = $this->user;
446
447 $this->has_items_with_host_context = false;
448
449 if (!isset($filter["object"])) {
450 $ids = array_keys($this->objects);
451 } else {
452 $ids = array($filter["object"]);
453 }
454
455 if (!$this->show_all) {
456 $filter["user_id"] = $ilUser->getId();
457 }
458
460 $repo = $f->getRepo();
461 $data = $repo->getListByDate($this->has_schedule, $ids, $filter);
462
463 if ($this->advmd) {
464 // advanced metadata
465 $this->record_gui = new ilAdvancedMDRecordGUI(
467 "book",
468 $this->pool_id,
469 "bobj"
470 );
471 $this->record_gui->setTableGUI($this);
472 $this->record_gui->parse();
473
474 foreach (array_keys($data) as $idx) {
475 $data[$idx]["pool_id"] = $this->pool_id;
476 }
477
479 $this->ref_id,
480 "book",
481 "bobj",
482 [$this->pool_id],
483 "bobj",
484 $data,
485 "pool_id",
486 "object_id",
487 $this->record_gui->getFilterElements()
488 );
489 }
490
491 if (count($this->getSelectedUserColumns()) > 0) {
492 // get additional user data
493 $user_ids = array_unique(array_map(static function ($d) {
494 return $d['user_id'];
495 }, $data));
496
497 $user_columns = [];
498 $odf_ids = [];
499 foreach ($this->getSelectedUserColumns() as $field) {
500 if (strpos($field, 'odf') === 0) {
501 $odf_ids[] = substr($field, 4);
502 } else {
503 $user_columns[] = $field;
504 }
505 }
506
507 // see ilCourseParticipantsTableGUI
508 $user_columns = array_diff(
509 $user_columns,
510 ['consultation_hour', 'prtf', 'roles', 'org_units']
511 );
512
513 // user data fields
514 $query = new ilUserQuery();
515 $query->setLimit(9999);
516 $query->setAdditionalFields($user_columns);
517 $query->setUserFilter($user_ids);
518 $ud = $query->query();
519 $usr_data = [];
520 foreach ($ud["set"] as $v) {
521 foreach ($user_columns as $c) {
522 $usr_data[$v["usr_id"]][$c] = $v[$c];
523 }
524 }
525 foreach ($data as $key => $v) {
526 if (isset($usr_data[$v["user_id"]])) {
527 $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
528 }
529 }
530
531 // object specific user data fields of parent course or group
532 if ($odf_ids) {
533 $parent = $this->getParentGroupCourse();
534 $parent_obj_id = ilObject::_lookupObjectId($parent['ref_id']);
535 $parent_obj_type = ilObject::_lookupType($parent_obj_id);
536
537 $confirmation_required = ($parent_obj_type === 'crs')
538 ? ilPrivacySettings::getInstance()->courseConfirmationRequired()
539 : ilPrivacySettings::getInstance()->groupConfirmationRequired();
540 if ($confirmation_required) {
541 $user_ids = array_diff($user_ids, ilMemberAgreement::lookupAcceptedAgreements($parent_obj_id));
542 }
543 $odf_data = ilCourseUserData::_getValuesByObjId($parent_obj_id);
544 $usr_data = [];
545 foreach ($odf_data as $usr_id => $fields) {
546 // this currently does not with strict mode, since
547 // $user_ids holds strings
548 if (in_array($usr_id, $user_ids)) {
549 foreach ($fields as $field_id => $value) {
550 if (in_array($field_id, $odf_ids, true)) {
551 $usr_data[$usr_id]['odf_' . $field_id] = $value;
552 }
553 }
554 }
555 }
556
557 foreach ($data as $key => $v) {
558 if (isset($usr_data[$v["user_id"]])) {
559 $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
560 }
561 }
562 }
563 }
564
565 foreach ($data as $k => $d) {
566 if ($d["context_obj_id"] > 0) {
567 $this->has_items_with_host_context = true;
568 $data[$k]["context_obj_title"] = ilObject::_lookupTitle($d["context_obj_id"]);
569 }
570 }
571
572 $this->setData($data);
573 }
574
576 {
577 return $this->record_gui;
578 }
579
580 public function getOrderField(): string
581 {
582 $field = parent::getOrderField();
583
584 // #16560 - this will enable matchting slot sorting to date/week
585 if (in_array($field, array("date", "week"))) {
586 $field = "_sortdate";
587 }
588
589 return $field;
590 }
591
592 protected function fillRow(array $a_set): void
593 {
595 $ilAccess = $this->access;
596 $ilCtrl = $this->ctrl;
597 $ilUser = $this->user;
598
599 $selected = $this->getSelectedColumns();
600
601 if ($this->has_items_with_host_context) {
602 $this->tpl->setCurrentBlock("context");
603 $this->tpl->setVariable("VALUE_CONTEXT_TITLE", ($a_set["context_obj_title"] ?? "") . " ");
604 $this->tpl->parseCurrentBlock();
605 }
606
607 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
608
609 $can_be_cancelled = (($ilAccess->checkAccess('write', '', $this->ref_id) ||
610 $a_set['user_id'] == $ilUser->getId()) &&
611 $a_set["can_be_cancelled"]);
612
613 if ($can_be_cancelled) {
614 $this->tpl->setVariable("MULTI_ID", $a_set["booking_reservation_id"]);
615 }
616
617 // #11995
618 $uname = $a_set["user_name"];
619 if (!trim($uname)) {
620 $uname = "[" . $lng->txt("user_deleted") . "]";
621 } else {
622 $uname = ilUserUtil::getNamePresentation($a_set['user_id'], false, true, "", true);
623 }
624 $this->tpl->setVariable("TXT_CURRENT_USER", $uname);
625
626 if ($this->has_schedule) {
627 $this->tpl->setVariable("VALUE_DATE", ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
628 if (in_array("week", $selected, true)) {
629 $this->tpl->setVariable("VALUE_WEEK", $a_set["week"]);
630 }
631 if (in_array("weekday", $selected, true)) {
632 $this->tpl->setVariable("VALUE_WEEKDAY", ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
633 }
634 $this->tpl->setVariable("VALUE_SLOT", $a_set["slot"]);
635 $this->tpl->setVariable("VALUE_COUNTER", $a_set["counter"]);
636 } elseif (in_array(
637 $a_set['status'],
639 )) {
640 $this->tpl->setVariable("TXT_STATUS", $lng->txt('book_reservation_status_' . $a_set['status']));
641 } else {
642 $this->tpl->setVariable("TXT_STATUS", "&nbsp;");
643 }
644
645 if ($this->advmd) {
646 foreach ($this->advmd as $item) {
647 $advmd_id = (int) $item["id"];
648
649 if (!in_array("advmd" . $advmd_id, $selected, true)) {
650 continue;
651 }
652
653 $val = " ";
654 $key = "md_" . $advmd_id . "_presentation";
655 if (isset($a_set[$key])) {
656 $pb = $a_set[$key]->getList();
657 if ($pb) {
658 $val = $pb;
659 }
660 }
661
662 $this->tpl->setCurrentBlock("advmd_bl");
663 $this->tpl->setVariable("VALUE_ADVMD", $val);
664 $this->tpl->parseCurrentBlock();
665 }
666 }
667
668 // additional user fields
669 $user_cols = $this->getSelectableUserColumns();
670 foreach ($this->getSelectedColumns() as $col) {
671 if (isset($user_cols[$col])) {
672 $this->tpl->setCurrentBlock("user_col");
673 $this->tpl->setVariable("VALUE_USER_COL", ($a_set[$col] ?? "") . " ");
674 $this->tpl->parseCurrentBlock();
675 }
676 }
677
678 if ($can_be_cancelled) {
679 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
680 $this->tpl->setVariable("URL_ACTION", $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmCancel'));
681 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
682 $this->tpl->setVariable("TXT_ACTION", $lng->txt('book_set_cancel'));
683 $this->tpl->setCurrentBlock("action");
684 $this->tpl->parseCurrentBlock();
685 }
686
687
688 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
689 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
690 $this->tpl->setVariable("URL_ACTION", $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmDelete'));
691 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
692 $this->tpl->setVariable("TXT_ACTION", $lng->txt('delete'));
693 $this->tpl->setCurrentBlock("action");
694 $this->tpl->parseCurrentBlock();
695 }
696 }
697
698 protected function getAdditionalExportCols(): array
699 {
700 $add_cols = [];
701 $cols = $this->getSelectableColumns();
702
703 unset($cols["week"], $cols["weekday"]);
704
705 // non-user columns
706 $user_cols = $this->getSelectableUserColumns();
707 foreach ($this->getSelectedColumns() as $col) {
708 if (array_key_exists($col, $cols)) {
709 if (!isset($user_cols[$col])) {
710 $add_cols[$col] = $cols[$col]["txt"];
711 }
712 }
713 }
714
715 $add_cols["user_name"] = $this->lng->txt("user");
716 $add_cols["login"] = $this->lng->txt("login");
717
718 // user columns
719 foreach ($this->getSelectedColumns() as $col) {
720 if (array_key_exists($col, $cols)) {
721 if (isset($user_cols[$col])) {
722 $add_cols[$col] = $cols[$col]["txt"];
723 }
724 }
725 }
726
727 return $add_cols;
728 }
729
730 protected function fillHeaderExcel(
731 ilExcel $a_excel,
732 int &$a_row
733 ): void {
734 $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
735 $col = 0;
736 if ($this->has_schedule) {
737 $a_excel->setCell($a_row, ++$col, $this->lng->txt("date"));
738 $a_excel->setCell($a_row, ++$col, $this->lng->txt("wk_short"));
739 $a_excel->setCell($a_row, ++$col, $this->lng->txt("cal_weekday"));
740 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_schedule_slot"));
741 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_no_of_objects"));
742 } else {
743 $a_excel->setCell($a_row, ++$col, $this->lng->txt("status"));
744 }
745
746 foreach ($this->getAdditionalExportCols() as $txt) {
747 $a_excel->setCell($a_row, ++$col, $txt);
748 }
749
750 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col) . $a_row);
751 }
752
753 protected function fillRowExcel(
754 ilExcel $a_excel,
755 int &$a_row,
756 array $a_set
757 ): void {
758 $a_excel->setCell($a_row, 0, $a_set["title"]);
759 $col = 0;
760 if ($this->has_schedule) {
761 $a_excel->setCell($a_row, ++$col, new ilDate($a_set["date"], IL_CAL_DATE));
762 $a_excel->setCell($a_row, ++$col, $a_set["week"]);
763 $a_excel->setCell($a_row, ++$col, ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
764 $a_excel->setCell($a_row, ++$col, $a_set["slot"]);
765 $a_excel->setCell($a_row, ++$col, $a_set["counter"]);
766 } else {
767 $status = "";
768 if (in_array($a_set['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE))) {
769 $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
770 }
771 $a_excel->setCell($a_row, ++$col, $status);
772 }
773
774 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
775 if (str_starts_with($colid, "advmd")) {
776 $val = " ";
777 $key = "md_" . (int) substr($colid, 5) . "_presentation";
778 if (isset($a_set[$key])) {
779 $pb = $a_set[$key]->getList();
780 if ($pb) {
781 $val = $pb;
782 }
783 }
784 $a_excel->setCell($a_row, ++$col, $val);
785 } else {
786 $a_excel->setCell($a_row, ++$col, $a_set[$colid]);
787 }
788 }
789 }
790
791 protected function fillHeaderCSV(
792 ilCSVWriter $a_csv
793 ): void {
794 $a_csv->addColumn($this->lng->txt("title"));
795 if ($this->has_schedule) {
796 $a_csv->addColumn($this->lng->txt("date"));
797 $a_csv->addColumn($this->lng->txt("wk_short"));
798 $a_csv->addColumn($this->lng->txt("cal_weekday"));
799 $a_csv->addColumn($this->lng->txt("book_schedule_slot"));
800 $a_csv->addColumn($this->lng->txt("book_no_of_objects"));
801 } else {
802 $a_csv->addColumn($this->lng->txt("status"));
803 }
804
805 foreach ($this->getAdditionalExportCols() as $txt) {
806 $a_csv->addColumn($txt);
807 }
808
809 $a_csv->addRow();
810 }
811
812 protected function fillRowCSV(
813 ilCSVWriter $a_csv,
814 array $a_set
815 ): void {
816 $a_csv->addColumn($a_set["title"]);
817 if ($this->has_schedule) {
818 $a_csv->addColumn(ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
819 $a_csv->addColumn($a_set["week"]);
820 $a_csv->addColumn(ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
821 $a_csv->addColumn($a_set["slot"]);
822 $a_csv->addColumn($a_set["counter"]);
823 } else {
824 $status = "";
825 if (in_array($a_set['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE))) {
826 $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
827 }
828 $a_csv->addColumn($status);
829 }
830
831 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
832 if (str_starts_with($colid, "advmd")) {
833 $val = " ";
834 $key = "md_" . (int) substr($colid, 5) . "_presentation";
835 if (isset($a_set[$key])) {
836 $pb = $a_set[$key]->getList();
837 if ($pb) {
838 $val = $pb;
839 }
840 }
841 $a_csv->addColumn($val);
842 } else {
843 $a_csv->addColumn($a_set[$colid]);
844 }
845 }
846
847 $a_csv->addRow();
848 }
849}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
ReservationTableSessionRepository $table_repo
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_ref_id, int $a_pool_id, bool $a_show_all, bool $a_has_schedule, array $a_filter_pre=null, int $a_group_id=null, array $context_obj_ids=null)
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.
getSelectableUserColumns()
Get selectable user fields.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getList(int $a_pool_id)
Get list of booking objects for given pool.
addColumn(string $a_col)
static _numericDayToString(int $a_day, bool $a_long=true)
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)
@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 $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
static _getInstanceByType(string $a_type)
Get Singleton Instance.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
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)
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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="ilpublicuserprofilegui")
Default behaviour is:
$c
Definition: cli.php:38
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const ANONYMOUS_USER_ID
Definition: constants.php:27
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
$query
$lng
$cols
Definition: xhr_table.php:11