ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilConsultationHourBookingTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroup.php';
6 include_once './Services/Table/classes/class.ilTable2GUI.php';
7 
14 {
15  private $user_id = 0;
16 
17  private $today = null;
18 
25  public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id)
26  {
27  $this->user_id = $a_user_id;
28  $this->setId('chboo_'.$this->user_id);
29  parent::__construct($a_parent_obj,$a_parent_cmd);
30 
31  $this->initTable();
32 
33 
34  $this->today = new ilDateTime(time(),IL_CAL_UNIX);
35  }
36 
40  protected function initTable()
41  {
42  $this->setRowTemplate('tpl.ch_booking_row.html','Services/Calendar');
43 
44  $this->setTitle($GLOBALS['lng']->txt('cal_ch_bookings_tbl'));
45  $this->setFormAction($GLOBALS['ilCtrl']->getFormAction($this->getParentObject(),$this->getParentCmd()));
46 
47  $this->addColumn('','','1px');
48  $this->addColumn($GLOBALS['lng']->txt('cal_start'),'start');
49  $this->addColumn($GLOBALS['lng']->txt('name'),'name');
50  $this->addColumn($GLOBALS['lng']->txt('cal_ch_booking_message_tbl'),'comment');
51  $this->addColumn($GLOBALS['lng']->txt('title'),'title');
52  $this->addColumn($GLOBALS['lng']->txt('actions'), '');
53 
54  $this->enable('sort');
55  $this->enable('header');
56  $this->enable('num_info');
57 
58  $this->setDefaultOrderField('start');
59  $this->setSelectAllCheckbox('bookuser');
60  $this->setShowRowsSelector(true);
61  $this->addMultiCommand('confirmRejectBooking', $this->lng->txt('cal_ch_reject_booking'));
62  $this->addMultiCommand('confirmDeleteBooking', $this->lng->txt('cal_ch_delete_booking'));
63  }
64 
69  public function fillRow($row)
70  {
71  global $ilCtrl;
72 
73  $this->tpl->setVariable('START',$row['start_str']);
74  $this->tpl->setVariable('NAME',$row['name']);
75  $this->tpl->setVariable('COMMENT',$row['comment']);
76  $this->tpl->setVariable('TITLE',$row['title']);
77  $this->tpl->setVariable('VAL_ID',$row['id']);
78 
79  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
80  $list = new ilAdvancedSelectionListGUI();
81  $list->setId('act_chboo_'.$row['id']);
82  $list->setListTitle($this->lng->txt('actions'));
83 
84  $ilCtrl->setParameter($this->getParentObject(),'bookuser',$row['id']);
85 
86  $start = new ilDateTime($row['start'],IL_CAL_UNIX);
87  if(ilDateTime::_after($start, $this->today,IL_CAL_DAY))
88  {
89  $list->addItem(
90  $this->lng->txt('cal_ch_reject_booking'),
91  '',
92  $ilCtrl->getLinkTarget($this->getParentObject(),'confirmRejectBooking')
93  );
94  }
95  $list->addItem(
96  $this->lng->txt('cal_ch_delete_booking'),
97  '',
98  $ilCtrl->getLinkTarget($this->getParentObject(),'confirmDeleteBooking')
99  );
100  $this->tpl->setVariable('ACTIONS',$list->getHTML());
101  }
102 
103 
108  public function parse(array $appointments)
109  {
110  global $ilCtrl;
111 
112  $rows = array();
113  $counter = 0;
114  foreach($appointments as $app)
115  {
116  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
117  $cal_entry = new ilCalendarEntry($app);
118 
119  include_once './Services/Booking/classes/class.ilBookingEntry.php';
121  {
122  include_once './Services/User/classes/class.ilUserUtil.php';
123  $rows[$counter]['name'] = ilUserUtil::getNamePresentation(
124  $user_id,
125  true,
126  true,
127  $ilCtrl->getLinkTarget($this->getParentObject(),$this->getParentCmd()),
128  true,
129  true
130  );
131 
132  $message = ilBookingEntry::lookupBookingMessage($app, $user_id);
133  if(strlen(trim($message)))
134  {
135  $rows[$counter]['comment'] = ('"'.$message.'"');
136  }
137  $rows[$counter]['title'] = $cal_entry->getTitle();
138  $rows[$counter]['start'] = $cal_entry->getStart()->get(IL_CAL_UNIX);
139  $rows[$counter]['start_str'] = ilDatePresentation::formatDate($cal_entry->getStart());
140  $rows[$counter]['id'] = $app.'_'.$user_id;
141  ++$counter;
142  }
143  }
144  $this->setData($rows);
145  }
146 }
147 ?>