From e441b246a811942725f86dddbe61710f3579cf28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Sep 2012 03:57:26 +0200 Subject: [PATCH] Debug of holiday module --- htdocs/holiday/admin/holiday.php | 3 +- htdocs/holiday/class/holiday.class.php | 5 +- htdocs/holiday/class/holidayagenda.class.php | 5 +- htdocs/holiday/define_holiday.php | 25 +++--- htdocs/holiday/fiche.php | 92 ++++++++++---------- htdocs/holiday/index.php | 19 ++-- htdocs/holiday/month_report.php | 3 +- htdocs/holiday/pre.inc.php | 5 +- htdocs/holiday/view_log.php | 33 ++++--- 9 files changed, 93 insertions(+), 97 deletions(-) diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index 3a1b1ac2ea7..9690e93f3cc 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . */ /** diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 69e5d9b0cfc..af159020ce5 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -12,9 +12,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ /** diff --git a/htdocs/holiday/class/holidayagenda.class.php b/htdocs/holiday/class/holidayagenda.class.php index 5abe1eeaaa4..10c5946e5c1 100644 --- a/htdocs/holiday/class/holidayagenda.class.php +++ b/htdocs/holiday/class/holidayagenda.class.php @@ -14,9 +14,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ /** diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 4df02005b20..4c004235df8 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -12,9 +12,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ /** @@ -35,10 +34,12 @@ if ($user->societe_id > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page if(!$user->rights->holiday->define_holiday) accessforbidden(); +$action=GETPOST('action'); + /* * View -*/ + */ llxHeader($langs->trans('CPTitreMenu')); @@ -49,8 +50,8 @@ $listUsers = $holiday->fetchUsers(false,false); $userstatic=new User($db); // Si il y a une action de mise à jour -if(isset($_POST['action']) && $_POST['action'] == 'update' && isset($_POST['update_cp'])) { - +if ($action == 'update' && isset($_POST['update_cp'])) +{ $userID = array_keys($_POST['update_cp']); $userID = $userID[0]; @@ -70,13 +71,13 @@ if(isset($_POST['action']) && $_POST['action'] == 'update' && isset($_POST['upda $holiday->updateSoldeCP($userID,$userValue); - print '
'; - print $langs->trans('UpdateConfCPOK'); - print '
'; + $mesg='
'.$langs->trans('UpdateConfCPOK').'
'; + dol_htmloutput_mesg($mesg); -} elseif(isset($_POST['action']) && $_POST['action'] == 'add_event') { - +} +elseif($action == 'add_event') +{ $error = false; if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) { @@ -138,7 +139,7 @@ foreach($listUsers as $users) print ''; print ''; print ' jours'."\n"; - print ''."\n"; + print ''."\n"; print ''; $i++; diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index 59ed1816d25..69c36f8acc1 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011 Dimitri Mouillard +/* Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2011 Dimitri Mouillard * * 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 @@ -12,9 +12,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ /** @@ -53,7 +52,7 @@ if ($action == 'add') { // Si pas le droit de créer une demande - if(!$user->rights->holiday->create_edit_read) + if(!$user->rights->holiday->write) { header('Location: fiche.php?action=request&error=CantCreate'); exit; @@ -142,7 +141,7 @@ if($action == 'update') { // Si pas le droit de modifier une demande - if(!$user->rights->holiday->create_edit_read) + if(!$user->rights->holiday->write) { header('Location: fiche.php?action=request&error=CantUpdate'); exit; @@ -244,7 +243,7 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') } // Si envoi de la demande -if ($_GET['action'] == 'confirm_send') +if ($action == 'confirm_send') { $cp = new Holiday($db); $cp->fetch($_GET['id']); @@ -333,7 +332,7 @@ if ($_GET['action'] == 'confirm_send') } // Si Validation de la demande -if($_GET['action'] == 'confirm_valid') +if($action == 'confirm_valid') { $cp = new Holiday($db); @@ -415,9 +414,9 @@ if($_GET['action'] == 'confirm_valid') } -if ($_GET['action'] == 'confirm_refuse') +if ($action == 'confirm_refuse') { - if($_POST['action'] == 'confirm_refuse' && !empty($_POST['detail_refuse'])) + if(!empty($_POST['detail_refuse'])) { $cp = new Holiday($db); $cp->fetch($_GET['id']); @@ -492,7 +491,7 @@ if ($_GET['action'] == 'confirm_refuse') } // Si Validation de la demande -if ($_GET['action'] == 'confirm_cancel' && $_GET['confirm'] == 'yes') +if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes') { $cp = new Holiday($db); $cp->fetch($_GET['id']); @@ -571,11 +570,11 @@ if ($_GET['action'] == 'confirm_cancel' && $_GET['confirm'] == 'yes') llxHeader($langs->trans('CPTitreMenu')); -if ($_GET['action'] == 'request') +if ($action == 'request') { // Si l'utilisateur n'a pas le droit de faire une demande - if(!$user->rights->holiday->create_edit_read) + if(!$user->rights->holiday->write) { print '
'; print $langs->trans('CantCreateCP'); @@ -756,7 +755,7 @@ elseif(isset($_GET['id'])) // Utilisateur connecté $userID = $user->id; - print_fiche_titre($langs->trans('TitreRequestCP')); + //print_fiche_titre($langs->trans('TitreRequestCP')); // Si il y a une erreur if(isset($_GET['error'])) { @@ -798,9 +797,10 @@ elseif(isset($_GET['id'])) } // On vérifie si l'utilisateur à le droit de lire cette demande - if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) { + if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) + { - if($_GET['action'] == 'delete' && $cp->statut == 1) { + if ($action == 'delete' && $cp->statut == 1) { if($user->rights->holiday->delete) { $html = new Form($db); @@ -843,10 +843,10 @@ elseif(isset($_GET['id'])) } - print '
'; + dol_fiche_head(array(),'card',$langs->trans("CPTitreMenu"),0,'holiday'); - if($_GET['action'] == 'edit' && $user->id == $cp->fk_user && $cp->statut == 1) + if ($action == 'edit' && $user->id == $cp->fk_user && $cp->statut == 1) { $edit = true; print '
'."\n"; @@ -856,14 +856,14 @@ elseif(isset($_GET['id'])) $html = new Form($db); } - print ''; + print '
'; print ''; - print ''; + /*print ''; print ''; - print ''; + print '';*/ print ''; - print ''; + print ''; print ''; print ''; @@ -898,6 +898,20 @@ elseif(isset($_GET['id'])) print ''; print ''; print ''; + + // Status + print ''; + print ''; + print ''; + print ''; + if($cp->statut == 5) { + print ''; + print ''; + print ''; + print ''; + } + + // Description if(!$edit) { print ''; print ''; @@ -912,16 +926,20 @@ elseif(isset($_GET['id'])) print ''; print '
'.$langs->trans("InfosCP").'
ID'.$langs->trans("Ref").''.$cp->rowid.'
'.$langs->trans('NbUseDaysCP').''.$cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)).'
'.$langs->trans('StatutCP').''.$cp->getStatutCP($cp->statut).'
'.$langs->trans('DetailRefusCP').''.$cp->detail_refuse.'
'.$langs->trans('DescCP').'
'."\n"; - print '
 
'; + print '

'; - print '
'."\n"; - print ''."\n"; + print '
'."\n"; print ''; print ''; print ''; print ''; + print ''; + print ''; + print ''; + print ''; + if(!$edit) { print ''; print ''; @@ -942,10 +960,6 @@ elseif(isset($_GET['id'])) print ''; } - print ''; - print ''; - print ''; - print ''; print ''; print ''; print ''; @@ -968,29 +982,17 @@ elseif(isset($_GET['id'])) print ''; print ''; } - print ''; - print ''; - print ''; - print ''; - if($cp->statut == 5) { - print ''; - print ''; - print ''; - print ''; - } print ''; print '
'.$langs->trans("InfosWorkflowCP").'
'.$langs->trans('RequestByCP').''.$userRequest->getNomUrl(1).'
'.$langs->trans('ValidateByCP').'
'.$langs->trans('RequestByCP').''.$userRequest->getNomUrl(1).'
'.$langs->trans('DateCreateCP').''.$cp->date_create.''.$cp->date_refuse.'
'.$langs->trans('StatutCP').''.$cp->getStatutCP($cp->statut).'
'.$langs->trans('DetailRefusCP').''.$cp->detail_refuse.'
'; - print '
'."\n"; + dol_fiche_end(); - print '
'; print '
'."\n"; - print '
'; if ($edit) { print '
'; - if($user->rights->holiday->create_edit_read && $_GET['action'] == 'edit' && $cp->statut == 1) + if($user->rights->holiday->write && $_GET['action'] == 'edit' && $cp->statut == 1) { print ''; } @@ -1006,7 +1008,7 @@ elseif(isset($_GET['id'])) // Boutons d'actions - if($user->rights->holiday->create_edit_read && $_GET['action'] != 'edit' && $cp->statut == 1) { + if($user->rights->holiday->write && $_GET['action'] != 'edit' && $cp->statut == 1) { print ''.$langs->trans("EditCP").''; } if($user->rights->holiday->delete && $cp->statut == 1) { diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index 7e05bbaeb5b..9acaaad8df3 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . */ /** @@ -72,7 +71,7 @@ $order = " ORDER BY $sortfield $sortorder " . $db->plimit( $conf->liste_limit + *************************************/ $max_year = 5; -$min_year = 5; +$min_year = 10; $search_ref = $_GET['search_ref']; $month_create = $_GET['month_create']; @@ -207,14 +206,14 @@ print '
'; print ''."\n"; print ''; print ""; -print_liste_field_titre($langs->trans("ID"),"index.php","cp.rowid","",'','',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("DateCreateCP"),"index.php","cp.date_create","",'','align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("Employe"),"index.php","cp.fk_user","",'','',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("ValidatorCP"),"index.php","cp.fk_validator","",'','',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("DateDebCP"),"index.php","cp.date_debut","",'','align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("DateFinCP"),"index.php","cp.date_fin","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cp.rowid","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("DateCreateCP"),$_SERVER["PHP_SELF"],"cp.date_create","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Employe"),$_SERVER["PHP_SELF"],"cp.fk_user","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("ValidatorCP"),$_SERVER["PHP_SELF"],"cp.fk_validator","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("DateDebCP"),$_SERVER["PHP_SELF"],"cp.date_debut","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("DateFinCP"),$_SERVER["PHP_SELF"],"cp.date_fin","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Duration")); -print_liste_field_titre($langs->trans("Statut"),"index.php","cp.statut","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Statut"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="center"',$sortfield,$sortorder); print "\n"; // FILTRES diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 86666f9f53d..6bf294e695c 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -13,8 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . */ /** diff --git a/htdocs/holiday/pre.inc.php b/htdocs/holiday/pre.inc.php index 6600c4d51b1..16c80250531 100644 --- a/htdocs/holiday/pre.inc.php +++ b/htdocs/holiday/pre.inc.php @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . */ /** @@ -77,7 +76,7 @@ function llxHeader($title) $menu = new Menu(); $menu->add("/holiday/index.php?mainmenu=holiday",$langs->trans("CPTitreMenu")); - if($user->rights->holiday->create_edit_read) { + if($user->rights->holiday->write) { $menu->add("/holiday/fiche.php?mainmenu=holiday&action=request",$langs->trans("MenuAddCP"),2); } if($user->rights->holiday->define_holiday) { diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index e3460839f66..c66b9779b48 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -1,21 +1,20 @@ - * Copyright (C) 2011 Dimitri Mouillard -* -* 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. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ +/* Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2011 Dimitri Mouillard + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * Displays the log of actions performed in the module.