4 include_once(
"./Services/Table/classes/class.ilTable2GUI.php");
5 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
6 require_once
"Services/Calendar/classes/class.ilCalendarUtil.php";
53 public function __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)
57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->
user = $DIC->user();
60 $this->access = $DIC->access();
62 $lng = $DIC->language();
64 $ilAccess = $DIC->access();
65 $this->tree = $DIC->repositoryTree();
67 $this->pool_id = $a_pool_id;
68 $this->ref_id = $a_ref_id;
69 $this->show_all = $a_show_all;
70 $this->has_schedule = (bool) $a_has_schedule;
71 $this->group_id = $a_group_id;
75 $this->
setId(
"bkrsv" . $a_ref_id);
77 parent::__construct($a_parent_obj, $a_parent_cmd);
82 $this->
addColumn($this->lng->txt(
"title"),
"title");
87 if ($this->has_schedule) {
88 $this->lng->loadLanguageModule(
"dateplaner");
90 $this->
addColumn($this->lng->txt(
"date"),
"date");
91 if (in_array(
"week", $selected)) {
92 $this->
addColumn($this->lng->txt(
"wk_short"),
"week");
95 if (in_array(
"weekday", $selected)) {
96 $this->
addColumn($this->lng->txt(
"cal_weekday"),
"weekday");
97 unset(
$cols[
"weekday"]);
99 $this->
addColumn($this->lng->txt(
"book_schedule_slot"),
"slot");
100 $this->
addColumn($this->lng->txt(
"book_no_of_objects"),
"counter");
105 $this->
addColumn($this->lng->txt(
"status"),
"status");
114 if (array_key_exists($col,
$cols)) {
115 if (!isset($user_cols[$col])) {
121 $this->
addColumn($this->lng->txt(
"user"),
"user_name");
125 if (array_key_exists($col,
$cols)) {
126 if (isset($user_cols[$col])) {
132 $this->
addColumn($this->lng->txt(
"actions"));
136 $this->
setRowTemplate(
"tpl.booking_reservation_row.html",
"Modules/BookingManager");
143 if ($this->group_id) {
146 $this->filters = array();
151 if (
$ilUser->getId() != ANONYMOUS_USER_ID) {
174 if ($this->has_schedule &&
175 !(
bool) $a_only_advmd) {
176 $this->lng->loadLanguageModule(
"dateplaner");
178 $cols[
"week"] = array(
179 "txt" => $this->lng->txt(
"wk_short"),
183 $cols[
"weekday"] = array(
184 "txt" => $this->lng->txt(
"cal_weekday"),
189 foreach ($this->advmd as $field) {
190 $cols[
"advmd" . $field[
"id"]] = array(
191 "txt" => $field[
"title"],
196 if ($a_include_user) {
214 if ($this->access->checkAccess(
"manage_members",
"", $parent[
"ref_id"])) {
215 include_once
'./Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
218 if (!in_array($k, [
"login"])) {
238 if (isset($user_cols[$col])) {
255 if (($par_ref_id =
$tree->checkForParentType($this->ref_id,
"grp")) > 0) {
257 "ref_id" => $par_ref_id,
261 if (($par_ref_id =
$tree->checkForParentType($this->ref_id,
"crs")) > 0) {
263 "ref_id" => $par_ref_id,
277 if (is_array($a_filter_pre) &&
278 isset($a_filter_pre[
"object"])) {
279 $_SESSION[
"form_" . $this->
getId()][
"object"] = serialize($a_filter_pre[
"object"]);
282 $this->objects = array();
283 include_once
"Modules/BookingManager/classes/class.ilBookingObject.php";
285 $this->objects[$item[
"booking_object_id"]] = $item[
"title"];
288 $item->setOptions(array(
"" => $this->lng->txt(
'book_all')) + $this->objects);
289 $this->filter[
"object"] = $item->getValue();
295 $this->lng->txt(
"object") .
" " . $this->lng->txt(
"title") .
"/" . $this->lng->txt(
"description")
297 $this->filter[
"title"] =
$title->getValue();
299 if ($this->has_schedule) {
306 include_once
"Modules/BookingManager/classes/class.ilObjBookingPool.php";
308 $period = $bpool->getReservationFilterPeriod();
309 if ($period !== null) {
314 $to = serialize($to);
318 "from" => serialize(
$from),
323 $this->filter[
"fromto"] = $item->getDate();
326 if ($this->show_all) {
328 $map = array_flip(array(
'su',
'mo',
'tu',
'we',
'th',
'fr',
'sa'));
330 $options = array(
"" => $this->lng->txt(
'book_all'));
333 require_once
"Modules/BookingManager/classes/class.ilBookingSchedule.php";
336 foreach ($schedule->getDefinition() as $day => $slots) {
339 foreach ($slots as $slot) {
340 $idx =
$map[$day] .
"_" . $slot;
341 $options[$idx] = $day_caption .
", " . $slot;
350 $this->filter[
"slot"] = $item->getValue();
354 $item =
new ilCheckboxInputGUI($this->lng->txt(
"book_filter_past_reservations"),
"past");
356 $item->readFromSession();
360 if (is_object($this->filter[
"fromto"][
"from"]) &&
361 $this->filter[
"fromto"][
"from"]->
get(
IL_CAL_DATE) < date(
"Y-m-d")) {
362 $item->setChecked(
true);
365 $this->filter[
"past"] = $item->getChecked();
370 if (!$this->has_schedule) {
371 $options = array(
"" => $this->lng->txt(
'book_all'));
375 foreach ($valid_status as $loop) {
377 $options[$loop] = $this->lng->txt(
'book_reservation_status_' . $loop);
379 $options[$loop] = $this->lng->txt(
'book_not') .
' ' . $this->lng->txt(
'book_reservation_status_' . -$loop);
384 $this->filter[
"status"] = $item->getValue();
387 if ($this->show_all) {
388 $options = array(
"" => $this->lng->txt(
'book_all')) +
392 if (is_array($a_filter_pre) && isset($a_filter_pre[
"user_id"])) {
393 $item->setValue($a_filter_pre[
"user_id"]);
394 $this->filter[
"user_id"] = $a_filter_pre[
"user_id"];
396 $this->filter[
"user_id"] = $item->getValue();
408 if ($this->filter[
"object"]) {
409 $filter[
"object"] = $this->filter[
"object"];
411 if ($this->filter[
"title"]) {
412 $filter[
"title"] = $this->filter[
"title"];
414 if ($this->filter[
"status"]) {
415 $filter[
"status"] = $this->filter[
"status"];
417 if ($this->filter[
"user_id"]) {
418 $filter[
"user_id"] = $this->filter[
"user_id"];
421 if ($this->has_schedule) {
426 if ($this->filter[
"slot"]) {
427 $filter[
"slot"] = $this->filter[
"slot"];
430 if ($this->filter[
"fromto"][
"from"] || $this->filter[
"fromto"][
"to"]) {
431 if ($this->filter[
"fromto"][
"from"]) {
434 if ($this->filter[
"fromto"][
"to"]) {
440 $filter[
"past"] = (bool) $this->filter[
"past"];
448 return in_array($a_field, array(
"counter",
"date",
"week",
"weekday"));
459 if (!$filter[
"object"]) {
460 $ids = array_keys($this->objects);
462 $ids = array($filter[
"object"]);
465 if (!$this->show_all) {
466 $filter[
"user_id"] =
$ilUser->getId();
469 include_once
"Modules/BookingManager/classes/class.ilBookingReservation.php";
474 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
476 $this->record_gui->setTableGUI($this);
477 $this->record_gui->parse();
479 foreach (array_keys(
$data) as $idx) {
483 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php");
493 $this->record_gui->getFilterElements()
499 $user_ids = array_unique(array_map(
function (
$d) {
500 return $d[
'user_id'];
506 if (substr($field, 0, 3) ==
'odf') {
507 $odf_ids[] = substr($field, 4);
509 $user_columns[] = $field;
516 $query->setAdditionalFields($user_columns);
517 $query->setUserFilter($user_ids);
521 foreach ($ud[
"set"] as $v) {
522 foreach ($user_columns as
$c) {
523 $usr_data[$v[
"usr_id"]][
$c] = $v[
$c];
527 if (isset($usr_data[$v[
"user_id"]])) {
528 $data[
$key] = array_merge($v, $usr_data[$v[
"user_id"]]);
538 $confirmation_required = ($parent_obj_type ==
'crs')
541 if ($confirmation_required) {
547 foreach ($odf_data as $usr_id => $fields) {
548 if (in_array($usr_id, $user_ids)) {
549 foreach ($fields as $field_id => $value) {
550 if (in_array($field_id, $odf_ids)) {
551 $usr_data[$usr_id][
'odf_' . $field_id] = $value;
558 if (isset($usr_data[$v[
"user_id"]])) {
559 $data[
$key] = array_merge($v, $usr_data[$v[
"user_id"]]);
570 return $this->record_gui;
575 $field = parent::getOrderField();
578 if (in_array($field, array(
"date",
"week"))) {
579 $field =
"_sortdate";
598 $this->tpl->setVariable(
"TXT_TITLE", $a_set[
"title"]);
600 $can_be_cancelled = (($ilAccess->checkAccess(
'write',
'', $this->ref_id) ||
601 $a_set[
'user_id'] ==
$ilUser->getId()) &&
602 $a_set[
"can_be_cancelled"]);
604 if ($can_be_cancelled) {
605 $this->tpl->setVariable(
"MULTI_ID", $a_set[
"booking_reservation_id"]);
609 $uname = $a_set[
"user_name"];
611 $uname =
"[" .
$lng->txt(
"user_deleted") .
"]";
616 include_once(
"./Services/User/classes/class.ilUserUtil.php");
619 $this->tpl->setVariable(
"TXT_CURRENT_USER", $uname);
621 if ($this->has_schedule) {
623 if (in_array(
"week", $selected)) {
624 $this->tpl->setVariable(
"VALUE_WEEK", $a_set[
"week"]);
626 if (in_array(
"weekday", $selected)) {
629 $this->tpl->setVariable(
"VALUE_SLOT", $a_set[
"slot"]);
630 $this->tpl->setVariable(
"VALUE_COUNTER", $a_set[
"counter"]);
633 $this->tpl->setVariable(
"TXT_STATUS",
$lng->txt(
'book_reservation_status_' . $a_set[
'status']));
635 $this->tpl->setVariable(
"TXT_STATUS",
" ");
640 foreach ($this->advmd as $item) {
641 $advmd_id = (int) $item[
"id"];
643 if (!in_array(
"advmd" . $advmd_id, $selected)) {
648 if (isset($a_set[
"md_" . $advmd_id .
"_presentation"])) {
649 $pb = $a_set[
"md_" . $advmd_id .
"_presentation"]->getList();
655 $this->tpl->setCurrentBlock(
"advmd_bl");
656 $this->tpl->setVariable(
"VALUE_ADVMD", $val);
657 $this->tpl->parseCurrentBlock();
664 if (isset($user_cols[$col])) {
665 $this->tpl->setCurrentBlock(
"user_col");
666 $this->tpl->setVariable(
"VALUE_USER_COL", $a_set[$col] .
" ");
667 $this->tpl->parseCurrentBlock();
671 if ($can_be_cancelled) {
672 $ilCtrl->setParameter($this->parent_obj,
'reservation_id', $a_set[
'booking_reservation_id']);
673 $this->tpl->setVariable(
"URL_ACTION",
$ilCtrl->getLinkTarget($this->parent_obj,
'rsvConfirmCancel'));
674 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
675 $this->tpl->setVariable(
"TXT_ACTION",
$lng->txt(
'book_set_cancel'));
676 $this->tpl->setCurrentBlock(
"action");
677 $this->tpl->parseCurrentBlock();
680 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id)) {
681 $ilCtrl->setParameter($this->parent_obj,
'reservation_id', $a_set[
'booking_reservation_id']);
682 $this->tpl->setVariable(
"URL_ACTION",
$ilCtrl->getLinkTarget($this->parent_obj,
'rsvConfirmDelete'));
683 $ilCtrl->setParameter($this->parent_obj,
'reservation_id',
"");
684 $this->tpl->setVariable(
"TXT_ACTION",
$lng->txt(
'delete'));
685 $this->tpl->setCurrentBlock(
"action");
686 $this->tpl->parseCurrentBlock();
756 unset(
$cols[
"week"]);
757 unset(
$cols[
"weekday"]);
762 if (array_key_exists($col,
$cols)) {
763 if (!isset($user_cols[$col])) {
764 $add_cols[$col] =
$cols[$col][
"txt"];
769 $add_cols[
"user_name"] = $this->lng->txt(
"user");
773 if (array_key_exists($col,
$cols)) {
774 if (isset($user_cols[$col])) {
775 $add_cols[$col] =
$cols[$col][
"txt"];
785 $a_excel->
setCell($a_row, 0, $this->lng->txt(
"title"));
787 if ($this->has_schedule) {
788 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"date"));
789 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"wk_short"));
790 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"cal_weekday"));
791 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"book_schedule_slot"));
792 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"book_no_of_objects"));
794 $a_excel->
setCell($a_row, ++$col, $this->lng->txt(
"status"));
806 $a_excel->
setCell($a_row, 0, $a_set[
"title"]);
808 if ($this->has_schedule) {
810 $a_excel->
setCell($a_row, ++$col, $a_set[
"week"]);
812 $a_excel->
setCell($a_row, ++$col, $a_set[
"slot"]);
813 $a_excel->
setCell($a_row, ++$col, $a_set[
"counter"]);
817 $status = $this->lng->txt(
'book_reservation_status_' . $a_set[
'status']);
819 $a_excel->
setCell($a_row, ++$col, $status);
824 if (substr($colid, 0, 5) ==
"advmd") {
825 $advmd_id = (int) substr($colid, 5);
827 if (isset($a_set[
"md_" . $advmd_id .
"_presentation"])) {
828 $pb = $a_set[
"md_" . $advmd_id .
"_presentation"]->getList();
833 $a_excel->
setCell($a_row, ++$col, $val);
835 $a_excel->
setCell($a_row, ++$col, $a_set[$colid]);
842 $a_csv->addColumn($this->lng->txt(
"title"));
843 if ($this->has_schedule) {
844 $a_csv->addColumn($this->lng->txt(
"date"));
845 $a_csv->addColumn($this->lng->txt(
"wk_short"));
846 $a_csv->addColumn($this->lng->txt(
"cal_weekday"));
847 $a_csv->addColumn($this->lng->txt(
"book_schedule_slot"));
848 $a_csv->addColumn($this->lng->txt(
"book_no_of_objects"));
850 $a_csv->addColumn($this->lng->txt(
"status"));
854 $a_csv->addColumn(
$txt);
862 $a_csv->addColumn($a_set[
"title"]);
863 if ($this->has_schedule) {
865 $a_csv->addColumn($a_set[
"week"]);
867 $a_csv->addColumn($a_set[
"slot"]);
868 $a_csv->addColumn($a_set[
"counter"]);
872 $status = $this->lng->txt(
'book_reservation_status_' . $a_set[
'status']);
874 $a_csv->addColumn($status);
878 if (substr($colid, 0, 5) ==
"advmd") {
879 $advmd_id = (int) substr($colid, 5);
881 if (isset($a_set[
"md_" . $advmd_id .
"_presentation"])) {
882 $pb = $a_set[
"md_" . $advmd_id .
"_presentation"]->getList();
887 $a_csv->addColumn($val);
889 $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 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.
static getListByDate( $a_has_schedule, array $a_object_ids=null, array $filter=null, array $a_pool_ids=null)
List all reservations by date.
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.
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)
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.
__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)
Constructor.
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.