Skip to content
Snippets Groups Projects
Commit 117df1c4 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: uniformize code

parent 54388ffa
No related branches found
No related tags found
No related merge requests found
...@@ -167,6 +167,7 @@ class Product extends CommonObject ...@@ -167,6 +167,7 @@ class Product extends CommonObject
function create($user) function create($user)
{ {
global $conf ; global $conf ;
$this->errno = 0; $this->errno = 0;
// Clean parameters // Clean parameters
...@@ -221,7 +222,9 @@ class Product extends CommonObject ...@@ -221,7 +222,9 @@ class Product extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "SELECT count(*)"; $sql = "SELECT count(*)";
$sql .= " FROM ".MAIN_DB_PREFIX."product WHERE ref = '" .$this->ref."'"; $sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " WHERE ref = '" .$this->ref."'";
$sql.= " AND entity = ".$conf->entity;
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
if ($result) if ($result)
...@@ -230,24 +233,35 @@ class Product extends CommonObject ...@@ -230,24 +233,35 @@ class Product extends CommonObject
if ($row[0] == 0) if ($row[0] == 0)
{ {
// Produit non deja existant // Produit non deja existant
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."product (";
$sql.= " (datec, "; $sql.= "datec";
if ($this->ref) $sql.= "ref, "; $sql.= ", entity";
$sql.= "price_min, price_min_ttc, "; $sql.= ", ref";
$sql.= "label, "; $sql.= ", price_min";
$sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas, finished)"; $sql.= ", price_min_ttc";
$sql.= " VALUES (".$this->db->idate(mktime()).", "; $sql.= ", label";
if ($this->ref) $sql.= "'".$this->ref."',"; $sql.= ", fk_user_author";
$sql.= price2num($price_min_ht).","; $sql.= ", fk_product_type";
$sql.= price2num($price_min_ttc).","; $sql.= ", price";
$sql.= " ".($this->libelle?"'".addslashes($this->libelle)."'":"null").","; $sql.= ", price_ttc";
$sql.= $user->id.","; $sql.= ", price_base_type";
$sql.= " ".$this->type.","; $sql.= ", canvas";
$sql.= price2num($price_ht).","; $sql.= ", finished";
$sql.= price2num($price_ttc).","; $sql.= ") VALUES (";
$sql.= "'".$this->price_base_type."',"; $sql.= $this->db->idate(mktime());
$sql.= "'".$this->canvas."',"; $sql.= ", ".$conf->entity;
$sql.= " ".$this->finished.")"; $sql.= ", '".$this->ref."'";
$sql.= ", ".price2num($price_min_ht);
$sql.= ", ".price2num($price_min_ttc);
$sql.= ", ".($this->libelle?"'".addslashes($this->libelle)."'":"null");
$sql.= ", ".$user->id;
$sql.= ", ".$this->type;
$sql.= ", ".price2num($price_ht);
$sql.= ", ".price2num($price_ttc);
$sql.= ", '".$this->price_base_type."'";
$sql.= ", '".$this->canvas."'";
$sql.= ", ".$this->finished;
$sql.= ")";
dol_syslog("Product::Create sql=".$sql); dol_syslog("Product::Create sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment