ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilConsultationHourGroupTableGUI.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 
16  private $user_id = 0;
17 
24  public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id)
25  {
26  $this->user_id = $a_user_id;
27  $this->setId('chgrp_'.$this->user_id);
28  parent::__construct($a_parent_obj,$a_parent_cmd);
29 
30  $this->initTable();
31  }
32 
36  protected function initTable()
37  {
38  $this->setRowTemplate('tpl.ch_group_row.html','Services/Calendar');
39 
40  $this->setTitle($GLOBALS['lng']->txt('cal_ch_grps'));
41  $this->setFormAction($GLOBALS['ilCtrl']->getFormAction($this->getParentObject(),$this->getParentCmd()));
42 
43  $this->addColumn($GLOBALS['lng']->txt('title'),'title');
44  $this->addColumn($GLOBALS['lng']->txt('cal_ch_assigned_apps'),'apps');
45  $this->addColumn($GLOBALS['lng']->txt('cal_ch_max_books'), 'max_books');
46  $this->addColumn($GLOBALS['lng']->txt('actions'), '');
47 
48  $this->enable('sort');
49  $this->enable('header');
50  $this->enable('num_info');
51 
52  $this->setDefaultOrderField('title');
53  }
54 
59  public function fillRow($a_set)
60  {
61  global $ilCtrl;
62 
63  $this->tpl->setVariable('TITLE',$a_set['title']);
64  $this->tpl->setVariable('MAX_BOOKINGS',$a_set['max_books']);
65  $this->tpl->setVariable('ASSIGNED',$a_set['assigned']);
66 
67  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
68  $list = new ilAdvancedSelectionListGUI();
69  $list->setId('act_chgrp_'.$this->user_id.'_'.$a_set['id']);
70  $list->setListTitle($this->lng->txt('actions'));
71 
72  $ilCtrl->setParameter($this->getParentObject(),'grp_id',$a_set['id']);
73  $list->addItem(
74  $this->lng->txt('edit'),
75  '',
76  $ilCtrl->getLinkTarget($this->getParentObject(),'editGroup')
77  );
78 
79  // add members
80  if($a_set['assigned'])
81  {
82  $list->addItem(
83  $this->lng->txt('cal_ch_assign_participants'),
84  '',
85  $ilCtrl->getLinkTargetByClass('ilRepositorySearchGUI','')
86  );
87  }
88 
89  $list->addItem(
90  $this->lng->txt('delete'),
91  '',
92  $ilCtrl->getLinkTarget($this->getParentObject(),'confirmDeleteGroup')
93  );
94 
95  $this->tpl->setVariable('ACTIONS',$list->getHTML());
96  }
97 
98 
103  public function parse(array $groups)
104  {
105  $rows = array();
106  $counter = 0;
107  foreach($groups as $group)
108  {
109  $rows[$counter]['id'] = $group->getGroupId();
110  $rows[$counter]['title'] = $group->getTitle();
111  $rows[$counter]['max_books'] = $group->getMaxAssignments();
112  $rows[$counter]['assigned'] = count(ilConsultationHourAppointments::getAppointmentIdsByGroup(
113  $this->user_id,
114  $group->getGroupId(),
115  null
116  )
117  );
118  ++$counter;
119  }
120  $this->setData($rows);
121  }
122 }
123 ?>