4 include_once(
"./Services/Table/classes/class.ilTable2GUI.php");
33 function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_pool_id, $a_pool_has_schedule, $a_pool_overall_limit)
37 $this->ref_id = $a_ref_id;
38 $this->pool_id = $a_pool_id;
39 $this->has_schedule = $a_pool_has_schedule;
40 $this->overall_limit = $a_pool_overall_limit;
41 $this->may_edit = $ilAccess->checkAccess(
'write',
'', $this->ref_id);
43 $this->
setId(
"bkobj");
47 $this->
setTitle($lng->txt(
"book_objects_list"));
51 $this->
addColumn($this->lng->txt(
"title"),
"title");
52 $this->
addColumn($this->lng->txt(
"description"),
"description");
54 if(!$this->has_schedule)
56 $this->
addColumn($this->lng->txt(
"available"));
59 $this->
addColumn($this->lng->txt(
"actions"));
62 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
63 $this->
setRowTemplate(
"tpl.booking_object_row.html",
"Modules/BookingManager");
75 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
78 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
79 foreach(
$data as $item)
81 $item_id = $item[
"booking_object_id"];
83 $this->reservations[$item_id] = $item_rsv[
"data"];
86 if(!$this->has_schedule &&
89 $this->current_bookings = 0;
90 foreach($this->reservations as $obj_rsv)
92 foreach($obj_rsv as $item)
96 if($item[
"user_id"] == $ilUser->getId())
98 $this->current_bookings++;
104 if($this->current_bookings >= $this->overall_limit)
122 $has_booking =
false;
123 $booking_possible =
true;
124 $has_reservations =
false;
126 $this->tpl->setVariable(
"TXT_TITLE", $a_set[
"title"]);
127 $this->tpl->setVariable(
"TXT_DESC", nl2br($a_set[
"description"]));
129 if(!$this->has_schedule)
132 foreach($this->reservations[$a_set[
"booking_object_id"]] as $item)
138 if($item[
"user_id"] == $ilUser->getId())
143 $has_reservations =
true;
147 $this->tpl->setVariable(
"VALUE_AVAIL", $a_set[
"nr_items"]-$cnt);
148 $this->tpl->setVariable(
"VALUE_AVAIL_ALL", $a_set[
"nr_items"]);
150 if($a_set[
"nr_items"] <= $cnt || $has_booking
151 || ($this->overall_limit && $this->current_bookings && $this->current_bookings >= $this->overall_limit))
153 $booking_possible =
false;
156 else if(!$this->may_edit)
158 foreach($this->reservations[$a_set[
"booking_object_id"]] as $item)
161 $item[
"user_id"] == $ilUser->getId())
170 $ilCtrl->setParameter($this->parent_obj,
'object_id', $a_set[
'booking_object_id']);
172 if($booking_possible)
174 $items[
'book'] = array($lng->txt(
'book_book'), $ilCtrl->getLinkTarget($this->parent_obj,
'book'));
178 if(!$this->has_schedule && $has_booking)
180 if(trim($a_set[
'post_text']) || $a_set[
'post_file'])
182 $items[
'post'] = array($lng->txt(
'book_post_booking_information'), $ilCtrl->getLinkTarget($this->parent_obj,
'displayPostInfo'));
185 $items[
'cancel'] = array($lng->txt(
'book_set_cancel'), $ilCtrl->getLinkTarget($this->parent_obj,
'rsvConfirmCancelUser'));
188 if($this->may_edit || $has_booking)
190 $ilCtrl->setParameterByClass(
'ilObjBookingPoolGUI',
'object_id', $a_set[
'booking_object_id']);
191 $items[
'log'] = array($lng->txt(
'book_log'), $ilCtrl->getLinkTargetByClass(
'ilObjBookingPoolGUI',
'log'));
192 $ilCtrl->setParameterByClass(
'ilObjBookingPoolGUI',
'object_id',
'');
195 if($a_set[
'info_file'])
197 $items[
'info'] = array($lng->txt(
'book_download_info'), $ilCtrl->getLinkTarget($this->parent_obj,
'deliverInfo'));
202 $items[
'edit'] = array($lng->txt(
'edit'), $ilCtrl->getLinkTarget($this->parent_obj,
'edit'));
205 if(!$has_reservations)
207 $items[
'delete'] = array($lng->txt(
'delete'), $ilCtrl->getLinkTarget($this->parent_obj,
'confirmDelete'));
213 $this->tpl->setCurrentBlock(
"actions");
214 foreach($items as $item)
216 $this->tpl->setVariable(
"ACTION_CAPTION", $item[0]);
217 $this->tpl->setVariable(
"ACTION_LINK", $item[1]);
218 $this->tpl->parseCurrentBlock();