ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilBookingParticipantsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
17 protected $access;
18
22 protected $user;
23
27 protected $ref_id; // [int]
28
32 protected $pool_id; // [int]
33
37 protected $filter; // [array]
38
42 protected $objects; // array
43
51 public function __construct(ilBookingParticipantGUI $a_parent_obj, $a_parent_cmd, $a_ref_id, $a_pool_id)
52 {
53 global $DIC;
54
55 $this->ctrl = $DIC->ctrl();
56 $this->lng = $DIC->language();
57 $this->user = $DIC->user();
58 $this->access = $DIC->access();
59 $this->ref_id = $a_ref_id;
60 $this->pool_id = $a_pool_id;
61
62 $this->setId("bkprt" . $a_ref_id);
63
64 parent::__construct($a_parent_obj, $a_parent_cmd);
65
66 $this->setTitle($this->lng->txt("participants"));
67
68 $this->addColumn($this->lng->txt("name"), "name");
69 $this->addColumn($this->lng->txt("book_bobj"));
70 $this->addColumn($this->lng->txt("action"));
71
72 $this->setDefaultOrderField("name");
73 $this->setDefaultOrderDirection("asc");
74
75 $this->setEnableHeader(true);
76 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
77 $this->setRowTemplate("tpl.booking_participant_row.html", "Modules/BookingManager");
78 $this->setResetCommand("resetParticipantsFilter");
79 $this->setFilterCommand("applyParticipantsFilter");
80 $this->setDisableFilterHiding(true);
81
82 $this->initFilter();
83
84 $this->getItems($this->getCurrentFilter());
85 }
86
87 public function initFilter()
88 {
89 //object
90 $this->objects = array();
91 foreach (ilBookingObject::getList($this->pool_id) as $item) {
92 $this->objects[$item["booking_object_id"]] = $item["title"];
93 }
95 $item->setOptions([
96 "" => $this->lng->txt('book_all'),
97 -1 => $this->lng->txt('book_no_objects')
98 ] + $this->objects);
99 $this->filter["object"] = $item->getValue();
100
102 "title",
104 false,
105 $this->lng->txt("object") . " " . $this->lng->txt("title") . "/" . $this->lng->txt("description")
106 );
107 $this->filter["title"] = $title->getValue();
108
109 //user
110 $options = array("" => $this->lng->txt('book_all')) +
113 $item->setOptions($options);
114 $this->filter["user_id"] = $item->getValue();
115 }
116
121 public function getCurrentFilter()
122 {
123 $filter = array();
124 if ($this->filter["object"]) {
125 $filter["object"] = $this->filter["object"];
126 }
127 if ($this->filter["title"]) {
128 $filter["title"] = $this->filter["title"];
129 }
130 if ($this->filter["user_id"]) {
131 $filter["user_id"] = $this->filter["user_id"];
132 }
133
134 return $filter;
135 }
136
141 public function getItems(array $filter)
142 {
143 if ($filter["object"] > 0) {
144 $data = ilBookingParticipant::getList($this->pool_id, $filter, $filter["object"]);
145 } elseif ($filter["object"] == -1) {
147 $data = array_filter($data, function ($item) {
148 return $item["obj_count"] == 0;
149 });
150 } else {
152 }
153
154 $this->setMaxCount(sizeof($data));
155 $this->setData($data);
156 }
157
162 protected function fillRow($a_set)
163 {
166
167 $this->tpl->setVariable("TXT_NAME", $a_set['name']);
168 $this->tpl->setCurrentBlock('object_titles');
169 foreach ($a_set['object_title'] as $obj_title) {
170 $this->tpl->setVariable("TXT_OBJECT", $obj_title);
171 $this->tpl->parseCurrentBlock();
172 }
173
174 // determin actions form data
175 // action assign only if user did not booked all objects.
176 $actions = [];
177 if ($a_set['obj_count'] < ilBookingObject::getNumberOfObjectsForPool($this->pool_id)) {
178 $ctrl->setParameterByClass('ilbookingparticipantgui', 'bkusr', $a_set['user_id']);
179 $actions[] = array(
180 'text' => $lng->txt("book_assign_object"),
181 'url' => $ctrl->getLinkTargetByClass("ilbookingparticipantgui", 'assignObjects')
182 );
183 $ctrl->setParameterByClass('ilbookingparticipantgui', 'bkusr', '');
184 }
185
186 $bp = new ilObjBookingPool($this->pool_id, false);
187 if ($bp->getScheduleType() == ilObjBookingPool::TYPE_NO_SCHEDULE && $a_set['obj_count'] == 1) {
188 $ctrl->setParameterByClass('ilbookingreservationsgui', 'bkusr', $a_set['user_id']);
189 $ctrl->setParameterByClass('ilbookingreservationsgui', 'object_id', $a_set['object_ids'][0]);
190 $ctrl->setParameterByClass('ilbookingreservationsgui', 'part_view', ilBookingParticipantGUI::PARTICIPANT_VIEW);
191
192 $actions[] = array(
193 'text' => $lng->txt("book_deassign"),
194 'url' => $ctrl->getLinkTargetByClass("ilbookingreservationsgui", 'rsvConfirmCancelUser')
195 );
196
197 $ctrl->setParameterByClass('ilbookingreservationsgui', 'bkusr', '');
198 $ctrl->setParameterByClass('ilbookingreservationsgui', 'object_id', '');
199 $ctrl->setParameterByClass('ilbookingreservationsgui', 'part_view', '');
200 } elseif ($bp->getScheduleType() == ilObjBookingPool::TYPE_FIX_SCHEDULE || $a_set['obj_count'] > 1) {
201 $ctrl->setParameterByClass('ilbookingreservationsgui', 'user_id', $a_set['user_id']);
202 $actions[] = array(
203 'text' => $lng->txt("book_deassign"),
204 'url' => $ctrl->getLinkTargetByClass("ilbookingreservationsgui", 'log')
205 );
206 $ctrl->setParameterByClass('ilbookingreservationsgui', 'user_id', '');
207 }
208
209 $this->tpl->setCurrentBlock('actions');
210 foreach ($actions as $action) {
211 $this->tpl->setVariable("TXT_ACTION", $action['text']);
212 $this->tpl->setVariable("URL_ACTION", $action['url']);
213 $this->tpl->parseCurrentBlock();
214 }
215 }
216}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
static getNumberOfObjectsForPool($a_pool_id)
Get number of booking objects for given booking pool id.
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
Class ilBookingParticipantGUI.
static getUserFilter($a_pool_id)
Get user data from db for an specific pool id.
static getList($a_booking_pool, array $a_filter=null, $a_object_id=null)
getItems(array $filter)
Gather data and build rows.
__construct(ilBookingParticipantGUI $a_parent_obj, $a_parent_cmd, $a_ref_id, $a_pool_id)
Constructor.
Class ilObjBookingPool.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
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.
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.
setMaxCount($a_max_count)
set max.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46