19declare(strict_types=1);
72 protected readonly UIFactory $ui_factory,
83 protected readonly
Settings $settings,
86 protected readonly
bool $active_management,
87 protected readonly
int $booking_context_obj_id,
105 $this->
user->getId(),
109 if ($this->pool->getOverallLimit() <= $booking_count) {
110 $components[] = $this->ui_factory->messageBox()->info($this->
lng->txt(
'book_overall_limit_warning'));
115 $filter_data = $this->ui_service->filter()->getData($filter);
119 $this->
lng->txt(
'book_booking_objects'),
123 ->withRequest($this->
http->getRequest())
125 ->withFilter($filter_data)
132 mixed $additional_viewcontrol_data,
134 mixed $additional_parameters
141 array $visible_column_ids,
144 mixed $additional_viewcontrol_data,
146 mixed $additional_parameters
148 $records = $this->limitRecords(
$range, $this->sortRecords($order, $this->loadRecords($filter_data)));
150 foreach ($records as $record) {
152 $row_builder->
buildDataRow((
string) $record[
'row_id'], $this->buildRowCells($record)),
171 abstract protected function loadRecords(mixed $filter_data): array;
184 $order_data = $order->
get();
185 if ($order_data === []) {
189 foreach ($order_data as $key => $direction) {
190 $order_direction = $direction === Order::DESC ? -1 : 1;
191 $callable = $this->getSortCallable($key, $order_direction);
193 if ($callable ===
null) {
197 usort($records, $callable);
205 return match ($key) {
206 'availability' =>
static fn(array
$a, array
$b):
int
207 => ((
int)
$a[
'available'] <=> (
int)
$b[
'available']) * $direction,
208 'title' =>
static fn(array
$a, array
$b):
int
209 => strcasecmp((
string)
$a[
'title'], (
string)
$b[
'title']) * $direction,
210 'description' =>
static fn(array
$a, array
$b):
int
211 => strcasecmp((
string)
$a[
'description'], (
string)
$b[
'description']) * $direction,
227 $filter_inputs = $this->getFilterInputs();
229 $filter_inputs = $this->presetFilterInputs($filter_inputs);
231 return $this->ui_service->filter()->standard(
232 "bookable_item_filter_{$this->pool->getId()}",
233 $this->
ctrl->getLinkTargetByClass(ilBookingObjectGUI::class),
235 array_fill(0, count($filter_inputs),
true),
243 if ($this->
settings->getReservationPeriod() > 0) {
244 $filter_inputs[
'period'] = $filter_inputs[
'period']->withValue(
246 new DateTimeImmutable(
'today 00:00:00'),
247 new DateTimeImmutable(
"today +{$this->settings->getReservationPeriod()} days 23:59:59")
252 return $filter_inputs;
261 [$this->getTableId()],
262 self::ROW_ID_PARAMETER,
263 self::ACTION_PARAMETER,
264 self::ACTION_TYPE_PARAMETER
280 $this->process_manager,
283 $this->active_management,
284 $this->booking_context_obj_id,
285 array_column($this->loadRecords([]),
null,
'row_id'),
293 ?
string $title_filter,
294 ?
string $description_filter,
295 ?array $object_ids_filter
298 $title_filter = mb_strtolower($title_filter ??
'') ?:
null;
299 $description_filter = mb_strtolower($description_filter ??
'') ?:
null;
300 $object_ids_filter = $object_ids_filter ?:
null;
303 foreach ($items as $item) {
304 $object_id = (
int) $item[
'booking_object_id'];
306 if ($object_ids_filter !==
null && !in_array($object_id, $object_ids_filter,
true)) {
310 if ($title_filter !==
null && !str_contains(mb_strtolower((
string) $item[
'title']), $title_filter)) {
314 if ($description_filter !==
null && !str_contains(mb_strtolower((
string) ($item[
'description'] ??
'')), $description_filter)) {
329 if (isset($this->reservation_cache[$booking_object_id])) {
330 return $this->reservation_cache[$booking_object_id];
334 $this->reservation_cache[$booking_object_id] = array_values(array_map(
335 static fn(array $row): array => [
336 'user_id' => (
int) $row[
'user_id'],
337 'status' => isset($row[
'status']) ? (
int) $row[
'status'] :
null,
338 'date_from' => (
int) $row[
'date_from'],
339 'date_to' => (
int) $row[
'date_to'],
344 return $this->reservation_cache[$booking_object_id];
349 $icon = $this->ui_factory->symbol()->icon()->custom(
351 $this->
lng->txt($available > 0 ?
'book_book' :
'book_no_objects')
353 return "{$this->ui_renderer->render($icon)} ({$available} / {$total})";
loadFilteredBookingObjects(?string $title_filter, ?string $description_filter, ?array $object_ids_filter)
__construct(protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly ilLanguage $lng, protected readonly HttpService $http, protected readonly ilUIService $ui_service, protected readonly ilCtrlInterface $ctrl, protected readonly ilGlobalTemplateInterface $tpl, protected readonly Refinery $refinery, protected readonly AccessManager $access, protected readonly ilObjBookingPool $pool, protected readonly BookingProcessManager $process_manager, protected readonly Settings $settings, protected readonly ilObjUser $user, protected readonly int $ref_id, protected readonly bool $active_management, protected readonly int $booking_context_obj_id,)
getSortCallable(string $key, int $direction)
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....
acquireParameters(URLBuilder $url_builder)
TableActions $table_actions
presetFilterInputs(array $filter_inputs)
buildAvailabilityCell(int $available, int $total)
getComponents(URLBuilder $url_builder)
const string ROW_ID_PARAMETER
loadRecords(mixed $filter_data)
getReservationsForObject(int $booking_object_id)
buildRowCells(array $record)
const string ACTION_TYPE_PARAMETER
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...
sortRecords(Order $order, array $records)
const string ACTION_PARAMETER
limitRecords(Range $range, array $records)
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)
@ilCtrl_Calls ilBookingObjectGUI: ilPropertyFormGUI, ilBookingProcessWithScheduleGUI,...
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 isBookingPoolLimitReachedByUser(int $a_user_id, int $a_pool_id)
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...
Util class various functions, usage as namespace.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A component is the most general form of an entity in the UI.
A Column describes the form of presentation for a certain aspect of data, i.e.
buildDataRow(string $id, array $record)
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.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples