ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBookingParticipantsTableGUI.php
Go to the documentation of this file.
1<?php
2
24{
26 protected ilObjUser $user;
27 protected int $ref_id;
28 protected int $pool_id;
29 protected array $filter;
30 protected array $objects;
31
32 public function __construct(
33 ilBookingParticipantGUI $a_parent_obj,
34 string $a_parent_cmd,
35 int $a_ref_id,
36 int $a_pool_id
37 ) {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->lng = $DIC->language();
42 $this->user = $DIC->user();
43 $this->access = $DIC->access();
44 $this->ref_id = $a_ref_id;
45 $this->pool_id = $a_pool_id;
46
47 $this->setId("bkprt" . $a_ref_id);
48
49 parent::__construct($a_parent_obj, $a_parent_cmd);
50
51 $this->setTitle($this->lng->txt("participants"));
52
53 $this->addColumn($this->lng->txt("name"), "name");
54 $this->addColumn($this->lng->txt("book_bobj"));
55 $this->addColumn($this->lng->txt("action"));
56
57 $this->setDefaultOrderField("name");
58 $this->setDefaultOrderDirection("asc");
59
60 $this->setEnableHeader(true);
61 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
62 $this->setRowTemplate("tpl.booking_participant_row.html", "components/ILIAS/BookingManager");
63 $this->setResetCommand("resetParticipantsFilter");
64 $this->setFilterCommand("applyParticipantsFilter");
65 $this->setDisableFilterHiding(true);
66
67 $this->initFilter();
68
69 $this->getItems($this->getCurrentFilter());
70 }
71
72 public function initFilter(): void
73 {
74 //object
75 $this->objects = array();
76 foreach (ilBookingObject::getList($this->pool_id) as $item) {
77 $this->objects[$item["booking_object_id"]] = $item["title"];
78 }
80 if ($item !== null) {
81 $item->setOptions([
82 "" => $this->lng->txt('book_all'),
83 -1 => $this->lng->txt('book_no_objects')
84 ] + $this->objects);
85 $this->filter["object"] = $item->getValue();
87 "title",
89 false,
90 $this->lng->txt("object") . " " . $this->lng->txt("title") . "/" . $this->lng->txt("description")
91 );
92 if ($title !== null) {
93 $this->filter["title"] = $title->getValue();
94 }
95 //user
96 $options = array("" => $this->lng->txt('book_all')) +
99 $item->setOptions($options);
100 $this->filter["user_id"] = $item->getValue();
101 }
102 }
103
107 public function getCurrentFilter(): array
108 {
109 $filter = array();
110 if ($this->filter["object"]) {
111 $filter["object"] = $this->filter["object"];
112 }
113 if ($this->filter["title"]) {
114 $filter["title"] = $this->filter["title"];
115 }
116 if ($this->filter["user_id"]) {
117 $filter["user_id"] = $this->filter["user_id"];
118 }
119
120 return $filter;
121 }
122
126 public function getItems(array $filter): void
127 {
128 $filter_object = (int) ($filter["object"] ?? 0);
129 if ($filter_object > 0) {
130 $data = ilBookingParticipant::getList($this->pool_id, $filter, $filter_object);
131 } elseif ($filter_object === -1) {
132 $data = array_filter(
133 ilBookingParticipant::getList($this->pool_id, $filter),
134 static fn(array $item): bool => ($item["obj_count"] ?? 0) === 0
135 );
136 } else {
138 }
139
140 $this->setMaxCount(count($data));
141 $this->setData($data);
142 }
143
144 protected function fillRow(array $a_set): void
145 {
148
149 $this->tpl->setVariable("TXT_NAME", $a_set['name']);
150 $this->tpl->setCurrentBlock('object_titles');
151 foreach ($a_set['object_title'] as $obj_title) {
152 $this->tpl->setVariable("TXT_OBJECT", $obj_title);
153 $this->tpl->parseCurrentBlock();
154 }
155
156 $obj_count = (int) ($a_set['obj_count'] ?? 0);
157
158 // determin actions form data
159 // action assign only if user did not booked all objects.
160 $actions = [];
161 if ($obj_count < ilBookingObject::getNumberOfObjectsForPool($this->pool_id)) {
162 $ctrl->setParameterByClass('ilbookingparticipantgui', 'bkusr', $a_set['user_id']);
163 $actions[] = array(
164 'text' => $lng->txt("book_assign_object"),
165 'url' => $ctrl->getLinkTargetByClass("ilbookingparticipantgui", 'assignObjects')
166 );
167 $ctrl->setParameterByClass('ilbookingparticipantgui', 'bkusr', '');
168 }
169
170 $bp = new ilObjBookingPool($this->pool_id, false);
171 if ($obj_count === 1 && $bp->getScheduleType() === ilObjBookingPool::TYPE_NO_SCHEDULE) {
172 $ctrl->setParameterByClass('ilbookingreservationsgui', 'bkusr', $a_set['user_id']);
173 $ctrl->setParameterByClass('ilbookingreservationsgui', 'object_id', $a_set['object_ids'][0]);
174 $ctrl->setParameterByClass('ilbookingreservationsgui', 'part_view', ilBookingParticipantGUI::PARTICIPANT_VIEW);
175
176 $actions[] = array(
177 'text' => $lng->txt("book_deassign"),
178 'url' => $ctrl->getLinkTargetByClass("ilbookingreservationsgui", 'rsvConfirmCancelUser')
179 );
180
181 $ctrl->setParameterByClass('ilbookingreservationsgui', 'bkusr', '');
182 $ctrl->setParameterByClass('ilbookingreservationsgui', 'object_id', '');
183 $ctrl->setParameterByClass('ilbookingreservationsgui', 'part_view', '');
184 } elseif ($obj_count > 1 || $bp->getScheduleType() === ilObjBookingPool::TYPE_FIX_SCHEDULE) {
185 $ctrl->setParameterByClass('ilbookingreservationsgui', 'user_id', $a_set['user_id']);
186 $actions[] = array(
187 'text' => $lng->txt("book_deassign"),
188 'url' => $ctrl->getLinkTargetByClass("ilbookingreservationsgui", 'log')
189 );
190 $ctrl->setParameterByClass('ilbookingreservationsgui', 'user_id', '');
191 }
192
193 $this->tpl->setCurrentBlock('actions');
194 foreach ($actions as $action) {
195 $this->tpl->setVariable("TXT_ACTION", $action['text']);
196 $this->tpl->setVariable("URL_ACTION", $action['url']);
197 $this->tpl->parseCurrentBlock();
198 }
199 }
200}
static getNumberOfObjectsForPool(int $a_pool_id)
Get number of booking objects for given booking pool id.
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getList(int $a_booking_pool, ?array $a_filter=null, ?int $a_object_id=null)
static getUserFilter(int $a_pool_id)
Get user data from db for an specific pool id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getItems(array $filter)
Gather data and build rows.
__construct(ilBookingParticipantGUI $a_parent_obj, string $a_parent_cmd, int $a_ref_id, int $a_pool_id)
fillRow(array $a_set)
Standard Version of Fill Row.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
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="")
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
setData(array $a_data)
Set table data.
ilLanguage $lng
setMaxCount(int $a_max_count)
set max.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26