ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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,
57  ilObjBookingPool $pool,
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();
70  $a_has_schedule = ($pool->getScheduleType() === ilObjBookingPool::TYPE_FIX_SCHEDULE);
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 (array_key_exists($col, $cols)) {
173  if (isset($user_cols[$col])) {
174  $this->addColumn($cols[$col]["txt"], $col);
175  }
176  }
177  }
178 
179  $this->addColumn($this->lng->txt("actions"));
180 
181  $this->setEnableHeader(true);
182  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
183  $this->setRowTemplate("tpl.booking_reservation_row.html", "components/ILIAS/BookingManager/Reservations");
184  $this->setResetCommand("resetLogFilter");
185  $this->setFilterCommand("applyLogFilter");
186  $this->setDisableFilterHiding(true);
187 
188  if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
189  if ($this->access->canManageAllReservations($this->ref_id) ||
190  $this->access->canManageOwnReservations($this->ref_id)) {
191  $this->addMultiCommand('rsvConfirmCancel', $lng->txt('book_set_cancel'));
192  }
193  if ($this->access->canManageAllReservations($this->ref_id)) {
194  $this->addMultiCommand('redirectMailToBooker', $lng->txt('book_mail_to_booker'));
195  $this->addMultiCommand('rsvConfirmDelete', $lng->txt('delete'));
196  }
197  }
199  }
200 
201  protected function showMessages(): bool
202  {
203  return $this->pool->usesMessages() &&
204  $this->access->canManageAllReservations($this->ref_id);
205  }
206 
207  public function getSelectableColumns(): array
208  {
209  $cols = array();
210 
211  if ($this->has_schedule) {
212  $this->lng->loadLanguageModule("dateplaner");
213 
214  $cols["week"] = array(
215  "txt" => $this->lng->txt("wk_short"),
216  "default" => true
217  );
218 
219  $cols["weekday"] = array(
220  "txt" => $this->lng->txt("cal_weekday"),
221  "default" => true
222  );
223  }
224 
225  foreach ($this->advmd as $field) {
226  $cols["advmd" . $field["id"]] = array(
227  "txt" => $field["title"],
228  "default" => false
229  );
230  }
231 
232  $cols = array_merge($cols, $this->getSelectableUserColumns());
233 
234  return $cols;
235  }
236 
240  protected function getSelectableUserColumns(): array
241  {
242  $cols = [];
243  // additional user fields
244  if ($this->access->canManageMembersOfParent($this->ref_id)) {
245  $parent = $this->access->getParentGroupCourse($this->ref_id);
246  $ef = ilExportFieldsInfo::_getInstanceByType($parent["type"]);
247  foreach ($ef->getSelectableFieldsInfo(ilObject::_lookupObjectId($parent["ref_id"])) as $k => $v) {
248  if ($k !== "login") {
249  $cols[$k] = $v;
250  }
251  }
252  }
253  return $cols;
254  }
255 
256  protected function getSelectedUserColumns(): array
257  {
258  $user_cols = $this->getSelectableUserColumns();
259  $sel = [];
260  foreach ($this->getSelectedColumns() as $col) {
261  if (isset($user_cols[$col])) {
262  $sel[] = $col;
263  }
264  }
265  return $sel;
266  }
267 
268  public function initFilter(
269  ?array $a_filter_pre = null
270  ): void {
271  if (is_array($a_filter_pre) &&
272  isset($a_filter_pre["object"])) {
273  $this->table_repo->setObjectFilter(
274  $this->getId(),
275  serialize($a_filter_pre["object"])
276  );
277  }
278 
279  $this->objects = array();
280  foreach (ilBookingObject::getList($this->pool_id) as $item) {
281  $this->objects[$item["booking_object_id"]] = $item["title"];
282  }
283  $item = $this->addFilterItemByMetaType("object", ilTable2GUI::FILTER_SELECT);
284  if ($item !== null) {
285  $item->setOptions(array("" => $this->lng->txt('book_all')) + $this->objects);
286  $this->filter["object"] = $item->getValue();
288  "title",
290  false,
291  $this->lng->txt("object") . " " . $this->lng->txt("title") . "/" . $this->lng->txt("description")
292  );
293  if ($title !== null) {
294  $this->filter["title"] = $title->getValue();
295  }
296 
297  if ($this->has_schedule) {
298  // default period: from:today [ to:(today + n days) ]
299  if (!$this->table_repo->hasFromToFilter($this->getId())) {
300  $from = new ilDateTime(date("Y-m-d"), IL_CAL_DATE); // today
301  $to = null;
302 
303  // add period end from pool settings?
304  $bpool = new ilObjBookingPool($this->pool_id, false);
305  $period = $bpool->getReservationFilterPeriod();
306  if ($period !== null) {
307  $to = clone $from;
308  if ($period) {
309  $to->increment(ilDateTime::DAY, $period);
310  }
311  $to = serialize($to);
312  }
313 
314  $this->table_repo->setFromToFilter(
315  $this->getId(),
316  serialize(array(
317  "from" => serialize($from),
318  "to" => $to
319  ))
320  );
321  }
322  $item = $this->addFilterItemByMetaType(
323  "fromto",
325  false,
326  $this->lng->txt('book_fromto')
327  );
328  $this->filter["fromto"] = $item->getDate();
329 
330  // only needed for full log
331  if ($this->show_all) {
332  // see ilObjBookingPoolGUI::buildDatesBySchedule()
333  $map = array_flip(array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'));
334 
335  $options = array("" => $this->lng->txt('book_all'));
336 
337  // schedule to slot
338  foreach ($this->schedule_manager->getScheduleList() as $id => $title) {
339  $schedule = new ilBookingSchedule($id);
340  foreach ($schedule->getDefinition() as $day => $slots) {
341  $day_caption = ilCalendarUtil::_numericDayToString((int) $map[$day], false);
342 
343  foreach ($slots as $slot) {
344  $idx = $map[$day] . "_" . $slot;
345  $options[$idx] = $day_caption . ", " . $slot;
346  }
347  }
348  }
349 
350  ksort($options);
351 
352  $item = $this->addFilterItemByMetaType("book_schedule_slot", ilTable2GUI::FILTER_SELECT);
353  $item->setOptions($options);
354  $this->filter["slot"] = $item->getValue();
355  }
356  }
357 
358  $item = new ilCheckboxInputGUI($this->lng->txt("book_filter_past_reservations"), "past");
359  $this->addFilterItem($item);
360  $item->readFromSession();
361 
362  // if period starts in the past we have to include past reservations
363  // :TODO: to be discussed
364  if (isset($this->filter["fromto"]["from"]) &&
365  $this->filter["fromto"]["from"]->get(IL_CAL_DATE) < date("Y-m-d")) {
366  $item->setChecked(true);
367  }
368 
369  $this->filter["past"] = $item->getChecked();
370 
371  // status
372  $valid_status = array(-ilBookingReservation::STATUS_CANCELLED,
374  );
375  if (!$this->has_schedule) {
376  $options = array("" => $this->lng->txt('book_all'));
377  } else {
378  $options = array();
379  }
380  foreach ($valid_status as $loop) {
381  if ($loop > 0) {
382  $options[$loop] = $this->lng->txt('book_reservation_status_' . $loop);
383  } else {
384  $options[$loop] = $this->lng->txt('book_not') . ' ' . $this->lng->txt('book_reservation_status_' . -$loop);
385  }
386  }
387  $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT);
388  $item->setOptions($options);
389  $this->filter["status"] = $item->getValue();
390 
391  // only needed for full log
392  if ($this->show_all) {
393  $options = array("" => $this->lng->txt('book_all')) +
394  ilBookingReservation::getUserFilter(array_keys($this->objects));
395  $item = $this->addFilterItemByMetaType("user", ilTable2GUI::FILTER_SELECT);
396  $item->setOptions($options);
397  if (is_array($a_filter_pre) && isset($a_filter_pre["user_id"])) {
398  $item->setValue($a_filter_pre["user_id"]);
399  $this->filter["user_id"] = $a_filter_pre["user_id"];
400  } else {
401  $this->filter["user_id"] = $item->getValue();
402  }
403  }
404  }
405  }
406 
410  public function getCurrentFilter(): array
411  {
412  $filter = array();
413  if ($this->filter["object"]) {
414  $filter["object"] = $this->filter["object"];
415  }
416  if ($this->filter["title"]) {
417  $filter["title"] = $this->filter["title"];
418  }
419  if ($this->filter["status"]) {
420  $filter["status"] = $this->filter["status"];
421  }
422  if (isset($this->filter["user_id"])) {
423  $filter["user_id"] = $this->filter["user_id"];
424  }
425  if (!is_null($this->context_obj_ids)) {
426  $filter["context_obj_ids"] = $this->context_obj_ids;
427  }
428 
429  if ($this->has_schedule) {
430  if (!isset($filter["status"])) {
431  // needs distinct status because of aggregation
432  $filter["status"] = -ilBookingReservation::STATUS_CANCELLED;
433  }
434  if (isset($this->filter["slot"])) {
435  $filter["slot"] = $this->filter["slot"];
436  }
437 
438  if ($this->filter["fromto"]["from"] || $this->filter["fromto"]["to"]) {
439  if ($this->filter["fromto"]["from"]) {
440  $filter["from"] = $this->filter["fromto"]["from"]->get(IL_CAL_UNIX);
441  }
442  if ($this->filter["fromto"]["to"]) {
443  $day_end = new ilDateTime(
444  $this->filter["fromto"]["to"]->get(IL_CAL_DATE) . " 23:59:59",
446  );
447  $filter["to"] = $day_end->get(IL_CAL_UNIX);
448  }
449  }
450 
451  $filter["past"] = (bool) $this->filter["past"];
452  }
453  return $filter;
454  }
455 
456  public function numericOrdering(string $a_field): bool
457  {
458  return in_array($a_field, array("counter", "date", "week", "weekday"));
459  }
460 
464  public function getItems(array $filter): void
465  {
466  $ilUser = $this->user;
467 
468  $this->has_items_with_host_context = false;
469 
470  if (!isset($filter["object"])) {
471  $ids = array_keys($this->objects);
472  } else {
473  $ids = array($filter["object"]);
474  }
475 
476  if (!$this->show_all) {
477  $filter["user_id"] = $ilUser->getId();
478  }
479 
480  $repo = $this->reservation_repo;
481  $data = $repo->getListByDate($this->has_schedule, $ids, $filter);
482 
483  if ($this->advmd) {
484  // advanced metadata
485  $this->record_gui = new ilAdvancedMDRecordGUI(
487  "book",
488  $this->pool_id,
489  "bobj"
490  );
491  $this->record_gui->setTableGUI($this);
492  $this->record_gui->parse();
493 
494  foreach (array_keys($data) as $idx) {
495  $data[$idx]["pool_id"] = $this->pool_id;
496  }
497 
499  $this->ref_id,
500  "book",
501  "bobj",
502  [$this->pool_id],
503  "bobj",
504  $data,
505  "pool_id",
506  "object_id",
507  $this->record_gui->getFilterElements()
508  );
509  }
510 
511  if (count($this->getSelectedUserColumns()) > 0) {
512  // get additional user data
513  $user_ids = array_unique(array_map(static function ($d) {
514  return $d['user_id'];
515  }, $data));
516 
517  $user_columns = [];
518  $odf_ids = [];
519  foreach ($this->getSelectedUserColumns() as $field) {
520  if (strpos($field, 'odf') === 0) {
521  $odf_ids[] = substr($field, 4);
522  } else {
523  $user_columns[] = $field;
524  }
525  }
526 
527  // see ilCourseParticipantsTableGUI
528  $user_columns = array_diff(
529  $user_columns,
530  ['consultation_hour', 'prtf', 'roles', 'org_units']
531  );
532 
533  // user data fields
534  $query = new ilUserQuery();
535  $query->setLimit(9999);
536  $query->setAdditionalFields($user_columns);
537  $query->setUserFilter($user_ids);
538  $ud = $query->query();
539  $usr_data = [];
540  foreach ($ud["set"] as $v) {
541  foreach ($user_columns as $c) {
542  $usr_data[$v["usr_id"]][$c] = $v[$c];
543  }
544  }
545  foreach ($data as $key => $v) {
546  if (isset($usr_data[$v["user_id"]])) {
547  $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
548  }
549  }
550 
551  // object specific user data fields of parent course or group
552  if ($odf_ids) {
553  $parent = $this->access->getParentGroupCourse($this->ref_id);
554  $parent_obj_id = ilObject::_lookupObjectId($parent['ref_id']);
555  $parent_obj_type = ilObject::_lookupType($parent_obj_id);
556 
557  $confirmation_required = ($parent_obj_type === 'crs')
558  ? ilPrivacySettings::getInstance()->courseConfirmationRequired()
559  : ilPrivacySettings::getInstance()->groupConfirmationRequired();
560  if ($confirmation_required) {
561  $user_ids = array_diff($user_ids, ilMemberAgreement::lookupAcceptedAgreements($parent_obj_id));
562  }
563  $odf_data = ilCourseUserData::_getValuesByObjId($parent_obj_id);
564  $usr_data = [];
565  foreach ($odf_data as $usr_id => $fields) {
566  // this currently does not with strict mode, since
567  // $user_ids holds strings
568  if (in_array($usr_id, $user_ids)) {
569  foreach ($fields as $field_id => $value) {
570  if (in_array($field_id, $odf_ids, true)) {
571  $usr_data[$usr_id]['odf_' . $field_id] = $value;
572  }
573  }
574  }
575  }
576 
577  foreach ($data as $key => $v) {
578  if (isset($usr_data[$v["user_id"]])) {
579  $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
580  }
581  }
582  }
583  }
584 
585  foreach ($data as $k => $d) {
586  if ($d["context_obj_id"] > 0) {
587  $this->has_items_with_host_context = true;
588  $data[$k]["context_obj_title"] = ilObject::_lookupTitle($d["context_obj_id"]);
589  }
590  }
591 
592  $this->setData($data);
593  }
594 
596  {
597  return $this->record_gui;
598  }
599 
600  public function getOrderField(): string
601  {
602  $field = parent::getOrderField();
603 
604  // #16560 - this will enable matchting slot sorting to date/week
605  if (in_array($field, array("date", "week"))) {
606  $field = "_sortdate";
607  }
608 
609  return $field;
610  }
611 
612  protected function fillRow(array $a_set): void
613  {
614  $lng = $this->lng;
615  $ilAccess = $this->access;
616  $ilCtrl = $this->ctrl;
617  $ilUser = $this->user;
618  $f = $this->gui->ui()->factory();
619 
620  $selected = $this->getSelectedColumns();
621 
622  $dd_items = [];
623 
624  if ($this->has_items_with_host_context) {
625  $this->tpl->setCurrentBlock("context");
626  $this->tpl->setVariable("VALUE_CONTEXT_TITLE", ($a_set["context_obj_title"] ?? "") . " ");
627  $this->tpl->parseCurrentBlock();
628  }
629 
630  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
631 
632  $can_be_cancelled = ($this->access->canManageReservationForUser($this->ref_id, $a_set['user_id']) &&
633  $a_set["can_be_cancelled"]);
634 
635  if ($can_be_cancelled) {
636  $this->tpl->setVariable("MULTI_ID", $a_set["booking_reservation_id"]);
637  }
638 
639  // #11995
640  $profile = $this->domain->profile();
641  $user_id = (int) $a_set['user_id'];
642  if (!$profile->exists($user_id)) {
643  $uname = $profile->getDeletedUserNamePresentation();
644  } else {
645  $uname = ilUserUtil::getNamePresentation($a_set['user_id'], false, true, "", true);
646  }
647  $this->tpl->setVariable("TXT_CURRENT_USER", $uname);
648  if ($this->has_schedule) {
649  $this->tpl->setVariable(
650  "VALUE_DATE",
652  );
653  if (in_array("week", $selected, true)) {
654  $this->tpl->setVariable("VALUE_WEEK", $a_set["week"]);
655  }
656  if (in_array("weekday", $selected, true)) {
657  $this->tpl->setVariable(
658  "VALUE_WEEKDAY",
659  ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false)
660  );
661  }
662  $this->tpl->setVariable("VALUE_SLOT", $a_set["slot"]);
663  $this->tpl->setVariable("VALUE_COUNTER", $a_set["counter"]);
664  } elseif (in_array(
665  $a_set['status'],
667  )) {
668  $this->tpl->setVariable("TXT_STATUS", $lng->txt('book_reservation_status_' . $a_set['status']));
669  } else {
670  $this->tpl->setVariable("TXT_STATUS", "&nbsp;");
671  }
672  if ($this->showMessages()) {
673  $this->tpl->setCurrentBlock("message");
674  $this->tpl->setVariable("MESSAGE", ilStr::shortenTextExtended($a_set["message"] . " ", 20, true));
675  $this->tpl->parseCurrentBlock();
676  }
677 
678  if ($this->advmd) {
679  foreach ($this->advmd as $item) {
680  $advmd_id = (int) $item["id"];
681 
682  if (!in_array("advmd" . $advmd_id, $selected, true)) {
683  continue;
684  }
685 
686  $val = " ";
687  $key = "md_" . $advmd_id . "_presentation";
688  if (isset($a_set[$key])) {
689  $pb = $a_set[$key]->getList();
690  if ($pb) {
691  $val = $pb;
692  }
693  }
694 
695  $this->tpl->setCurrentBlock("advmd_bl");
696  $this->tpl->setVariable("VALUE_ADVMD", $val);
697  $this->tpl->parseCurrentBlock();
698  }
699  }
700 
701  // additional user fields
702  $user_cols = $this->getSelectableUserColumns();
703  foreach ($this->getSelectedColumns() as $col) {
704  if (isset($user_cols[$col])) {
705  $this->tpl->setCurrentBlock("user_col");
706  $this->tpl->setVariable("VALUE_USER_COL", ($a_set[$col] ?? "") . " ");
707  $this->tpl->parseCurrentBlock();
708  }
709  }
710 
711  // reservation information
712  if ($a_set['user_id'] == $ilUser->getId() || $ilAccess->canManageAllReservations($this->ref_id)) {
713  if ($a_set['post_text'] !== "" || $a_set['post_file'] !== "") {
714  $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
715  $ilCtrl->setParameter($this->parent_obj, 'object_id', $a_set['object_id']);
716  $dd_items[] = $f->button()->shy(
717  $lng->txt('book_post_booking_information'),
718  $ilCtrl->getLinkTarget($this->parent_obj, 'displayPostInfo')
719  );
720  $ilCtrl->setParameter($this->parent_obj, 'object_id', null);
721  $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
722  }
723  }
724 
725  if ($can_be_cancelled) {
726  $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
727  $dd_items[] = $f->button()->shy(
728  $lng->txt('book_set_cancel'),
729  $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmCancel')
730  );
731  $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
732  }
733 
734  if ($this->access->canManageAllReservations($this->ref_id)) {
735  $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
736  $dd_items[] = $f->button()->shy(
737  $lng->txt('book_mail_to_booker'),
738  $ilCtrl->getLinkTarget($this->parent_obj, 'redirectMailToBooker')
739  );
740  $dd_items[] = $f->button()->shy(
741  $lng->txt('delete'),
742  $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmDelete')
743  );
744  $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
745  }
746 
747  $render_items = [];
748  if ($this->showMessages() && $a_set["message"] !== "") {
749  $c = $this->gui->modal(
750  $this->lng->txt("book_message"),
751  $this->lng->txt("close")
752  )
753  ->legacy(nl2br($a_set["message"]))
754  ->getTriggerButtonComponents(
755  $this->lng->txt("book_show_message"),
756  true
757  );
758  $dd_items[] = $c["button"];
759  $render_items[] = $c["modal"];
760  }
761 
762  if (count($dd_items) > 0) {
763  $render_items[] = $f->dropdown()->standard($dd_items);
764  $this->tpl->setVariable("ACTIONS", $this->gui->ui()->renderer()->render($render_items));
765  }
766  }
767 
768  protected function getAdditionalExportCols(): array
769  {
770  $add_cols = [];
771  $cols = $this->getSelectableColumns();
772 
773  unset($cols["week"], $cols["weekday"]);
774 
775  // non-user columns
776  $user_cols = $this->getSelectableUserColumns();
777  foreach ($this->getSelectedColumns() as $col) {
778  if (array_key_exists($col, $cols)) {
779  if (!isset($user_cols[$col])) {
780  $add_cols[$col] = $cols[$col]["txt"];
781  }
782  }
783  }
784 
785  $add_cols["user_name"] = $this->lng->txt("user");
786  $add_cols["login"] = $this->lng->txt("login");
787 
788  // user columns
789  foreach ($this->getSelectedColumns() as $col) {
790  if (array_key_exists($col, $cols)) {
791  if (isset($user_cols[$col])) {
792  $add_cols[$col] = $cols[$col]["txt"];
793  }
794  }
795  }
796 
797  return $add_cols;
798  }
799 
800  protected function fillHeaderExcel(
801  ilExcel $a_excel,
802  int &$a_row
803  ): void {
804  $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
805  $col = 0;
806  if ($this->has_schedule) {
807  $a_excel->setCell($a_row, ++$col, $this->lng->txt("date"));
808  $a_excel->setCell($a_row, ++$col, $this->lng->txt("wk_short"));
809  $a_excel->setCell($a_row, ++$col, $this->lng->txt("cal_weekday"));
810  $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_schedule_slot"));
811  $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_no_of_objects"));
812  } else {
813  $a_excel->setCell($a_row, ++$col, $this->lng->txt("status"));
814  }
815  if ($this->showMessages()) {
816  $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_message"));
817  }
818 
819  foreach ($this->getAdditionalExportCols() as $txt) {
820  $a_excel->setCell($a_row, ++$col, $txt);
821  }
822 
823  $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col) . $a_row);
824  }
825 
826  protected function fillRowExcel(
827  ilExcel $a_excel,
828  int &$a_row,
829  array $a_set
830  ): void {
831  $a_excel->setCell($a_row, 0, $a_set["title"]);
832  $col = 0;
833  if ($this->has_schedule) {
834  $a_excel->setCell($a_row, ++$col, new ilDate($a_set["date"], IL_CAL_DATE));
835  $a_excel->setCell($a_row, ++$col, $a_set["week"]);
836  $a_excel->setCell($a_row, ++$col, ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
837  $a_excel->setCell($a_row, ++$col, $a_set["slot"]);
838  $a_excel->setCell($a_row, ++$col, $a_set["counter"]);
839  } else {
840  $status = "";
841  if (in_array(
842  $a_set['status'],
844  )) {
845  $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
846  }
847  $a_excel->setCell($a_row, ++$col, $status);
848  }
849  if ($this->showMessages()) {
850  $a_excel->setCell($a_row, ++$col, $a_set["message"]);
851  }
852 
853  foreach ($this->getAdditionalExportCols() as $colid => $txt) {
854  if (str_starts_with($colid, "advmd")) {
855  $val = " ";
856  $key = "md_" . (int) substr($colid, 5) . "_presentation";
857  if (isset($a_set[$key])) {
858  $pb = $a_set[$key]->getList();
859  if ($pb) {
860  $val = $pb;
861  }
862  }
863  $a_excel->setCell($a_row, ++$col, $val);
864  } else {
865  $a_excel->setCell($a_row, ++$col, $a_set[$colid]);
866  }
867  }
868  }
869 
870  protected function fillHeaderCSV(
871  ilCSVWriter $a_csv
872  ): void {
873  $a_csv->addColumn($this->lng->txt("title"));
874  if ($this->has_schedule) {
875  $a_csv->addColumn($this->lng->txt("date"));
876  $a_csv->addColumn($this->lng->txt("wk_short"));
877  $a_csv->addColumn($this->lng->txt("cal_weekday"));
878  $a_csv->addColumn($this->lng->txt("book_schedule_slot"));
879  $a_csv->addColumn($this->lng->txt("book_no_of_objects"));
880  } else {
881  $a_csv->addColumn($this->lng->txt("status"));
882  }
883  if ($this->showMessages()) {
884  $a_csv->addColumn($this->lng->txt("book_message"));
885  }
886 
887  foreach ($this->getAdditionalExportCols() as $txt) {
888  $a_csv->addColumn($txt);
889  }
890 
891  $a_csv->addRow();
892  }
893 
894  protected function fillRowCSV(
895  ilCSVWriter $a_csv,
896  array $a_set
897  ): void {
898  $a_csv->addColumn($a_set["title"]);
899  if ($this->has_schedule) {
900  $a_csv->addColumn(ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
901  $a_csv->addColumn($a_set["week"]);
902  $a_csv->addColumn(ilCalendarUtil::_numericDayToString((int) $a_set["weekday"], false));
903  $a_csv->addColumn($a_set["slot"]);
904  $a_csv->addColumn($a_set["counter"]);
905  } else {
906  $status = "";
907  if (in_array(
908  $a_set['status'],
910  )) {
911  $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
912  }
913  $a_csv->addColumn($status);
914  }
915  if ($this->showMessages()) {
916  $a_csv->addColumn($a_set["message"]);
917  }
918 
919  foreach ($this->getAdditionalExportCols() as $colid => $txt) {
920  if (str_starts_with($colid, "advmd")) {
921  $val = " ";
922  $key = "md_" . (int) substr($colid, 5) . "_presentation";
923  if (isset($a_set[$key])) {
924  $pb = $a_set[$key]->getList();
925  if ($pb) {
926  $val = $pb;
927  }
928  }
929  $a_csv->addColumn($val);
930  } else {
931  $a_csv->addColumn($a_set[$colid]);
932  }
933  }
934 
935  $a_csv->addRow();
936  }
937 }
ReservationTableSessionRepository $table_repo
setData(array $a_data)
static array static setUseRelativeDates(bool $a_status)
set use relative dates
addColumn(string $a_col)
setExportFormats(array $formats)
Set available export formats.
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
static getUserFilter(array $a_object_ids)
Get all users who have reservations for object(s)
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
setResetCommand(string $a_val, string $a_caption="")
Repo class for reservations Acts on tables booking_reservation (rw), booking_reservation_group (rw) a...
getSelectableUserColumns()
Get selectable user fields.
getItems(array $filter)
Gather data and build rows.
getColumnCoord(int $a_col)
Get column "name" from number.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDisableFilterHiding(bool $a_val=true)
static _getValuesByObjId(int $a_obj_id)
static getAdvancedMDFields(int $a_ref_id)
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
$c
Definition: deliver.php:25
ilLanguage $lng
setId(string $a_val)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
Author: Alexander Killing killing@leifos.de
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setBold(string $a_coords)
Set cell(s) to bold.
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 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:
static _lookupTitle(int $obj_id)
setDefaultOrderField(string $a_defaultorderfield)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
global $DIC
Definition: shib_login.php:22
setDefaultOrderDirection(string $a_defaultorderdirection)
static _lookupObjectId(int $ref_id)
legacy()
expected output: > ILIAS shows the rendered Component.
Definition: legacy.php:29
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
$txt
Definition: error.php:31
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
const IL_CAL_DATE
static _getInstanceByType(string $a_type)
Get Singleton Instance.
__construct(Container $dic, ilPlugin $plugin)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
setLimit(int $a_limit=0, int $a_default_limit=0)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
__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)
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)
disable(string $a_module_name)
static lookupAcceptedAgreements(int $a_obj_id)
Lookup users who have accepted the agreement.
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
ILIAS BookingManager Access AccessManager $access
static _lookupType(int $id, bool $reference=false)
addMultiCommand(string $a_cmd, string $a_text)
$service
Definition: ltiservices.php:40
setEnableHeader(bool $a_enableheader)