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