Fix: Gestion erreur
This commit is contained in:
parent
064785e926
commit
46c7aa71dd
@ -179,6 +179,13 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (empty($this->libelle))
|
||||||
|
{
|
||||||
|
$this->error='ErrorWrongParameters';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
dolibarr_syslog("Product::Create ref=".$this->ref." price=".$this->price." tva_tx=".$this->tva_tx." Categorie : ".$this->catid);
|
dolibarr_syslog("Product::Create ref=".$this->ref." price=".$this->price." tva_tx=".$this->tva_tx." Categorie : ".$this->catid);
|
||||||
|
|
||||||
if ($this->ref)
|
if ($this->ref)
|
||||||
@ -198,11 +205,11 @@ class Product extends CommonObject
|
|||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " (datec, ";
|
$sql.= " (datec, ";
|
||||||
if ($this->ref) $sql.= "ref, ";
|
if ($this->ref) $sql.= "ref, ";
|
||||||
if ($this->libelle) $sql.= "label, ";
|
$sql.= "label, ";
|
||||||
$sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)";
|
$sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)";
|
||||||
$sql.= " VALUES (now(), ";
|
$sql.= " VALUES (now(), ";
|
||||||
if ($this->ref) $sql.= "'".$this->ref."',";
|
if ($this->ref) $sql.= "'".$this->ref."',";
|
||||||
if ($this->libelle) $sql.= "'".addslashes($this->libelle)."', ";
|
$sql.= " ".($this->libelle?"'".addslashes($this->libelle)."'":"null").",";
|
||||||
$sql.= $user->id.",";
|
$sql.= $user->id.",";
|
||||||
$sql.= " ".$this->type.",";
|
$sql.= " ".$this->type.",";
|
||||||
$sql.= price2num($price_ht).",";
|
$sql.= price2num($price_ht).",";
|
||||||
@ -241,7 +248,8 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->_setErrNo("Create",264);
|
$this->error=$this->db->error();
|
||||||
|
$this->_setErrNo("Create",264,$this->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -251,7 +259,8 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->_setErrNo("Create",258);
|
$this->error=$this->db->error();
|
||||||
|
$this->_setErrNo("Create",258,$this->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -58,6 +58,19 @@ if ($_GET["action"] == 'fastappro')
|
|||||||
|
|
||||||
// Action ajout d'un produit ou service
|
// Action ajout d'un produit ou service
|
||||||
if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
if (empty($_POST["libelle"]))
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'</div>';
|
||||||
|
$_GET["action"] = "create";
|
||||||
|
$_GET["canvas"] = $product->canvas;
|
||||||
|
$_GET["type"] = $_POST["type"];
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
if ($_POST["canvas"] <> '' && file_exists('canvas/product.'.$_POST["canvas"].'.class.php') )
|
if ($_POST["canvas"] <> '' && file_exists('canvas/product.'.$_POST["canvas"].'.class.php') )
|
||||||
{
|
{
|
||||||
@ -125,6 +138,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
|||||||
$_GET["type"] = $_POST["type"];
|
$_GET["type"] = $_POST["type"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Action mise a jour d'un produit ou service
|
// Action mise a jour d'un produit ou service
|
||||||
if ($_POST["action"] == 'update' &&
|
if ($_POST["action"] == 'update' &&
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user