67 array $a_filter_pre = null,
73 $this->ctrl = $DIC->ctrl();
74 $this->lng = $DIC->language();
75 $this->
user = $DIC->user();
76 $this->access = $DIC->access();
78 $lng = $DIC->language();
80 $ilAccess = $DIC->access();
81 $this->tree = $DIC->repositoryTree();
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;
92 $this->
setId(
"bkrsv" . $a_ref_id);
99 $this->
addColumn($this->lng->txt(
"title"),
"title");
104 if ($this->has_schedule) {
105 $this->lng->loadLanguageModule(
"dateplaner");
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"]);
112 if (in_array(
"weekday", $selected)) {
113 $this->
addColumn($this->lng->txt(
"cal_weekday"),
"weekday");
114 unset(
$cols[
"weekday"]);
116 $this->
addColumn($this->lng->txt(
"book_schedule_slot"),
"slot");
117 $this->
addColumn($this->lng->txt(
"book_no_of_objects"),
"counter");
122 $this->
addColumn($this->lng->txt(
"status"),
"status");
131 if (array_key_exists($col,
$cols)) {
132 if (!isset($user_cols[$col])) {
141 if ($this->group_id) {
144 $this->filters = array();
150 if ($this->has_items_with_host_context) {
151 $this->
addColumn($this->lng->txt(
"book_booked_in"),
"context_obj_title");
154 $this->
addColumn($this->lng->txt(
"user"),
"user_name");
158 if (array_key_exists($col,
$cols)) {
159 if (isset($user_cols[$col])) {
165 $this->
addColumn($this->lng->txt(
"actions"));
169 $this->
setRowTemplate(
"tpl.booking_reservation_row.html",
"Modules/BookingManager/Reservations");
175 if (
$ilUser->getId() != ANONYMOUS_USER_ID) {
188 if ($this->has_schedule &&
189 !(
bool) $a_only_advmd) {
190 $this->lng->loadLanguageModule(
"dateplaner");
192 $cols[
"week"] = array(
193 "txt" => $this->lng->txt(
"wk_short"),
197 $cols[
"weekday"] = array(
198 "txt" => $this->lng->txt(
"cal_weekday"),
203 foreach ($this->advmd as $field) {
204 $cols[
"advmd" . $field[
"id"]] = array(
205 "txt" => $field[
"title"],
210 if ($a_include_user) {
228 if ($this->access->checkAccess(
"manage_members",
"", $parent[
"ref_id"])) {
231 if (!in_array($k, [
"login"])) {
251 if (isset($user_cols[$col])) {
268 if (($par_ref_id =
$tree->checkForParentType($this->ref_id,
"grp")) > 0) {
270 "ref_id" => $par_ref_id,
274 if (($par_ref_id =
$tree->checkForParentType($this->ref_id,
"crs")) > 0) {
276 "ref_id" => $par_ref_id,
290 if (is_array($a_filter_pre) &&
291 isset($a_filter_pre[
"object"])) {
292 $_SESSION[
"form_" . $this->
getId()][
"object"] = serialize($a_filter_pre[
"object"]);
295 $this->objects = array();
297 $this->objects[$item[
"booking_object_id"]] = $item[
"title"];
300 $item->setOptions(array(
"" => $this->lng->txt(
'book_all')) + $this->objects);
301 $this->filter[
"object"] = $item->getValue();
307 $this->lng->txt(
"object") .
" " . $this->lng->txt(
"title") .
"/" . $this->lng->txt(
"description")
309 $this->filter[
"title"] =
$title->getValue();
311 if ($this->has_schedule) {
319 $period = $bpool->getReservationFilterPeriod();
320 if ($period !== null) {
325 $to = serialize($to);
329 "from" => serialize($from),
334 $this->filter[
"fromto"] = $item->getDate();
337 if ($this->show_all) {
339 $map = array_flip(array(
'su',
'mo',
'tu',
'we',
'th',
'fr',
'sa'));
341 $options = array(
"" => $this->lng->txt(
'book_all'));
346 foreach ($schedule->getDefinition() as $day => $slots) {
349 foreach ($slots as $slot) {
350 $idx = $map[$day] .
"_" . $slot;
351 $options[$idx] = $day_caption .
", " . $slot;
359 $item->setOptions($options);
360 $this->filter[
"slot"] = $item->getValue();
364 $item =
new ilCheckboxInputGUI($this->lng->txt(
"book_filter_past_reservations"),
"past");
366 $item->readFromSession();
370 if (is_object($this->filter[
"fromto"][
"from"]) &&
371 $this->filter[
"fromto"][
"from"]->
get(
IL_CAL_DATE) < date(
"Y-m-d")) {
372 $item->setChecked(
true);
375 $this->filter[
"past"] = $item->getChecked();
380 if (!$this->has_schedule) {
381 $options = array(
"" => $this->lng->txt(
'book_all'));
385 foreach ($valid_status as $loop) {
387 $options[$loop] = $this->lng->txt(
'book_reservation_status_' . $loop);
389 $options[$loop] = $this->lng->txt(
'book_not') .
' ' . $this->lng->txt(
'book_reservation_status_' . -$loop);
393 $item->setOptions($options);
394 $this->filter[
"status"] = $item->getValue();
397 if ($this->show_all) {
398 $options = array(
"" => $this->lng->txt(
'book_all')) +
401 $item->setOptions($options);
402 if (is_array($a_filter_pre) && isset($a_filter_pre[
"user_id"])) {
403 $item->setValue($a_filter_pre[
"user_id"]);
404 $this->filter[
"user_id"] = $a_filter_pre[
"user_id"];
406 $this->filter[
"user_id"] = $item->getValue();
418 if ($this->filter[
"object"]) {
419 $filter[
"object"] = $this->filter[
"object"];
421 if ($this->filter[
"title"]) {
422 $filter[
"title"] = $this->filter[
"title"];
424 if ($this->filter[
"status"]) {
425 $filter[
"status"] = $this->filter[
"status"];
427 if ($this->filter[
"user_id"]) {
428 $filter[
"user_id"] = $this->filter[
"user_id"];
430 if (is_array($this->context_obj_ids)) {
434 if ($this->has_schedule) {
439 if ($this->filter[
"slot"]) {
440 $filter[
"slot"] = $this->filter[
"slot"];
443 if ($this->filter[
"fromto"][
"from"] || $this->filter[
"fromto"][
"to"]) {
444 if ($this->filter[
"fromto"][
"from"]) {
447 if ($this->filter[
"fromto"][
"to"]) {
453 $filter[
"past"] = (bool) $this->filter[
"past"];
461 return in_array($a_field, array(
"counter",
"date",
"week",
"weekday"));
472 $this->has_items_with_host_context =
false;
474 if (!$filter[
"object"]) {
475 $ids = array_keys($this->objects);
477 $ids = array($filter[
"object"]);
480 if (!$this->show_all) {
481 $filter[
"user_id"] =
$ilUser->getId();
485 $repo =
$f->getRepo();
486 $data = $repo->getListByDate($this->has_schedule, $ids, $filter);
491 $this->record_gui->setTableGUI($this);
492 $this->record_gui->parse();
494 foreach (array_keys(
$data) as $idx) {
507 $this->record_gui->getFilterElements()
513 $user_ids = array_unique(array_map(
function (
$d) {
514 return $d[
'user_id'];
520 if (substr($field, 0, 3) ==
'odf') {
521 $odf_ids[] = substr($field, 4);
523 $user_columns[] = $field;
528 $user_columns = array_diff($user_columns,
529 [
'consultation_hour',
'prtf',
'roles',
'org_units']);
534 $query->setAdditionalFields($user_columns);
535 $query->setUserFilter($user_ids);
538 foreach ($ud[
"set"] as $v) {
539 foreach ($user_columns as
$c) {
540 $usr_data[$v[
"usr_id"]][
$c] = $v[
$c];
543 foreach (
$data as $key => $v) {
544 if (isset($usr_data[$v[
"user_id"]])) {
545 $data[$key] = array_merge($v, $usr_data[$v[
"user_id"]]);
555 $confirmation_required = ($parent_obj_type ==
'crs')
558 if ($confirmation_required) {
564 foreach ($odf_data as $usr_id => $fields) {
565 if (in_array($usr_id, $user_ids)) {
566 foreach ($fields as $field_id => $value) {
567 if (in_array($field_id, $odf_ids)) {
568 $usr_data[$usr_id][
'odf_' . $field_id] = $value;
574 foreach (
$data as $key => $v) {
575 if (isset($usr_data[$v[
"user_id"]])) {
576 $data[$key] = array_merge($v, $usr_data[$v[
"user_id"]]);
583 if (
$d[
"context_obj_id"] > 0) {
584 $this->has_items_with_host_context =
true;
594 return $this->record_gui;
599 $field = parent::getOrderField();
602 if (in_array($field, array(
"date",
"week"))) {
603 $field =
"_sortdate";
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();
630 $this->tpl->setVariable(
"TXT_TITLE", $a_set[
"title"]);
632 $can_be_cancelled = (($ilAccess->checkAccess(
'write',
'', $this->ref_id) ||
633 $a_set[
'user_id'] ==
$ilUser->getId()) &&
634 $a_set[
"can_be_cancelled"]);
636 if ($can_be_cancelled) {
637 $this->tpl->setVariable(
"MULTI_ID", $a_set[
"booking_reservation_id"]);
641 $uname = $a_set[
"user_name"];
643 $uname =
"[" .
$lng->txt(
"user_deleted") .
"]";
647 $this->tpl->setVariable(
"TXT_CURRENT_USER", $uname);
649 if ($this->has_schedule) {
651 if (in_array(
"week", $selected)) {
652 $this->tpl->setVariable(
"VALUE_WEEK", $a_set[
"week"]);
654 if (in_array(
"weekday", $selected)) {
657 $this->tpl->setVariable(
"VALUE_SLOT", $a_set[
"slot"]);
658 $this->tpl->setVariable(
"VALUE_COUNTER", $a_set[
"counter"]);
661 $this->tpl->setVariable(
"TXT_STATUS",
$lng->txt(
'book_reservation_status_' . $a_set[
'status']));
663 $this->tpl->setVariable(
"TXT_STATUS",
" ");
668 foreach ($this->advmd as $item) {
669 $advmd_id = (int) $item[
"id"];
671 if (!in_array(
"advmd" . $advmd_id, $selected)) {
676 if (isset($a_set[
"md_" . $advmd_id .
"_presentation"])) {
677 $pb = $a_set[
"md_" . $advmd_id .
"_presentation"]->getList();
683 $this->tpl->setCurrentBlock(
"advmd_bl");
684 $this->tpl->setVariable(
"VALUE_ADVMD", $val);
685 $this->tpl->parseCurrentBlock();
692 if (isset($user_cols[$col])) {
693 $this->tpl->setCurrentBlock(
"user_col");
694 $this->tpl->setVariable(
"VALUE_USER_COL", $a_set[$col] .
" ");
695 $this->tpl->parseCurrentBlock();
699 if ($can_be_cancelled) {
700 $ilCtrl->setParameter($this->parent_obj,
'reservation_id', $a_set[
'booking_reservation_id']);
701 $this->tpl->setVariable(
"URL_ACTION",
$ilCtrl->getLinkTarget($this->parent_obj,
'rsvConfirmCancel'));
702 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
703 $this->tpl->setVariable(
"TXT_ACTION",
$lng->txt(
'book_set_cancel'));
704 $this->tpl->setCurrentBlock(
"action");
705 $this->tpl->parseCurrentBlock();
709 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id)) {
710 $ilCtrl->setParameter($this->parent_obj,
'reservation_id', $a_set[
'booking_reservation_id']);
711 $this->tpl->setVariable(
"URL_ACTION",
$ilCtrl->getLinkTarget($this->parent_obj,
'rsvConfirmDelete'));
712 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
713 $this->tpl->setVariable(
"TXT_ACTION",
$lng->txt(
'delete'));
714 $this->tpl->setCurrentBlock(
"action");
715 $this->tpl->parseCurrentBlock();
727 unset(
$cols[
"week"]);
728 unset(
$cols[
"weekday"]);
733 if (array_key_exists($col,
$cols)) {
734 if (!isset($user_cols[$col])) {
735 $add_cols[$col] =
$cols[$col][
"txt"];
740 $add_cols[
"user_name"] = $this->lng->txt(
"user");
744 if (array_key_exists($col,
$cols)) {
745 if (isset($user_cols[$col])) {
746 $add_cols[$col] =
$cols[$col][
"txt"];
756 $a_excel->
setCell($a_row, 0, $this->lng->txt(
"title"));
758 if ($this->has_schedule) {
759 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"date"));
760 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"wk_short"));
761 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"cal_weekday"));
762 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"book_schedule_slot"));
763 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"book_no_of_objects"));
765 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"status"));
777 $a_excel->
setCell($a_row, 0, $a_set[
"title"]);
779 if ($this->has_schedule) {
781 $a_excel->
setCell($a_row, ++$col, $a_set[
"week"]);
783 $a_excel->
setCell($a_row, ++$col, $a_set[
"slot"]);
784 $a_excel->
setCell($a_row, ++$col, $a_set[
"counter"]);
788 $status = $this->lng->txt(
'book_reservation_status_' . $a_set[
'status']);
790 $a_excel->
setCell($a_row, ++$col, $status);
794 if (substr($colid, 0, 5) ==
"advmd") {
795 $advmd_id = (int) substr($colid, 5);
797 if (isset($a_set[
"md_" . $advmd_id .
"_presentation"])) {
798 $pb = $a_set[
"md_" . $advmd_id .
"_presentation"]->getList();
803 $a_excel->
setCell($a_row, ++$col, $val);
805 $a_excel->
setCell($a_row, ++$col, $a_set[$colid]);
812 $a_csv->addColumn($this->lng->txt(
"title"));
813 if ($this->has_schedule) {
814 $a_csv->addColumn($this->lng->txt(
"date"));
815 $a_csv->addColumn($this->lng->txt(
"wk_short"));
816 $a_csv->addColumn($this->lng->txt(
"cal_weekday"));
817 $a_csv->addColumn($this->lng->txt(
"book_schedule_slot"));
818 $a_csv->addColumn($this->lng->txt(
"book_no_of_objects"));
820 $a_csv->addColumn($this->lng->txt(
"status"));
824 $a_csv->addColumn(
$txt);
832 $a_csv->addColumn($a_set[
"title"]);
833 if ($this->has_schedule) {
835 $a_csv->addColumn($a_set[
"week"]);
837 $a_csv->addColumn($a_set[
"slot"]);
838 $a_csv->addColumn($a_set[
"counter"]);
842 $status = $this->lng->txt(
'book_reservation_status_' . $a_set[
'status']);
844 $a_csv->addColumn($status);
848 if (substr($colid, 0, 5) ==
"advmd") {
849 $advmd_id = (int) substr($colid, 5);
851 if (isset($a_set[
"md_" . $advmd_id .
"_presentation"])) {
852 $pb = $a_set[
"md_" . $advmd_id .
"_presentation"]->getList();
857 $a_csv->addColumn($val);
859 $a_csv->addColumn($a_set[$colid]);
getSelectedUserColumns()
Get selected user colimns.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
initFilter(array $a_filter_pre=null)
Init filter.
setExportFormats(array $formats)
Set available export formats.
fillRowCSV($a_csv, $a_set)
numericOrdering($a_field)
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
static _numericDayToString($a_day, $a_long=true)
get
static getUserFilter(array $a_object_ids)
Get all users who have reservations for object(s)
getParentGroupCourse()
Get parent group or course.
getSelectableColumns()
Get selectable columns.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
getSelectableUserColumns()
Get selectable user fields.
getItems(array $filter)
Gather data and build rows.
schedule for booking ressource
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
getAdditionalExportCols()
Get additional export columns.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
$has_items_with_host_context
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static _lookupObjectId($a_ref_id)
lookup object id
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
getColumnCoord($a_col)
Get column "name" from number.
setBold($a_coords)
Set cell(s) to bold.
getSelectableColumns($a_only_advmd=false, $a_include_user=true)
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.
getCurrentFilter()
Get current filter settings.
static _getInstanceByType($a_type)
Get Singleton Instance.
fillHeaderExcel(ilExcel $a_excel, &$a_row)
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
addMultiCommand($a_cmd, $a_text)
Add Command button.
getSelectedColumns()
Get selected columns.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
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:
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
fillRow($a_set)
Fill table row.
Factory for reservation repo.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
__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.
__construct(Container $dic, ilPlugin $plugin)
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.
setEnableHeader($a_enableheader)
Set Enable Header.
static _getInstance()
Get instance of ilPrivacySettings.
static getList($a_pool_id)
Get list of booking objects for given pool.
static getAdvancedMDFields($a_ref_id)
static lookupAcceptedAgreements($a_obj_id)
Lookup users who have accepted the agreement.
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.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
setLimit($a_limit=0, $a_default_limit=0)
setFilterCommand($a_val, $a_caption=null)
Set filter command.