ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarChangedAppointmentsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
25 include_once('./Services/Table/classes/class.ilTable2GUI.php');
26 
35 {
36  private $cat_id = 0;
37  private $categories = null;
38  private $is_editable = false;
39 
47  public function __construct($a_parent_obj,$a_parent_cmd)
48  {
49  global $lng,$ilCtrl;
50 
51 
52  $this->categories = ilCalendarCategories::_getInstance();
53 
54  $this->lng = $lng;
55  $this->lng->loadLanguageModule('dateplaner');
56  $this->ctrl = $ilCtrl;
57 
58  parent::__construct($a_parent_obj,$a_parent_cmd);
59  $this->setFormName('appointments');
60  $this->addColumn($this->lng->txt('title'),'title',"30%");
61  $this->addColumn($this->lng->txt('date'),'begin',"30%");
62  $this->addColumn($this->lng->txt('cal_duration'),'duration',"15%");
63  $this->addColumn($this->lng->txt('cal_recurrences'),'frequence',"10%");
64  $this->addColumn($this->lng->txt('last_update'),'last_update',"15%");
65 
66 
67  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
68  $this->setRowTemplate("tpl.show_changed_appointment_row.html","Services/Calendar");
69  $this->enable('sort');
70  $this->enable('header');
71  $this->enable('numinfo');
72 
73  $this->setDefaultOrderField('last_update');
74  $this->setDefaultOrderDirection('desc');
75 
76  $this->setPrefix('apps');
77  }
78 
79 
87  protected function fillRow($a_set)
88  {
89  global $ilUser, $lng;
90 
91  if ($a_set["milestone"])
92  {
93  $this->tpl->setCurrentBlock("img_ms");
94  $this->tpl->setVariable("IMG_MS", ilUtil::getImagePath("icon_ms_s.gif"));
95  $this->tpl->setVariable("ALT_MS", $lng->txt("cal_milestone"));
96  $this->tpl->parseCurrentBlock();
97  }
98 
99  $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
100 
101  $this->tpl->setVariable('VAL_TITLE_LINK',$a_set['title']);
102  $this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_set['id']);
103  $this->tpl->setVariable('VAL_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
104 
105  switch($a_set['frequence'])
106  {
107  case IL_CAL_FREQ_DAILY:
108  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_daily'));
109  break;
110 
111  case IL_CAL_FREQ_WEEKLY:
112  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_weekly'));
113  break;
114 
115  case IL_CAL_FREQ_MONTHLY:
116  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_monthly'));
117  break;
118 
119  case IL_CAL_FREQ_YEARLY:
120  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_yearly'));
121  break;
122 
123  default:
124  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence'));
125  break; $this->addColumn($this->lng->txt('cal_duration'),'duration',"20%");
126  }
127  // TOD: Localization
128  if($a_set['fullday'])
129  {
131  new ilDate($a_set['begin'],IL_CAL_UNIX),
132  new ilDate($a_set['end'],IL_CAL_UNIX)
133  );
134  }
135  else
136  {
138  new ilDateTime($a_set['begin'],IL_CAL_UNIX),
139  new ilDateTime($a_set['end'],IL_CAL_UNIX)
140  );
141  }
142  $this->tpl->setVariable('VAL_BEGIN',$date);
143  if($a_set['duration'])
144  {
145  if($a_set['milestone'])
146  {
147  $this->tpl->setVariable('VAL_DURATION','-');
148  }
149  else
150  {
151  $this->tpl->setVariable('VAL_DURATION',ilFormat::_secondsToString($a_set['duration']));
152  }
153  }
154  else
155  {
156  $this->tpl->setVariable('VAL_DURATION','');
157  }
158  $update = new ilDateTime($a_set['last_update'],IL_CAL_UNIX,$ilUser->getTimeZone());
159  $this->tpl->setVariable('VAL_LAST_UPDATE',ilDatePresentation::formatDate($update));
160 
161 
162  }
163 
170  public function setAppointments($a_apps)
171  {
172  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
173  include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
174 
175 
176  foreach($a_apps as $entry)
177  {
178  $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
179 
180  $tmp_arr['id'] = $entry->getEntryId();
181  $tmp_arr['milestone'] = $entry->isMilestone();
182  $tmp_arr['title'] = $entry->getPresentationTitle();
183  $tmp_arr['description'] = $entry->getDescription();
184  $tmp_arr['fullday'] = $entry->isFullday();
185  $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
186  $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
187 
188  #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24;
189  $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
190  if($tmp_arr['fullday'])
191  {
192  $tmp_arr['duration'] += (60 * 60 * 24);
193  }
194  if(!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin'])
195  {
196  $tmp_arr['duration'] = '';
197  }
198 
199  $tmp_arr['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX);
200  $tmp_arr['frequence'] = $rec->getFrequenceType();
201 
202  $appointments[] = $tmp_arr;
203  }
204 
205  $this->setData($appointments ? $appointments : array());
206  }
207 
208 }
209 ?>