ILIAS  release_8 Revision v8.24
class.ilBookingInfoScreenAdapter.php
Go to the documentation of this file.
1<?php
2
24{
26 protected ?int $context_obj_id;
28
29 public function __construct(
31 ) {
32 global $DIC;
33 $this->info_screen_gui = $info_screen_gui;
34 $this->context_obj_id = $this->info_screen_gui->getContextObjId();
35
36 $this->use_book_repo = new ilObjUseBookDBRepository($DIC->database());
37 }
38
43 protected function getPoolIds(): array
44 {
45 return array_map(static function ($ref_id) {
47 }, $this->use_book_repo->getUsedBookingPools($this->context_obj_id, false));
48 }
49
54 protected function getList(): array
55 {
56 $filter = ["context_obj_ids" => [$this->context_obj_id]];
57 $filter['past'] = true;
58 $filter['status'] = -ilBookingReservation::STATUS_CANCELLED;
60 $repo = $f->getRepo();
61 $list = $repo->getListByDate(true, null, $filter, $this->getPoolIds());
62 $list = ilArrayUtil::sortArray($list, "slot", "asc", true);
63 $list = ilArrayUtil::stableSortArray($list, "date", "asc", true);
64 $list = ilArrayUtil::stableSortArray($list, "pool_id", "asc", true);
65 return $list;
66 }
67
68
72 public function add(): void
73 {
75 $current_pool_id = 0;
76
77 foreach ($this->getList() as $item) {
78 // headings (pool title)
79 if ($current_pool_id != $item["pool_id"]) {
80 $info->addSection(ilObject::_lookupTitle($item["pool_id"]));
81 }
82 // booking object
83 $info->addProperty(
84 $item["title"] . " (" . $item["counter"] . ")",
85 ilDatePresentation::formatDate(new ilDate($item["date"], IL_CAL_DATE)) . ", " . $item["slot"]
86 );
87 $current_pool_id = $item["pool_id"];
88 }
89 }
90}
const IL_CAL_DATE
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilInfoScreenGUI $info_screen_gui)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
Class for single dates.
Class ilInfoScreenGUI.
addSection(string $a_title)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67