Should finish the basic holiday management.

This commit is contained in:
skeeter 2001-05-19 03:24:36 +00:00
parent 15ec83f520
commit 95bde96cef
6 changed files with 166 additions and 22 deletions

View File

@ -66,4 +66,5 @@
$p->parse('yes','form_button');
$p->pparse('out','form');
$phpgw->common->phpgw_footer();
?>

70
calendar/deletelocale.php Executable file
View File

@ -0,0 +1,70 @@
<?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$ */
if(!$locale)
{
Header('Location: ' . $phpgw->link('/calendar/holiday_admin.php'));
}
$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');
if(isset($yes) && $yes==True)
{
$phpgw->calendar->holidays->delete_locale($locale);
Header('Location: ' . $phpgw->link('/calendar/holiday_admin.php'));
}
$phpgw->common->phpgw_header();
echo parse_navbar();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$templates = Array(
'form' => 'delete_common.tpl',
'form_button' => 'form_button_script.tpl'
);
$p->set_file($templates);
$p->set_var('messages',lang('Are you sure you want to delete this ?'));
$var = Array(
'action_url_button' => $phpgw->link('/calendar/holiday_admin.php'),
'action_text_button' => lang('No'),
'action_confirm_button' => '',
'action_extra_field' => ''
);
$p->set_var($var);
$p->parse('no','form_button');
$var = Array(
'action_url_button' => $phpgw->link('/calendar/deletelocale.php','locale='.$locale.'&yes=true'),
'action_text_button' => lang('Yes'),
'action_confirm_button' => '',
'action_extra_field' => ''
);
$p->set_var($var);
$p->parse('yes','form_button');
$p->pparse('out','form');
$phpgw->common->phpgw_footer();
?>

View File

@ -15,6 +15,8 @@
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'admin_header' => True,
'noheader' => True,
'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True,
'parent_page' => 'holiday_admin.php'
@ -27,25 +29,27 @@
$start = 0;
}
function country_total($query)
function country_total($locale,$query)
{
global $phpgw;
$querymethod='';
if($query)
{
$querymethod = ' WHERE '.$query;
$querymethod = ' AND '.$query;
}
$phpgw->db->query("SELECT locale FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__);
$count = 0;
while($phpgw->db->next_record())
{
$count++;
}
return $count;
$phpgw->db->query("SELECT count(*) FROM phpgw_cal_holidays WHERE locale='".$locale."'".$querymethod,__LINE__,__FILE__);
$phpgw->db->next_record();
return intval($phpgw->db->f(0));
// $count = 0;
// while($phpgw->db->next_record())
// {
// $count++;
// }
// return $count;
}
function get_holiday_list($sort, $order, $query, $total)
function get_holiday_list($locale, $sort, $order, $query, $total)
{
global $phpgw;
@ -53,14 +57,14 @@
if($query)
{
$querymethod .= ' WHERE '.$query;
$querymethod .= ' AND '.$query;
}
if($order)
{
$querymethod .= ' ORDER BY '.$order;
}
$phpgw->db->query("SELECT hol_id,name FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__);
$phpgw->db->query("SELECT hol_id,name FROM phpgw_cal_holidays WHERE locale='".$locale."'".$querymethod,__LINE__,__FILE__);
while($phpgw->db->next_record())
{
$holiday[$phpgw->db->f('hol_id')] = $phpgw->strip_html($phpgw->db->f('name'));
@ -72,16 +76,20 @@
{
$query = str_replace('=',"='",$query)."'";
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$templates = Array(
'group' => 'groups.tpl'
'locale' => 'locales.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');
$p->set_block('locale','list','list');
$p->set_block('locale','row','row');
$p->set_block('locale','row_empty','row_empty');
$total = country_total($query);
$total = country_total($locale,$query);
if(!$total && !isset($query))
{
Header('Location: ' . $phpgw->link('/calendar/holiday_admin.php'));
}
$p->set_var('th_bg',$phpgw_info['theme']['th_bg']);
@ -93,7 +101,7 @@
$p->set_var('header_edit',lang('Edit'));
$p->set_var('header_delete',lang('Delete'));
$holidays = get_holiday_list($sort, $order, $query, $total);
$holidays = get_holiday_list($locale, $sort, $order, $query, $total);
if (!count($holidays))
{
@ -120,10 +128,14 @@
$p->set_var('new_action',$phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id=0'));
$p->set_var('lang_add',lang('add'));
$p->set_var('back_action',$phpgw->link('/calendar/holiday_admin.php'));
$p->set_var('lang_back',lang('Back'));
$p->set_var('search_action',$phpgw->link('/calendar/editlocale.php'));
$p->set_var('lang_search',lang('search'));
$phpgw->common->phpgw_header();
echo parse_navbar();
$p->pparse('out','list');
$phpgw->common->phpgw_footer();
?>

View File

@ -118,7 +118,7 @@
}
}
$p->set_var('new_action',$phpgw->link('/calendar/new_locale.php'));
$p->set_var('new_action',$phpgw->link('/calendar/editholiday.php','id=0'));
$p->set_var("lang_add",lang('add'));
$p->set_var('search_action',$phpgw->link('/calendar/holiday_admin.php'));

View File

@ -78,6 +78,12 @@ class calendar_holiday
$this->db->query($sql,__LINE__,__FILE__);
}
function delete_locale($locale)
{
$sql = "DELETE FROM phpgw_cal_holidays WHERE locale='".$locale."'";
$this->db->query($sql,__LINE__,__FILE__);
}
function load_from_network($locale)
{
global $phpgw_info, $HTTP_HOST, $SERVER_PORT;

View File

@ -0,0 +1,55 @@
<!-- BEGIN list -->
<p>
<table border="0" width="45%" align="center">
<tr>
<td align="left">{left_next_matchs}</td>
<td align="center">{lang_groups}</td>
<td align="right">{right_next_matchs}</td>
</tr>
</table>
<table border="0" width="45%" align="center">
<tr bgcolor="{th_bg}">
<td>{sort_name}</td>
<td>{header_edit}</td>
<td>{header_delete}</td>
</tr>
{rows}
</table>
<table border="0" width="45%" align="center">
<tr>
<td align="left">
<form method="POST" action="{new_action}">
<input type="submit" value="{lang_add}">
</form>
</td>
<td align="center">
<form method="POST" action="{back_action}">
<input type="submit" value="{lang_back}">
</form>
</td>
<td align="right">{lang_search}&nbsp;
<form method="POST" action="{search_action}">
<input name="query">
</form>
</td>
</tr>
</table>
<!-- END list -->
<!-- BEGIN row -->
<tr bgcolor="{tr_color}">
<td>{group_name}</td>
<td width="5%">{edit_link}</td>
<td width="5%">{delete_link}</td>
</tr>
<!-- END row -->
<!-- BEGIN row_empty -->
<tr>
<td colspan="5" align="center">{message}</td>
</tr>
<!-- END row_empty -->