ILIAS  release_8 Revision v8.24
class.ilBookingAssignObjectsTableGUI.php
Go to the documentation of this file.
1<?php
2
24{
25 protected \ILIAS\BookingManager\StandardGUIRequest $book_request;
27 protected ilObjUser $user;
28 protected int $ref_id;
29 protected int $pool_id;
30 protected int $user_id_to_book;
31 protected int $current_bookings;
32 protected array $filter;
33 protected array $objects;
35
36 public function __construct(
37 ilBookingParticipantGUI $a_parent_obj,
38 string $a_parent_cmd,
39 int $a_ref_id,
40 int $a_pool_id
41 ) {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $this->user = $DIC->user();
47 $this->access = $DIC->access();
48 $this->ref_id = $a_ref_id;
49 $this->book_request = $DIC->bookingManager()
50 ->internal()
51 ->gui()
52 ->standardRequest();
53
54 $this->pool_id = $a_pool_id;
55 $this->pool = new ilObjBookingPool($this->pool_id, false);
56
57 $user_name = "";
58 if ($this->book_request->getBookedUser() > 0) {
59 $this->user_id_to_book = $this->book_request->getBookedUser();
60 if (!ilObjUser::_exists($this->user_id_to_book)) {
61 $this->ctrl->redirect($a_parent_obj, $a_parent_cmd);
62 }
63 $user_name_data = ilObjUser::_lookupName($this->user_id_to_book);
64 $user_name = $user_name_data['lastname'] . ", " . $user_name_data['firstname'];
65 } else {
66 $this->ctrl->redirect($a_parent_obj, 'render');
67 }
68
69 $this->setId("bkaobj" . $a_ref_id);
70
71 parent::__construct($a_parent_obj, $a_parent_cmd);
72
73 $this->setTitle($this->lng->txt("book_assign_object") . ": " . $user_name);
74
75 $this->addColumn($this->lng->txt("title"), "title");
76 $this->addColumn($this->lng->txt("description"));
77 if ($this->pool->getScheduleType() !== ilObjBookingPool::TYPE_FIX_SCHEDULE) {
78 $this->addColumn($this->lng->txt("available"));
79 }
80 $this->addColumn($this->lng->txt("action"));
81
82 //Fix this order field
83 //$this->setDefaultOrderField("title");
84 //$this->setDefaultOrderDirection("asc");
85
86 $this->setEnableHeader(true);
87 //$this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
88 $this->setRowTemplate("tpl.booking_assign_object_row.html", "Modules/BookingManager");
89
90 $this->getItems();
91 }
92
93 public function getItems(): void
94 {
95 $data = array();
96 $obj_items = ilBookingObject::getList($this->pool_id);
97 foreach ($obj_items as $item) {
98 if ($this->pool->getScheduleType() === ilObjBookingPool::TYPE_FIX_SCHEDULE ||
99 count(ilBookingReservation::getObjectReservationForUser($item['booking_object_id'], $this->user_id_to_book)) === 0) {
100 $this->ctrl->setParameterByClass('ilbookingobjectgui', 'bkusr', $this->user_id_to_book);
101 $this->ctrl->setParameterByClass('ilbookingobjectgui', 'object_id', $item['booking_object_id']);
102 $this->ctrl->setParameterByClass('ilbookingobjectgui', 'part_view', ilBookingParticipantGUI::PARTICIPANT_VIEW);
103 $data[] = array(
104 'object_id' => $item['booking_object_id'],
105 'title' => $item['title'],
106 'description' => $item['description'],
107 'nr_items' => ilBookingReservation::numAvailableFromObjectNoSchedule($item['booking_object_id']) . '/' . $item['nr_items'],
108 'url_assign' => $this->ctrl->getLinkTargetByClass(["ilbookingobjectgui", "ilbookingprocessgui"], 'book')
109 );
110 $this->ctrl->setParameterByClass('ilbookingobjectgui', 'bkusr', '');
111 $this->ctrl->setParameterByClass('ilbookingobjectgui', 'object_id', '');
112 $this->ctrl->setParameterByClass('ilbookingobjectgui', 'part_view', '');
113 }
114 }
115 $this->setData($data);
116 }
117
118 protected function fillRow(array $a_set): void
119 {
120 if ($this->pool->getScheduleType() !== ilObjBookingPool::TYPE_FIX_SCHEDULE) {
121 $this->tpl->setCurrentBlock("available");
122 $this->tpl->setVariable("TXT_AVAILABLE", $a_set['nr_items']);
123 $this->tpl->parseCurrentBlock();
124 }
125 $this->tpl->setVariable("TXT_TITLE", $a_set['title']);
126 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set['description']);
127 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("book_assign"));
128 $this->tpl->setVariable("URL_ACTION", $a_set['url_assign']);
129 }
130}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRow(array $a_set)
Standard Version of Fill Row.
ILIAS BookingManager StandardGUIRequest $book_request
__construct(ilBookingParticipantGUI $a_parent_obj, string $a_parent_cmd, int $a_ref_id, int $a_pool_id)
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 getObjectReservationForUser(int $a_object_id, int $a_user_id)
static numAvailableFromObjectNoSchedule(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static _lookupName(int $a_user_id)
lookup user name
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc