From 95bde96cef06bd27180b943135e42306322e4fc8 Mon Sep 17 00:00:00 2001 From: skeeter Date: Sat, 19 May 2001 03:24:36 +0000 Subject: [PATCH] Should finish the basic holiday management. --- calendar/deleteholiday.php | 1 + calendar/deletelocale.php | 70 +++++++++++++++++++++ calendar/editlocale.php | 54 +++++++++------- calendar/holiday_admin.php | 2 +- calendar/inc/class.calendar_holiday.inc.php | 6 ++ calendar/templates/default/locales.tpl | 55 ++++++++++++++++ 6 files changed, 166 insertions(+), 22 deletions(-) create mode 100755 calendar/deletelocale.php create mode 100755 calendar/templates/default/locales.tpl diff --git a/calendar/deleteholiday.php b/calendar/deleteholiday.php index dfd9ca283f..247e58895d 100755 --- a/calendar/deleteholiday.php +++ b/calendar/deleteholiday.php @@ -66,4 +66,5 @@ $p->parse('yes','form_button'); $p->pparse('out','form'); + $phpgw->common->phpgw_footer(); ?> diff --git a/calendar/deletelocale.php b/calendar/deletelocale.php new file mode 100755 index 0000000000..c44a22a736 --- /dev/null +++ b/calendar/deletelocale.php @@ -0,0 +1,70 @@ + * + * -------------------------------------------- * + * 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(); +?> diff --git a/calendar/editlocale.php b/calendar/editlocale.php index e761452b29..1d64d53b9e 100755 --- a/calendar/editlocale.php +++ b/calendar/editlocale.php @@ -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,9 +101,9 @@ $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)) + if (!count($holidays)) { $p->set_var('message',lang('No matchs found')); $p->parse('rows','row_empty',True); @@ -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(); ?> diff --git a/calendar/holiday_admin.php b/calendar/holiday_admin.php index 0a43e2c36a..9b14a5d3b6 100755 --- a/calendar/holiday_admin.php +++ b/calendar/holiday_admin.php @@ -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')); diff --git a/calendar/inc/class.calendar_holiday.inc.php b/calendar/inc/class.calendar_holiday.inc.php index d3b30ac301..04179f1074 100755 --- a/calendar/inc/class.calendar_holiday.inc.php +++ b/calendar/inc/class.calendar_holiday.inc.php @@ -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; diff --git a/calendar/templates/default/locales.tpl b/calendar/templates/default/locales.tpl new file mode 100755 index 0000000000..c405125297 --- /dev/null +++ b/calendar/templates/default/locales.tpl @@ -0,0 +1,55 @@ + +

+ + + + + + +
{left_next_matchs}{lang_groups}{right_next_matchs}
+ + + + + + + + + {rows} + +
{sort_name}{header_edit}{header_delete}
+ + + + + + + +
+
+ +
+
+
+ +
+
{lang_search}  +
+ +
+
+ + + + + {group_name} + {edit_link} + {delete_link} + + + + + + {message} + +