19declare(strict_types=1);
56 private readonly UIFactory $ui_factory,
66 private readonly
bool $active_management,
67 private readonly array $bookable_items,
71 !$this->
access->canManageAllReservations($this->pool->getRefId())
72 && !$this->access->canReadPublicLog($this->pool->getRefId())
74 $filter[
'user_id'] = $this->
user->getId();
76 $this->bookings = array_column(
79 'booking_reservation_id'
100 $this->active_management
101 && ($this->
access->canManageOwnReservations($this->ref_id) || $this->
access->canManageObjects($this->ref_id));
113 ->withParameter($action_token, self::
ACTION_ID)
121 return $record[
'has_user_active_booking'] ??
false;
130 return match ($this->
http->resolveRowParameter($action_type_token->getName())) {
143 array $selected_records,
144 bool $all_records_selected
147 $this->
lng->txt(
'book_confirm_cancel'),
148 $this->
lng->txt(
'book_confirm_cancel_info'),
149 $url_builder->buildURI()->__toString()
150 )->withAffectedItems(array_map(
152 (string) $record[
'reservation_id'],
153 $this->buildItemDescription($record)
156 ))->withActionButtonLabel($this->
lng->txt(
'book_set_cancel'));
165 $selected_records = $this->
http->resolveRowParameters($row_id_token->getName());
166 $all_records_selected = $selected_records === HttpService::ALL_OBJECTS;
167 if ($all_records_selected) {
168 $selected_records = array_map(
169 fn(array $record):
string =>
"{$record['object_id']}_{$record['date_from']}_{$record['date_to']}",
174 $this->
http->sendAsync(
175 $this->ui_renderer->renderAsync(
180 $all_records_selected
181 ? HttpService::ALL_OBJECTS
184 ->withParameter($action_token, self::ACTION_ID)
187 $all_records_selected
195 array $selected_records,
196 bool $all_records_selected
198 if (!$this->
access->canManageOwnReservations($this->ref_id)) {
199 $this->tpl->setOnScreenMessage(
201 $this->
lng->txt(
'no_permission'),
208 foreach ($selected_records as $record) {
211 $reservation->update();
215 if ($cancelled === 0) {
216 $this->tpl->setOnScreenMessage(
218 $this->
lng->txt(
'no_valid_selection'),
224 $this->tpl->setOnScreenMessage(
226 $this->
lng->txt(
'book_reservation_cancelled'),
237 $value = $this->
http->get(
239 $this->
refinery->custom()->transformation(
240 static function (mixed $raw): array {
241 if ($raw ===
null || $raw ===
'') {
245 if (is_array($raw)) {
246 return array_values(array_map(
'strval', $raw));
249 return [(string) $raw];
254 return array_values(array_filter($value,
static fn(
string $v):
bool => $v !==
''));
265 $titles[(
int) $item[
'booking_object_id']] = (
string) $item[
'title'];
268 if ($selected_ids ===
null) {
269 $selected_ids = array_map(
270 fn(array $record):
string =>
"{$record['object_id']}_{$record['date_from']}_{$record['date_to']}",
277 foreach ($selected_ids as $row_id) {
278 $row_id = (string) $row_id;
279 $parts = explode(
'_', $row_id);
281 if ($object_id <= 0 || !isset($titles[$object_id])) {
286 foreach ($reservations[
'data'] ?? [] as $reservation) {
287 if ((
int) $reservation[
'user_id'] !==
$user_id) {
295 $slot_from = (
int) $reservation[
'date_from'];
296 $slot_to = (
int) $reservation[
'date_to'];
297 if (count(
$parts) === 3) {
304 'reservation_id' => (
int) ($reservation[
'booking_reservation_id'] ?? $reservation[
'id'] ?? 0),
305 'object_id' => $object_id,
306 'title' => $titles[$object_id],
307 'slot_from' => $slot_from,
308 'slot_to' => $slot_to + 1,
309 'has_schedule' => count(
$parts) === 3,
310 'has_user_active_booking' =>
315 if (count(
$parts) === 3) {
326 if (!$record[
'has_schedule']) {
327 return $record[
'title'];
330 $this->
lng->loadLanguageModule(
'dateplaner');
336 return "{$record['title']} ({$period})";
const string SUBMIT_MODAL_ACTION
onSubmit(URLBuilder $url_builder, array $selected_records, bool $all_records_selected)
onExecute(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
resolveRowIds(string $key)
allowActionForRecord(mixed $record)
buildItemDescription(array $record)
const string ACTION_LABEL
__construct(private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly ilLanguage $lng, private readonly ilGlobalTemplateInterface $tpl, private readonly HttpService $http, private readonly Refinery $refinery, private readonly AccessManager $access, private readonly ilObjBookingPool $pool, private readonly ilObjUser $user, private readonly int $ref_id, private readonly bool $active_management, private readonly array $bookable_items,)
showModal(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
const string SHOW_MODAL_ACTION
getModal(URLBuilder $url_builder, array $selected_records, bool $all_records_selected)
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
resolveRecords(?array $selected_ids=null)
Builds a Color from either hex- or rgb values.
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
const int STATUS_CANCELLED
static getList(array $a_object_ids, int $a_limit=10, int $a_offset=0, array $filter=[])
List all reservations.
Class for date presentation.
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TYPE_NO_SCHEDULE_PREFERENCES
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const MESSAGE_TYPE_SUCCESS
const MESSAGE_TYPE_FAILURE
Interface InterruptiveItem.
This describes commonalities between the different modals.
An entity that renders components to a string output.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
showModal(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token,)
resolveRecords(?array $selected_ids=null)
readonly HttpService $http
readonly UIRenderer $ui_renderer
trait TableActionModalTrait
@template RecordType
const string SUBMIT_MODAL_ACTION
submit(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token,)
static http()
Fetches the global http state from ILIAS.
modal(string $title="", string $cancel_label="")
if(!file_exists('../ilias.ini.php'))