Skip to content
Snippets Groups Projects
Commit 91023d7d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Better error management

parent 62756501
No related branches found
No related tags found
No related merge requests found
......@@ -1673,7 +1673,7 @@ class Product extends CommonObject
* \param user Utilisateur qui fait le lien
* \param id_fourn Id du fournisseur
* \param ref_fourn Reference chez le fournisseur
* \return int < 0 si erreur, > 0 si ok
* \return int < 0 if KO, 0 if link already exists, > 0 if OK
*/
function add_fournisseur($user, $id_fourn, $ref_fourn)
{
......@@ -1737,8 +1737,9 @@ class Product extends CommonObject
$obj = $this->db->fetch_object($resql);
$this->product_fourn_id = $obj->rowid;
}
return 0;
}
$this->db->free($resql);
}
else
{
......
......@@ -115,7 +115,15 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
$error++;
$mesg='<div class="error">'.$product->error.'</div>';
}
if ($ret == 0)
{
$error++;
$mesg='<div class="error">'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct").'</div>';
}
}
if (! $error)
{
if ($_POST["qty"])
{
if ($_POST["price"] >= 0)
......@@ -124,22 +132,15 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
$result=$supplier->fetch($_POST["id_fourn"]);
$ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier);
if (!$error)
if ($ret < 0)
{
if ($ret < 0)
$error++;
$mesg='<div class="error">'.$product->error.'</div>';
if ($ret == -2)
{
$error++;
$mesg='<div class="error">'.$product->error.'</div>';
if ($ret == -2)
{
$mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>';
}
$mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>';
}
}
else
{
$mesg='<div class="error">'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct").'</div>';
}
}
else
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment