ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilConsultationHoursTableGUI.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 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
6 
17 {
18  private $user_id = 0;
19 
27  public function __construct($a_gui,$a_cmd,$a_user_id)
28  {
29  global $lng,$ilCtrl;
30 
31  $this->user_id = $a_user_id;
32  $this->setId('chtg_'.$this->getUserId());
33  parent::__construct($a_gui,$a_cmd);
34 
35  $this->addColumn('','f',1);
36  $this->addColumn($this->lng->txt('title'),'title');
37  $this->addColumn($this->lng->txt('cal_start'),'start');
38  $this->addColumn($this->lng->txt('cal_ch_num_bookings'),'num_bookings');
39  $this->addColumn($this->lng->txt('cal_ch_bookings'));
40  $this->addColumn($this->lng->txt('cal_ch_target_object'));
41  $this->addColumn('');
42 
43  $this->setRowTemplate('tpl.ch_upcoming_row.html','Services/Calendar');
44  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(),$this->getParentCmd()));
45  $this->setTitle($this->lng->txt('cal_ch_ch'));
46 
47  $this->enable('sort');
48  $this->enable('header');
49  $this->enable('numinfo');
50 
51  $this->setDefaultOrderField('start');
52  $this->setSelectAllCheckbox('apps');
53  $this->setShowRowsSelector(true);
54 
55  $this->addMultiCommand('edit', $this->lng->txt('edit'));
56  $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
57  }
58 
63  public function getUserId()
64  {
65  return $this->user_id;
66  }
67 
72  public function fillRow($row)
73  {
74  global $ilCtrl;
75 
76  $this->tpl->setVariable('VAL_ID',$row['id']);
77  $this->tpl->setVariable('TITLE',$row['title']);
78  $this->tpl->setVariable('START',$row['start_p']);
79  $this->tpl->setVariable('NUM_BOOKINGS',$row['num_bookings']);
80  $this->tpl->setVariable('TARGET', $row['target']);
81 
82  if($row['bookings'])
83  {
84  $this->tpl->setCurrentBlock('bookings');
85  foreach($row['bookings'] as $user_id => $name)
86  {
87  $ilCtrl->setParameter($this->getParentObject(), 'user', $user_id);
88  $this->tpl->setVariable('URL_BOOKING', $ilCtrl->getLinkTarget($this->getParentObject(), 'showprofile'));
89  $ilCtrl->setParameter($this->getParentObject(), 'user', '');
90  $this->tpl->setVariable('TXT_BOOKING', $name);
91  $this->tpl->parseCurrentBlock();
92  }
93  }
94 
95  $this->tpl->setVariable('BOOKINGS',implode(', ', $row['bookings']));
96  }
97 
102  public function parse()
103  {
104  global $ilDB, $ilObjDataCache;
105 
106  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
107 
108  $data = array();
109  $counter = 0;
111  {
112  $data[$counter]['id'] = $app->getEntryId();
113  $data[$counter]['title'] = $app->getTitle();
114  $data[$counter]['description'] = $app->getDescription();
115  $data[$counter]['start'] = $app->getStart()->get(IL_CAL_UNIX);
116  $data[$counter]['start_p'] = ilDatePresentation::formatDate($app->getStart());
117 
118  $booking = new ilBookingEntry($app->getContextId());
119  $users = array();
120  foreach($booking->getCurrentBookings($app->getEntryId()) as $user_id)
121  {
122  $users[$user_id] = ilObjUser::_lookupFullname($user_id);
123  }
124  $data[$counter]['num_bookings'] = sizeof($users);
125  $data[$counter]['bookings'] = $users;
126 
127  $target = $booking->getTargetObjId();
128  if($target)
129  {
130  $data[$counter]['target'] = $ilObjDataCache->lookupTitle($target);
131  }
132 
133  $counter++;
134  }
135 
136  $this->setData($data);
137  }
138 }
139 ?>