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