Fix: Error return must be < 0
This commit is contained in:
parent
432dc7a009
commit
af4033e4b4
@ -17,7 +17,8 @@ For users:
|
|||||||
- Fix: bug #28055 : Unable to modify the date of a cloned command.
|
- Fix: bug #28055 : Unable to modify the date of a cloned command.
|
||||||
- Fix: bug #27891.
|
- Fix: bug #27891.
|
||||||
- Fix: Change of numbering module was not effective.
|
- Fix: Change of numbering module was not effective.
|
||||||
|
- Fix: Change error management when adding already used supplier ref
|
||||||
|
for a product.
|
||||||
|
|
||||||
***** ChangeLog for 2.7 compared to 2.6 *****
|
***** ChangeLog for 2.7 compared to 2.6 *****
|
||||||
|
|
||||||
|
|||||||
@ -1672,11 +1672,11 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Lie un fournisseur au produit/service
|
* \brief Add a supplier reference for the product
|
||||||
* \param user Utilisateur qui fait le lien
|
* \param user User that make link
|
||||||
* \param id_fourn Id du fournisseur
|
* \param id_fourn Supplier id
|
||||||
* \param ref_fourn Reference chez le fournisseur
|
* \param ref_fourn Supplier ref
|
||||||
* \return int < 0 if KO, 0 if link already exists, > 0 if OK
|
* \return int < 0 if KO, 0 if link already exists for this product, > 0 if OK
|
||||||
*/
|
*/
|
||||||
function add_fournisseur($user, $id_fourn, $ref_fourn)
|
function add_fournisseur($user, $id_fourn, $ref_fourn)
|
||||||
{
|
{
|
||||||
@ -1693,10 +1693,9 @@ class Product extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$nb = count($obj);
|
|
||||||
|
|
||||||
// The reference supplier does not exist, it creates for this product.
|
// The reference supplier does not exist, we create it for this product.
|
||||||
if (!$nb)
|
if (! $obj)
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur (";
|
||||||
$sql.= "datec";
|
$sql.= "datec";
|
||||||
@ -1727,19 +1726,19 @@ class Product extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the reference supplier is already linked to this product
|
// If the supplier ref already exists for this product
|
||||||
else if ($obj->fk_product == $this->id)
|
else if ($obj->fk_product == $this->id)
|
||||||
{
|
{
|
||||||
$this->product_fourn_id = $obj->rowid;
|
$this->product_fourn_id = $obj->rowid;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// If the reference provider is not linked to this product
|
// If the supplier ref already exists but for another product
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->product_id_already_linked = $obj->fk_product;
|
$this->product_id_already_linked = $obj->fk_product;
|
||||||
|
|
||||||
return 2;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -110,12 +110,7 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
|
$ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
|
||||||
if ($ret < 0)
|
if ($ret == -3)
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
$mesg='<div class="error">'.$product->error.'</div>';
|
|
||||||
}
|
|
||||||
if ($ret == 2)
|
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
|
|
||||||
@ -124,6 +119,11 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
|
|||||||
|
|
||||||
$mesg='<div class="error">'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink).'</div>';
|
$mesg='<div class="error">'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink).'</div>';
|
||||||
}
|
}
|
||||||
|
else if ($ret < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$mesg='<div class="error">'.$product->error.'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user