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