ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBookingInfoScreenAdapter.php
Go to the documentation of this file.
1<?php
2
24{
25 protected \ILIAS\BookingManager\InternalRepoService $repo;
27 protected ?int $context_obj_id;
29
30 public function __construct(
32 ) {
33 global $DIC;
34 $this->info_screen_gui = $info_screen_gui;
35 $this->context_obj_id = $this->info_screen_gui->getContextObjId();
36 $this->use_book_repo = new ilObjUseBookDBRepository($DIC->database());
37 $this->repo = $DIC->bookingManager()->internal()
38 ->repo();
39 }
40
45 protected function getPoolIds(): array
46 {
47 return array_map(static function ($ref_id) {
49 }, $this->use_book_repo->getUsedBookingPools($this->context_obj_id, false));
50 }
51
56 protected function getList(): array
57 {
58 $filter = ["context_obj_ids" => [$this->context_obj_id]];
59 $filter['past'] = true;
60 $filter['status'] = -ilBookingReservation::STATUS_CANCELLED;
61 $repo = $this->repo->reservation();
62 $list = $repo->getListByDate(true, null, $filter, $this->getPoolIds());
63 $list = ilArrayUtil::sortArray($list, "slot", "asc", true);
64 $list = ilArrayUtil::stableSortArray($list, "date", "asc", true);
65 $list = ilArrayUtil::stableSortArray($list, "pool_id", "asc", true);
66 return $list;
67 }
68
69
73 public function add(): void
74 {
76 $current_pool_id = 0;
77
78 foreach ($this->getList() as $item) {
79 // headings (pool title)
80 if ($current_pool_id != $item["pool_id"]) {
81 $info->addSection(ilObject::_lookupTitle($item["pool_id"]));
82 }
83 // booking object
84 $info->addProperty(
85 $item["title"] . " (" . $item["counter"] . ")",
86 ilDatePresentation::formatDate(new ilDate($item["date"], IL_CAL_DATE)) . ", " . $item["slot"]
87 );
88 $current_pool_id = $item["pool_id"];
89 }
90 }
91}
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)
ILIAS BookingManager InternalRepoService $repo
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
Class ilInfoScreenGUI.
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)
$info
Definition: entry_point.php:21
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26