Fix: Corrige creation categorie

This commit is contained in:
Laurent Destailleur 2008-02-15 00:26:52 +00:00
parent c3c507a122
commit 00448a43d5
2 changed files with 18 additions and 9 deletions

View File

@ -325,10 +325,10 @@ class Categorie
} }
/** /**
* Ajout d'un objet à la catégorie * \brief Link an object to the category
* retour : 1 : OK * \param obj Object to link to category
* -1 : erreur SQL * \param type Type of category
* -2 : id non renseign * \return int 1 : OK, -1 : erreur SQL, -2 : id non renseign, -3 : Already linked
*/ */
function add_type($obj,$type) function add_type($obj,$type)
{ {
@ -345,8 +345,16 @@ class Categorie
return 1; return 1;
} }
else else
{
if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->lasterrno();
return -3;
}
else
{ {
$this->error=$this->db->error().' sql='.$sql; $this->error=$this->db->error().' sql='.$sql;
}
return -1; return -1;
} }
} }

View File

@ -49,7 +49,7 @@ else
accessforbidden(); accessforbidden();
} }
// S<EFBFBD>curit<EFBFBD> d'acc<63>s client et commerciaux // Securite d'acces 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<EFBFBD>gorie //Suppression d'un objet d'une categorie
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<EFBFBD>gorie //Ajoute d'un objet dans une categorie
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)
@ -101,7 +101,8 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("Error").' '.$cat->error.'</div>'; if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="warning">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
else $mesg='<div class="error">'.$langs->trans("Error").' '.$cat->error.'</div>';
} }
} }