[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/calendar/inc/ -> class.uiholiday.inc.php (source)

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


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7