FIX convert stock class

This commit is contained in:
Regis Houssin 2022-01-27 10:17:11 +01:00
parent 7ff2678ef0
commit 07a47629d1
6 changed files with 46 additions and 46 deletions

View File

@ -104,7 +104,7 @@ class StockMovements extends DolibarrApi
} }
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as t"; $sql .= " FROM ".$this->db->prefix()."stock_mouvement as t";
//$sql.= ' WHERE t.entity IN ('.getEntity('stock').')'; //$sql.= ' WHERE t.entity IN ('.getEntity('stock').')';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
// Add sql filters // Add sql filters

View File

@ -104,9 +104,9 @@ class Warehouses extends DolibarrApi
} }
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as t"; $sql .= " FROM ".$this->db->prefix()."entrepot as t";
if ($category > 0) { if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c"; $sql .= ", ".$this->db->prefix()."categorie_societe as c";
} }
$sql .= ' WHERE t.entity IN ('.getEntity('stock').')'; $sql .= ' WHERE t.entity IN ('.getEntity('stock').')';
// Select warehouses of given category // Select warehouses of given category

View File

@ -204,13 +204,13 @@ class Entrepot extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (ref, entity, datec, fk_user_author, fk_parent, fk_project)"; $sql = "INSERT INTO ".$this->db->prefix()."entrepot (ref, entity, datec, fk_user_author, fk_parent, fk_project)";
$sql .= " VALUES ('".$this->db->escape($this->label)."', ".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $user->id).", ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "NULL").", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "NULL").")"; $sql .= " VALUES ('".$this->db->escape($this->label)."', ".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $user->id).", ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "NULL").", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "NULL").")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."entrepot"); $id = $this->db->last_insert_id($this->db->prefix()."entrepot");
if ($id > 0) { if ($id > 0) {
$this->id = $id; $this->id = $id;
@ -293,7 +293,7 @@ class Entrepot extends CommonObject
$this->town = trim($this->town); $this->town = trim($this->town);
$this->country_id = ($this->country_id > 0 ? $this->country_id : 0); $this->country_id = ($this->country_id > 0 ? $this->country_id : 0);
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot"; $sql = "UPDATE ".$this->db->prefix()."entrepot";
$sql .= " SET ref = '".$this->db->escape($this->label)."'"; $sql .= " SET ref = '".$this->db->escape($this->label)."'";
$sql .= ", fk_parent = ".(($this->fk_parent > 0) ? $this->fk_parent : "NULL"); $sql .= ", fk_parent = ".(($this->fk_parent > 0) ? $this->fk_parent : "NULL");
$sql .= ", fk_project = ".(($this->fk_project > 0) ? $this->fk_project : "NULL"); $sql .= ", fk_project = ".(($this->fk_project > 0) ? $this->fk_project : "NULL");
@ -365,7 +365,7 @@ class Entrepot extends CommonObject
$elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties'); $elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties');
foreach ($elements as $table) { foreach ($elements as $table) {
if (!$error) { if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql = "DELETE FROM ".$this->db->prefix().$table;
$sql .= " WHERE fk_entrepot = ".((int) $this->id); $sql .= " WHERE fk_entrepot = ".((int) $this->id);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -388,7 +388,7 @@ class Entrepot extends CommonObject
} }
if (!$error) { if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot"; $sql = "DELETE FROM ".$this->db->prefix()."entrepot";
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
$resql1 = $this->db->query($sql); $resql1 = $this->db->query($sql);
if (!$resql1) { if (!$resql1) {
@ -400,7 +400,7 @@ class Entrepot extends CommonObject
if (!$error) { if (!$error) {
// Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql // Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql
$sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET stock = (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql = "UPDATE ".$this->db->prefix()."product as p SET stock = (SELECT SUM(ps.reel) FROM ".$this->db->prefix()."product_stock as ps WHERE ps.fk_product = p.rowid)";
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if (!$resql2) { if (!$resql2) {
$error++; $error++;
@ -441,7 +441,7 @@ class Entrepot extends CommonObject
$sql = "SELECT rowid, entity, fk_parent, fk_project, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax,"; $sql = "SELECT rowid, entity, fk_parent, fk_project, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax,";
$sql .= " model_pdf, import_key"; $sql .= " model_pdf, import_key";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " FROM ".$this->db->prefix()."entrepot";
if ($id) { if ($id) {
$sql .= " WHERE rowid = ".((int) $id); $sql .= " WHERE rowid = ".((int) $id);
} else { } else {
@ -506,7 +506,7 @@ class Entrepot extends CommonObject
public function info($id) public function info($id)
{ {
$sql = "SELECT e.rowid, e.datec, e.tms as datem, e.fk_user_author"; $sql = "SELECT e.rowid, e.datec, e.tms as datem, e.fk_user_author";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql .= " FROM ".$this->db->prefix()."entrepot as e";
$sql .= " WHERE e.rowid = ".((int) $id); $sql .= " WHERE e.rowid = ".((int) $id);
dol_syslog(get_class($this)."::info", LOG_DEBUG); dol_syslog(get_class($this)."::info", LOG_DEBUG);
@ -553,7 +553,7 @@ class Entrepot extends CommonObject
$liste = array(); $liste = array();
$sql = "SELECT rowid, ref as label"; $sql = "SELECT rowid, ref as label";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " FROM ".$this->db->prefix()."entrepot";
$sql .= " WHERE entity IN (".getEntity('stock').")"; $sql .= " WHERE entity IN (".getEntity('stock').")";
$sql .= " AND statut = ".((int) $status); $sql .= " AND statut = ".((int) $status);
@ -583,8 +583,8 @@ class Entrepot extends CommonObject
$ret = array(); $ret = array();
$sql = "SELECT count(distinct p.rowid) as nb"; $sql = "SELECT count(distinct p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " FROM ".$this->db->prefix()."product_stock as ps";
$sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= ", ".$this->db->prefix()."product as p";
$sql .= " WHERE ps.fk_entrepot = ".((int) $this->id); $sql .= " WHERE ps.fk_entrepot = ".((int) $this->id);
$sql .= " AND ps.fk_product = p.rowid"; $sql .= " AND ps.fk_product = p.rowid";
@ -625,10 +625,10 @@ class Entrepot extends CommonObject
} else { } else {
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value";
} }
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " FROM ".$this->db->prefix()."product_stock as ps";
$sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= ", ".$this->db->prefix()."product as p";
if ($separatedPMP) { if ($separatedPMP) {
$sql .= ", ".MAIN_DB_PREFIX."product_perentity as pa"; $sql .= ", ".$this->db->prefix()."product_perentity as pa";
} }
$sql .= " WHERE ps.fk_entrepot = ".((int) $this->id); $sql .= " WHERE ps.fk_entrepot = ".((int) $this->id);
if ($separatedPMP) { if ($separatedPMP) {
@ -819,7 +819,7 @@ class Entrepot extends CommonObject
$parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents
$i = 0; $i = 0;
while ($parentid > 0 && $i < $protection) { while ($parentid > 0 && $i < $protection) {
$sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."entrepot WHERE rowid = ".((int) $parentid); $sql = "SELECT fk_parent FROM ".$this->db->prefix()."entrepot WHERE rowid = ".((int) $parentid);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$objarbo = $this->db->fetch_object($resql); $objarbo = $this->db->fetch_object($resql);
@ -853,7 +853,7 @@ class Entrepot extends CommonObject
// phpcs:enable // phpcs:enable
$sql = 'SELECT rowid $sql = 'SELECT rowid
FROM '.MAIN_DB_PREFIX.'entrepot FROM '.$this->db->prefix().'entrepot
WHERE fk_parent = '.((int) $id); WHERE fk_parent = '.((int) $id);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -287,7 +287,7 @@ class MouvementStock extends CommonObject
// If found and eatby/sellby not defined into table and provided, we update table // If found and eatby/sellby not defined into table and provided, we update table
// If found and eatby/sellby not defined into table and not provided, we do nothing // If found and eatby/sellby not defined into table and not provided, we do nothing
// If not found, we add record // If not found, we add record
$sql = "SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".MAIN_DB_PREFIX."product_lot as pb"; $sql = "SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".$this->db->prefix()."product_lot as pb";
$sql .= " WHERE pb.fk_product = ".((int) $fk_product)." AND pb.batch = '".$this->db->escape($batch)."'"; $sql .= " WHERE pb.fk_product = ".((int) $fk_product)." AND pb.batch = '".$this->db->escape($batch)."'";
dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG); dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -435,7 +435,7 @@ class MouvementStock extends CommonObject
$origin_id = 0; $origin_id = 0;
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement("; $sql = "INSERT INTO ".$this->db->prefix()."stock_mouvement(";
$sql .= " datem, fk_product, batch, eatby, sellby,"; $sql .= " datem, fk_product, batch, eatby, sellby,";
$sql .= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet"; $sql .= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
$sql .= ")"; $sql .= ")";
@ -457,7 +457,7 @@ class MouvementStock extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$mvid = $this->db->last_insert_id(MAIN_DB_PREFIX."stock_mouvement"); $mvid = $this->db->last_insert_id($this->db->prefix()."stock_mouvement");
$this->id = $mvid; $this->id = $mvid;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -473,7 +473,7 @@ class MouvementStock extends CommonObject
// Test if there is already a record for couple (warehouse / product), so later we will make an update or create. // Test if there is already a record for couple (warehouse / product), so later we will make an update or create.
$alreadyarecord = 0; $alreadyarecord = 0;
if (!$error) { if (!$error) {
$sql = "SELECT rowid, reel FROM ".MAIN_DB_PREFIX."product_stock"; $sql = "SELECT rowid, reel FROM ".$this->db->prefix()."product_stock";
$sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); // This is a unique key $sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); // This is a unique key
dol_syslog(get_class($this)."::_create check if a record already exists in product_stock", LOG_DEBUG); dol_syslog(get_class($this)."::_create check if a record already exists in product_stock", LOG_DEBUG);
@ -524,10 +524,10 @@ class MouvementStock extends CommonObject
// Update stock quantity // Update stock quantity
if (!$error) { if (!$error) {
if ($alreadyarecord > 0) { if ($alreadyarecord > 0) {
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".((float) $qty); $sql = "UPDATE ".$this->db->prefix()."product_stock SET reel = reel + ".((float) $qty);
$sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); $sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product);
} else { } else {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock"; $sql = "INSERT INTO ".$this->db->prefix()."product_stock";
$sql .= " (reel, fk_entrepot, fk_product) VALUES "; $sql .= " (reel, fk_entrepot, fk_product) VALUES ";
$sql .= " (".((float) $qty).", ".((int) $entrepot_id).", ".((int) $fk_product).")"; $sql .= " (".((float) $qty).", ".((int) $entrepot_id).", ".((int) $fk_product).")";
} }
@ -538,7 +538,7 @@ class MouvementStock extends CommonObject
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
$error = -3; $error = -3;
} elseif (empty($fk_product_stock)) { } elseif (empty($fk_product_stock)) {
$fk_product_stock = $this->db->last_insert_id(MAIN_DB_PREFIX."product_stock"); $fk_product_stock = $this->db->last_insert_id($this->db->prefix()."product_stock");
} }
} }
@ -559,11 +559,11 @@ class MouvementStock extends CommonObject
if (!$error) { if (!$error) {
$newpmp = price2num($newpmp, 'MU'); $newpmp = price2num($newpmp, 'MU');
// $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty; // $sql = "UPDATE ".$this->db->prefix()."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty;
// $sql.= " WHERE rowid = ".((int) $fk_product); // $sql.= " WHERE rowid = ".((int) $fk_product);
// Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql
$sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".((float) $newpmp).","; $sql = "UPDATE ".$this->db->prefix()."product as p SET pmp = ".((float) $newpmp).",";
$sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql .= " stock=(SELECT SUM(ps.reel) FROM ".$this->db->prefix()."product_stock as ps WHERE ps.fk_product = p.rowid)";
$sql .= " WHERE rowid = ".((int) $fk_product); $sql .= " WHERE rowid = ".((int) $fk_product);
dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG); dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG);
@ -576,7 +576,7 @@ class MouvementStock extends CommonObject
// If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine // If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine
// having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot.
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; $sql = "DELETE FROM ".$this->db->prefix()."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".$this->db->prefix()."product_batch as pb)";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
// We do not test error, it can fails if there is child in batch details // We do not test error, it can fails if there is child in batch details
} }
@ -644,7 +644,7 @@ class MouvementStock extends CommonObject
$sql .= " t.eatby,"; $sql .= " t.eatby,";
$sql .= " t.sellby,"; $sql .= " t.sellby,";
$sql .= " t.fk_projet as fk_project"; $sql .= " t.fk_projet as fk_project";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.((int) $id); $sql .= ' WHERE t.rowid = '.((int) $id);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -721,7 +721,7 @@ class MouvementStock extends CommonObject
$pqtys = array(); $pqtys = array();
$sql = "SELECT fk_product_pere, fk_product_fils, qty"; $sql = "SELECT fk_product_pere, fk_product_fils, qty";
$sql .= " FROM ".MAIN_DB_PREFIX."product_association"; $sql .= " FROM ".$this->db->prefix()."product_association";
$sql .= " WHERE fk_product_pere = ".((int) $idProduct); $sql .= " WHERE fk_product_pere = ".((int) $idProduct);
$sql .= " AND incdec = 1"; $sql .= " AND incdec = 1";
@ -824,7 +824,7 @@ class MouvementStock extends CommonObject
{ {
$nb = 0; $nb = 0;
$sql = 'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.'stock_mouvement'; $sql = 'SELECT SUM(value) as nb from '.$this->db->prefix().'stock_mouvement';
$sql .= ' WHERE fk_product = '.((int) $productidselected); $sql .= ' WHERE fk_product = '.((int) $productidselected);
$sql .= " AND datem < '".$this->db->idate($datebefore)."'"; $sql .= " AND datem < '".$this->db->idate($datebefore)."'";
@ -1203,8 +1203,8 @@ class MouvementStock extends CommonObject
$cpt = 0; $cpt = 0;
$sql = "SELECT sum(pb.qty) as cpt"; $sql = "SELECT sum(pb.qty) as cpt";
$sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql .= " FROM ".$this->db->prefix()."product_batch as pb";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."product_stock as ps ON ps.rowid = pb.fk_product_stock"; $sql .= " INNER JOIN ".$this->db->prefix()."product_stock as ps ON ps.rowid = pb.fk_product_stock";
$sql .= " WHERE ps.fk_product = " . ((int) $fk_product); $sql .= " WHERE ps.fk_product = " . ((int) $fk_product);
$sql .= " AND pb.batch = '" . $this->db->escape($batch) . "'"; $sql .= " AND pb.batch = '" . $this->db->escape($batch) . "'";

View File

@ -188,7 +188,7 @@ class Productlot extends CommonObject
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'(';
$sql .= 'entity,'; $sql .= 'entity,';
$sql .= 'fk_product,'; $sql .= 'fk_product,';
$sql .= 'batch,'; $sql .= 'batch,';
@ -230,7 +230,7 @@ class Productlot extends CommonObject
} }
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
// Actions on extra fields // Actions on extra fields
if (!$error) { if (!$error) {
@ -296,7 +296,7 @@ class Productlot extends CommonObject
$sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif,"; $sql .= " t.fk_user_modif,";
$sql .= " t.import_key"; $sql .= " t.import_key";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
if ($product_id > 0 && $batch != '') { if ($product_id > 0 && $batch != '') {
$sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".((int) $product_id); $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".((int) $product_id);
} else { } else {
@ -394,7 +394,7 @@ class Productlot extends CommonObject
} }
// Update request // Update request
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql = 'UPDATE '.$this->db->prefix().$this->table_element.' SET';
$sql .= ' entity = '.(isset($this->entity) ? $this->entity : "null").','; $sql .= ' entity = '.(isset($this->entity) ? $this->entity : "null").',';
$sql .= ' fk_product = '.(isset($this->fk_product) ? $this->fk_product : "null").','; $sql .= ' fk_product = '.(isset($this->fk_product) ? $this->fk_product : "null").',';
$sql .= ' batch = '.(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").','; $sql .= ' batch = '.(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").',';
@ -479,7 +479,7 @@ class Productlot extends CommonObject
//} //}
if (!$error) { if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element;
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -113,7 +113,7 @@ class ProductStockEntrepot extends CommonObject
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'(';
$sql .= 'fk_product,'; $sql .= 'fk_product,';
$sql .= 'fk_entrepot,'; $sql .= 'fk_entrepot,';
@ -143,7 +143,7 @@ class ProductStockEntrepot extends CommonObject
} }
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
//if (!$notrigger) { //if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
@ -192,7 +192,7 @@ class ProductStockEntrepot extends CommonObject
$sql .= " t.seuil_stock_alerte,"; $sql .= " t.seuil_stock_alerte,";
$sql .= " t.desiredstock,"; $sql .= " t.desiredstock,";
$sql .= " t.import_key"; $sql .= " t.import_key";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
if (!empty($id)) { if (!empty($id)) {
$sql .= ' WHERE t.rowid = '.((int) $id); $sql .= ' WHERE t.rowid = '.((int) $id);
} else { } else {
@ -265,7 +265,7 @@ class ProductStockEntrepot extends CommonObject
$sql .= " t.import_key"; $sql .= " t.import_key";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
$sql .= ' WHERE 1=1'; $sql .= ' WHERE 1=1';
@ -355,7 +355,7 @@ class ProductStockEntrepot extends CommonObject
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
// Update request // Update request
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql = 'UPDATE '.$this->db->prefix().$this->table_element.' SET';
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").',';
$sql .= ' fk_product = '.(isset($this->fk_product) ? $this->fk_product : "null").','; $sql .= ' fk_product = '.(isset($this->fk_product) ? $this->fk_product : "null").',';
@ -425,7 +425,7 @@ class ProductStockEntrepot extends CommonObject
//} //}
if (!$error) { if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element;
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);