Fix: erreur sql si pas d'entrepôt

This commit is contained in:
Regis Houssin 2006-03-07 09:58:54 +00:00
parent fd8f8c63c5
commit 75e80411ba

View File

@ -1328,15 +1328,14 @@ class Product
*/ */
function correct_stock($user, $id_entrepot, $nbpiece, $mouvement) function correct_stock($user, $id_entrepot, $nbpiece, $mouvement)
{ {
if ($id_entrepot)
{
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."product_stock "; $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."product_stock ";
$sql .= " WHERE fk_product = $this->id AND fk_entrepot = $id_entrepot"; $sql .= " WHERE fk_product = $this->id AND fk_entrepot = $id_entrepot";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$row = $this->db->fetch_row(0); $row = $this->db->fetch_row(0);
if ($id_entrepot)
{
if ($row[0] > 0) if ($row[0] > 0)
{ {
return $this->ajust_stock($user, $id_entrepot, $nbpiece, $mouvement); return $this->ajust_stock($user, $id_entrepot, $nbpiece, $mouvement);
@ -1345,7 +1344,6 @@ class Product
{ {
return $this->create_stock($id_entrepot, $nbpiece); return $this->create_stock($id_entrepot, $nbpiece);
} }
}
} }
else else
{ {
@ -1353,6 +1351,7 @@ class Product
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
}
} }