Vérif si le fournisseur a ajouter n'est pas deja referencé

This commit is contained in:
Rodolphe Quiedeville 2003-10-11 21:04:15 +00:00
parent 9d1b6ece7b
commit fe78884f9b

View File

@ -375,6 +375,14 @@ class Product
* *
*/ */
Function add_fournisseur($user, $id_fourn, $ref_fourn) Function add_fournisseur($user, $id_fourn, $ref_fourn)
{
$sql = "SELECT count(*) FROM llx_product_fournisseur WHERE fk_product = $this->id AND fk_soc = $id_fourn";
if ($this->db->query($sql) )
{
$row = $this->db->fetch_row(0);
$this->db->free();
if ($row[0] == 0)
{ {
$sql = "INSERT INTO llx_product_fournisseur "; $sql = "INSERT INTO llx_product_fournisseur ";
@ -391,6 +399,17 @@ class Product
return -1; return -1;
} }
} }
else
{
return -2;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
return -3;
}
}
/* /*
* *
* *