36 protected \ILIAS\BookingManager\Access\AccessManager
$access;
59 ?array $a_filter_pre =
null,
60 ?
int $a_group_id =
null,
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();
77 $ilUser =
$DIC->user();
78 $this->tree =
$DIC->repositoryTree();
79 $this->reservation_repo =
$DIC->bookingManager()
83 $this->schedule_manager =
$DIC
87 ->schedules($a_pool_id);
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;
96 $this->table_repo =
$DIC->bookingManager()
103 $this->
setId(
"bkrsv" . $a_ref_id);
112 $this->
lng->loadLanguageModule(
"crs");
117 if ($this->has_schedule) {
118 $this->
lng->loadLanguageModule(
"dateplaner");
121 if (in_array(
"week", $selected,
true)) {
123 unset($cols[
"week"]);
125 if (in_array(
"weekday", $selected,
true)) {
126 $this->
addColumn($this->
lng->txt(
"cal_weekday"),
"weekday");
127 unset($cols[
"weekday"]);
129 $this->
addColumn($this->
lng->txt(
"book_schedule_slot"),
"slot");
130 $this->
addColumn($this->
lng->txt(
"book_no_of_objects"),
"counter");
147 if (array_key_exists($col, $cols)) {
148 if (!isset($user_cols[$col])) {
149 $this->
addColumn($cols[$col][
"txt"], $col);
155 if ($this->group_id) {
158 $this->filters = array();
164 if ($this->has_items_with_host_context) {
165 $this->
addColumn($this->
lng->txt(
"book_booked_in"),
"context_obj_title");
172 if (isset($cols[$col][
"txt"], $user_cols[$col])) {
173 $this->
addColumn($cols[$col][
"txt"], $col);
180 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
181 $this->
setRowTemplate(
"tpl.booking_reservation_row.html",
"components/ILIAS/BookingManager/Reservations");
187 if ($this->
access->canManageAllReservations($this->ref_id) ||
188 $this->access->canManageOwnReservations($this->ref_id)) {
191 if ($this->
access->canManageAllReservations($this->ref_id)) {
200 return $this->pool->usesMessages() && $this->
access->canManageAllReservations($this->ref_id);
207 if ($this->has_schedule) {
208 $this->
lng->loadLanguageModule(
'dateplaner');
210 $cols[
'week'] = [
'txt' => $this->
lng->txt(
'wk_short'),
'default' =>
true];
211 $cols[
'weekday'] = [
'txt' => $this->
lng->txt(
'cal_weekday'),
'default' =>
true];
214 foreach ($this->advmd as $field) {
215 $cols[
"advmd{$field['id']}"] = [
'txt' => $field[
'title'],
'default' =>
false];
228 if ($this->
access->canManageMembersOfParent($this->ref_id)) {
229 $parent = $this->
access->getParentGroupCourse($this->ref_id);
232 if ($k !==
"login") {
245 if (isset($user_cols[$col])) {
253 ?array $a_filter_pre =
null
255 if (is_array($a_filter_pre) &&
256 isset($a_filter_pre[
"object"])) {
257 $this->table_repo->setObjectFilter(
259 serialize($a_filter_pre[
"object"])
263 $this->objects = array();
265 $this->objects[$item[
"booking_object_id"]] = $item[
"title"];
268 if ($item !==
null) {
269 $item->setOptions(array(
"" => $this->
lng->txt(
'book_all')) + $this->objects);
270 $this->
filter[
"object"] = $item->getValue();
275 $this->
lng->txt(
"object") .
" " . $this->lng->txt(
"title") .
"/" . $this->lng->txt(
"description")
281 if ($this->has_schedule) {
283 if (!$this->table_repo->hasFromToFilter($this->getId())) {
289 $period = $bpool->getReservationFilterPeriod();
290 if ($period !==
null) {
295 $to = serialize($to);
298 $this->table_repo->setFromToFilter(
301 "from" => serialize($from),
310 $this->
lng->txt(
'book_fromto')
312 $this->
filter[
"fromto"] = $item->getDate();
315 if ($this->show_all) {
317 $map = array_flip(array(
'su',
'mo',
'tu',
'we',
'th',
'fr',
'sa'));
319 $options = array(
"" => $this->
lng->txt(
'book_all'));
322 foreach ($this->schedule_manager->getScheduleList() as
$id =>
$title) {
324 foreach ($schedule->getDefinition() as $day => $slots) {
327 foreach ($slots as $slot) {
329 ? $this->
lng->txt(
'book_all_day')
332 $options[
"{$map[$day]}_{$slot}"] =
"{$day_caption}, {$slot}";
341 $this->
filter[
"slot"] = $item->getValue();
347 $item->readFromSession();
351 if (isset($this->
filter[
"fromto"][
"from"]) &&
353 $item->setChecked(
true);
356 $this->
filter[
"past"] = $item->getChecked();
362 if (!$this->has_schedule) {
363 $options = array(
"" => $this->
lng->txt(
'book_all'));
367 foreach ($valid_status as $loop) {
369 $options[$loop] = $this->
lng->txt(
'book_reservation_status_' . $loop);
371 $options[$loop] = $this->
lng->txt(
'book_not') .
' ' . $this->
lng->txt(
'book_reservation_status_' . -$loop);
376 $this->
filter[
"status"] = $item->getValue();
379 if ($this->show_all) {
380 $options = array(
"" => $this->
lng->txt(
'book_all')) +
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"];
388 $this->
filter[
"user_id"] = $item->getValue();
400 if ($this->
filter[
"object"]) {
401 $filter[
"object"] = $this->
filter[
"object"];
403 if ($this->
filter[
"title"]) {
404 $filter[
"title"] = $this->
filter[
"title"];
406 if ($this->
filter[
"status"]) {
407 $filter[
"status"] = $this->
filter[
"status"];
409 if (isset($this->
filter[
"user_id"])) {
410 $filter[
"user_id"] = $this->
filter[
"user_id"];
412 if (!is_null($this->context_obj_ids)) {
413 $filter[
"context_obj_ids"] = $this->context_obj_ids;
416 if ($this->has_schedule) {
417 if (!isset($filter[
"status"])) {
421 if (isset($this->
filter[
"slot"])) {
422 $filter[
"slot"] = $this->
filter[
"slot"];
425 if ($this->
filter[
"fromto"][
"from"] || $this->
filter[
"fromto"][
"to"]) {
426 if ($this->
filter[
"fromto"][
"from"]) {
429 if ($this->
filter[
"fromto"][
"to"]) {
438 $filter[
"past"] = (bool) $this->
filter[
"past"];
445 return in_array($a_field, array(
"counter",
"date",
"week",
"weekday"));
453 $ilUser = $this->user;
455 $this->has_items_with_host_context =
false;
457 if (!isset($filter[
"object"])) {
458 $ids = array_keys($this->objects);
460 $ids = array($filter[
"object"]);
463 if (!$this->show_all) {
464 $filter[
"user_id"] = $ilUser->getId();
467 $repo = $this->reservation_repo;
468 $data = $repo->getListByDate($this->has_schedule, $ids, $filter);
478 $this->record_gui->setTableGUI($this);
479 $this->record_gui->parse();
481 foreach (array_keys(
$data) as $idx) {
482 $data[$idx][
"pool_id"] = $this->pool_id;
494 $this->record_gui->getFilterElements()
498 if (count($this->getSelectedUserColumns()) > 0) {
500 $user_ids = array_unique(array_map(
static function (
$d) {
501 return $d[
'user_id'];
506 foreach ($this->getSelectedUserColumns() as $field) {
507 if (str_starts_with($field,
'odf')) {
508 $odf_ids[] = (
int) substr($field, 4);
512 $user_columns[] = $field;
516 $user_columns = array_diff(
518 [
'consultation_hour',
'prtf',
'roles',
'org_units']
523 $query->setLimit(9999);
524 $query->setAdditionalFields($user_columns);
525 $query->setUserFilter($user_ids);
526 $ud = $query->query();
528 foreach ($ud[
"set"] as $v) {
529 foreach ($user_columns as
$c) {
530 $usr_data[$v[
"usr_id"]][
$c] = $v[
$c];
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"]]);
540 if ($odf_ids !== []) {
541 $parent = $this->
access->getParentGroupCourse($this->ref_id);
546 $confirmation_required = $parent_obj_type ===
'crs'
547 ? $privacy_settings->courseConfirmationRequired()
548 : $privacy_settings->groupConfirmationRequired();
549 if ($confirmation_required) {
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;
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']]);
573 if (
$d[
"context_obj_id"] > 0) {
574 $this->has_items_with_host_context =
true;
579 $this->setData(
$data);
584 return $this->record_gui;
589 $field = parent::getOrderField();
592 if (in_array($field, array(
"date",
"week"))) {
593 $field =
"_sortdate";
599 protected function fillRow(array $a_set): void
602 $ilAccess = $this->access;
603 $ilCtrl = $this->ctrl;
604 $ilUser = $this->user;
605 $f = $this->gui->ui()->factory();
607 $selected = $this->getSelectedColumns();
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();
617 $this->tpl->setVariable(
"TXT_TITLE", $a_set[
"title"]);
619 $can_be_cancelled = ($this->
access->canManageReservationForUser($this->ref_id, $a_set[
'user_id']) &&
620 $a_set[
"can_be_cancelled"]);
622 if ($can_be_cancelled) {
623 $this->tpl->setVariable(
"MULTI_ID", $a_set[
"booking_reservation_id"]);
627 $profile = $this->domain->profile();
630 $uname = $profile->getDeletedUserNamePresentation();
634 $this->tpl->setVariable(
"TXT_CURRENT_USER", $uname);
635 if ($this->has_schedule) {
636 $this->tpl->setVariable(
640 if (in_array(
"week", $selected,
true)) {
641 $this->tpl->setVariable(
"VALUE_WEEK", $a_set[
"week"]);
643 if (in_array(
"weekday", $selected,
true)) {
644 $this->tpl->setVariable(
649 $this->tpl->setVariable(
652 ? $this->
lng->txt(
'book_all_day')
655 $this->tpl->setVariable(
"VALUE_COUNTER", $a_set[
"counter"]);
660 $this->tpl->setVariable(
"TXT_STATUS",
$lng->txt(
'book_reservation_status_' . $a_set[
'status']));
662 $this->tpl->setVariable(
"TXT_STATUS",
" ");
664 if ($this->showMessages()) {
665 $this->tpl->setCurrentBlock(
"message");
667 $this->tpl->parseCurrentBlock();
671 foreach ($this->advmd as $item) {
672 $advmd_id = (
int) $item[
"id"];
674 if (!in_array(
"advmd" . $advmd_id, $selected,
true)) {
679 $key =
"md_" . $advmd_id .
"_presentation";
680 if (isset($a_set[$key])) {
681 $pb = $a_set[$key]->getList();
687 $this->tpl->setCurrentBlock(
"advmd_bl");
688 $this->tpl->setVariable(
"VALUE_ADVMD", $val);
689 $this->tpl->parseCurrentBlock();
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();
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')
712 $ilCtrl->setParameter($this->parent_obj,
'object_id',
null);
713 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
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')
723 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
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(
730 $ilCtrl->getLinkTarget($this->parent_obj,
'rsvConfirmDelete')
732 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
736 if ($this->showMessages() && $a_set[
"message"] !==
"") {
737 $c = $this->gui->modal(
738 $this->
lng->txt(
"book_message"),
739 $this->lng->txt(
"close")
741 ->legacy(nl2br($a_set[
"message"]))
742 ->getTriggerButtonComponents(
743 $this->
lng->txt(
"book_show_message"),
746 $dd_items[] =
$c[
"button"];
747 $render_items[] =
$c[
"modal"];
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));
759 $cols = $this->getSelectableColumns();
761 unset($cols[
"week"], $cols[
"weekday"]);
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"];
773 $add_cols[
"user_name"] = $this->
lng->txt(
"user");
774 $add_cols[
"login"] = $this->
lng->txt(
"login");
777 foreach ($this->getSelectedColumns() as $col) {
778 if (isset($cols[$col][
"txt"], $user_cols[$col])) {
779 $add_cols[$col] = $cols[$col][
"txt"];
790 $a_excel->setCell($a_row, 0, $this->
lng->txt(
"title"));
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"));
799 $a_excel->
setCell($a_row, ++$col, $this->
lng->txt(
"status"));
801 if ($this->showMessages()) {
802 $a_excel->
setCell($a_row, ++$col, $this->
lng->txt(
"book_message"));
805 foreach ($this->getAdditionalExportCols() as $txt) {
806 $a_excel->
setCell($a_row, ++$col, $txt);
817 $a_excel->setCell($a_row, 0, $a_set[
"title"]);
819 if ($this->has_schedule) {
821 $a_excel->
setCell($a_row, ++$col, $a_set[
"week"]);
823 $a_excel->
setCell($a_row, ++$col, $a_set[
"slot"]);
824 $a_excel->
setCell($a_row, ++$col, $a_set[
"counter"]);
831 $status = $this->
lng->txt(
'book_reservation_status_' . $a_set[
'status']);
833 $a_excel->
setCell($a_row, ++$col, $status);
835 if ($this->showMessages()) {
836 $a_excel->
setCell($a_row, ++$col, $a_set[
"message"]);
839 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
840 if (str_starts_with($colid,
"advmd")) {
842 $key =
"md_" . (
int) substr($colid, 5) .
"_presentation";
843 if (isset($a_set[$key])) {
844 $pb = $a_set[$key]->getList();
849 $a_excel->
setCell($a_row, ++$col, $val);
851 $a_excel->
setCell($a_row, ++$col, $a_set[$colid] ??
"");
859 $a_csv->addColumn($this->
lng->txt(
"title"));
860 if ($this->has_schedule) {
864 $a_csv->
addColumn($this->
lng->txt(
"book_schedule_slot"));
865 $a_csv->
addColumn($this->
lng->txt(
"book_no_of_objects"));
869 if ($this->showMessages()) {
873 foreach ($this->getAdditionalExportCols() as $txt) {
884 $a_csv->addColumn($a_set[
"title"]);
885 if ($this->has_schedule) {
897 $status = $this->
lng->txt(
'book_reservation_status_' . $a_set[
'status']);
901 if ($this->showMessages()) {
905 foreach ($this->getAdditionalExportCols() as $colid => $txt) {
906 if (str_starts_with($colid,
"advmd")) {
908 $key =
"md_" . (
int) substr($colid, 5) .
"_presentation";
909 if (isset($a_set[$key])) {
910 $pb = $a_set[$key]->getList();
Author: Alexander Killing killing@leifos.de
Reservation table related session data.
Repo class for reservations Acts on tables booking_reservation (rw), booking_reservation_group (rw) a...
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.
const int STATUS_CANCELLED
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
InternalDomainService $domain
ilAdvancedMDRecordGUI $record_gui
ReservationTableSessionRepository $table_repo
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
initFilter(?array $a_filter_pre=null)
ReservationDBRepository $reservation_repo
getCurrentFilter()
Get current filter settings.
getAdditionalExportCols()
ScheduleManager $schedule_manager
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?
bool $has_items_with_host_context
getSelectableColumns()
Get selectable columns.
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...
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
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
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)
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.
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
disable(string $a_module_name)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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:
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
if(!file_exists('../ilias.ini.php'))