Fix: Corrige creation categorie

This commit is contained in:
Laurent Destailleur 2008-02-15 00:12:30 +00:00
parent 77b72f3521
commit c3c507a122
2 changed files with 35 additions and 22 deletions

View File

@ -49,7 +49,7 @@ else
accessforbidden(); accessforbidden();
} }
// Sécurité d'accès client et commerciaux // S<EFBFBD>curit<EFBFBD> d'acc<63>s client et commerciaux
$objectid = restrictedArea($user, $type, $objectid); $objectid = restrictedArea($user, $type, $objectid);
@ -58,7 +58,7 @@ $objectid = restrictedArea($user, $type, $objectid);
* Actions * Actions
*/ */
//Suppression d'un objet d'une catégorie //Suppression d'un objet d'une cat<EFBFBD>gorie
if ($_REQUEST["removecat"]) if ($_REQUEST["removecat"])
{ {
if ($_REQUEST["socid"] && $user->rights->societe->creer) if ($_REQUEST["socid"] && $user->rights->societe->creer)
@ -77,7 +77,7 @@ if ($_REQUEST["removecat"])
$result=$cat->del_type($object,$type); $result=$cat->del_type($object,$type);
} }
//Ajoute d'un objet dans une catégorie //Ajoute d'un objet dans une cat<EFBFBD>gorie
if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
{ {
if ($_REQUEST["socid"] && $user->rights->societe->creer) if ($_REQUEST["socid"] && $user->rights->societe->creer)
@ -172,7 +172,7 @@ if ($_GET["socid"])
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$soc->url\" target=\"_blank\">".$soc->url."</a>&nbsp;</td></tr>"; print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$soc->url\" target=\"_blank\">".$soc->url."</a>&nbsp;</td></tr>";
// Assujeti à TVA ou pas // Assujeti <EFBFBD> TVA ou pas
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">'; print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($soc->tva_assuj); print yn($soc->tva_assuj);
@ -316,8 +316,11 @@ function formCategory($db,$object,$type,$typeid)
// Lien supprimer // Lien supprimer
print '<td align="right">'; print '<td align="right">';
$module = ($type=='fournisseur'?'societe':$type); $permission=0;
if ($user->rights->$module->creer) 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 "<a href= '".DOL_URL_ROOT."/categories/categorie.php?".$nameId."=".$object->id."&amp;typeid=".$typeid."&amp;removecat=".$cat->id."'>"; print "<a href= '".DOL_URL_ROOT."/categories/categorie.php?".$nameId."=".$object->id."&amp;typeid=".$typeid."&amp;removecat=".$cat->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' '; print img_delete($langs->trans("DeleteFromCat")).' ';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* *
@ -37,7 +37,7 @@ if (isset ($_REQUEST['choix']))
$nbcats = $_REQUEST['choix']; $nbcats = $_REQUEST['choix'];
} }
else else
{ // par défault, une nouvelle catégorie sera dans une seule catégorie mère { // par d<EFBFBD>fault, une nouvelle cat<61>gorie sera dans une seule cat<61>gorie m<>re
$nbcats = 1; $nbcats = 1;
} }
@ -56,17 +56,22 @@ if ($_REQUEST['origin'])
if ($_POST["action"] == 'add' && $user->rights->categorie->creer) if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
{ {
// Action ajout d'une catégorie // Action ajout d'une cat<EFBFBD>gorie
if ($_POST["cancel"]) if ($_POST["cancel"])
{ {
if ($idProdOrigin) 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; 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; exit;
} }
} }
@ -104,7 +109,7 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
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 ($_GET["action"] == 'confirmed')
{ {
if ($idProdOrigin) 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"))); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit; exit;
} }
else if ($idSupplierOrigin || $idCompanyOrigin) if ($idCompanyOrigin)
{ {
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit; 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; 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) if ($user->rights->categorie->creer)
{ {
/* /*
* Fiche en mode création * Fiche en mode creation
*/ */
if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat') if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat')
{ {
@ -146,10 +154,12 @@ if ($user->rights->categorie->creer)
print '<form action="'.$_SERVER['PHP_SELF'].'?type='.$_GET['type'].'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?type='.$_GET['type'].'" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="addcat" value="addcat">'; print '<input type="hidden" name="addcat" value="addcat">';
print '<input type="hidden" name="type" value='.$_GET['type'].'>'; //print '<input type="hidden" name="id" value="'.$_GET['id'].'">'; Mis dans origin
//print '<input type="hidden" name="socid" value="'.$_GET['socid'].'">'; Mis dans origin
print '<input type="hidden" name="type" value="'.$_GET['type'].'">';
if ($_REQUEST['origin']) if ($_REQUEST['origin'])
{ {
print '<input type="hidden" name="origin" value='.$_REQUEST['origin'].'>'; print '<input type="hidden" name="origin" value="'.$_REQUEST['origin'].'">';
} }
print '<input type="hidden" name="nom" value="'.$nom.'">'; print '<input type="hidden" name="nom" value="'.$nom.'">';