ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBookingAssignObjectsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
17  protected $access;
18 
22  protected $user;
23 
27  protected $ref_id;
28 
32  protected $pool_id;
33 
37  protected $user_id_to_book;
38 
42  //protected $bp_object;
43 
47  protected $current_bookings; // [int]
48 
52  protected $filter; // [array]
53 
57  protected $objects; // array
58 
62  protected $pool;
63 
72  public function __construct(ilBookingParticipantGUI $a_parent_obj, $a_parent_cmd, $a_ref_id, $a_pool_id)
73  {
74  global $DIC;
75 
76  $this->ctrl = $DIC->ctrl();
77  $this->lng = $DIC->language();
78  $this->user = $DIC->user();
79  $this->access = $DIC->access();
80  $this->ref_id = $a_ref_id;
81 
82  $this->pool_id = $a_pool_id;
83  $this->pool = new ilObjBookingPool($this->pool_id, false);
84 
85  if ($_GET['bkusr']) {
86  $this->user_id_to_book = (int) $_GET['bkusr'];
87  if (!ilObjUser::_exists($this->user_id_to_book)) {
88  $this->ctrl->redirect($a_parent_obj, $a_parent_cmd);
89  }
90  $user_name_data = ilObjUser::_lookupName($this->user_id_to_book);
91  $user_name = $user_name_data['lastname'] . ", " . $user_name_data['firstname'];
92  } else {
93  $this->ctrl->redirect($a_parent_obj, 'render');
94  }
95 
96  $this->setId("bkaobj" . $a_ref_id);
97 
98  parent::__construct($a_parent_obj, $a_parent_cmd);
99 
100  $this->setTitle($this->lng->txt("book_assign_object") . ": " . $user_name);
101 
102  $this->addColumn($this->lng->txt("title"), "title");
103  $this->addColumn($this->lng->txt("description"));
104  if ($this->pool->getScheduleType() != ilObjBookingPool::TYPE_FIX_SCHEDULE) {
105  $this->addColumn($this->lng->txt("available"));
106  }
107  $this->addColumn($this->lng->txt("action"));
108 
109  //Fix this order field
110  //$this->setDefaultOrderField("title");
111  //$this->setDefaultOrderDirection("asc");
112 
113  $this->setEnableHeader(true);
114  //$this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
115  $this->setRowTemplate("tpl.booking_assign_object_row.html", "Modules/BookingManager");
116 
117  $this->getItems();
118  }
119 
124  public function getItems()
125  {
126  $data = array();
127  $obj_items = ilBookingObject::getList($this->pool_id);
128  foreach ($obj_items as $item) {
129  if ($this->pool->getScheduleType() == ilObjBookingPool::TYPE_FIX_SCHEDULE ||
130  empty(ilBookingReservation::getObjectReservationForUser($item['booking_object_id'], $this->user_id_to_book))) {
131  $this->ctrl->setParameterByClass('ilbookingobjectgui', 'bkusr', $this->user_id_to_book);
132  $this->ctrl->setParameterByClass('ilbookingobjectgui', 'object_id', $item['booking_object_id']);
133  $this->ctrl->setParameterByClass('ilbookingobjectgui', 'part_view', ilBookingParticipantGUI::PARTICIPANT_VIEW);
134  $data[] = array(
135  'object_id' => $item['booking_object_id'],
136  'title' => $item['title'],
137  'description' => $item['description'],
138  'nr_items' => ilBookingReservation::numAvailableFromObjectNoSchedule($item['booking_object_id']) . '/' . $item['nr_items'],
139  'url_assign' => $this->ctrl->getLinkTargetByClass("ilbookingobjectgui", 'book')
140  );
141  $this->ctrl->setParameterByClass('ilbookingobjectgui', 'bkusr', '');
142  $this->ctrl->setParameterByClass('ilbookingobjectgui', 'object_id', '');
143  $this->ctrl->setParameterByClass('ilbookingobjectgui', 'part_view', '');
144  }
145  }
146  $this->setData($data);
147  }
148 
153  protected function fillRow($a_set)
154  {
155  if ($this->pool->getScheduleType() != ilObjBookingPool::TYPE_FIX_SCHEDULE) {
156  $this->tpl->setCurrentBlock("available");
157  $this->tpl->setVariable("TXT_AVAILABLE", $a_set['nr_items']);
158  $this->tpl->parseCurrentBlock();
159  }
160  $this->tpl->setVariable("TXT_TITLE", $a_set['title']);
161  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set['description']);
162  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("book_assign"));
163  $this->tpl->setVariable("URL_ACTION", $a_set['url_assign']);
164  }
165 }
static _lookupName($a_user_id)
lookup user name
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
__construct(ilBookingParticipantGUI $a_parent_obj, $a_parent_cmd, $a_ref_id, $a_pool_id)
Constructor.
global $DIC
Definition: saml.php:7
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
List objects / booking pool assignment.
Class ilObjBookingPool.
setId($a_val)
Set id.
user()
Definition: user.php:4
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilBookingParticipantGUI.
Class ilTable2GUI.
static getObjectReservationForUser($a_object_id, $a_user_id, $a_multi=false)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
static numAvailableFromObjectNoSchedule($a_obj_id)
setEnableHeader($a_enableheader)
Set Enable Header.