From 7a1b1f30acda62424ec932ca09c2d419ff36d00d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2007 20:59:41 +0000 Subject: [PATCH] Ajout confirmation suppression categorie --- htdocs/categories/delete.php | 59 ----------------------------------- htdocs/categories/viewcat.php | 47 ++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 65 deletions(-) delete mode 100644 htdocs/categories/delete.php diff --git a/htdocs/categories/delete.php b/htdocs/categories/delete.php deleted file mode 100644 index cef3e76e198..00000000000 --- a/htdocs/categories/delete.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * 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. - * - * $Id$ - * $Source$ - */ - -require "./pre.inc.php"; - -if (!$user->rights->categorie->supprimer) accessforbidden(); - - -llxHeader("","",$langs->trans("Categories")); - -print_titre($langs->trans("CategoriesArea")); - -print ''; - -print '
'; - - -$cat = new Categorie ($db, $_REQUEST['id']); - -if (!isset ($_REQUEST['valid'])) -{ - print "

Veuillez valider la suppression de la catégorie ".$cat->label." : supprimer la catégorie ".$cat->label."

\n"; -} -else -{ - if ($cat->remove () < 0) - { - print "

Impossible de supprimer la catégorie ".$cat->label.".

"; - } - else - { - print "

La catégorie ".$cat->label." a été supprimée.

"; - } -} - -print '
'; - -$db->close(); - -llxFooter("Dernière modification $Date$ révision $Revision$"); -?> diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 3b3488703ec..0f04eb2df31 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -26,17 +26,41 @@ require "./pre.inc.php"; -$user->getrights('categorie'); +if ($_REQUEST['id'] == "") +{ + dolibarr_print_error('','Missing parameter id'); + exit(); +} +// Securite +$user->getrights('categorie'); if (! $user->rights->categorie->lire) { accessforbidden(); } -if ($_REQUEST['id'] == "") +$mesg=''; + +$c = new Categorie($db); +$c->fetch($_REQUEST['id']); + + + +/* +* Actions +*/ + +if ($user->rights->categorie->supprimer && $_POST["action"] == 'confirm_delete' && $_POST['confirm'] == 'yes') { - dolibarr_print_error('','Missing parameter id'); - exit(); + if ($c->remove() >= 0) + { + header("Location: ".DOL_URL_ROOT.'/categories/index.php'); + exit; + } + else + { + $mesg='
'.$c->error.'
'; + } } @@ -45,8 +69,10 @@ if ($_REQUEST['id'] == "") * Affichage fiche categorie */ llxHeader ("","",$langs->trans("Categories")); +$html=new Form($db); + +if ($mesg) print $mesg.'
'; -$c = new Categorie ($db, $_REQUEST['id']); $h = 0; $head = array(); @@ -59,6 +85,15 @@ $h++; dolibarr_fiche_head($head, 'card', $langs->trans("Category")); +/* +* Confirmation suppression +*/ +if ($_GET['action'] == 'delete' && $resteapayer <= 0) +{ + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$c->id,$langs->trans('DeleteCategory'),$langs->trans('ConfirmDeleteCategory'),'confirm_delete'); + print '
'; +} + print ''; print '
'; @@ -98,7 +133,7 @@ if ($user->rights->categorie->creer) if ($user->rights->categorie->supprimer) { - print "".$langs->trans("Delete").""; + print "".$langs->trans("Delete").""; } print "";