ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBookingInfoScreenAdapter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
17
21 protected $context_obj_id;
22
26 protected $use_book_repo;
27
33 {
34 global $DIC;
35 $this->info_screen_gui = $info_screen_gui;
36 $this->context_obj_id = $this->info_screen_gui->getContextObjId();
37
38 $this->use_book_repo = new ilObjUseBookDBRepository($DIC->database());
39 }
40
46 protected function getPoolIds()
47 {
48 $pool_ids = array_map(function ($ref_id) {
49 return ilObject::_lookupObjId($ref_id);
50 }, $this->use_book_repo->getUsedBookingPools($this->context_obj_id));
51 return $pool_ids;
52 }
53
58 protected function getList() : array
59 {
60 $filter = ["context_obj_ids" => [$this->context_obj_id]];
61 $filter['past'] = true;
62 $filter['status'] = -ilBookingReservation::STATUS_CANCELLED;
64 $repo = $f->getRepo();
65 $list = $repo->getListByDate(true, null, $filter, $this->getPoolIds());
66 $list = ilUtil::sortArray($list, "slot", "asc", true);
67 $list = ilUtil::stableSortArray($list, "date", "asc", true);
68 $list = ilUtil::stableSortArray($list, "pool_id", "asc", true);
69 return $list;
70 }
71
72
76 public function add()
77 {
79 $current_pool_id = 0;
80
81 foreach ($this->getList() as $item) {
82 // headings (pool title)
83 if ($current_pool_id != $item["pool_id"]) {
84 $info->addSection(ilObject::_lookupTitle($item["pool_id"]));
85 }
86 // booking object
87 $info->addProperty(
88 $item["title"] . " (" . $item["counter"] . ")",
89 ilDatePresentation::formatDate(new ilDate($item["date"], IL_CAL_DATE)) . ", " . $item["slot"]
90 );
91 $current_pool_id = $item["pool_id"];
92 }
93 }
94}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
Embeds booking information into info screen.
__construct(ilInfoScreenGUI $info_screen_gui)
Constructor.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
Class ilInfoScreenGUI.
This repo stores infos on repository objects that are using booking managers as a service (resource m...
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static stableSortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
global $DIC
Definition: goto.php:24