forked from extern/egroupware
Can now save new holidays by locales.
This commit is contained in:
parent
1de46d028c
commit
b7a4b1ca57
@ -11,11 +11,6 @@
|
|||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
if(!$id)
|
|
||||||
{
|
|
||||||
Header('Location: ' . $phpgw->link('/calendar/editlocale.php','locale='.$locale));
|
|
||||||
}
|
|
||||||
|
|
||||||
$phpgw_flags = Array(
|
$phpgw_flags = Array(
|
||||||
'currentapp' => 'calendar',
|
'currentapp' => 'calendar',
|
||||||
'enable_nextmatchs_class' => True,
|
'enable_nextmatchs_class' => True,
|
||||||
@ -24,7 +19,7 @@
|
|||||||
'nonavbar' => True,
|
'nonavbar' => True,
|
||||||
'noappheader' => True,
|
'noappheader' => True,
|
||||||
'noappfooter' => True,
|
'noappfooter' => True,
|
||||||
'parent_page' => 'holiday_admin.php'
|
'parent_page' => '/calendar/editlocale.php'
|
||||||
);
|
);
|
||||||
$phpgw_info['flags'] = $phpgw_flags;
|
$phpgw_info['flags'] = $phpgw_flags;
|
||||||
include('../header.inc.php');
|
include('../header.inc.php');
|
||||||
@ -36,7 +31,22 @@
|
|||||||
$p->parse('rows','list',True);
|
$p->parse('rows','list',True);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$submit)
|
if(isset($submit) && $submit)
|
||||||
|
{
|
||||||
|
if(empty($holiday['mday']))
|
||||||
|
{
|
||||||
|
$holiday['mday'] = 0;
|
||||||
|
}
|
||||||
|
// Still need to put some validation in here.....
|
||||||
|
|
||||||
|
$ok = True;
|
||||||
|
if(isset($ok) && $ok)
|
||||||
|
{
|
||||||
|
$phpgw->calendar->holidays->save_holiday($holiday);
|
||||||
|
Header('Location: ' . $phpgw->link('/calendar/editlocale.php','locale='.$locale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($id != 0)
|
||||||
{
|
{
|
||||||
$phpgw->calendar->holidays->users['admin'] = $locale;
|
$phpgw->calendar->holidays->users['admin'] = $locale;
|
||||||
$phpgw->calendar->holidays->read_holiday();
|
$phpgw->calendar->holidays->read_holiday();
|
||||||
@ -46,120 +56,133 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$phpgw->common->phpgw_header();
|
|
||||||
echo parse_navbar();
|
|
||||||
$index = $phpgw->calendar->holidays->index[$id];
|
$index = $phpgw->calendar->holidays->index[$id];
|
||||||
|
$holiday = $phpgw->calendar->holidays->get_holiday($index);
|
||||||
}
|
}
|
||||||
|
$title_descriptor = 'Edit';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$holiday['locale'] = $locale;
|
||||||
|
$holiday['name'] = '';
|
||||||
|
$holiday['day'] = 0;
|
||||||
|
$holiday['month'] = 0;
|
||||||
|
$holiday['occurence'] = 0;
|
||||||
|
$holiday['dow'] = 0;
|
||||||
|
$holiday['observance_rule'] = 0;
|
||||||
|
$title_descriptor = 'Add';
|
||||||
|
}
|
||||||
|
|
||||||
$sb = CreateObject('phpgwapi.sbox');
|
$phpgw->common->phpgw_header();
|
||||||
|
echo parse_navbar();
|
||||||
|
|
||||||
$holiday = $phpgw->calendar->holidays->get_holiday($index);
|
$sb = CreateObject('phpgwapi.sbox');
|
||||||
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
|
||||||
$templates = Array(
|
|
||||||
'holiday' => 'holiday.tpl',
|
|
||||||
'form_button' => 'form_button_script.tpl'
|
|
||||||
);
|
|
||||||
$t->set_file($templates);
|
|
||||||
$t->set_block('holiday','form','form');
|
|
||||||
$t->set_block('holiday','list','list');
|
|
||||||
|
|
||||||
$title_holiday = lang('Holiday');
|
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
||||||
|
$templates = Array(
|
||||||
|
'holiday' => 'holiday.tpl',
|
||||||
|
'form_button' => 'form_button_script.tpl'
|
||||||
|
);
|
||||||
|
$t->set_file($templates);
|
||||||
|
$t->set_block('holiday','form','form');
|
||||||
|
$t->set_block('holiday','list','list');
|
||||||
|
|
||||||
if ($errorcount)
|
$title_holiday = lang($title_descriptor).' '.lang('Holiday');
|
||||||
{
|
|
||||||
$message = $phpgw->common->error_list($error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$message = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$actionurl = $phpgw->link('/calendar/editholiday.php');
|
if ($errorcount)
|
||||||
$hidden_vars = '<input type="hidden" name="locale" value="'.$locale.'">'."\n"
|
{
|
||||||
. '<input type="hidden" name="id" value="'.$id.'">'."\n";
|
$message = $phpgw->common->error_list($error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$actionurl = $phpgw->link('/calendar/editholiday.php');
|
||||||
|
$hidden_vars = '<input type="hidden" name="holiday[locale]" value="'.$locale.'">'."\n"
|
||||||
|
. '<input type="hidden" name="holiday[hol_id]" value="'.$id.'">'."\n"
|
||||||
|
. '<input type="hidden" name="locale" value="'.$locale.'">'."\n"
|
||||||
|
. '<input type="hidden" name="id" value="'.$id.'">'."\n";
|
||||||
|
|
||||||
$var = Array(
|
$var = Array(
|
||||||
'title_holiday' => $title_holiday,
|
'title_holiday' => $title_holiday,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'actionurl' => $actionurl,
|
'actionurl' => $actionurl,
|
||||||
'hidden_vars' => $hidden_vars
|
'hidden_vars' => $hidden_vars
|
||||||
);
|
);
|
||||||
|
|
||||||
$t->set_var($var);
|
$t->set_var($var);
|
||||||
|
|
||||||
// Title/Name
|
// Title/Name
|
||||||
display_item($t,lang('title'),'<input name="name" size="25" maxlength="50" value="'.$holiday['name'].'">');
|
display_item($t,lang('title'),'<input name="holiday[name]" size="25" maxlength="50" value="'.$holiday['name'].'">');
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
$day_html = $sb->getDays('day',$holiday['day']);
|
$day_html = $sb->getDays('holiday[mday]',$holiday['day']);
|
||||||
$month_html = $sb->getMonthText('month',$holiday['month']);
|
$month_html = $sb->getMonthText('holiday[month_num]',$holiday['month']);
|
||||||
$year_html = '';
|
$year_html = '';
|
||||||
display_item($t,lang('Date'),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
|
display_item($t,lang('Date'),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
|
||||||
|
|
||||||
// Occurence
|
// Occurence
|
||||||
$occur = Array(
|
$occur = Array(
|
||||||
0 => '0',
|
0 => '0',
|
||||||
1 => '1st',
|
1 => '1st',
|
||||||
2 => '2nd',
|
2 => '2nd',
|
||||||
3 => '3rd',
|
3 => '3rd',
|
||||||
4 => '4th',
|
4 => '4th',
|
||||||
5 => '5th',
|
5 => '5th',
|
||||||
99 => 'Last'
|
99 => 'Last'
|
||||||
);
|
);
|
||||||
$out = '<select name="occurence">'."\n";
|
$out = '<select name="holiday[occurence]">'."\n";
|
||||||
while(list($key,$value) = each($occur))
|
while(list($key,$value) = each($occur))
|
||||||
{
|
{
|
||||||
$out .= '<option value="'.$key.'"';
|
$out .= '<option value="'.$key.'"';
|
||||||
if($holiday['occurence']==$key) $out .= ' selected';
|
if($holiday['occurence']==$key) $out .= ' selected';
|
||||||
$out .= '>'.$value.'</option>'."\n";
|
$out .= '>'.$value.'</option>'."\n";
|
||||||
}
|
|
||||||
$out .= '</select>'."\n";
|
|
||||||
|
|
||||||
$occurence_html = $out;
|
|
||||||
|
|
||||||
$dow = Array(
|
|
||||||
0 => lang('Sun'),
|
|
||||||
1 => lang('Mon'),
|
|
||||||
2 => lang('Tue'),
|
|
||||||
3 => lang('Wed'),
|
|
||||||
4 => lang('Thu'),
|
|
||||||
5 => lang('Fri'),
|
|
||||||
6 => lang('Sat')
|
|
||||||
);
|
|
||||||
$out = '<select name="dow">'."\n";
|
|
||||||
for($i=0;$i<7;$i++)
|
|
||||||
{
|
|
||||||
$out .= '<option value="'.$i.'"';
|
|
||||||
if($holiday['occurence']==$i) $out .= ' selected';
|
|
||||||
$out .= '>'.$dow[$i].'</option>'."\n";
|
|
||||||
}
|
|
||||||
$out .= '</select>'."\n";
|
|
||||||
|
|
||||||
$dow_html = $out;
|
|
||||||
|
|
||||||
display_item($t,lang('Occurence'),$occurence_html.' '.$dow_html);
|
|
||||||
|
|
||||||
$str = '<input type="checkbox" name="observance_rule" value="True"';
|
|
||||||
if($holiday['observance_rule'])
|
|
||||||
{
|
|
||||||
$str .= ' checked';
|
|
||||||
}
|
|
||||||
$str .= '>';
|
|
||||||
display_item($t,lang('Observance Rule'),$str);
|
|
||||||
|
|
||||||
|
|
||||||
$t->set_var('lang_add',lang('Save'));
|
|
||||||
$t->set_var('lang_reset',lang('Reset'));
|
|
||||||
$var = Array(
|
|
||||||
'action_url_button' => $phpgw->link('/calendar/editlocale.php','locale='.$locale),
|
|
||||||
'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');
|
|
||||||
$phpgw->common->phpgw_footer();
|
|
||||||
}
|
}
|
||||||
|
$out .= '</select>'."\n";
|
||||||
|
|
||||||
|
$occurence_html = $out;
|
||||||
|
|
||||||
|
$dow = Array(
|
||||||
|
0 => lang('Sun'),
|
||||||
|
1 => lang('Mon'),
|
||||||
|
2 => lang('Tue'),
|
||||||
|
3 => lang('Wed'),
|
||||||
|
4 => lang('Thu'),
|
||||||
|
5 => lang('Fri'),
|
||||||
|
6 => lang('Sat')
|
||||||
|
);
|
||||||
|
$out = '<select name="holiday[dow]">'."\n";
|
||||||
|
for($i=0;$i<7;$i++)
|
||||||
|
{
|
||||||
|
$out .= '<option value="'.$i.'"';
|
||||||
|
if($holiday['dow']==$i) $out .= ' selected';
|
||||||
|
$out .= '>'.$dow[$i].'</option>'."\n";
|
||||||
|
}
|
||||||
|
$out .= '</select>'."\n";
|
||||||
|
|
||||||
|
$dow_html = $out;
|
||||||
|
|
||||||
|
display_item($t,lang('Occurence'),$occurence_html.' '.$dow_html);
|
||||||
|
|
||||||
|
$str = '<input type="checkbox" name="holiday[observance_rule]" value="True"';
|
||||||
|
if($holiday['observance_rule'])
|
||||||
|
{
|
||||||
|
$str .= ' checked';
|
||||||
|
}
|
||||||
|
$str .= '>';
|
||||||
|
display_item($t,lang('Observance Rule'),$str);
|
||||||
|
|
||||||
|
$t->set_var('lang_add',lang('Save'));
|
||||||
|
$t->set_var('lang_reset',lang('Reset'));
|
||||||
|
$var = Array(
|
||||||
|
'action_url_button' => $phpgw->link('/calendar/editlocale.php','locale='.$locale),
|
||||||
|
'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');
|
||||||
|
$phpgw->common->phpgw_footer();
|
||||||
?>
|
?>
|
||||||
|
@ -117,8 +117,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$p->set_var('new_action',$phpgw->link('/calendar/new_holiday.php','locale='.$locale));
|
$p->set_var('new_action',$phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id=0'));
|
||||||
$p->set_var("lang_add",lang('add'));
|
$p->set_var('lang_add',lang('add'));
|
||||||
|
|
||||||
$p->set_var('search_action',$phpgw->link('/calendar/editlocale.php'));
|
$p->set_var('search_action',$phpgw->link('/calendar/editlocale.php'));
|
||||||
$p->set_var('lang_search',lang('search'));
|
$p->set_var('lang_search',lang('search'));
|
||||||
|
@ -56,6 +56,22 @@ class calendar_holiday
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function save_holiday($holiday)
|
||||||
|
{
|
||||||
|
if(isset($holiday['hol_id']) && $holiday['hol_id'])
|
||||||
|
{
|
||||||
|
// echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
|
||||||
|
$sql = "UPDATE phpgw_cal_holidays SET name='".$holiday['name']."', mday=".$holiday['mday'].', month_num='.$holiday['month_num'].', occurence='.$holiday['occurence'].', dow='.$holiday['dow'].', observance_rule='.intval($holiday['observance_rule']).' WHERE hol_id='.$holiday['hol_id'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
|
||||||
|
$sql = 'INSERT INTO phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) '
|
||||||
|
. "VALUES('".$holiday['locale']."','".$holiday['name']."',".$holiday['mday'].','.$holiday['month_num'].','.$holiday['occurence'].','.$holiday['dow'].','.intval($holiday['observance_rule']).")";
|
||||||
|
}
|
||||||
|
$this->db->query($sql,__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
|
||||||
function load_from_network($locale)
|
function load_from_network($locale)
|
||||||
{
|
{
|
||||||
global $phpgw_info, $HTTP_HOST, $SERVER_PORT;
|
global $phpgw_info, $HTTP_HOST, $SERVER_PORT;
|
||||||
@ -101,16 +117,15 @@ class calendar_holiday
|
|||||||
$holiday = explode("\t",$lines[$i]);
|
$holiday = explode("\t",$lines[$i]);
|
||||||
if(count($holiday) == 7)
|
if(count($holiday) == 7)
|
||||||
{
|
{
|
||||||
$loc = $holiday[0];
|
$holiday['locale'] = $holiday[0];
|
||||||
$name = addslashes($holiday[1]);
|
$holiday['name'] = addslashes($holiday[1]);
|
||||||
$day = intval($holiday[2]);
|
$holiday['mday'] = intval($holiday[2]);
|
||||||
$month = intval($holiday[3]);
|
$holiday['month_num'] = intval($holiday[3]);
|
||||||
$occurence = intval($holiday[4]);
|
$holiday['occurence'] = intval($holiday[4]);
|
||||||
$dow = intval($holiday[5]);
|
$holiday['dow'] = intval($holiday[5]);
|
||||||
$observ_rule = intval($holiday[6]);
|
$holiday['observance_rule'] = intval($holiday[6]);
|
||||||
// echo "Inserting LOCALE='".$loc."' NAME='".$name."' extra=(".$day.'/'.$month.'/'.$occurence.'/'.$dow.'/'.")<br>\n";
|
$holiday['hol_id'] = 0;
|
||||||
$sql = "INSERT INTO phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) VALUES('$loc','$name',$day,$month,$occurence,$dow,$observ_rule)";
|
$this->save_holiday($holiday);
|
||||||
$this->db->query($sql,__LINE__,__FILE__);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user