phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: calendar/inc class.boholiday.inc.php,1.10,1.11 c


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: calendar/inc class.boholiday.inc.php,1.10,1.11 class.soholiday.inc.php,1.2,1.3 class.uiholiday.inc.php,1.3,1.4
Date: Thu, 27 Feb 2003 14:28:27 -0500

Update of /cvsroot/phpgroupware/calendar/inc
In directory subversions:/tmp/cvs-serv12039

Modified Files:
        class.boholiday.inc.php class.soholiday.inc.php 
        class.uiholiday.inc.php 
Log Message:
fixed holiday-management:
- holidays not complying to a (simple) rule like Eastern can now be entered as 
a one-time holiday for a fixed year
- fixed some wrong links and other stuff in the UI
- added a error-msg to accept_holiday on phpgroupware.org if there is already a 
file for the locale
- added download for holiday-files

Index: class.boholiday.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.boholiday.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** class.boholiday.inc.php     24 Dec 2001 03:07:24 -0000      1.10
--- class.boholiday.inc.php     27 Feb 2003 19:28:25 -0000      1.11
***************
*** 51,55 ****
                        if(isset($GLOBALS['locale'])) { $this->locales[] = 
$GLOBALS['locale']; }
  
!                       if(isset($GLOBALS['start']))  { $this->start = 
$GLOBALS['start'];      } else { $this->start = 0; }
  
                        if(isset($GLOBALS['query']))  { $this->query = 
$GLOBALS['query'];      }
--- 51,55 ----
                        if(isset($GLOBALS['locale'])) { $this->locales[] = 
$GLOBALS['locale']; }
  
!                       if(isset($GLOBALS['start']))  { $this->start = 
intval($GLOBALS['start']); } else { $this->start = 0; }
  
                        if(isset($GLOBALS['query']))  { $this->query = 
$GLOBALS['query'];      }
***************
*** 61,64 ****
--- 61,66 ----
                        if(isset($GLOBALS['id']))     { $this->id = 
$GLOBALS['id'];            }
                        
+                       if(isset($GLOBALS['year']))   { $this->year = 
$GLOBALS['year'];        } else { $this->year = date('Y'); }
+                       
                        if($this->debug)
                        {
***************
*** 66,70 ****
                        }
  
!                       $this->total = 
$this->so->holiday_total($this->locales[0],$this->query);
                }
  
--- 68,72 ----
                        }
  
!                       $this->total = 
$this->so->holiday_total($this->locales[0],$this->query,$this->year);
                }
  
***************
*** 155,159 ****
                }
                
!               function get_holiday_list($locale='', $sort='', $order='', 
$query='', $total='')
                {
                        $locale = ($locale?$locale:$this->locales[0]);
--- 157,161 ----
                }
                
!               function get_holiday_list($locale='', $sort='', $order='', 
$query='', $total='', $year=0)
                {
                        $locale = ($locale?$locale:$this->locales[0]);
***************
*** 161,165 ****
                        $order = ($order?$order:$this->order);
                        $query = ($query?$query:$this->query);
!                       return $this->so->read_holidays($locale,$query,$order);
                }
  
--- 163,168 ----
                        $order = ($order?$order:$this->order);
                        $query = ($query?$query:$this->query);
!                       $year = ($$year?$$year:$this->year);
!                       return 
$this->so->read_holidays($locale,$query,$order,$year);
                }
  
***************
*** 294,325 ****
                        if(@$GLOBALS['HTTP_POST_VARS']['submit'])
                        {
!                               
if(empty($GLOBALS['HTTP_POST_VARS']['holiday']['mday']))
                                {
!                                       
$GLOBALS['HTTP_POST_VARS']['holiday']['mday'] = 0;
                                }
                                if(!isset($this->bo->locales[0]) || 
$this->bo->locales[0]=='')
                                {
!                                       $this->bo->locales[0] = 
$GLOBALS['HTTP_POST_VARS']['holiday']['locale'];
                                }
!                               
elseif(!isset($GLOBALS['HTTP_POST_VARS']['holiday']['locale']) || 
$GLOBALS['HTTP_POST_VARS']['holiday']['locale']=='')
                                {
!                                       
$GLOBALS['HTTP_POST_VARS']['holiday']['locale'] = $this->bo->locales[0];
                                }
!                               
if(!isset($GLOBALS['HTTP_POST_VARS']['holiday']['hol_id']))
                                {
!                                       
$GLOBALS['HTTP_POST_VARS']['holiday']['hol_id'] = $this->bo->id;
                                }
                
        // Still need to put some validation in here.....
  
                                $this->ui = CreateObject('calendar.uiholiday');
                                if (is_array($errors))
                                {
!                                       
$this->ui->add($errors,$GLOBALS['HTTP_POST_VARS']['holiday']);
                                }
                                else
                                {
!                                       
$this->so->save_holiday($GLOBALS['HTTP_POST_VARS']['holiday']);
!                                       $this->ui->edit_locale();
                                }
                        }
--- 297,350 ----
                        if(@$GLOBALS['HTTP_POST_VARS']['submit'])
                        {
!                               $holiday = 
$GLOBALS['HTTP_POST_VARS']['holiday'];
! 
!                               if(empty($holiday['mday']))
                                {
!                                       $holiday['mday'] = 0;
                                }
                                if(!isset($this->bo->locales[0]) || 
$this->bo->locales[0]=='')
                                {
!                                       $this->bo->locales[0] = 
$holiday['locale'];
!                               }
!                               elseif(!isset($holiday['locale']) || 
$holiday['locale']=='')
!                               {
!                                       $holiday['locale'] = 
$this->bo->locales[0];
!                               }
!                               if(!isset($holiday['hol_id']))
!                               {
!                                       $holiday['hol_id'] = $this->bo->id;
!                               }
!                               
!                               // some input validation
! 
!                               if (!$holiday['mday'] == !$holiday['occurence'])
!                               {
!                                       $errors[] = lang('You need to set 
either a day or a occurence !!!');
                                }
!                               if($holiday['year'] && $holiday['occurence'])
                                {
!                                       $errors[] = lang('You can only set a 
year or a occurence !!!');
                                }
!                               else
                                {
!                                       $holiday['occurence'] = 
intval($holiday['occurence'] ? $holiday['occurence'] : $holiday['year']);
!                                       unset($holiday['year']);
                                }
+ 
                
        // Still need to put some validation in here.....
  
                                $this->ui = CreateObject('calendar.uiholiday');
+ 
                                if (is_array($errors))
                                {
!                                       $holiday['month'] = 
$holiday['month_num'];
!                                       $holiday['day']   = $holiday['mday'];
!                                       
$this->ui->edit_holiday($errors,$holiday);
                                }
                                else
                                {
!                                       $this->so->save_holiday($holiday);
!                                       
$this->ui->edit_locale($holiday['locale']);
                                }
                        }
***************
*** 361,366 ****
                                return $this->cached_holidays;
                        }
! 
!                       $holidays = $this->so->read_holidays($this->locales);
  
                        if(count($holidays) == 0)
--- 386,390 ----
                                return $this->cached_holidays;
                        }
!                       $holidays = 
$this->so->read_holidays($this->locales,'','',$this->year);
  
                        if(count($holidays) == 0)
***************
*** 404,407 ****
--- 428,461 ----
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php'));
                        }
+               }
+               
+               function rule_string($holiday)
+               {
+                       if (!is_array($holiday))
+                       {
+                               return false;
+                       }
+                       $sbox = CreateObject('phpgwapi.sbox');
+                       $month = $holiday['month'] ? 
lang($sbox->monthnames[$holiday['month']]) : '';
+                       unset($sbox);
+ 
+                       if (!$holiday['day'])
+                       {
+                               $occ = $holiday['occurence'] == 99 ? 
lang('last') : $holiday['occurence'].'.';
+ 
+                               $dow_str = 
Array(lang('Sun'),lang('Mon'),lang('Tue'),lang('Wed'),lang('Thu'),lang('Fri'),lang('Sat'));
+                               $dow = $dow_str[$holiday['dow']];
+                               
+                               $str = lang('%1 %2 in %3',$occ,$dow,$month);
+                       }
+                       else
+                       {
+                               $str = 
$GLOBALS['phpgw']->common->dateformatorder($holiday['occurence']>1900?$holiday['occurence']:'',$month,$holiday[day]);
+                       }
+                       if ($holiday['observance_rule'])
+                       {
+                               $str .= ' ('.lang('Observance Rule').')';
+                       }
+                       return $str;
                }
        }

Index: class.soholiday.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.soholiday.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.soholiday.inc.php     28 Jul 2001 13:17:29 -0000      1.2
--- class.soholiday.inc.php     27 Feb 2003 19:28:25 -0000      1.3
***************
*** 71,75 ****
                }
  
!               function read_holidays($locales='',$query='',$order='')
                {
                        global $phpgw;
--- 71,75 ----
                }
  
!               function read_holidays($locales='',$query='',$order='',$year=0)
                {
                        global $phpgw;
***************
*** 82,86 ****
                        }
  
!                       $sql = $this->build_query($locales,$query,$order);
  
                        if($this->debug)
--- 82,86 ----
                        }
  
!                       $sql = $this->build_query($locales,$query,$order,$year);
  
                        if($this->debug)
***************
*** 118,122 ****
                
                /* Private functions */
!               function build_query($locales,$query='',$order='')
                {
  
--- 118,122 ----
                
                /* Private functions */
!               function build_query($locales,$query='',$order='',$year=0)
                {
  
***************
*** 143,152 ****
                                $querymethod = " AND name like '%".$query."%'";
                        }
!               
!                       if($order)
                        {
!                               $querymethod .= ' ORDER BY '.$order;
                        }
!                       
                        return 'SELECT * FROM phpgw_cal_holidays WHERE locale 
in ('.$find.')'.$querymethod;
                }
--- 143,152 ----
                                $querymethod = " AND name like '%".$query."%'";
                        }
!                       if (intval($year) > 1900)
                        {
!                               $querymethod .= " AND (occurence < 1900 OR 
occurence = $year)";
                        }
!                       $querymethod .= ' ORDER BY '.($order ? $order : 
'month_num,mday');
! 
                        return 'SELECT * FROM phpgw_cal_holidays WHERE locale 
in ('.$find.')'.$querymethod;
                }
***************
*** 172,176 ****
                }
                
!               function holiday_total($locale,$query='')
                {
                        $querymethod='';
--- 172,176 ----
                }
                
!               function holiday_total($locale,$query='',$year=0)
                {
                        $querymethod='';
***************
*** 178,181 ****
--- 178,185 ----
                        {
                                $querymethod = " AND name like '%".$query."%'";
+                       }
+                       if (intval($year) >= 1900)
+                       {
+                               $querymethod .= " AND (occurence < 1900 OR 
occurence = $year)";
                        }
                        $sql = "SELECT count(*) FROM phpgw_cal_holidays WHERE 
locale='".$locale."'".$querymethod;

Index: class.uiholiday.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.uiholiday.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.uiholiday.inc.php     24 Dec 2001 04:04:05 -0000      1.3
--- class.uiholiday.inc.php     27 Feb 2003 19:28:25 -0000      1.4
***************
*** 28,34 ****
                        'edit_locale' => True,
                        'edit_holiday' => True,
!                       'add_holiday' => True,
                        'delete_holiday' => True,
!                       'delete_locale' => True
                );
  
--- 28,35 ----
                        'edit_locale' => True,
                        'edit_holiday' => True,
!                       'copy_holiday' => True,
                        'delete_holiday' => True,
!                       'delete_locale' => True,
!                       'submit'        => True
                );
  
***************
*** 41,44 ****
--- 42,47 ----
                        $this->base_url = $this->bo->base_url;
                        $this->template_dir = 
$GLOBALS['phpgw']->common->get_tpl_dir('calendar');
+                       
+                       $this->sb = CreateObject('phpgwapi.sbox');
                }
  
***************
*** 59,75 ****
                        $var = Array(
                                'th_bg'         => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
!                               'left_next_matchs'      => 
$GLOBALS['phpgw']->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total),
!                               'right_next_matchs'     => 
$GLOBALS['phpgw']->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total),
!                               'lang_groups'   => lang('Countries'),
                                'sort_name'             => 
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->bo->sort,'locale',$this->bo->order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')),
                                'header_edit'   => lang('Edit'),
                                'header_delete' => lang('Delete'),
!                               'submit_extra'  => '',
!                               'submit_link'   => lang('Submit to Repository'),
                                'back_button'   => ''
                        );
  
                        $p->set_var($var);
-                       $p->parse('header_submit','submit_column',False);
  
                        $locales = $this->bo->get_locale_list($this->bo->sort, 
$this->bo->order, $this->bo->query, $this->bo->total);
--- 62,79 ----
                        $var = Array(
                                'th_bg'         => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
!                               'left_next_matchs'      => 
$GLOBALS['phpgw']->nextmatchs->left('/index.php?menuaction=calendar.uiholiday.admin',$this->bo->start,$this->bo->total),
!                               'right_next_matchs'     => 
$GLOBALS['phpgw']->nextmatchs->right('/index.php?menuaction=calendar.uiholiday.admin',$this->bo->start,$this->bo->total),
!                               'center'                        => '<td 
align="center">'.lang('Countries').'</td>',
                                'sort_name'             => 
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->bo->sort,'locale',$this->bo->order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')),
                                'header_edit'   => lang('Edit'),
                                'header_delete' => lang('Delete'),
!                               'header_extra'  => lang('Submit to Repository'),
!                               'extra_width'  => 'width="45%"',
!                               'rule'         => '',
!                               'header_rule'  => '',
                                'back_button'   => ''
                        );
  
                        $p->set_var($var);
  
                        $locales = $this->bo->get_locale_list($this->bo->sort, 
$this->bo->order, $this->bo->query, $this->bo->total);
***************
*** 93,100 ****
                                                'edit_link'             => '<a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$value))
 . '"> '.lang('Edit').' </a>',
                                                'delete_link'   => '<a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.delete_locale','locale'=>$value)).'">
 '.lang('Delete').' </a>',
!                                               'submit_link'   => '<a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.submit','locale'=>$value)).'">
 '.lang('Submit').' </a>'
                                        );
                                        $p->set_var($var);
-                                       
$p->parse('submit_link_column','submit_column',False);
                                        $p->parse('rows','row',True);
                                }
--- 97,104 ----
                                                'edit_link'             => '<a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$value))
 . '"> '.lang('Edit').' </a>',
                                                'delete_link'   => '<a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.delete_locale','locale'=>$value)).'">
 '.lang('Delete').' </a>',
!                                               'extra_link'    => '<a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.submit','locale'=>$value)).'">
 '.lang('Submit').' </a>'.
!                                                       ' &nbsp; &nbsp; <a 
href="'.$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.submit','locale'=>$value,'download'=>1)).'">
 '.lang('Download').' </a>'
                                        );
                                        $p->set_var($var);
                                        $p->parse('rows','row',True);
                                }
***************
*** 102,106 ****
  
                        $var = Array(
!                               'new_action'            => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.add_holiday','id'=>0)),
                                'lang_add'                      => lang('add'),
                                'search_action' => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')),
--- 106,110 ----
  
                        $var = Array(
!                               'new_action'            => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_holiday','id'=>0)),
                                'lang_add'                      => lang('add'),
                                'search_action' => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')),
***************
*** 112,117 ****
                }
  
!               function edit_locale()
                {
                        if(!$this->bo->total && !isset($this->bo->query))
                        {
--- 116,126 ----
                }
  
!               function edit_locale($locale='')
                {
+                       if ($locale)
+                       {
+                               $this->bo->locales = array($locale);
+                               $this->bo->total = 
$this->bo->so->holiday_total($locale,$this->bo->query);
+                       }
                        if(!$this->bo->total && !isset($this->bo->query))
                        {
***************
*** 121,125 ****
                                Header('Location: ' . 
$GLOBALS['phpgw']->link($this->base_url,$link_params));
                        }
-  
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
--- 130,133 ----
***************
*** 133,152 ****
                        
$p->set_block('locale','back_button_form','back_button_form');
  
                        $var = Array(
                                'th_bg'                 => 
$phpgw_info['theme']['th_bg'],
!                               'left_next_matchs'      => 
$GLOBALS['phpgw']->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total,'&locale='.$this->bo->locales[0]),
!                               'right_next_matchs'     => 
$GLOBALS['phpgw']->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total,'&locale='.$this->bo->locales[0]),
!                               'lang_groups'           => lang('Holidays').' 
('.$this->bo->locales[0].')',
!                               'sort_name'             => 
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->bo->sort,'name',$this->bo->order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Holiday'),'&locale='.$this->bo->locales[0]),
!                               'header_edit'           => lang('Edit'),
                                'header_delete'         => lang('Delete'),
!                               'header_submit'         => '',
!                               'submit_link_column'    => ''
                        );
  
                        $p->set_var($var);
  
-                       $holidays = $this->bo->get_holiday_list();
- 
                        if (!count($holidays))
                        {
--- 141,166 ----
                        
$p->set_block('locale','back_button_form','back_button_form');
  
+                       $html = CreateObject('calendar.html');
+                       $year_form = str_replace('<option 
value=""></option>','',$html->form($html->sbox_submit($this->sb->getYears('year',$this->bo->year),true),array(),
+                               
$this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0])));
+                       unset($html);
+ 
+                       $holidays = $this->bo->get_holiday_list();
+ 
                        $var = Array(
                                'th_bg'                 => 
$phpgw_info['theme']['th_bg'],
!                               'left_next_matchs'      => 
$GLOBALS['phpgw']->nextmatchs->left('/index.php',$this->bo->start,$this->bo->total,'&menuaction=calendar.uiholiday.edit_locale&locale='.$this->bo->locales[0].'&year='.$this->bo->year),
!                               'right_next_matchs'     => 
$GLOBALS['phpgw']->nextmatchs->right('/index.php',$this->bo->start,$this->bo->total,'&menuaction=calendar.uiholiday.edit_locale&locale='.$this->bo->locales[0].'&year='.$this->bo->year),
!                               'center'                                        
=> '<td align="right">'.lang('Holidays').' ('.$this->bo->locales[0].')</td><td 
align="left">'.$year_form.'</td>',
!                               '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),
!                               'header_edit'                   => lang('Edit'),
                                'header_delete'         => lang('Delete'),
!                               '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>',
!                               'header_extra'       => lang('Copy'),
!                               'extra_width'        => 'width="5%"'
                        );
  
                        $p->set_var($var);
  
                        if (!count($holidays))
                        {
***************
*** 156,160 ****
                        else
                        {
!                               for($i=0;$i<count($holidays);$i++)
                                {
                                        $tr_color = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
--- 170,175 ----
                        else
                        {
!                               $maxmatchs = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
!                               for($i=$this->bo->start; $i < count($holidays) 
&& $i < $this->bo->start+$maxmatchs; $i++)
                                {
                                        $tr_color = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
***************
*** 168,173 ****
                                                'header_delete'=> 
lang('Delete'),
                                                'group_name'    => 
$holidays[$i]['name'],
!                                               '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'])).'">
 '.lang('Edit').' </a>',
!                                               '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'])).'">
 '.lang('Delete').' </a>'
                                        );
  
--- 183,190 ----
                                                'header_delete'=> 
lang('Delete'),
                                                'group_name'    => 
$holidays[$i]['name'],
!                                               'rule'                  => 
'<td>'.$this->bo->rule_string($holidays[$i]).'</td>',
!                                               '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>',
!                                               '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>',
!                                               '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>'
                                        );
  
***************
*** 178,186 ****
  
                        $var = Array(
!                               'new_action'    => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.add_holiday','locale'=>$this->bo->locales[0],'id'=>0)),
                                'lang_add'              => lang('add'),
                                'back_action'   => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')),
                                'lang_back'             => lang('Back'),
!                               'search_action'=> 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0])),
                                'lang_search'   => lang('search')
                        );
--- 195,203 ----
  
                        $var = Array(
!                               '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)),
                                'lang_add'              => lang('add'),
                                'back_action'   => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')),
                                'lang_back'             => lang('Back'),
!                               'search_action'=> 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0],'year'=>$this->bo->year)),
                                'lang_search'   => lang('search')
                        );
***************
*** 190,194 ****
                }
  
!               function edit_holiday()
                {
                        if(@$this->bo->id)
--- 207,211 ----
                }
  
!               function copy_holiday()
                {
                        if(@$this->bo->id)
***************
*** 196,204 ****
                                $holiday = $this->bo->read_entry($this->bo->id);
                        }
!                       if(!$holiday || address@hidden>bo->id)
                        {
!                               Header('Location: ' . 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0])));
                        }
  
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
--- 213,235 ----
                                $holiday = $this->bo->read_entry($this->bo->id);
                        }
!                       $this->bo->id = 0;
! 
!                       if (!$holiday['occurence'] || $holiday['occurence'] >= 
1900)
                        {
!                               $holiday['occurence'] = date('Y');
                        }
+                       $this->edit_holiday('',$holiday);
+               }
  
+               function edit_holiday($error='',$holiday='')
+               {
+                       if(@$this->bo->id && !$holiday)
+                       {
+                               $holiday = $this->bo->read_entry($this->bo->id);
+                       }
+                       if ($GLOBALS['HTTP_GET_VARS']['locale'])
+                       {
+                               $holiday['locale'] = 
$GLOBALS['HTTP_GET_VARS']['locale'];
+                       }
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
***************
*** 206,211 ****
                        $GLOBALS['phpgw']->common->phpgw_header();
  
-                       $sb = CreateObject('phpgwapi.sbox');
- 
                        $t = 
CreateObject('phpgwapi.Template',$this->template_dir);
                        
$t->set_file(Array('holiday'=>'holiday.tpl','form_button'=>'form_button_script.tpl'));
--- 237,240 ----
***************
*** 213,217 ****
                        $t->set_block('holiday','list','list');
  
!                       if (@$errorcount)
                        {
                                $message = 
$GLOBALS['phpgw']->common->error_list($error);
--- 242,246 ----
                        $t->set_block('holiday','list','list');
  
!                       if (@count($error))
                        {
                                $message = 
$GLOBALS['phpgw']->common->error_list($error);
***************
*** 223,229 ****
        
                        $var = Array(
!                               'title_holiday'=> lang('Edit').' 
'.lang('Holiday'),
                                'message'               => $message,
!                               'actionurl'        => 
$GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.add'),
                                'hidden_vars'   => '<input type="hidden" 
name="holiday[hol_id]" value="'.$this->bo->id.'">'."\n"
                                                         . '<input 
type="hidden" name="holiday[locales]" value="'.$this->bo->locales[0].'">'."\n"
--- 252,258 ----
        
                        $var = Array(
!                               'title_holiday'=> ($this->bo->id ? lang('Edit') 
: lang('Add')).' '.lang('Holiday'),
                                'message'               => $message,
!                               'actionurl'        => 
$GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.add&year='.$this->bo->year),
                                'hidden_vars'   => '<input type="hidden" 
name="holiday[hol_id]" value="'.$this->bo->id.'">'."\n"
                                                         . '<input 
type="hidden" name="holiday[locales]" value="'.$this->bo->locales[0].'">'."\n"
***************
*** 232,252 ****
  
  // Locale
!                       $this->display_item($t,lang('Country'),'<input 
name="holiday[locale]" size="2" maxlength="2" value="'.$holiday[locale].'">');
  
  // Title/Name
!                       $this->display_item($t,lang('title'),'<input 
name="holiday[name]" size="25" maxlength="50" value="'.$holiday['name'].'">');
  
  // Date
!                       
$this->display_item($t,lang('Date'),$GLOBALS['phpgw']->common->dateformatorder('',$sb->getMonthText('holiday[month_num]',$holiday['month']),$sb->getDays('holiday[mday]',$holiday['day'])));
  
  // Occurence
                        $occur = Array(
!                               0       => '0',
!                               1       => '1st',
!                               2       => '2nd',
!                               3       => '3rd',
!                               4       => '4th',
!                               5       => '5th',
!                               99      => 'Last'
                        );
                        $out = '';
--- 261,281 ----
  
  // Locale
!                       $this->display_item($t,lang('Country'),'<input 
name="holiday[locale]" size="3" maxlength="2" value="'.$holiday[locale].'">');
  
  // Title/Name
!                       $this->display_item($t,lang('title'),'<input 
name="holiday[name]" size="60" maxlength="50" value="'.$holiday['name'].'">');
  
  // Date
!                       
$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'])));
  
  // Occurence
                        $occur = Array(
!                               0       => '',
!                               1       => '1.',
!                               2       => '2.',
!                               3       => '3.',
!                               4       => '4.',
!                               5       => '5.',
!                               99      => lang('Last')
                        );
                        $out = '';
***************
*** 282,285 ****
--- 311,315 ----
                                $link_params = Array(
                                        'menuaction'    => 
'calendar.uiholiday.edit_locale',
+                                       'year'  => $this->bo->year,
                                        'locale'                => 
$this->bo->locales[0]
                                );
***************
*** 304,422 ****
  
  
-               function add_holiday($messages='',$holiday='')
-               {
-                       unset($GLOBALS['phpgw_info']['flags']['noheader']);
-                       unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
-                       $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
-                       $GLOBALS['phpgw']->common->phpgw_header();
- 
-                       $sb = CreateObject('phpgwapi.sbox');
- 
-                       $t = 
CreateObject('phpgwapi.Template',$this->template_dir);
-                       
$t->set_file(Array('holiday'=>'holiday.tpl','form_button'=>'form_button_script.tpl'));
-                       $t->set_block('holiday','form','form');
-                       $t->set_block('holiday','list','list');
- 
-                       if($messages)
-                       {
-                               if (is_array($messages))
-                               {
-                                       $message = 
$GLOBALS['phpgw']->common->error_list($messages);
-                               }
-                               else
-                               {
-                                       $message = '';
-                               }
-                       }
-       
-                       $var = Array(
-                               'title_holiday' => lang('Add').' 
'.lang('Holiday'),
-                               'message'                       => $message,
-                               'actionurl'                     => 
$GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.add'),
-                               'hidden_vars'           => '<input 
type="hidden" name="locale" value="'.$this->bo->locales[0].'">'."\n"
-                                                                       . 
'<input type="hidden" name="id" value="'.$this->bo->id.'">'."\n"
-                                                                       . 
'<input type="hidden" name="holiday[hol_id]" value="'.$this->bo->id.'">'."\n"
-                                                                       . 
'<input type="hidden" name="holiday[locales]" 
value="'.$this->bo->locales[0].'">'."\n"
-                       );
- 
-                       $t->set_var($var);
- 
- // Locale
-                       if($this->bo->locales[0])
-                       {
-                               $holiday['locale'] = $this->bo->locales[0];
-                       }
-                       $this->display_item($t,lang('Country'),'<input 
name="holiday[locale]" size="2" maxlength="2" value="'.$holiday[locale].'">');
- 
- // Title/Name
-                       $this->display_item($t,lang('title'),'<input 
name="holiday[name]" size="25" maxlength="50" value="'.$holiday['name'].'">');
- 
- // Date
-                       $day_html = 
$sb->getDays('holiday[mday]',$holiday['day']);
-                       $month_html = 
$sb->getMonthText('holiday[month_num]',$holiday['month']);
-                       $year_html = '';
-                       
$this->display_item($t,lang('Date'),$GLOBALS['phpgw']->common->dateformatorder($year_html,$month_html,$day_html));
- 
- // Occurence
-                       $occur = Array(
-                               0       => '0',
-                               1       => '1st',
-                               2       => '2nd',
-                               3       => '3rd',
-                               4       => '4th',
-                               5       => '5th',
-                               99      => 'Last'
-                       );
-                       $out = '';
-                       while(list($key,$value) = each($occur))
-                       {
-                               $out .= '<option 
value="'.$key.'"'.($holiday['occurence']==$key?' 
selected':'').'>'.$value.'</option>'."\n";
-                       }
-                       $occurence_html = '<select 
name="holiday[occurence]">'."\n".$out.'</select>'."\n";
- 
-                       $dow = Array(
-                               0       => lang('Sun'),
-                               1       => lang('Mon'),
-                               2       => lang('Tue'),
-                               3       => lang('Wed'),
-                               4       => lang('Thu'),
-                               5       => lang('Fri'),
-                               6       => lang('Sat')
-                       );
-                       $out = '';
-                       for($i=0;$i<7;$i++)
-                       {
-                               $out .= '<option 
value="'.$i.'"'.($holiday['dow']==$i?' 
selected':'').'>'.$dow[$i].'</option>'."\n";
-                       }
-                       $dow_html = '<select 
name="holiday[dow]">'."\n".$out.'</select>'."\n";
-                       
$this->display_item($t,lang('Occurence'),$occurence_html.'&nbsp;'.$dow_html);
-                       $this->display_item($t,lang('Observance Rule'),'<input 
type="checkbox" name="holiday[observance_rule]" 
value="True"'.($holiday['observance_rule']?' checked':'').'>');
- 
-                       $t->set_var('lang_add',lang('Save'));
-                       $t->set_var('lang_reset',lang('Reset'));
-                       if(@$this->bo->locales[0])
-                       {
-                               $link_params = Array(
-                                       'menuaction'    => 
'calendar.uiholiday.edit_locale',
-                                       'locale'                => 
$this->bo->locales[0]
-                               );
-                       }
-                       else
-                       {
-                               $link_params = Array(
-                                       'menuaction'    => 
'calendar.uiholiday.admin'
-                               );
-                       }
-                       $var = Array(
-                               'action_url_button'     => 
$GLOBALS['phpgw']->link($this->base_url,$link_params),
-                               'action_text_button'    => lang('Cancel'),
-                               'action_confirm_button' => '',
-                               'action_extra_field'    => ''
-                       );
-                       $t->set_var($var);
-                       $t->parse('cancel_button','form_button');
-                       $t->pparse('out','form');
-               }
- 
                function delete_locale()
                {
--- 334,337 ----
***************
*** 425,429 ****
                                $this->admin();
                        }
!                       
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
--- 340,344 ----
                                $this->admin();
                        }
! 
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
***************
*** 474,481 ****
                        
$p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl'));
                
!                       $p->set_var('messages',lang('Are you sure you want to 
delete this holiday ?')."<br>".$holiday['name'].' ('.$this->bo->locales[0].')');
  
                        $var = Array(
!                               'action_url_button'     => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0])),
                                'action_text_button'    => lang('No'),
                                'action_confirm_button' => '',
--- 389,396 ----
                        
$p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl'));
                
!                       $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));
  
                        $var = Array(
!                               'action_url_button'     => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0],'year'=>$this->bo->year)),
                                'action_text_button'    => lang('No'),
                                'action_confirm_button' => '',
***************
*** 486,490 ****
  
                        $var = Array(
!                               'action_url_button'     => 
$GLOBALS['phpgw']->link($this->base_url,Array('menuaction'=>'calendar.boholiday.delete_holiday','locale'=>$this->bo->locales[0],'id'=>$this->bo->id)),
                                'action_text_button'    => lang('Yes'),
                                'action_confirm_button' => '',
--- 401,405 ----
  
                        $var = Array(
!                               '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)),
                                'action_text_button'    => lang('Yes'),
                                'action_confirm_button' => '',
***************
*** 503,521 ****
                                $this->admin();
                        }
                        $holidays = $this->bo->get_holiday_list();
-                       $GLOBALS['phpgw_info']['flags']['noappheader']  = True;
-                       $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
-                       $GLOBALS['phpgw_info']['flags']['nofooter'] = True;
-                       $GLOBALS['phpgw']->common->phpgw_header();
  
!                       echo '<body 
onLoad="document.submitform.submit()">'."\n";
!                       if($this->debug)
                        {
!                               echo '<form 
action="'.$GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.accept_holiday').'"
 method="post" name="submitform">'."\n";
                        }
                        else
                        {
!                               echo '<form 
action="http://www.phpgroupware.org/cal/accept_holiday.php"; method="post" 
name="submitform">'."\n";
                        }
  
                        $c_holidays = count($holidays);
--- 418,452 ----
                                $this->admin();
                        }
+                       $this->bo->year = 0;    // for a complete list with all 
years
                        $holidays = $this->bo->get_holiday_list();
  
!                       if (isset($GLOBALS['HTTP_GET_VARS']['download']))
!                       {
!                               $locale = $this->bo->locales[0];
!                               $browser = CreateObject('phpgwapi.browser');
!                               
$browser->content_header('holidays.'.$locale,'text/text');
!                               unset($browser);
! 
!                               while (list(,$holiday) = @each($holidays))
!                               {
!                                       echo 
"$locale\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n";
!                               }
!                               $GLOBALS['phpgw']->common->phpgw_exit();
!                       }
!                       elseif($this->debug)
                        {
!                               $action = 
$GLOBALS['phpgw']->link('/calendar/phpgroupware.org/accept_holiday.php');
                        }
                        else
                        {
!                               $action = 
'http://www.phpgroupware.org/cal/accept_holiday.php';
                        }
+                       $GLOBALS['phpgw_info']['flags']['noappheader']  = True;
+                       $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
+                       $GLOBALS['phpgw_info']['flags']['nofooter'] = True;
+                       $GLOBALS['phpgw']->common->phpgw_header();
+ 
+                       echo '<body 
onLoad="document.submitform.submit()">'."\n";
+                       echo '<form action="'.$action.'" method="post" 
name="submitform">'."\n";
  
                        $c_holidays = count($holidays);
***************
*** 529,532 ****
--- 460,467 ----
                                        . '<input type="hidden" name="dow[]" 
value="'.$holidays[$i]['dow'].'">'."\n"
                                        . '<input type="hidden" 
name="observance[]" value="'.$holidays[$i]['observance_rule'].'">'."\n";
+                       }
+                       if ($mailto)
+                       {
+                               echo "<input type='submit' value='Mail to 
$mailto'>\n";
                        }
                        echo "</form>\n</body>\n</head>";





reply via email to

[Prev in Thread] Current Thread [Next in Thread]