Better error management

This commit is contained in:
Laurent Destailleur 2009-12-09 23:40:30 +00:00
parent 6275650129
commit 91023d7ddf
2 changed files with 17 additions and 15 deletions

View File

@ -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
{

View File

@ -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
{