19declare(strict_types=1);
84 protected readonly UIFactory $ui_factory,
95 protected readonly
Settings $settings,
98 $this->booking_items = array_column(
106 !$this->
access->canManageAllReservations($this->booking_pool->getRefId())
107 && !$this->access->canReadPublicLog($this->booking_pool->getRefId())
109 $filter[
'user_id'] = $this->
user->getId();
111 $this->bookings = array_column(
114 'booking_reservation_id'
117 $this->participants = array_column(
123 foreach ([
'dateplaner',
'tbl'] as $module) {
124 $this->
lng->loadLanguageModule($module);
127 $this->column_factory = $this->ui_factory->table()->column();
128 $this->input_factory = $this->ui_factory->input()->field();
143 array $visible_column_ids,
146 mixed $additional_viewcontrol_data,
148 mixed $additional_parameters
157 if (!$filter_data instanceof
Filter) {
163 foreach ($this->ui_service->filter()->getData($filter_data) ?? [] as $key => $filter_data_value) {
164 if ($filter_data_value ===
null || $filter_data_value ===
'') {
169 'object' =>
static fn(array
$bookings): array => array_filter(
171 static fn(array $booking):
bool => (
int) $booking[
'object_id'] === (
int) $filter_data_value
173 'object_title_or_description' =>
static fn(array
$bookings): array => array_filter(
175 static function (array $booking) use ($filter_data_value):
bool {
176 $filter_data_value = strtolower($filter_data_value);
178 str_contains(strtolower($booking[
'title']), $filter_data_value)
179 || str_contains(strtolower($booking[
'message']), $filter_data_value);
182 'period' =>
function (array
$bookings) use ($filter_data_value): array {
184 if ($bounds ===
null) {
188 [$period_from, $period_to] = $bounds;
191 static fn(array $booking):
bool =>
192 $booking[
'date_from'] >= $period_from && $booking[
'date_to'] <= $period_to
195 'time_slot' => fn(array
$bookings): array => array_filter(
199 'past_bookings' =>
static function (array
$bookings) use ($filter_data_value): array {
200 $now =
new DateTimeImmutable();
203 static fn(array $booking):
bool => (
int) $filter_data_value === 1
204 ?
new DateTimeImmutable(
"@{$booking['date_to']}") < $now
205 :
new DateTimeImmutable(
"@{$booking['date_to']}") >= $now
208 'status' =>
static fn(array
$bookings): array => array_filter(
210 static fn(array $booking):
bool => match ((
int) $filter_data_value) {
218 'user' =>
static fn(array
$bookings): array => array_filter(
220 static fn(array $booking):
bool => (
int) $booking[
'user_id'] === (
int) $filter_data_value
231 $order_data = $order->
get();
232 if ($order_data === []) {
237 foreach ($order_data as $key => $value) {
238 $order_direction = $value ===
Order::DESC ? -1 : 1;
239 $callable = match ($key) {
240 'title' =>
static fn(array $record_a, array $record_b):
int => strcasecmp(
243 ) * $order_direction,
244 'status' =>
static fn(array $record_a, array $record_b):
int =>
245 ($record_a[
'status'] <=> $record_b[
'status']) * $order_direction,
246 'date' =>
static fn(array $record_a, array $record_b):
int =>
247 ($record_a[
'date_from'] <=> $record_b[
'date_from']) * $order_direction,
248 'week' =>
static function (array $record_a, array $record_b) use ($order_direction):
int {
249 $week_a = (
int) (
new DateTimeImmutable(
"@{$record_a['date_from']}"))->format(
'W');
250 $week_b = (
int) (
new DateTimeImmutable(
"@{$record_b['date_from']}"))->format(
'W');
251 return ($week_a <=> $week_b) * $order_direction;
253 'weekday' =>
static function (array $record_a, array $record_b) use ($order_direction):
int {
254 $week_a = (
int) (
new DateTimeImmutable(
"@{$record_a['date_from']}"))->format(
'N');
255 $week_b = (
int) (
new DateTimeImmutable(
"@{$record_b['date_from']}"))->format(
'N');
256 return ($week_a <=> $week_b) * $order_direction;
258 'time_slot' =>
function (array $record_a, array $record_b) use ($order_direction):
int {
262 ) * $order_direction;
264 'unit_count' =>
static fn(array $record_a, array $record_b):
int => 0 * $order_direction,
265 'message' =>
static fn(array $record_a, array $record_b):
int => strcasecmp(
266 (
string) ($record_a[
'message'] ??
''),
267 (
string) ($record_b[
'message'] ??
'')
268 ) * $order_direction,
269 'user' =>
function (array $record_a, array $record_b) use (&$users, $order_direction):
int {
270 $user_a = $record_a[
'user_id'];
271 $user_b = $record_b[
'user_id'];
274 return strcasecmp($user_a, $user_b) * $order_direction;
279 if ($callable ===
null) {
283 usort($records, $callable);
300 if ($filter_inputs === []) {
304 return $this->ui_service->filter()->standard(
305 "{$this->getTableId()}_filter",
306 $this->
ctrl->getLinkTargetByClass(ilBookingReservationsGUI::class),
308 array_fill(0, count($filter_inputs),
true),
316 $query_params = $this->
http->getRequest()->getQueryParams();
319 $this->
access->canManageAllReservations($this->booking_pool->getRefId())
320 || $this->access->canReadPublicLog($this->booking_pool->getRefId())
322 $user_id = $query_params[
'user_id'] ??
null;
324 $filter_inputs[
'user'] = $filter_inputs[
'user']->withValue((
int)
$user_id);
326 } elseif ($this->
access->canManageOwnReservations($this->booking_pool->getRefId())) {
327 $filter_inputs[
'user'] = $filter_inputs[
'user']->withValue($this->
user->getId());
330 $object_id = $query_params[
'object_id'] ??
null;
331 if (is_numeric($object_id)) {
332 $filter_inputs[
'object'] = $filter_inputs[
'object']->withValue((
int) $object_id);
335 if ($this->
settings->getReservationPeriod() > 0) {
336 $filter_inputs[
'period'] = $filter_inputs[
'period']->withValue(
338 new DateTimeImmutable(
'today 00:00:00'),
339 new DateTimeImmutable(
"today +{$this->settings->getReservationPeriod()} days 23:59:59")
344 $period_from = $query_params[
'period_from'] ??
null;
345 $period_to = $query_params[
'period_to'] ??
null;
346 if (is_numeric($period_from) && is_numeric($period_to)) {
347 $filter_inputs[
'period'] = $filter_inputs[
'period']->withValue(
349 new DateTimeImmutable(
"@{$period_from}"),
350 new DateTimeImmutable(
"@{$period_to}")
358 return $filter_inputs;
362 mixed $additional_viewcontrol_data,
364 mixed $additional_parameters
366 return count($this->bookings);
371 $filter = $this->getFilter();
372 $table = $this->getTable($url_builder)->withFilter($filter);
373 return array_filter([$filter, $table, $this->ui_factory->divider()->horizontal(), $this->getExportDropdown()]);
379 [$this->getTableId()],
380 self::ROW_ID_PARAMETER,
381 self::ACTION_PARAMETER,
382 self::ACTION_TYPE_PARAMETER
389 $this->ui_factory->table()->data(
391 $this->
lng->txt(
'bookings'),
395 ->withRequest($this->
http->getRequest())
396 ->withId($this->getTableId());
401 $parameter =
"bkrsv{$this->booking_pool->getRefId()}_xpt";
405 foreach ($export_formats as $format => $caption_lng_id) {
406 $this->
ctrl->setParameterByClass(ilBookingReservationsGUI::class, $parameter, $format);
407 $actions[] = $this->ui_factory->link()->standard(
408 $this->
lng->txt($caption_lng_id),
409 $this->ctrl->getLinkTargetByClass(
410 ilBookingReservationsGUI::class,
414 $this->
ctrl->setParameterByClass(ilBookingReservationsGUI::class, $parameter,
null);
417 return $this->ui_factory->dropdown()->standard($actions)->withLabel($this->
lng->txt(
'export'));
430 fn(array $participant):
string => $this->getUserPresentationName($participant[
'user_id']),
457 $this->reservation_repository,
460 ))->getTableActions();
465 $user_name = $this->getUserPresentationName(
$user_id);
467 return $this->ui_factory->link()->standard($user_name,
'')->withDisabled(
true);
470 $this->
ctrl->setParameterByClass(PublicProfileGUI::class,
'user_id',
$user_id);
472 return $this->ui_factory->link()->standard(
474 $this->
ctrl->getLinkTargetByClass(
475 [ilPublicProfileBaseClassGUI::class, PublicProfileGUI::class],
487 $from = $this->parseBookingPeriodValue($period[0] ??
null);
488 $to = $this->parseBookingPeriodValue($period[1] ??
null);
490 if ($from ===
null && $to ===
null) {
495 $from ?? PHP_INT_MIN,
506 if ($value instanceof DateTimeImmutable) {
507 return $value->getTimestamp();
511 return (
new DateTimeImmutable((
string) $value))->getTimestamp();
512 }
catch (Throwable) {
519 $date_from =
new DateTimeImmutable(
"@{$booking['date_from']}");
520 $date_to =
new DateTimeImmutable(
'@' . ((
int) $booking[
'date_to'] + 1));
522 return "{$date_from->format('H:i')} - {$date_to->format('H:i')}";
readonly array $participants
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...
readonly ColumnFactory $column_factory
getUserPresentationName(int $user_id)
const ACTION_TYPE_PARAMETER
getTable(URLBuilder $url_builder)
loadRecords(mixed $filter_data)
sortRecords(Order $order, array $records)
getComponents(URLBuilder $url_builder)
acquireParameters(URLBuilder $url_builder)
readonly array $booking_items
limitRecords(Range $range, array $records)
readonly InputFactory $input_factory
parseBookingPeriodValue(mixed $value)
presetFilterInputs(array $filter_inputs)
getUserComponent(int $user_id)
getUsers(?int $user_id=null)
getBookingTimeSlotFilterLabel(array $booking)
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....
__construct(protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly AccessManager $access, protected readonly ilGlobalTemplateInterface $tpl, protected readonly Refinery $refinery, protected readonly Language $lng, protected readonly HttpService $http, protected readonly ilObjUser $user, protected readonly ReservationDBRepository $reservation_repository, protected readonly ilCtrlInterface $ctrl, protected readonly ilUIService $ui_service, protected readonly Settings $settings, protected readonly ilObjBookingPool $booking_pool)
resolveBookingPeriodBounds(mixed $period)
Repo class for reservations Acts on tables booking_reservation (rw), booking_reservation_group (rw) a...
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
acquireParameters(array $namespace, string ... $names)
GUI class for public user profile presentation.
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...
static getList(int $a_booking_pool, ?array $a_filter=null, ?int $a_object_id=null)
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class is just a connector as base classes cannot be namespaced.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static hasPublicProfile(int $a_user_id)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes a Standard Dropdown.
This describes a Data Table.
withActions(array $actions)
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait TableActionExecutorTrait
readonly HttpService $http
readonly UIRenderer $ui_renderer
static http()
Fetches the global http state from ILIAS.