ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBookingObjectsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
23  function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_type_id)
24  {
25  global $ilCtrl, $lng, $ilAccess, $lng, $ilObjDataCache;
26 
27  $this->ref_id = $a_ref_id;
28  $this->type_id = $a_type_id;
29  $this->setId("bkobj");
30 
31  parent::__construct($a_parent_obj, $a_parent_cmd);
32 
33  include_once 'Modules/BookingManager/classes/class.ilBookingType.php';
34  $type = new ilBookingType($this->type_id);
35  $this->setTitle($lng->txt("book_objects_list").$type->getTitle());
36 
37  $this->setLimit(9999);
38 
39  $this->addColumn($this->lng->txt("title"), "title");
40 
41  if ($ilAccess->checkAccess('write', '', $this->ref_id))
42  {
43  $this->addColumn($this->lng->txt("status"));
44  $this->addColumn($this->lng->txt("book_current_user"));
45  $this->addColumn($this->lng->txt("book_period"));
46  }
47 
48  $this->addColumn($this->lng->txt("actions"));
49 
50  $this->setEnableHeader(true);
51  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
52  $this->setRowTemplate("tpl.booking_object_row.html", "Modules/BookingManager");
53 
54  $this->getItems($this->type_id);
55  }
56 
61  function getItems($a_type_id)
62  {
63  global $lng;
64 
65  include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
66  $data = ilBookingObject::getList($a_type_id);
67 
68  $this->setMaxCount(sizeof($data));
69  $this->setData($data);
70  }
71 
76  protected function fillRow($a_set)
77  {
78  global $lng, $ilAccess, $ilCtrl;
79 
80  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
81 
82  if ($ilAccess->checkAccess('write', '', $this->ref_id))
83  {
84  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
85  $reservation = ilBookingReservation::getCurrentOrUpcomingReservation($a_set['booking_object_id']);
86  }
87 
88  if ($ilAccess->checkAccess('write', '', $this->ref_id))
89  {
90  $this->tpl->setCurrentBlock('details');
91 
92  if($reservation)
93  {
94  $date_from = new ilDateTime($reservation['date_from'], IL_CAL_UNIX);
95  $date_to = new ilDateTime($reservation['date_to'], IL_CAL_UNIX);
96 
97  if(in_array($reservation['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE)))
98  {
99  $this->tpl->setVariable("TXT_STATUS", $lng->txt('book_reservation_status_'.$reservation['status']));
100  }
101  $this->tpl->setVariable("TXT_CURRENT_USER", ilObjUser::_lookupFullName($reservation['user_id']));
102  $this->tpl->setVariable("VALUE_DATE", ilDatePresentation::formatPeriod($date_from, $date_to));
103  }
104  else
105  {
106  $this->tpl->setVariable("TXT_STATUS", "");
107  $this->tpl->setVariable("TXT_CURRENT_USER", "");
108  $this->tpl->setVariable("VALUE_DATE", "");
109  }
110 
111  $this->tpl->parseCurrentBlock();
112  }
113 
114  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
115  $alist = new ilAdvancedSelectionListGUI();
116  $alist->setId($a_set['booking_object_id']);
117  $alist->setListTitle($lng->txt("actions"));
118 
119  $ilCtrl->setParameter($this->parent_obj, 'object_id', $a_set['booking_object_id']);
120 
121  if ($a_set["schedule_id"])
122  {
123  $alist->addItem($lng->txt('book_book'), 'book', $ilCtrl->getLinkTarget($this->parent_obj, 'book'));
124  }
125 
126  if ($ilAccess->checkAccess('write', '', $this->ref_id))
127  {
128  if(!$reservation)
129  {
130  $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTarget($this->parent_obj, 'confirmDelete'));
131  }
132 
133  $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTarget($this->parent_obj, 'edit'));
134  }
135 
136  $this->tpl->setVariable("LAYER", $alist->getHTML());
137  }
138 }
139 
140 ?>