From c3c507a122f1423ec4ce53a59c3067e0aa7736ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Feb 2008 00:12:30 +0000 Subject: [PATCH] Fix: Corrige creation categorie --- htdocs/categories/categorie.php | 15 +++++++----- htdocs/categories/fiche.php | 42 ++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index c4c0feb5272..f0b719be985 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -49,7 +49,7 @@ else accessforbidden(); } -// Sécurité d'accès client et commerciaux +// S�curit� d'acc�s client et commerciaux $objectid = restrictedArea($user, $type, $objectid); @@ -58,7 +58,7 @@ $objectid = restrictedArea($user, $type, $objectid); * Actions */ -//Suppression d'un objet d'une catégorie +//Suppression d'un objet d'une cat�gorie if ($_REQUEST["removecat"]) { if ($_REQUEST["socid"] && $user->rights->societe->creer) @@ -77,7 +77,7 @@ if ($_REQUEST["removecat"]) $result=$cat->del_type($object,$type); } -//Ajoute d'un objet dans une catégorie +//Ajoute d'un objet dans une cat�gorie if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) { if ($_REQUEST["socid"] && $user->rights->societe->creer) @@ -172,7 +172,7 @@ if ($_GET["socid"]) print ''.$langs->trans("Web")."url\" target=\"_blank\">".$soc->url." "; - // Assujeti à TVA ou pas + // Assujeti � TVA ou pas print ''; print ''.$langs->trans('VATIsUsed').''; print yn($soc->tva_assuj); @@ -316,8 +316,11 @@ function formCategory($db,$object,$type,$typeid) // Lien supprimer print ''; - $module = ($type=='fournisseur'?'societe':$type); - if ($user->rights->$module->creer) + $permission=0; + if ($type == 'fournisseur') $permission=$user->rights->societe->creer; + if ($type == 'societe') $permission=$user->rights->societe->creer; + if ($type == 'product') $permission=$user->rights->produit->creer; + if ($permission) { print ""; print img_delete($langs->trans("DeleteFromCat")).' '; diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index 660b6dd2e8d..86f0fa255a3 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2007 Laurent Destailleur + * Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2007 Patrick Raguin * @@ -37,15 +37,15 @@ if (isset ($_REQUEST['choix'])) $nbcats = $_REQUEST['choix']; } else -{ // par défault, une nouvelle catégorie sera dans une seule catégorie mère +{ // par d�fault, une nouvelle cat�gorie sera dans une seule cat�gorie m�re $nbcats = 1; } if ($_REQUEST['origin']) { - if($_GET['type'] == 0)$idProdOrigin = $_REQUEST['origin']; - if($_GET['type'] == 1)$idSupplierOrigin = $_REQUEST['origin']; - if($_GET['type'] == 2)$idCompanyOrigin = $_REQUEST['origin']; + if ($_GET['type'] == 0) $idProdOrigin = $_REQUEST['origin']; + if ($_GET['type'] == 1) $idSupplierOrigin = $_REQUEST['origin']; + if ($_GET['type'] == 2) $idCompanyOrigin = $_REQUEST['origin']; } @@ -56,17 +56,22 @@ if ($_REQUEST['origin']) if ($_POST["action"] == 'add' && $user->rights->categorie->creer) { - // Action ajout d'une catégorie + // Action ajout d'une cat�gorie if ($_POST["cancel"]) { if ($idProdOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin); + header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&type='.$_GET["type"]); exit; } - if ($idSupplierOrigin || $idCompanyOrigin) + if ($idCompanyOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin); + header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&type='.$_GET["type"]); + exit; + } + if ($idSupplierOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&type='.$_GET["type"]); exit; } } @@ -104,7 +109,7 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) if ($_POST["action"] == 'add' && $user->rights->categorie->creer) { - // Action confirmation de création de la catégorie + // Action confirmation de creation categorie if ($_GET["action"] == 'confirmed') { if ($idProdOrigin) @@ -112,16 +117,19 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } - else if ($idSupplierOrigin || $idCompanyOrigin) + if ($idCompanyOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } - else + if ($idSupplierOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$_POST["type"]); + header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } + + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$_POST["type"]); + exit; } } @@ -133,7 +141,7 @@ $html = new Form($db); if ($user->rights->categorie->creer) { /* - * Fiche en mode création + * Fiche en mode creation */ if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat') { @@ -146,10 +154,12 @@ if ($user->rights->categorie->creer) print '
'; print ''; print ''; - print ''; + //print ''; Mis dans origin + //print ''; Mis dans origin + print ''; if ($_REQUEST['origin']) { - print ''; + print ''; } print '';