ILIAS  Release_4_1_x_branch Revision 61804
 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  $items = array();
115 
116  $ilCtrl->setParameter($this->parent_obj, 'object_id', $a_set['booking_object_id']);
117 
118  if ($a_set["schedule_id"])
119  {
120  $items['book'] = array($lng->txt('book_book'), $ilCtrl->getLinkTarget($this->parent_obj, 'book'));
121  }
122 
123  if ($ilAccess->checkAccess('write', '', $this->ref_id))
124  {
125  if(!$reservation)
126  {
127  $items['delete'] = array($lng->txt('delete'), $ilCtrl->getLinkTarget($this->parent_obj, 'confirmDelete'));
128  }
129 
130  $items['edit'] = array($lng->txt('edit'), $ilCtrl->getLinkTarget($this->parent_obj, 'edit'));
131  }
132 
133  if(sizeof($items))
134  {
135  $this->tpl->setCurrentBlock("actions");
136  foreach($items as $item)
137  {
138  $this->tpl->setVariable("ACTION_CAPTION", $item[0]);
139  $this->tpl->setVariable("ACTION_LINK", $item[1]);
140  $this->tpl->parseCurrentBlock();
141  }
142  }
143  }
144 }
145 
146 ?>