ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBookingReservationsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
14{
18 protected $user;
19
23 protected $access;
24
25 protected $ref_id; // int
26 protected $filter; // array
27 protected $pool_id; // int
28 protected $show_all; // bool
29 protected $has_schedule; // bool
30 protected $objects; // array
31 protected $group_id; // int
32 protected $advmd; // [array]
33
38
42 protected $tree;
43
48
60 public function __construct(
61 $a_parent_obj,
62 $a_parent_cmd,
63 $a_ref_id,
64 $a_pool_id,
65 $a_show_all,
66 $a_has_schedule,
67 array $a_filter_pre = null,
68 $a_group_id = null,
69 array $context_obj_ids = null
70 ) {
71 global $DIC;
72
73 $this->ctrl = $DIC->ctrl();
74 $this->lng = $DIC->language();
75 $this->user = $DIC->user();
76 $this->access = $DIC->access();
77 $ilCtrl = $DIC->ctrl();
78 $lng = $DIC->language();
79 $ilUser = $DIC->user();
80 $ilAccess = $DIC->access();
81 $this->tree = $DIC->repositoryTree();
82
83 $this->context_obj_ids = $context_obj_ids;
84 $this->pool_id = $a_pool_id;
85 $this->ref_id = $a_ref_id;
86 $this->show_all = $a_show_all;
87 $this->has_schedule = (bool) $a_has_schedule;
88 $this->group_id = $a_group_id;
89
90 $this->advmd = ilObjBookingPool::getAdvancedMDFields($a_ref_id);
91
92 $this->setId("bkrsv" . $a_ref_id);
93
94 parent::__construct($a_parent_obj, $a_parent_cmd);
95
96 $this->setTitle($lng->txt("book_reservations_list"));
97
98 $this->addColumn("", "", 1);
99 $this->addColumn($this->lng->txt("title"), "title");
100
101 $selected = $this->getSelectedColumns();
102 $cols = $this->getSelectableColumns();
103
104 if ($this->has_schedule) {
105 $this->lng->loadLanguageModule("dateplaner");
106
107 $this->addColumn($this->lng->txt("date"), "date");
108 if (in_array("week", $selected)) {
109 $this->addColumn($this->lng->txt("wk_short"), "week");
110 unset($cols["week"]);
111 }
112 if (in_array("weekday", $selected)) {
113 $this->addColumn($this->lng->txt("cal_weekday"), "weekday");
114 unset($cols["weekday"]);
115 }
116 $this->addColumn($this->lng->txt("book_schedule_slot"), "slot");
117 $this->addColumn($this->lng->txt("book_no_of_objects"), "counter");
118
119 $this->setDefaultOrderField("date");
120 $this->setDefaultOrderDirection("asc");
121 } else {
122 $this->addColumn($this->lng->txt("status"), "status");
123
124 $this->setDefaultOrderField("title");
125 $this->setDefaultOrderDirection("asc");
126 }
127
128 // non-user columns
129 $user_cols = $this->getSelectableUserColumns();
130 foreach ($this->getSelectedColumns() as $col) {
131 if (array_key_exists($col, $cols)) {
132 if (!isset($user_cols[$col])) {
133 $this->addColumn($cols[$col]["txt"], $col);
134 }
135 }
136 }
137
138
139
140 $this->initFilter($a_filter_pre);
141 if ($this->group_id) {
142 $this->setLimit(9999);
143 $this->disable("numinfo");
144 $this->filters = array();
145 } else {
146 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
147 }
148 $this->getItems($this->getCurrentFilter());
149
150 if ($this->has_items_with_host_context) {
151 $this->addColumn($this->lng->txt("book_booked_in"), "context_obj_title");
152 }
153
154 $this->addColumn($this->lng->txt("user"), "user_name");
155
156 // user columns
157 foreach ($this->getSelectedColumns() as $col) {
158 if (array_key_exists($col, $cols)) {
159 if (isset($user_cols[$col])) {
160 $this->addColumn($cols[$col]["txt"], $col);
161 }
162 }
163 }
164
165 $this->addColumn($this->lng->txt("actions"));
166
167 $this->setEnableHeader(true);
168 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
169 $this->setRowTemplate("tpl.booking_reservation_row.html", "Modules/BookingManager/Reservations");
170 $this->setResetCommand("resetLogFilter");
171 $this->setFilterCommand("applyLogFilter");
172 $this->setDisableFilterHiding(true);
173
174
175 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
176 $this->addMultiCommand('rsvConfirmCancel', $lng->txt('book_set_cancel'));
177 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
178 $this->addMultiCommand('rsvConfirmDelete', $lng->txt('delete'));
179 }
180 $this->setSelectAllCheckbox('mrsv');
181 }
182
183
185 }
186
187 public function getSelectableColumns($a_only_advmd = false, $a_include_user = true)
188 {
189 $cols = array();
190
191 if ($this->has_schedule &&
192 !(bool) $a_only_advmd) {
193 $this->lng->loadLanguageModule("dateplaner");
194
195 $cols["week"] = array(
196 "txt" => $this->lng->txt("wk_short"),
197 "default" => true
198 );
199
200 $cols["weekday"] = array(
201 "txt" => $this->lng->txt("cal_weekday"),
202 "default" => true
203 );
204 }
205
206 foreach ($this->advmd as $field) {
207 $cols["advmd" . $field["id"]] = array(
208 "txt" => $field["title"],
209 "default" => false
210 );
211 }
212
213 if ($a_include_user) {
214 $cols = array_merge($cols, $this->getSelectableUserColumns());
215 }
216
217 return $cols;
218 }
219
226 protected function getSelectableUserColumns()
227 {
228 $cols = [];
229 // additional user fields
230 if (($parent = $this->getParentGroupCourse()) !== false) {
231 if ($this->access->checkAccess("manage_members", "", $parent["ref_id"])) {
232 $ef = ilExportFieldsInfo::_getInstanceByType($parent["type"]);
233 foreach ($ef->getSelectableFieldsInfo(ilObject::_lookupObjectId($parent["ref_id"])) as $k => $v) {
234 if (!in_array($k, ["login"])) {
235 $cols[$k] = $v;
236 }
237 }
238 }
239 }
240 return $cols;
241 }
242
249 protected function getSelectedUserColumns()
250 {
251 $user_cols = $this->getSelectableUserColumns();
252 $sel = [];
253 foreach ($this->getSelectedColumns() as $col) {
254 if (isset($user_cols[$col])) {
255 $sel[] = $col;
256 }
257 }
258 return $sel;
259 }
260
261
268 protected function getParentGroupCourse()
269 {
271 if (($par_ref_id = $tree->checkForParentType($this->ref_id, "grp")) > 0) {
272 return [
273 "ref_id" => $par_ref_id,
274 "type" => "grp"
275 ];
276 }
277 if (($par_ref_id = $tree->checkForParentType($this->ref_id, "crs")) > 0) {
278 return [
279 "ref_id" => $par_ref_id,
280 "type" => "crs"
281 ];
282 }
283 return false;
284 }
285
286
287
291 public function initFilter(array $a_filter_pre = null)
292 {
293 if (is_array($a_filter_pre) &&
294 isset($a_filter_pre["object"])) {
295 $_SESSION["form_" . $this->getId()]["object"] = serialize($a_filter_pre["object"]);
296 }
297
298 $this->objects = array();
299 foreach (ilBookingObject::getList($this->pool_id) as $item) {
300 $this->objects[$item["booking_object_id"]] = $item["title"];
301 }
302 $item = $this->addFilterItemByMetaType("object", ilTable2GUI::FILTER_SELECT);
303 $item->setOptions(array("" => $this->lng->txt('book_all')) + $this->objects);
304 $this->filter["object"] = $item->getValue();
305
307 "title",
309 false,
310 $this->lng->txt("object") . " " . $this->lng->txt("title") . "/" . $this->lng->txt("description")
311 );
312 $this->filter["title"] = $title->getValue();
313
314 if ($this->has_schedule) {
315 // default period: from:today [ to:(today + n days) ]
316 if (!$_SESSION["form_" . $this->getId()]["fromto"]) {
317 $from = new ilDateTime(date("Y-m-d"), IL_CAL_DATE); // today
318 $to = null;
319
320 // add period end from pool settings?
321 $bpool = new ilObjBookingPool($this->pool_id, false);
322 $period = $bpool->getReservationFilterPeriod();
323 if ($period !== null) {
324 $to = clone $from;
325 if ($period) {
326 $to->increment(ilDateTime::DAY, $period);
327 }
328 $to = serialize($to);
329 }
330
331 $_SESSION["form_" . $this->getId()]["fromto"] = serialize(array(
332 "from" => serialize($from),
333 "to" => $to
334 ));
335 }
336 $item = $this->addFilterItemByMetaType("fromto", ilTable2GUI::FILTER_DATE_RANGE, false, $this->lng->txt('book_fromto'));
337 $this->filter["fromto"] = $item->getDate();
338
339 // only needed for full log
340 if ($this->show_all) {
341 // see ilObjBookingPoolGUI::buildDatesBySchedule()
342 $map = array_flip(array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'));
343
344 $options = array("" => $this->lng->txt('book_all'));
345
346 // schedule to slot
347 foreach (ilBookingSchedule::getList($this->pool_id) as $def) {
348 $schedule = new ilBookingSchedule($def["booking_schedule_id"]);
349 foreach ($schedule->getDefinition() as $day => $slots) {
350 $day_caption = ilCalendarUtil::_numericDayToString($map[$day], false);
351
352 foreach ($slots as $slot) {
353 $idx = $map[$day] . "_" . $slot;
354 $options[$idx] = $day_caption . ", " . $slot;
355 }
356 }
357 }
358
359 ksort($options);
360
361 $item = $this->addFilterItemByMetaType("book_schedule_slot", ilTable2GUI::FILTER_SELECT);
362 $item->setOptions($options);
363 $this->filter["slot"] = $item->getValue();
364 }
365 }
366
367 $item = new ilCheckboxInputGUI($this->lng->txt("book_filter_past_reservations"), "past");
368 $this->addFilterItem($item);
369 $item->readFromSession();
370
371 // if period starts in the past we have to include past reservations
372 // :TODO: to be discussed
373 if (is_object($this->filter["fromto"]["from"]) &&
374 $this->filter["fromto"]["from"]->get(IL_CAL_DATE) < date("Y-m-d")) {
375 $item->setChecked(true);
376 }
377
378 $this->filter["past"] = $item->getChecked();
379
380 // status
381 $valid_status = array(-ilBookingReservation::STATUS_CANCELLED,
383 if (!$this->has_schedule) {
384 $options = array("" => $this->lng->txt('book_all'));
385 } else {
386 $options = array();
387 }
388 foreach ($valid_status as $loop) {
389 if ($loop > 0) {
390 $options[$loop] = $this->lng->txt('book_reservation_status_' . $loop);
391 } else {
392 $options[$loop] = $this->lng->txt('book_not') . ' ' . $this->lng->txt('book_reservation_status_' . -$loop);
393 }
394 }
395 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT);
396 $item->setOptions($options);
397 $this->filter["status"] = $item->getValue();
398
399 // only needed for full log
400 if ($this->show_all) {
401 $options = array("" => $this->lng->txt('book_all')) +
402 ilBookingReservation::getUserFilter(array_keys($this->objects));
404 $item->setOptions($options);
405 if (is_array($a_filter_pre) && isset($a_filter_pre["user_id"])) {
406 $item->setValue($a_filter_pre["user_id"]);
407 $this->filter["user_id"] = $a_filter_pre["user_id"];
408 } else {
409 $this->filter["user_id"] = $item->getValue();
410 }
411 }
412 }
413
418 public function getCurrentFilter()
419 {
420 $filter = array();
421 if ($this->filter["object"]) {
422 $filter["object"] = $this->filter["object"];
423 }
424 if ($this->filter["title"]) {
425 $filter["title"] = $this->filter["title"];
426 }
427 if ($this->filter["status"]) {
428 $filter["status"] = $this->filter["status"];
429 }
430 if ($this->filter["user_id"]) {
431 $filter["user_id"] = $this->filter["user_id"];
432 }
433 if (is_array($this->context_obj_ids)) {
434 $filter["context_obj_ids"] = $this->context_obj_ids;
435 }
436
437 if ($this->has_schedule) {
438 if (!$filter["status"]) {
439 // needs distinct status because of aggregation
441 }
442 if ($this->filter["slot"]) {
443 $filter["slot"] = $this->filter["slot"];
444 }
445
446 if ($this->filter["fromto"]["from"] || $this->filter["fromto"]["to"]) {
447 if ($this->filter["fromto"]["from"]) {
448 $filter["from"] = $this->filter["fromto"]["from"]->get(IL_CAL_UNIX);
449 }
450 if ($this->filter["fromto"]["to"]) {
451 $day_end = new ilDateTime($this->filter["fromto"]["to"]->get(IL_CAL_DATE) . " 23:59:59", IL_CAL_DATETIME);
452 $filter["to"] = $day_end->get(IL_CAL_UNIX);
453 }
454 }
455
456 $filter["past"] = (bool) $this->filter["past"];
457 }
458
459 return $filter;
460 }
461
462 public function numericOrdering($a_field)
463 {
464 return in_array($a_field, array("counter", "date", "week", "weekday"));
465 }
466
471 public function getItems(array $filter)
472 {
474
475 $this->has_items_with_host_context = false;
476
477 if (!$filter["object"]) {
478 $ids = array_keys($this->objects);
479 } else {
480 $ids = array($filter["object"]);
481 }
482
483 if (!$this->show_all) {
484 $filter["user_id"] = $ilUser->getId();
485 }
486
488 $repo = $f->getRepo();
489 $data = $repo->getListByDate($this->has_schedule, $ids, $filter);
490 if ($this->advmd) {
491 // advanced metadata
492 $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_FILTER, "book", $this->pool_id, "bobj");
493 $this->record_gui->setTableGUI($this);
494 $this->record_gui->parse();
495
496 foreach (array_keys($data) as $idx) {
497 $data[$idx]["pool_id"] = $this->pool_id;
498 }
499
501 $this->ref_id,
502 "book",
503 "bobj",
504 $this->pool_id,
505 "bobj",
506 $data,
507 "pool_id",
508 "object_id",
509 $this->record_gui->getFilterElements()
510 );
511 }
512
513 if (count($this->getSelectedUserColumns()) > 0) {
514 // get additional user data
515 $user_ids = array_unique(array_map(function ($d) {
516 return $d['user_id'];
517 }, $data));
518
519 $user_columns = [];
520 $odf_ids = [];
521 foreach ($this->getSelectedUserColumns() as $field) {
522 if (substr($field, 0, 3) == 'odf') {
523 $odf_ids[] = substr($field, 4);
524 } else {
525 $user_columns[] = $field;
526 }
527 }
528
529 // see ilCourseParticipantsTableGUI
530 $user_columns = array_diff(
531 $user_columns,
532 ['consultation_hour', 'prtf', 'roles', 'org_units']
533 );
534
535 // user data fields
536 $query = new ilUserQuery();
537 $query->setLimit(9999);
538 $query->setAdditionalFields($user_columns);
539 $query->setUserFilter($user_ids);
540 $ud = $query->query();
541 $usr_data = [];
542 foreach ($ud["set"] as $v) {
543 foreach ($user_columns as $c) {
544 $usr_data[$v["usr_id"]][$c] = $v[$c];
545 }
546 }
547 foreach ($data as $key => $v) {
548 if (isset($usr_data[$v["user_id"]])) {
549 $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
550 }
551 }
552
553 // object specific user data fields of parent course or group
554 if ($odf_ids) {
555 $parent = $this->getParentGroupCourse();
556 $parent_obj_id = ilObject::_lookupObjectId($parent['ref_id']);
557 $parent_obj_type = ilObject::_lookupType($parent_obj_id);
558
559 $confirmation_required = ($parent_obj_type == 'crs')
560 ? ilPrivacySettings::_getInstance()->courseConfirmationRequired()
561 : ilPrivacySettings::_getInstance()->groupConfirmationRequired();
562 if ($confirmation_required) {
563 $user_ids = array_diff($user_ids, ilMemberAgreement::lookupAcceptedAgreements($parent_obj_id));
564 }
565 $odf_data = ilCourseUserData::_getValuesByObjId($parent_obj_id);
566
567 $usr_data = [];
568 foreach ($odf_data as $usr_id => $fields) {
569 if (in_array($usr_id, $user_ids)) {
570 foreach ($fields as $field_id => $value) {
571 if (in_array($field_id, $odf_ids)) {
572 $usr_data[$usr_id]['odf_' . $field_id] = $value;
573 }
574 }
575 }
576 }
577
578 foreach ($data as $key => $v) {
579 if (isset($usr_data[$v["user_id"]])) {
580 $data[$key] = array_merge($v, $usr_data[$v["user_id"]]);
581 }
582 }
583 }
584 }
585
586 foreach ($data as $k => $d) {
587 if ($d["context_obj_id"] > 0) {
588 $this->has_items_with_host_context = true;
589 $data[$k]["context_obj_title"] = ilObject::_lookupTitle($d["context_obj_id"]);
590 }
591 }
592
593 $this->setData($data);
594 }
595
596 public function getAdvMDRecordGUI()
597 {
598 return $this->record_gui;
599 }
600
601 public function getOrderField()
602 {
603 $field = parent::getOrderField();
604
605 // #16560 - this will enable matchting slot sorting to date/week
606 if (in_array($field, array("date", "week"))) {
607 $field = "_sortdate";
608 }
609
610 return $field;
611 }
612
617 protected function fillRow($a_set)
618 {
620 $ilAccess = $this->access;
621 $ilCtrl = $this->ctrl;
623
624 $selected = $this->getSelectedColumns();
625
626
627
628 if ($this->has_items_with_host_context) {
629 $this->tpl->setCurrentBlock("context");
630 $this->tpl->setVariable("VALUE_CONTEXT_TITLE", $a_set["context_obj_title"] . " ");
631 $this->tpl->parseCurrentBlock();
632 }
633
634 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
635
636 $can_be_cancelled = (($ilAccess->checkAccess('write', '', $this->ref_id) ||
637 $a_set['user_id'] == $ilUser->getId()) &&
638 $a_set["can_be_cancelled"]);
639
640 if ($can_be_cancelled) {
641 $this->tpl->setVariable("MULTI_ID", $a_set["booking_reservation_id"]);
642 }
643
644 // #11995
645 $uname = $a_set["user_name"];
646 if (!trim($uname)) {
647 $uname = "[" . $lng->txt("user_deleted") . "]";
648 } else {
649 $uname = ilUserUtil::getNamePresentation($a_set['user_id'], false, true, "", true);
650 }
651 $this->tpl->setVariable("TXT_CURRENT_USER", $uname);
652
653 if ($this->has_schedule) {
654 $this->tpl->setVariable("VALUE_DATE", ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
655 if (in_array("week", $selected)) {
656 $this->tpl->setVariable("VALUE_WEEK", $a_set["week"]);
657 }
658 if (in_array("weekday", $selected)) {
659 $this->tpl->setVariable("VALUE_WEEKDAY", ilCalendarUtil::_numericDayToString($a_set["weekday"], false));
660 }
661 $this->tpl->setVariable("VALUE_SLOT", $a_set["slot"]);
662 $this->tpl->setVariable("VALUE_COUNTER", $a_set["counter"]);
663 } else {
664 if (in_array($a_set['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE))) {
665 $this->tpl->setVariable("TXT_STATUS", $lng->txt('book_reservation_status_' . $a_set['status']));
666 } else {
667 $this->tpl->setVariable("TXT_STATUS", "&nbsp;");
668 }
669 }
670
671 if ($this->advmd) {
672 foreach ($this->advmd as $item) {
673 $advmd_id = (int) $item["id"];
674
675 if (!in_array("advmd" . $advmd_id, $selected)) {
676 continue;
677 }
678
679 $val = " ";
680 if (isset($a_set["md_" . $advmd_id . "_presentation"])) {
681 $pb = $a_set["md_" . $advmd_id . "_presentation"]->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 if ($can_be_cancelled) {
704 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
705 $this->tpl->setVariable("URL_ACTION", $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmCancel'));
706 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
707 $this->tpl->setVariable("TXT_ACTION", $lng->txt('book_set_cancel'));
708 $this->tpl->setCurrentBlock("action");
709 $this->tpl->parseCurrentBlock();
710 }
711
712
713 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
714 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', $a_set['booking_reservation_id']);
715 $this->tpl->setVariable("URL_ACTION", $ilCtrl->getLinkTarget($this->parent_obj, 'rsvConfirmDelete'));
716 $ilCtrl->setParameter($this->parent_obj, 'reservation_id', "");
717 $this->tpl->setVariable("TXT_ACTION", $lng->txt('delete'));
718 $this->tpl->setCurrentBlock("action");
719 $this->tpl->parseCurrentBlock();
720 }
721 }
722
726 protected function getAdditionalExportCols()
727 {
728 $add_cols = [];
729 $cols = $this->getSelectableColumns();
730
731 unset($cols["week"]);
732 unset($cols["weekday"]);
733
734 // non-user columns
735 $user_cols = $this->getSelectableUserColumns();
736 foreach ($this->getSelectedColumns() as $col) {
737 if (array_key_exists($col, $cols)) {
738 if (!isset($user_cols[$col])) {
739 $add_cols[$col] = $cols[$col]["txt"];
740 }
741 }
742 }
743
744 $add_cols["user_name"] = $this->lng->txt("user");
745 $add_cols["login"] = $this->lng->txt("login");
746
747 // user columns
748 foreach ($this->getSelectedColumns() as $col) {
749 if (array_key_exists($col, $cols)) {
750 if (isset($user_cols[$col])) {
751 $add_cols[$col] = $cols[$col]["txt"];
752 }
753 }
754 }
755
756 return $add_cols;
757 }
758
759 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
760 {
761 $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
762 $col = 0;
763 if ($this->has_schedule) {
764 $a_excel->setCell($a_row, ++$col, $this->lng->txt("date"));
765 $a_excel->setCell($a_row, ++$col, $this->lng->txt("wk_short"));
766 $a_excel->setCell($a_row, ++$col, $this->lng->txt("cal_weekday"));
767 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_schedule_slot"));
768 $a_excel->setCell($a_row, ++$col, $this->lng->txt("book_no_of_objects"));
769 } else {
770 $a_excel->setCell($a_row, ++$col, $this->lng->txt("status"));
771 }
772
773 foreach ($this->getAdditionalExportCols() as $txt) {
774 $a_excel->setCell($a_row, ++$col, $txt);
775 }
776
777 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col) . $a_row);
778 }
779
780 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
781 {
782 $a_excel->setCell($a_row, 0, $a_set["title"]);
783 $col = 0;
784 if ($this->has_schedule) {
785 $a_excel->setCell($a_row, ++$col, new ilDate($a_set["date"], IL_CAL_DATE));
786 $a_excel->setCell($a_row, ++$col, $a_set["week"]);
787 $a_excel->setCell($a_row, ++$col, ilCalendarUtil::_numericDayToString($a_set["weekday"], false));
788 $a_excel->setCell($a_row, ++$col, $a_set["slot"]);
789 $a_excel->setCell($a_row, ++$col, $a_set["counter"]);
790 } else {
791 $status = "";
792 if (in_array($a_set['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE))) {
793 $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
794 }
795 $a_excel->setCell($a_row, ++$col, $status);
796 }
797
798 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
799 if (substr($colid, 0, 5) == "advmd") {
800 $advmd_id = (int) substr($colid, 5);
801 $val = " ";
802 if (isset($a_set["md_" . $advmd_id . "_presentation"])) {
803 $pb = $a_set["md_" . $advmd_id . "_presentation"]->getList();
804 if ($pb) {
805 $val = $pb;
806 }
807 }
808 $a_excel->setCell($a_row, ++$col, $val);
809 } else {
810 $a_excel->setCell($a_row, ++$col, $a_set[$colid]);
811 }
812 }
813 }
814
815 protected function fillHeaderCSV($a_csv)
816 {
817 $a_csv->addColumn($this->lng->txt("title"));
818 if ($this->has_schedule) {
819 $a_csv->addColumn($this->lng->txt("date"));
820 $a_csv->addColumn($this->lng->txt("wk_short"));
821 $a_csv->addColumn($this->lng->txt("cal_weekday"));
822 $a_csv->addColumn($this->lng->txt("book_schedule_slot"));
823 $a_csv->addColumn($this->lng->txt("book_no_of_objects"));
824 } else {
825 $a_csv->addColumn($this->lng->txt("status"));
826 }
827
828 foreach ($this->getAdditionalExportCols() as $txt) {
829 $a_csv->addColumn($txt);
830 }
831
832 $a_csv->addRow();
833 }
834
835 protected function fillRowCSV($a_csv, $a_set)
836 {
837 $a_csv->addColumn($a_set["title"]);
838 if ($this->has_schedule) {
839 $a_csv->addColumn(ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
840 $a_csv->addColumn($a_set["week"]);
841 $a_csv->addColumn(ilCalendarUtil::_numericDayToString($a_set["weekday"], false));
842 $a_csv->addColumn($a_set["slot"]);
843 $a_csv->addColumn($a_set["counter"]);
844 } else {
845 $status = "";
846 if (in_array($a_set['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE))) {
847 $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
848 }
849 $a_csv->addColumn($status);
850 }
851
852 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
853 if (substr($colid, 0, 5) == "advmd") {
854 $advmd_id = (int) substr($colid, 5);
855 $val = " ";
856 if (isset($a_set["md_" . $advmd_id . "_presentation"])) {
857 $pb = $a_set["md_" . $advmd_id . "_presentation"]->getList();
858 if ($pb) {
859 $val = $pb;
860 }
861 }
862 $a_csv->addColumn($val);
863 } else {
864 $a_csv->addColumn($a_set[$colid]);
865 }
866 }
867
868 $a_csv->addRow();
869 }
870}
user()
Definition: user.php:4
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
static queryForRecords($adv_rec_obj_ref_id, $adv_rec_obj_type, $adv_rec_obj_subtype, $a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, array $a_amet_filter=null)
Query data for given object records.
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
static getUserFilter(array $a_object_ids)
Get all users who have reservations for object(s)
initFilter(array $a_filter_pre=null)
Init filter.
__construct( $a_parent_obj, $a_parent_cmd, $a_ref_id, $a_pool_id, $a_show_all, $a_has_schedule, array $a_filter_pre=null, $a_group_id=null, array $context_obj_ids=null)
Constructor.
getSelectableColumns($a_only_advmd=false, $a_include_user=true)
fillHeaderExcel(ilExcel $a_excel, &$a_row)
Excel Version of Fill Header.
numericOrdering($a_field)
Should this field be sorted numeric?
getAdditionalExportCols()
Get additional export columns.
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
Excel Version of Fill Row.
getItems(array $filter)
Gather data and build rows.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
fillHeaderCSV($a_csv)
CSV Version of Fill Header.
getSelectableUserColumns()
Get selectable user fields.
schedule for booking ressource
static getList($a_pool_id)
Get list of booking objects for given pool.
static _numericDayToString($a_day, $a_long=true)
get
This class represents a checkbox property in a property form.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
@classDescription Date and time handling
Class for single dates.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
setBold($a_coords)
Set cell(s) to bold.
getColumnCoord($a_col)
Get column "name" from number.
static _getInstanceByType($a_type)
Get Singleton Instance.
static lookupAcceptedAgreements($a_obj_id)
Lookup users who have accepted the agreement.
Class ilObjBookingPool.
static getAdvancedMDFields($a_ref_id)
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Get instance of ilPrivacySettings.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setExportFormats(array $formats)
Set available export formats.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
initFilter()
Init filter.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
getId()
Get element id.
setData($a_data)
set table data @access public
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
getSelectableColumns()
Get selectable columns.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
disable($a_module_name)
diesables particular modules of table
User query class.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
$c
Definition: cli.php:37
const ANONYMOUS_USER_ID
Definition: constants.php:25
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$txt
Definition: error.php:13
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
$cols
Definition: xhr_table.php:11