ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
BookingTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use Generator;
28use ILIAS\UI\Factory as UIFactory;
29use ILIAS\Data\Factory as DataFactory;
31use Psr\Http\Message\ServerRequestInterface as ServerRequestInterface;
32use ILIAS\UI\Renderer as Renderer;
33use ilLanguage;
34use ilObjUser;
35use ilCtrl;
38
40{
41 public const ACTION_TOKEN = 'action';
42 public const ID_TOKEN = 'id';
43 public const TABLE_NS = 'ch_booking_table';
44
45 public const ACTION_TOKEN_NS = self::TABLE_NS . '_' . self::ACTION_TOKEN;
46
47 public const ID_TOKEN_NS = self::TABLE_NS . '_' . self::ID_TOKEN;
48
49
51
52 protected readonly ilLanguage $lng;
53 protected readonly ilObjUser $user;
54 protected readonly ilCtrl $ctrl;
55 protected readonly UIFactory $ui_factory;
56 protected readonly DataFactory $data_factory;
57 protected readonly ServerRequestInterface $http_request;
59
60
62 {
63 global $DIC;
64
65 $this->provider = $provider;
66
67 $this->lng = $DIC->language();
68 $this->user = $DIC->user();
69 $this->ctrl = $DIC->ctrl();
70
71 $this->http_request = $DIC->http()->request();
72 $this->ui_factory = $DIC->ui()->factory();
73 $this->data_factory = new DataFactory();
74 $this->ui_renderer = $DIC->ui()->renderer();
75 }
76
77 public function getRows(
78 DataRowBuilder $row_builder,
79 array $visible_column_ids,
81 Order $order,
82 mixed $additional_viewcontrol_data,
83 mixed $filter_data,
84 mixed $additional_parameters
85 ): Generator {
86 $records = $this->provider->limitData($range, $order);
87 foreach ($records as $row) {
88 $id = $row['id'];
89 $records_row = $row_builder->buildDataRow($id, $row);
90 if (count($row['booking_participant']->getItems()) === 0) {
91 $records_row = $records_row
92 ->withDisabledAction('confirmCancelBooking')
93 ->withDisabledAction('confirmDeleteBooking')
94 ->withDisabledAction('sendMail');
95 }
96 yield $records_row;
97 }
98 }
99
100 public function getTotalRowCount(
101 mixed $additional_viewcontrol_data,
102 mixed $filter_data,
103 mixed $additional_parameters
104 ): ?int {
105 return count($this->provider->getData());
106 }
107
108 public function get(): Data
109 {
110 return $this->ui_factory
111 ->table()
112 ->data(
113 $this,
114 $this->lng->txt('cal_ch_ch'),
115 $this->getColumns(),
116 )
117 ->withId(self::class)
118 ->withActions($this->getActions())
119 ->withRequest($this->http_request);
120 }
121
122
126 protected function getActions(): array
127 {
128 $uri_command_handler = $this->data_factory->uri(
129 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
130 ilConsultationHoursGUI::class,
131 'handleBookingTableActions'
132 )
133 );
134
135 [
136 $url_builder,
137 $action_parameter_token,
138 $row_id_token
139 ] =
140 (new URLBuilder($uri_command_handler))->acquireParameters(
141 [self::TABLE_NS],
142 self::ACTION_TOKEN,
143 self::ID_TOKEN
144 );
145
146 return [
147 'edit' => $this->ui_factory->table()->action()->standard(
148 $this->lng->txt('edit'),
149 $url_builder->withParameter($action_parameter_token, 'edit'),
150 $row_id_token
151 ),
152 'searchUsersForAppointments' => $this->ui_factory->table()->action()->standard(
153 $this->lng->txt('cal_ch_assign_participants'),
154 $url_builder->withParameter($action_parameter_token, 'searchUsersForAppointments'),
155 $row_id_token
156 ),
157 'confirmCancelBooking' => $this->ui_factory->table()->action()->single(
158 $this->lng->txt('cal_ch_cancel_booking'),
159 $url_builder->withParameter($action_parameter_token, 'confirmCancelBooking'),
160 $row_id_token
161 )->withAsync(true),
162 'confirmDeleteBooking' => $this->ui_factory->table()->action()->single(
163 $this->lng->txt('cal_ch_delete_booking'),
164 $url_builder->withParameter($action_parameter_token, 'confirmDeleteBooking'),
165 $row_id_token
166 )->withAsync(true),
167 'confirmDeleteAppointments' => $this->ui_factory->table()->action()->standard(
168 $this->lng->txt('delete'),
169 $url_builder->withParameter($action_parameter_token, 'confirmDeleteAppointments'),
170 $row_id_token
171 )->withAsync(true),
172 'sendMail' => $this->ui_factory->table()->action()->standard(
173 $this->lng->txt('cal_ch_send_mail'),
174 $url_builder->withParameter($action_parameter_token, 'sendMail'),
175 $row_id_token
176 )
177 ];
178 }
179
183 protected function getColumns(): array
184 {
185 if ($this->user->getTimeFormat() === \ilCalendarSettings::TIME_FORMAT_12) {
186 $format = $this->data_factory->dateFormat()->withTime12($this->user->getDateFormat());
187 } else {
188 $format = $this->data_factory->dateFormat()->withTime24($this->user->getDateFormat());
189 }
190
191 return [
192 'booking_start' => $this->ui_factory
193 ->table()
194 ->column()
195 ->date($this->lng->txt('cal_ch_booking_start'), $format)
196 ->withIsSortable(true),
197 'booking_duration' => $this->ui_factory
198 ->table()
199 ->column()
200 ->number($this->lng->txt('cal_ch_minutes'))
201 ->withIsSortable(true),
202 'booking_title' => $this->ui_factory
203 ->table()
204 ->column()
205 ->text($this->lng->txt('title'))
206 ->withIsSortable(true),
207 'booking_participant' => $this->ui_factory
208 ->table()
209 ->column()
210 ->linkListing($this->lng->txt('cal_ch_booking_participants')),
211 'booking_comment' => $this->ui_factory
212 ->table()
213 ->column()
214 ->linkListing($this->lng->txt('cal_ch_booking_col_comments')),
215 'booking_location' => $this->ui_factory
216 ->table()
217 ->column()
218 ->linkListing($this->lng->txt('cal_ch_target_object'))
219 ];
220
221 }
222
223 public function render(): string
224 {
225 return $this->ui_renderer->render(
226 [
227 $this->get()
228 ]
229 );
230 }
231
232}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
readonly ServerRequestInterface $http_request
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
Consultation hours editor.
Class ilCtrl provides processing control methods.
language handling
User class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildDataRow(string $id, array $record)
This describes a Data Table.
Definition: Data.php:33
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26