Fix: uniformisation du code

This commit is contained in:
Regis Houssin 2007-12-08 21:04:59 +00:00
parent 2ba54e72dc
commit bda79cba8f

View File

@ -54,8 +54,8 @@ class MouvementStock
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement";
$sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, price)"; $sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, price)";
$sql.= " VALUES (now(), $fk_product, $entrepot_id, $qty, $type, $user->id"; $sql.= " VALUES (now(), ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.", ".$user->id;
$sql.= ",'".ereg_replace(",",".",$price)."');"; $sql.= ",'".price2num($price)."')";
if ($resql = $this->db->query($sql)) if ($resql = $this->db->query($sql))
{ {
@ -72,7 +72,7 @@ class MouvementStock
if ($error === 0) if ($error === 0)
{ {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_stock"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_stock";
$sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $fk_product"; $sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -90,14 +90,14 @@ class MouvementStock
{ {
if ($num > 0) if ($num > 0)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + $qty"; $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".$qty;
$sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $fk_product"; $sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product;
} }
else else
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock";
$sql.= " (reel, fk_entrepot, fk_product) VALUES "; $sql.= " (reel, fk_entrepot, fk_product) VALUES ";
$sql.= " ($qty,$entrepot_id,$fk_product);"; $sql.= " (".$qty.",".$entrepot_id.",".$fk_product.")";
} }
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -111,7 +111,6 @@ class MouvementStock
} }
} }
if ($error === 0) if ($error === 0)
{ {
$valo_mouvement = 0; $valo_mouvement = 0;
@ -137,8 +136,7 @@ class MouvementStock
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error() . " - $sql"; $this->error=$this->db->error() . " - $sql";
dolibarr_syslog("MouvementStock::_Create ERROR : $error"); dolibarr_syslog("MouvementStock::_Create ERROR : ".$this->error);
dolibarr_syslog("MouvementStock::_Create ROLLBACK");
return -2; return -2;
} }
} }