1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - Calendar * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> * |
---|
6 | * http://www.radix.net/~cknudsen * |
---|
7 | * Modified by Mark Peters <skeeter@phpgroupware.org> * |
---|
8 | * -------------------------------------------- * |
---|
9 | * This program is free software; you can redistribute it and/or modify it * |
---|
10 | * under the terms of the GNU General Public License as published by the * |
---|
11 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
12 | * option) any later version. * |
---|
13 | \**************************************************************************/ |
---|
14 | |
---|
15 | |
---|
16 | class uiholiday |
---|
17 | { |
---|
18 | var $debug = False; |
---|
19 | var $base_url; |
---|
20 | var $bo; |
---|
21 | var $template_dir; |
---|
22 | var $holidays; |
---|
23 | var $cat_id; |
---|
24 | |
---|
25 | var $public_functions = array( |
---|
26 | 'admin' => True, |
---|
27 | 'edit_locale' => True, |
---|
28 | 'edit_holiday' => True, |
---|
29 | 'copy_holiday' => True, |
---|
30 | 'delete_holiday' => True, |
---|
31 | 'delete_locale' => True, |
---|
32 | 'submit' => True |
---|
33 | ); |
---|
34 | |
---|
35 | function uiholiday() |
---|
36 | { |
---|
37 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
38 | |
---|
39 | $this->bo = CreateObject('calendar.boholiday'); |
---|
40 | $this->bo->check_admin(); |
---|
41 | $this->base_url = $this->bo->base_url; |
---|
42 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); |
---|
43 | $this->sb = CreateObject('phpgwapi.sbox'); |
---|
44 | |
---|
45 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Holiday Management'); |
---|
46 | } |
---|
47 | |
---|
48 | function admin() |
---|
49 | { |
---|
50 | if (!$GLOBALS['phpgw']->acl->check('run',1,'admin')) |
---|
51 | { |
---|
52 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); |
---|
53 | } |
---|
54 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
55 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
56 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
57 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
58 | |
---|
59 | $p = &$GLOBALS['phpgw']->template; |
---|
60 | $p->set_file(Array('locales'=>'locales.tpl')); |
---|
61 | $p->set_block('locales','list','list'); |
---|
62 | $p->set_block('locales','row','row'); |
---|
63 | $p->set_block('locales','row_empty','row_empty'); |
---|
64 | $p->set_block('locales','submit_column','submit_column'); |
---|
65 | |
---|
66 | $var = Array( |
---|
67 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
68 | 'left_next_matchs' => $GLOBALS['phpgw']->nextmatchs->left('/index.php?menuaction=calendar.uiholiday.admin',$this->bo->start,$this->bo->total), |
---|
69 | 'right_next_matchs' => $GLOBALS['phpgw']->nextmatchs->right('/index.php?menuaction=calendar.uiholiday.admin',$this->bo->start,$this->bo->total), |
---|
70 | 'center' => '<td align="center">'.lang('Countries').'</td>', |
---|
71 | 'sort_name' => $GLOBALS['phpgw']->nextmatchs->show_sort_order($this->bo->sort,'locale',$this->bo->order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')), |
---|
72 | 'header_edit' => lang('Edit'), |
---|
73 | 'header_delete' => lang('Delete'), |
---|
74 | 'header_extra' => lang('Submit to Repository'), |
---|
75 | 'extra_width' => 'width="45%"', |
---|
76 | 'rule' => '', |
---|
77 | 'header_rule' => '', |
---|
78 | 'back_button' => '' |
---|
79 | ); |
---|
80 | |
---|
81 | $p->set_var($var); |
---|
82 | |
---|
83 | $locales = $this->bo->get_locale_list($this->bo->sort, $this->bo->order, $this->bo->query, $this->bo->total); |
---|
84 | @reset($locales); |
---|
85 | if (!$locales) |
---|
86 | { |
---|
87 | $p->set_var('message',lang('no matches found')); |
---|
88 | $p->parse('rows','row_empty',True); |
---|
89 | } |
---|
90 | else |
---|
91 | { |
---|
92 | $p->set_var('submit_extra',' width="5%"'); |
---|
93 | while (list(,$value) = each($locales)) |
---|
94 | { |
---|
95 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
96 | if (! $value) $value = ' '; |
---|
97 | |
---|
98 | $var = Array( |
---|
99 | 'tr_color' => $tr_color, |
---|
100 | 'group_name' => $value, |
---|
101 | 'edit_link' => '<a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$value)) . '"> '.lang('Edit').' </a>', |
---|
102 | 'delete_link' => '<a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.delete_locale','locale'=>$value)).'"> '.lang('Delete').' </a>', |
---|
103 | 'extra_link' => '<a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.submit','locale'=>$value)).'"> '.lang('Submit').' </a>'. |
---|
104 | ' <a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.submit','locale'=>$value,'download'=>1)).'"> '.lang('Download').' </a>' |
---|
105 | ); |
---|
106 | $p->set_var($var); |
---|
107 | $p->parse('rows','row',True); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | $var = Array( |
---|
112 | 'new_action' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_holiday','id'=>0)), |
---|
113 | 'lang_add' => lang('add'), |
---|
114 | 'search_action' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')), |
---|
115 | 'lang_search' => lang('search') |
---|
116 | ); |
---|
117 | |
---|
118 | $p->set_var($var); |
---|
119 | $p->pparse('out','list'); |
---|
120 | } |
---|
121 | |
---|
122 | function edit_locale($locale='') |
---|
123 | { |
---|
124 | if ($locale === '') |
---|
125 | { |
---|
126 | $locale = $this->bo->locale; |
---|
127 | } |
---|
128 | if ($locale) |
---|
129 | { |
---|
130 | $this->bo->locales = array($locale); |
---|
131 | $this->bo->total = $this->bo->so->holiday_total($locale,$this->bo->query); |
---|
132 | } |
---|
133 | if(!$this->bo->total && !isset($this->bo->query)) |
---|
134 | { |
---|
135 | $link_params = Array( |
---|
136 | 'menuaction' => 'calendar.uiholiday.admin' |
---|
137 | ); |
---|
138 | $GLOBALS['phpgw']->redirect_link($this->base_url,$link_params); |
---|
139 | } |
---|
140 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
141 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
142 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
143 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
144 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
145 | $p->set_file(Array('locale'=>'locales.tpl')); |
---|
146 | $p->set_block('locale','list','list'); |
---|
147 | $p->set_block('locale','row','row'); |
---|
148 | $p->set_block('locale','row_empty','row_empty'); |
---|
149 | $p->set_block('locale','back_button_form','back_button_form'); |
---|
150 | |
---|
151 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
152 | { |
---|
153 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
154 | } |
---|
155 | $html = &$GLOBALS['phpgw']->html; |
---|
156 | $year_form = str_replace('<option value=""></option>','',$html->form($html->sbox_submit($this->sb->getYears('year',$this->bo->year),true),array(), |
---|
157 | $this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0]))); |
---|
158 | unset($html); |
---|
159 | |
---|
160 | $holidays = $this->bo->get_holiday_list(); |
---|
161 | $total = count($holidays); |
---|
162 | |
---|
163 | $var = Array( |
---|
164 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
165 | 'left_next_matchs' => $GLOBALS['phpgw']->nextmatchs->left('/index.php',$this->bo->start,$total,'&menuaction=calendar.uiholiday.edit_locale&locale='.$this->bo->locales[0].'&year='.$this->bo->year), |
---|
166 | 'right_next_matchs' => $GLOBALS['phpgw']->nextmatchs->right('/index.php',$this->bo->start,$total,'&menuaction=calendar.uiholiday.edit_locale&locale='.$this->bo->locales[0].'&year='.$this->bo->year), |
---|
167 | 'center' => '<td align="right">'.lang('Holidays').' ('.$this->bo->locales[0].')</td><td align="left">'.$year_form.'</td>', |
---|
168 | 'sort_name' => $GLOBALS['phpgw']->nextmatchs->show_sort_order($this->bo->sort,'name',$this->bo->order,'/index.php',lang('Holiday'),'&menuaction=calendar.uiholiday.edit_locale&locale='.$this->bo->locales[0].'&year='.$this->bo->year), |
---|
169 | 'header_edit' => lang('Edit'), |
---|
170 | 'header_delete' => lang('Delete'), |
---|
171 | 'header_rule' => '<td>'.$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->bo->sort,'month_num,mday',$this->bo->order,'/index.php',lang('Rule'),'&menuaction=calendar.uiholiday.edit_locale&locale='.$this->bo->locales[0].'&year='.$this->bo->year).'</td>', |
---|
172 | 'header_extra' => lang('Copy'), |
---|
173 | 'extra_width' => 'width="5%"' |
---|
174 | ); |
---|
175 | |
---|
176 | $p->set_var($var); |
---|
177 | |
---|
178 | if (!count($holidays)) |
---|
179 | { |
---|
180 | $p->set_var('message',lang('no matches found')); |
---|
181 | $p->parse('rows','row_empty',True); |
---|
182 | } |
---|
183 | else |
---|
184 | { |
---|
185 | $maxmatchs = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; |
---|
186 | $end = min($total,$this->bo->start+$maxmatchs); |
---|
187 | $p->set_var('rows',lang('showing %1 - %2 of %3',1+$this->bo->start,$end,$total)); |
---|
188 | for($i=$this->bo->start; $i < $end; ++$i) |
---|
189 | { |
---|
190 | $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); |
---|
191 | if (!$holidays[$i]['name']) |
---|
192 | { |
---|
193 | $holidays[$i]['name'] = ' '; |
---|
194 | } |
---|
195 | |
---|
196 | $var = Array( |
---|
197 | 'tr_color' => $tr_color, |
---|
198 | 'header_delete'=> lang('Delete'), |
---|
199 | 'group_name' => $holidays[$i]['name'], |
---|
200 | 'rule' => '<td>'.$this->bo->rule_string($holidays[$i]).'</td>', |
---|
201 | 'edit_link' => '<a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_holiday','locale'=>$this->bo->locales[0],'id'=>$holidays[$i]['index'],'year'=>$this->bo->year)).'"> '.lang('Edit').' </a>', |
---|
202 | 'extra_link' => '<a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.copy_holiday','locale'=>$this->bo->locales[0],'id'=>$holidays[$i]['index'],'year'=>$this->bo->year)).'"> '.lang('Copy').' </a>', |
---|
203 | 'delete_link' => '<a href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.delete_holiday','locale'=>$this->bo->locales[0],'id'=>$holidays[$i]['index'],'year'=>$this->bo->year)).'"> '.lang('Delete').' </a>' |
---|
204 | ); |
---|
205 | |
---|
206 | $p->set_var($var); |
---|
207 | $p->parse('rows','row',True); |
---|
208 | } |
---|
209 | } |
---|
210 | |
---|
211 | $var = Array( |
---|
212 | 'new_action' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_holiday','locale'=>$this->bo->locales[0],'id'=>0,'year'=>$this->bo->year)), |
---|
213 | 'lang_add' => lang('add'), |
---|
214 | 'back_action' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')), |
---|
215 | 'lang_back' => lang('Back'), |
---|
216 | 'search_action'=> $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0],'year'=>$this->bo->year)), |
---|
217 | 'lang_search' => lang('search') |
---|
218 | ); |
---|
219 | $p->set_var($var); |
---|
220 | $p->parse('back_button','back_button_form',False); |
---|
221 | $p->pparse('out','list'); |
---|
222 | } |
---|
223 | |
---|
224 | function copy_holiday() |
---|
225 | { |
---|
226 | if(@$this->bo->id) |
---|
227 | { |
---|
228 | $holiday = $this->bo->read_entry($this->bo->id); |
---|
229 | } |
---|
230 | $this->bo->id = 0; |
---|
231 | |
---|
232 | if (!$holiday['occurence'] || $holiday['occurence'] >= 1900) |
---|
233 | { |
---|
234 | $holiday['occurence'] = date('Y'); |
---|
235 | } |
---|
236 | $this->edit_holiday('',$holiday); |
---|
237 | } |
---|
238 | |
---|
239 | function edit_holiday($error='',$holiday='') |
---|
240 | { |
---|
241 | if(@$this->bo->id && !$holiday) |
---|
242 | { |
---|
243 | $holiday = $this->bo->read_entry($this->bo->id); |
---|
244 | } |
---|
245 | if ($this->locale) |
---|
246 | { |
---|
247 | $holiday['locale'] = $this->locale; |
---|
248 | } |
---|
249 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
250 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
251 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
252 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.($this->bo->id ? lang('Edit') : lang('Add')).' '.lang('Holiday'); |
---|
253 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
254 | |
---|
255 | $t = &$GLOBALS['phpgw']->template; |
---|
256 | $t->set_file(Array('holiday'=>'holiday.tpl','form_button'=>'form_button_script.tpl')); |
---|
257 | $t->set_block('holiday','form','form'); |
---|
258 | $t->set_block('holiday','list','list'); |
---|
259 | |
---|
260 | if (@count($error)) |
---|
261 | { |
---|
262 | $message = $GLOBALS['phpgw']->common->error_list($error); |
---|
263 | } |
---|
264 | else |
---|
265 | { |
---|
266 | $message = ''; |
---|
267 | } |
---|
268 | |
---|
269 | $var = Array( |
---|
270 | 'title_holiday' => ($this->bo->id ? lang('Edit') : lang('Add')).' '.lang('Holiday'), |
---|
271 | 'message' => $message, |
---|
272 | 'actionurl' => $GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.add&year='.$this->bo->year), |
---|
273 | 'hidden_vars' => '<input type="hidden" name="holiday[hol_id]" value="'.$this->bo->id.'">'."\n" |
---|
274 | . '<input type="hidden" name="holiday[locales]" value="'.$this->bo->locales[0].'">'."\n" |
---|
275 | ); |
---|
276 | $t->set_var($var); |
---|
277 | |
---|
278 | // Locale |
---|
279 | $this->display_item($t,lang('Country'),$this->sb->form_select($holiday['locale'],'holiday[locale]')); |
---|
280 | |
---|
281 | // Title/Name |
---|
282 | $this->display_item($t,lang('title'),'<input name="holiday[name]" size="60" maxlength="50" value="'.$holiday['name'].'">'); |
---|
283 | |
---|
284 | // Date |
---|
285 | $this->display_item($t,lang('Date'),$GLOBALS['phpgw']->common->dateformatorder($this->sb->getYears('holiday[year]',$holiday['occurence']>1900?$holiday['occurence']:0),$this->sb->getMonthText('holiday[month_num]',$holiday['month']),$this->sb->getDays('holiday[mday]',$holiday['day'])). |
---|
286 | ' '.lang('Set a Year only for one-time / non-regular holidays.')); |
---|
287 | |
---|
288 | // Occurence |
---|
289 | $occur = Array( |
---|
290 | 0 => '', |
---|
291 | 1 => '1.', |
---|
292 | 2 => '2.', |
---|
293 | 3 => '3.', |
---|
294 | 4 => '4.', |
---|
295 | 5 => '5.', |
---|
296 | 99 => lang('Last') |
---|
297 | ); |
---|
298 | $out = ''; |
---|
299 | while(list($key,$value) = each($occur)) |
---|
300 | { |
---|
301 | $out .= '<option value="'.$key.'"'.($holiday['occurence']==$key?' selected':'').'>'.$value.'</option>'."\n"; |
---|
302 | } |
---|
303 | $occurence_html = '<select name="holiday[occurence]">'."\n".$out.'</select>'."\n"; |
---|
304 | |
---|
305 | $dow = Array( |
---|
306 | 0 => lang('Sun'), |
---|
307 | 1 => lang('Mon'), |
---|
308 | 2 => lang('Tue'), |
---|
309 | 3 => lang('Wed'), |
---|
310 | 4 => lang('Thu'), |
---|
311 | 5 => lang('Fri'), |
---|
312 | 6 => lang('Sat') |
---|
313 | ); |
---|
314 | $out = ''; |
---|
315 | for($i=0;$i<7;++$i) |
---|
316 | { |
---|
317 | $out .= '<option value="'.$i.'"'.($holiday['dow']==$i?' selected':'').'>'.$dow[$i].'</option>'."\n"; |
---|
318 | } |
---|
319 | $dow_html = '<select name="holiday[dow]">'."\n".$out.'</select>'."\n"; |
---|
320 | $this->display_item($t,lang('Occurence'),$occurence_html.' '.$dow_html. |
---|
321 | ' '.lang('You can either set a Year or a Occurence, not both !!!')); |
---|
322 | $this->display_item($t,lang('Observance Rule'),'<input type="checkbox" name="holiday[observance_rule]" value="True"'.($holiday['observance_rule']?' checked':'').'>'. |
---|
323 | ' '.lang('If checked holidays falling on a weekend, are taken on the monday after.')); |
---|
324 | |
---|
325 | $t->set_var('lang_add',lang('Save')); |
---|
326 | $t->set_var('lang_reset',lang('Reset')); |
---|
327 | |
---|
328 | if(@$this->bo->locales[0]) |
---|
329 | { |
---|
330 | $link_params = Array( |
---|
331 | 'menuaction' => 'calendar.uiholiday.edit_locale', |
---|
332 | 'year' => $this->bo->year, |
---|
333 | 'locale' => $this->bo->locales[0] |
---|
334 | ); |
---|
335 | } |
---|
336 | else |
---|
337 | { |
---|
338 | $link_params = Array( |
---|
339 | 'menuaction' => 'calendar.uiholiday.admin' |
---|
340 | ); |
---|
341 | } |
---|
342 | |
---|
343 | $t->set_var(Array( |
---|
344 | 'action_url_button' => $GLOBALS['phpgw']->link($this->base_url,$link_params), |
---|
345 | 'action_text_button' => lang('Cancel'), |
---|
346 | 'action_confirm_button' => '', |
---|
347 | 'action_extra_field' => '' |
---|
348 | )); |
---|
349 | $t->parse('cancel_button','form_button'); |
---|
350 | |
---|
351 | if ($this->bo->id) |
---|
352 | { |
---|
353 | $link_params = Array( |
---|
354 | 'menuaction' => 'calendar.uiholiday.delete_holiday', |
---|
355 | 'year' => $this->bo->year, |
---|
356 | 'locale' => $this->bo->locales[0], |
---|
357 | 'id' => $this->bo->id |
---|
358 | ); |
---|
359 | $t->set_var(Array( |
---|
360 | 'action_url_button' => $GLOBALS['phpgw']->link($this->base_url,$link_params), |
---|
361 | 'action_text_button' => lang('Delete'), |
---|
362 | 'action_confirm_button' => '', |
---|
363 | 'action_extra_field' => '' |
---|
364 | )); |
---|
365 | $t->parse('delete_button','form_button'); |
---|
366 | } |
---|
367 | else |
---|
368 | { |
---|
369 | $t->set_var('delete_button',' '); |
---|
370 | } |
---|
371 | $t->pparse('out','form'); |
---|
372 | } |
---|
373 | |
---|
374 | |
---|
375 | function delete_locale() |
---|
376 | { |
---|
377 | if(!$this->bo->total) |
---|
378 | { |
---|
379 | $this->admin(); |
---|
380 | } |
---|
381 | |
---|
382 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
383 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
384 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
385 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
386 | |
---|
387 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
388 | $p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl')); |
---|
389 | |
---|
390 | $p->set_var('messages',lang('Are you sure want to delete this Country?')."<br>".$this->bo->locales[0]); |
---|
391 | |
---|
392 | $var = Array( |
---|
393 | 'action_url_button' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')), |
---|
394 | 'action_text_button' => lang('No'), |
---|
395 | 'action_confirm_button' => '', |
---|
396 | 'action_extra_field' => '' |
---|
397 | ); |
---|
398 | $p->set_var($var); |
---|
399 | $p->parse('no','form_button'); |
---|
400 | |
---|
401 | $var = Array( |
---|
402 | 'action_url_button' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.boholiday.delete_locale','locale'=>$this->bo->locales[0])), |
---|
403 | 'action_text_button' => lang('Yes'), |
---|
404 | 'action_confirm_button' => '', |
---|
405 | 'action_extra_field' => '' |
---|
406 | ); |
---|
407 | $p->set_var($var); |
---|
408 | $p->parse('yes','form_button'); |
---|
409 | |
---|
410 | $p->pparse('out','form'); |
---|
411 | } |
---|
412 | |
---|
413 | function delete_holiday() |
---|
414 | { |
---|
415 | $holiday = $this->bo->read_entry($this->bo->id); |
---|
416 | |
---|
417 | if(!$holiday) |
---|
418 | { |
---|
419 | $this->edit_locale(); |
---|
420 | } |
---|
421 | |
---|
422 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
423 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
424 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
425 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
426 | |
---|
427 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
428 | $p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl')); |
---|
429 | |
---|
430 | $p->set_var('messages',lang('Are you sure want to delete this holiday?')."<br>".$holiday['name'].' ('.$this->bo->locales[0].') '.$this->bo->rule_string($holiday)); |
---|
431 | |
---|
432 | $var = Array( |
---|
433 | 'action_url_button' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0],'year'=>$this->bo->year)), |
---|
434 | 'action_text_button' => lang('No'), |
---|
435 | 'action_confirm_button' => '', |
---|
436 | 'action_extra_field' => '' |
---|
437 | ); |
---|
438 | $p->set_var($var); |
---|
439 | $p->parse('no','form_button'); |
---|
440 | |
---|
441 | $var = Array( |
---|
442 | 'action_url_button' => $GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.boholiday.delete_holiday','locale'=>$this->bo->locales[0],'id'=>$this->bo->id,'year'=>$this->bo->year)), |
---|
443 | 'action_text_button' => lang('Yes'), |
---|
444 | 'action_confirm_button' => '', |
---|
445 | 'action_extra_field' => '' |
---|
446 | ); |
---|
447 | $p->set_var($var); |
---|
448 | $p->parse('yes','form_button'); |
---|
449 | |
---|
450 | $p->pparse('out','form'); |
---|
451 | } |
---|
452 | |
---|
453 | function submit() |
---|
454 | { |
---|
455 | if(!@$this->bo->locales[0]) |
---|
456 | { |
---|
457 | $this->admin(); |
---|
458 | } |
---|
459 | $this->bo->year = 0; // for a complete list with all years |
---|
460 | $holidays = $this->bo->get_holiday_list(); |
---|
461 | |
---|
462 | if (isset($_GET['download'])) |
---|
463 | { |
---|
464 | $locale = $this->bo->locales[0]; |
---|
465 | $browser = CreateObject('phpgwapi.browser'); |
---|
466 | $browser->content_header("holidays.$locale.csv",'text/text'); |
---|
467 | unset($browser); |
---|
468 | |
---|
469 | while (list(,$holiday) = @each($holidays)) |
---|
470 | { |
---|
471 | echo "$locale\t{$holiday['name']}\t{$holiday['day']}\t{$holiday['month']}\t{$holiday['occurence']}\t{$holiday['dow']}\t{$holiday['observance_rule']}\n"; |
---|
472 | } |
---|
473 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
474 | } |
---|
475 | elseif($this->debug) |
---|
476 | { |
---|
477 | $action = $GLOBALS['phpgw']->link('/calendar/phpgroupware.org/accept_holiday.php'); |
---|
478 | } |
---|
479 | else |
---|
480 | { |
---|
481 | $action = 'http://www.egroupware.org/cal/accept_holiday.php'; |
---|
482 | } |
---|
483 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
484 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
485 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
486 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
487 | |
---|
488 | echo '<body onLoad="document.submitform.submit()">'."\n"; |
---|
489 | echo '<form action="'.$action.'" method="post" name="submitform">'."\n"; |
---|
490 | |
---|
491 | $c_holidays = count($holidays); |
---|
492 | echo '<input type="hidden" name="locale" value="'.$this->bo->locales[0].'">'."\n"; |
---|
493 | for($i=0;$i<$c_holidays;++$i) |
---|
494 | { |
---|
495 | echo '<input type="hidden" name="name[]" value="'.htmlspecialchars($holidays[$i]['name']).'">'."\n" |
---|
496 | . '<input type="hidden" name="day[]" value="'.$holidays[$i]['day'].'">'."\n" |
---|
497 | . '<input type="hidden" name="month[]" value="'.$holidays[$i]['month'].'">'."\n" |
---|
498 | . '<input type="hidden" name="occurence[]" value="'.$holidays[$i]['occurence'].'">'."\n" |
---|
499 | . '<input type="hidden" name="dow[]" value="'.$holidays[$i]['dow'].'">'."\n" |
---|
500 | . '<input type="hidden" name="observance[]" value="'.$holidays[$i]['observance_rule'].'">'."\n"; |
---|
501 | } |
---|
502 | echo "</form>\n</body>\n</head>"; |
---|
503 | } |
---|
504 | |
---|
505 | /* private functions */ |
---|
506 | function display_item(&$p,$field,$data) |
---|
507 | { |
---|
508 | $var = Array( |
---|
509 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
510 | 'field' => $field, |
---|
511 | 'data' => $data |
---|
512 | ); |
---|
513 | $p->set_var($var); |
---|
514 | $p->parse('rows','list',True); |
---|
515 | } |
---|
516 | } |
---|
517 | ?> |
---|