Holiday Management pages. -- Not completely finished.. still need to code the save portion of edit and add and delete.

This commit is contained in:
skeeter 2001-05-15 04:10:37 +00:00
parent 87db00fe42
commit 0ab640ddc1
5 changed files with 483 additions and 0 deletions

165
calendar/editholiday.php Executable file
View File

@ -0,0 +1,165 @@
<?php
/**************************************************************************\
* phpGroupWare - Admin *
* http://www.phpgroupware.org *
* Written by Bettina Gille [ceb@phpgroupware.org] *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
if(!$id)
{
Header('Location: ' . $phpgw->link('/calendar/editlocale.php','locale='.$locale));
}
$phpgw_flags = Array(
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'admin_header' => True,
'noheader' => True,
'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True,
'parent_page' => 'holiday_admin.php'
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
function display_item(&$p,$field,$data)
{
$p->set_var('field',$field);
$p->set_var('data',$data);
$p->parse('rows','list',True);
}
if(!$submit)
{
$phpgw->calendar->holidays->users['admin'] = $locale;
$phpgw->calendar->holidays->read_holiday();
if(!isset($phpgw->calendar->holidays->index[$id]))
{
Header('Location: ' . $phpgw->link('/calendar/editlocale.php','locale='.$locale));
}
else
{
$phpgw->common->phpgw_header();
echo parse_navbar();
$index = $phpgw->calendar->holidays->index[$id];
}
$sb = CreateObject('phpgwapi.sbox');
$holiday = $phpgw->calendar->holidays->get_holiday($index);
$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');
if ($errorcount)
{
$message = $phpgw->common->error_list($error);
}
else
{
$message = '';
}
$actionurl = $phpgw->link('/calendar/editholiday.php');
$hidden_vars = '<input type="hidden" name="locale" value="'.$locale.'">'."\n"
. '<input type="hidden" name="id" value="'.$id.'">'."\n";
$var = Array(
'title_holiday' => $title_holiday,
'message' => $message,
'actionurl' => $actionurl,
'hidden_vars' => $hidden_vars
);
$t->set_var($var);
// Title/Name
display_item($t,lang('title'),'<input name="name" size="25" maxlength="50" value="'.$holiday['name'].'">');
// Date
$day_html = $sb->getDays('day',$holiday['day']);
$month_html = $sb->getMonthText('month',$holiday['month']);
$year_html = '';
display_item($t,lang('Date'),$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 = '<select name="occurence">'."\n";
while(list($key,$value) = each($occur))
{
$out .= '<option value="'.$key.'"';
if($holiday['occurence']==$key) $out .= ' selected';
$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.'&nbsp;'.$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();
}
?>

129
calendar/editlocale.php Executable file
View File

@ -0,0 +1,129 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_flags = Array(
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'admin_header' => True,
'noappheader' => True,
'noappfooter' => True,
'parent_page' => 'holiday_admin.php'
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
if(!isset($start))
{
$start = 0;
}
function country_total($query)
{
global $phpgw;
$querymethod='';
if($query)
{
$querymethod = ' WHERE '.$query;
}
$phpgw->db->query("SELECT locale FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__);
$count = 0;
while($phpgw->db->next_record())
{
$count++;
}
return $count;
}
function get_holiday_list($sort, $order, $query, $total)
{
global $phpgw;
$querymethod = '';
if($query)
{
$querymethod .= ' WHERE '.$query;
}
if($order)
{
$querymethod .= ' ORDER BY '.$order;
}
$phpgw->db->query("SELECT hol_id,name FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__);
while($phpgw->db->next_record())
{
$holiday[$phpgw->db->f('hol_id')] = $phpgw->strip_html($phpgw->db->f('name'));
}
return $holiday;
}
if($query)
{
$query = str_replace('=',"='",$query)."'";
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$templates = Array(
'group' => 'groups.tpl'
);
$p->set_file($templates);
$p->set_block('group','list','list');
$p->set_block('group','row','row');
$p->set_block('group','row_empty','row_empty');
$total = country_total($query);
$p->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$p->set_var('left_next_matchs',$phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$start,$total,'&locale='.$locale));
$p->set_var('right_next_matchs',$phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$start,$total,'&locale='.$locale));
$p->set_var('lang_groups',lang('Holidays').' ('.$locale.')');
$p->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'name',$order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Holiday'),'&locale='.$locale));
$p->set_var('header_edit',lang('Edit'));
$p->set_var('header_delete',lang('Delete'));
$holidays = get_holiday_list($sort, $order, $query, $total);
if (! count($holidays))
{
$p->set_var('message',lang('No matchs found'));
$p->parse('rows','row_empty',True);
}
else
{
while (list($index,$name) = each($holidays))
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$p->set_var('tr_color',$tr_color);
if (! $name) $name = '&nbsp;';
$p->set_var('group_name',$name);
$p->set_var('edit_link','<a href="' . $phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id='.$index) . '"> ' . lang('Edit') . ' </a>');
$p->set_var('delete_link','<a href="' . $phpgw->link('/calendar/deleteholiday.php','locale='.$locale.'&id='.$index) . '"> ' . lang('Delete') . ' </a>');
$p->parse('rows','row',True);
}
}
$p->set_var('new_action',$phpgw->link('/calendar/new_holiday.php','locale='.$locale));
$p->set_var("lang_add",lang('add'));
$p->set_var('search_action',$phpgw->link('/calendar/editlocale.php'));
$p->set_var('lang_search',lang('search'));
$p->pparse('out','list');
$phpgw->common->phpgw_footer();
?>

131
calendar/holiday_admin.php Executable file
View File

@ -0,0 +1,131 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_flags = Array(
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'admin_header' => True,
'noappheader' => True,
'noappfooter' => True,
'parent_page' => '../admin/index.php'
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
if(!isset($start))
{
$start = 0;
}
function country_total($query)
{
global $phpgw;
$querymethod='';
if($query)
{
$querymethod = "WHERE locale='".$query."'";
}
$phpgw->db->query("SELECT DISTINCT locale FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__);
$count = 0;
while($phpgw->db->next_record())
{
$count++;
}
return $count;
}
function get_locale_list($sort, $order, $query, $total)
{
global $phpgw;
$querymethod = '';
if($query)
{
$querymethod .= " WHERE locale='".$query."'";
}
if($order)
{
$querymethod .= ' ORDER BY '.$order;
}
$phpgw->db->query("SELECT DISTINCT locale FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__);
while($phpgw->db->next_record())
{
$locale[] = $phpgw->db->f('locale');
}
return $locale;
}
if($query)
{
$query = str_replace('=',"='",$query)."'";
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$templates = Array(
'group' => 'groups.tpl'
);
$p->set_file($templates);
$p->set_block('group','list','list');
$p->set_block('group','row','row');
$p->set_block('group','row_empty','row_empty');
$total = country_total($query);
$p->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$p->set_var('left_next_matchs',$phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$start,$total));
$p->set_var('right_next_matchs',$phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$start,$total));
$p->set_var('lang_groups',lang('Countries'));
$p->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'locale',$order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')));
$p->set_var('header_edit',lang('Edit'));
$p->set_var('header_delete',lang('Delete'));
$locales = get_locale_list($sort, $order, $query, $total);
if (! count($locales))
{
$p->set_var('message',lang('No matchs found'));
$p->parse('rows','row_empty',True);
}
else
{
while (list(,$value) = each($locales))
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$p->set_var('tr_color',$tr_color);
if (! $value) $value = '&nbsp;';
$p->set_var('group_name',$value);
$p->set_var("edit_link",'<a href="' . $phpgw->link('/calendar/editlocale.php','locale='.$value) . '"> ' . lang('Edit') . ' </a>');
$p->set_var("delete_link",'<a href="' . $phpgw->link('/calendar/deletelocale.php','locale='.$value) . '"> ' . lang('Delete') . ' </a>');
$p->parse('rows','row',True);
}
}
$p->set_var('new_action',$phpgw->link('/calendar/new_locale.php'));
$p->set_var("lang_add",lang('add'));
$p->set_var('search_action',$phpgw->link('/calendar/holiday_admin.php'));
$p->set_var('lang_search',lang('search'));
$p->pparse('out','list');
$phpgw->common->phpgw_footer();
?>

22
calendar/inc/hook_admin.inc.php Executable file
View File

@ -0,0 +1,22 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
{
echo "<p>";
$imgpath = $phpgw->common->image($appname,'navbar.gif');
section_start(ucfirst($appname),$imgpath);
echo '<a href="' . $phpgw->link('/calendar/holiday_admin.php') . '">' . lang('Calendar Holiday Management') . '</a>';
section_end();
}
?>

View File

@ -0,0 +1,36 @@
<!-- $Id$ -->
<!-- BEGIN form -->
<center>
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<tr><td colspan="1" align="center" bgcolor="#c9c9c9"><b>{title_holiday}<b/></td></tr>
</table>
{message}
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
{hidden_vars}
{rows}
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr valign="bottom">
<td height="50" align="center">
<input type="submit" name="submit" value="{lang_add}">
</td>
<td height="50" align="center">
<input type="reset" name="reset" value="{lang_reset}">
</td>
</tr>
</table>
<td>
</tr>
</form>
</table>
{cancel_button}
</center>
<!-- END form -->
<!-- BEGIN list -->
<tr>
<td valign="top" width="35%"><b>{field}:</b></td>
<td valign="top" width="65%">{data}</td>
</tr>
<!-- END list -->