Modif gestion des erreurs
This commit is contained in:
parent
870675f62f
commit
94a37e7c88
@ -75,6 +75,7 @@ class Product
|
||||
//! Intitule de l'erreur
|
||||
var $error;
|
||||
//! Numero de l'erreur
|
||||
//! Numero d'erreur Plage 0256-0511
|
||||
var $errno = 0;
|
||||
//! Canevas a utiliser si le produit n'est pas un produit generique
|
||||
var $canvas;
|
||||
@ -134,16 +135,15 @@ class Product
|
||||
|
||||
$this->price = $price;
|
||||
$this->price_base_type = $base_type;
|
||||
|
||||
}
|
||||
/**
|
||||
* \brief Insère le produit en base
|
||||
* \param user Utilisateur qui effectue l'insertion
|
||||
* \return int id du produit ou numero d'erreur < 0
|
||||
\brief Insère le produit en base
|
||||
\param user Utilisateur qui effectue l'insertion
|
||||
\return int id du produit ou numero d'erreur < 0
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $langs;
|
||||
$this->errno = 0;
|
||||
|
||||
$this->ref = trim(sanitize_string($this->ref));
|
||||
|
||||
@ -205,50 +205,67 @@ class Product
|
||||
$cat = new Categorie ($this->db, $this->catid);
|
||||
$cat->add_product($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = 260;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = 259;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = 258;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Produit existe deja
|
||||
$this->errno = 257;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = 263;
|
||||
}
|
||||
|
||||
/*
|
||||
* END COMMIT
|
||||
*/
|
||||
|
||||
if ($this->errno === 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - sql=".$sql;
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Produit existe deja
|
||||
$this->error=$langs->trans("ErrorProductAlreadyExists", $this->ref);
|
||||
$this->errno = 257;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Produit existe deja
|
||||
$this->error=$langs->trans("ErrorProductBadRefOrLabel");
|
||||
$this->errno = 257;
|
||||
return -2;
|
||||
}
|
||||
dolibarr_syslog("Product::Create ROLLBACK ERRNO (".$this->errno.")");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = 262;
|
||||
return -2;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
function error($errno)
|
||||
{
|
||||
|
||||
$errs[257] = "ErrorProductAlreadyExists";
|
||||
$errs[262] = "ErrorProductBadRefOrLabel";
|
||||
|
||||
return $errs[$errno];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour du produit en base
|
||||
|
||||
Loading…
Reference in New Issue
Block a user