|
@@ -689,7 +689,7 @@ class Product extends CommonObject
|
|
|
|
|
|
if ($result >= 0) {
|
|
|
$sql = "SELECT count(*) as nb";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product";
|
|
|
$sql .= " WHERE entity IN (".getEntity('product').")";
|
|
|
$sql .= " AND ref = '".$this->db->escape($this->ref)."'";
|
|
|
|
|
@@ -698,7 +698,7 @@ class Product extends CommonObject
|
|
|
$obj = $this->db->fetch_object($result);
|
|
|
if ($obj->nb == 0) {
|
|
|
// Produit non deja existant
|
|
|
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product (";
|
|
|
+ $sql = "INSERT INTO ".$this->db->prefix()."product (";
|
|
|
$sql .= "datec";
|
|
|
$sql .= ", entity";
|
|
|
$sql .= ", ref";
|
|
@@ -761,7 +761,7 @@ class Product extends CommonObject
|
|
|
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
|
|
|
$result = $this->db->query($sql);
|
|
|
if ($result) {
|
|
|
- $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");
|
|
|
+ $id = $this->db->last_insert_id($this->db->prefix()."product");
|
|
|
|
|
|
if ($id > 0) {
|
|
|
$this->id = $id;
|
|
@@ -782,9 +782,9 @@ class Product extends CommonObject
|
|
|
|
|
|
// update accountancy for this entity
|
|
|
if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
|
|
- $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = " .((int) $this->id) . " AND entity = " . ((int) $conf->entity));
|
|
|
+ $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " .((int) $this->id) . " AND entity = " . ((int) $conf->entity));
|
|
|
|
|
|
- $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (";
|
|
|
+ $sql = "INSERT INTO " . $this->db->prefix() . "product_perentity (";
|
|
|
$sql .= " fk_product";
|
|
|
$sql .= ", entity";
|
|
|
$sql .= ", accountancy_code_buy";
|
|
@@ -1074,7 +1074,7 @@ class Product extends CommonObject
|
|
|
foreach ($ObjW->detail_batch as $detail) { // Each lines of detail in product_batch of the current $ObjW = product_stock
|
|
|
if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') {
|
|
|
// We discard this line, we will create it later
|
|
|
- $sqlclean = "DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$this->db->escape($valueforundefinedlot)."') AND fk_product_stock = ".((int) $ObjW->id);
|
|
|
+ $sqlclean = "DELETE FROM ".$this->db->prefix()."product_batch WHERE batch in('Undefined', '".$this->db->escape($valueforundefinedlot)."') AND fk_product_stock = ".((int) $ObjW->id);
|
|
|
$result = $this->db->query($sqlclean);
|
|
|
if (!$result) {
|
|
|
dol_print_error($this->db);
|
|
@@ -1106,7 +1106,7 @@ class Product extends CommonObject
|
|
|
$this->barcode = $this->get_barcode($this, $this->barcode_type_code);
|
|
|
}
|
|
|
|
|
|
- $sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
|
|
+ $sql = "UPDATE ".$this->db->prefix()."product";
|
|
|
$sql .= " SET label = '".$this->db->escape($this->label)."'";
|
|
|
|
|
|
if ($updatetype && ($this->isProduct() || $this->isService())) {
|
|
@@ -1194,9 +1194,9 @@ class Product extends CommonObject
|
|
|
|
|
|
// update accountancy for this entity
|
|
|
if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
|
|
- $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity));
|
|
|
+ $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity));
|
|
|
|
|
|
- $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (";
|
|
|
+ $sql = "INSERT INTO " . $this->db->prefix() . "product_perentity (";
|
|
|
$sql .= " fk_product";
|
|
|
$sql .= ", entity";
|
|
|
$sql .= ", accountancy_code_buy";
|
|
@@ -1339,9 +1339,9 @@ class Product extends CommonObject
|
|
|
|
|
|
// Delete from product_batch on product delete
|
|
|
if (!$error) {
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch';
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix().'product_batch';
|
|
|
$sql .= " WHERE fk_product_stock IN (";
|
|
|
- $sql .= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock';
|
|
|
+ $sql .= "SELECT rowid FROM ".$this->db->prefix().'product_stock';
|
|
|
$sql .= " WHERE fk_product = ".((int) $this->id).")";
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
@@ -1356,7 +1356,7 @@ class Product extends CommonObject
|
|
|
$elements = array('product_fournisseur_price', 'product_price', 'product_lang', 'categorie_product', 'product_stock', 'product_customer_price', 'product_lot'); // product_batch is done before
|
|
|
foreach ($elements as $table) {
|
|
|
if (!$error) {
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table;
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix().$table;
|
|
|
$sql .= " WHERE fk_product = ".(int) $this->id;
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
@@ -1389,7 +1389,7 @@ class Product extends CommonObject
|
|
|
|
|
|
// Delete from product_association
|
|
|
if (!$error) {
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix()."product_association";
|
|
|
$sql .= " WHERE fk_product_pere = ".(int) $this->id." OR fk_product_fils = ".(int) $this->id;
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
@@ -1410,7 +1410,7 @@ class Product extends CommonObject
|
|
|
|
|
|
// Delete product
|
|
|
if (!$error) {
|
|
|
- $sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product";
|
|
|
+ $sqlz = "DELETE FROM ".$this->db->prefix()."product";
|
|
|
$sqlz .= " WHERE rowid = ".(int) $this->id;
|
|
|
|
|
|
$resultz = $this->db->query($sqlz);
|
|
@@ -1468,14 +1468,14 @@ class Product extends CommonObject
|
|
|
foreach ($langs_available as $key => $value) {
|
|
|
if ($key == $current_lang) {
|
|
|
$sql = "SELECT rowid";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_lang";
|
|
|
$sql .= " WHERE fk_product = ".((int) $this->id);
|
|
|
$sql .= " AND lang = '".$this->db->escape($key)."'";
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
if ($this->db->num_rows($result)) { // if there is already a description line for this language
|
|
|
- $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
|
|
|
+ $sql2 = "UPDATE ".$this->db->prefix()."product_lang";
|
|
|
$sql2 .= " SET ";
|
|
|
$sql2 .= " label='".$this->db->escape($this->label)."',";
|
|
|
$sql2 .= " description='".$this->db->escape($this->description)."'";
|
|
@@ -1484,7 +1484,7 @@ class Product extends CommonObject
|
|
|
}
|
|
|
$sql2 .= " WHERE fk_product = ".((int) $this->id)." AND lang = '".$this->db->escape($key)."'";
|
|
|
} else {
|
|
|
- $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description";
|
|
|
+ $sql2 = "INSERT INTO ".$this->db->prefix()."product_lang (fk_product, lang, label, description";
|
|
|
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
|
|
|
$sql2 .= ", note";
|
|
|
}
|
|
@@ -1508,14 +1508,14 @@ class Product extends CommonObject
|
|
|
}
|
|
|
|
|
|
$sql = "SELECT rowid";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_lang";
|
|
|
$sql .= " WHERE fk_product = ".((int) $this->id);
|
|
|
$sql .= " AND lang = '".$this->db->escape($key)."'";
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
if ($this->db->num_rows($result)) { // if there is already a description line for this language
|
|
|
- $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang";
|
|
|
+ $sql2 = "UPDATE ".$this->db->prefix()."product_lang";
|
|
|
$sql2 .= " SET ";
|
|
|
$sql2 .= " label = '".$this->db->escape($this->multilangs["$key"]["label"])."',";
|
|
|
$sql2 .= " description = '".$this->db->escape($this->multilangs["$key"]["description"])."'";
|
|
@@ -1524,7 +1524,7 @@ class Product extends CommonObject
|
|
|
}
|
|
|
$sql2 .= " WHERE fk_product = ".((int) $this->id)." AND lang = '".$this->db->escape($key)."'";
|
|
|
} else {
|
|
|
- $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description";
|
|
|
+ $sql2 = "INSERT INTO ".$this->db->prefix()."product_lang (fk_product, lang, label, description";
|
|
|
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
|
|
|
$sql2 .= ", note";
|
|
|
}
|
|
@@ -1570,7 +1570,7 @@ class Product extends CommonObject
|
|
|
*/
|
|
|
public function delMultiLangs($langtodelete, $user)
|
|
|
{
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang";
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix()."product_lang";
|
|
|
$sql .= " WHERE fk_product = ".((int) $this->id)." AND lang = '".$this->db->escape($langtodelete)."'";
|
|
|
|
|
|
dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
|
|
@@ -1624,7 +1624,7 @@ class Product extends CommonObject
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ";
|
|
|
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET ";
|
|
|
$sql .= "$field = '".$this->db->escape($value)."'";
|
|
|
$sql .= " WHERE rowid = ".((int) $this->id);
|
|
|
|
|
@@ -1667,7 +1667,7 @@ class Product extends CommonObject
|
|
|
$current_lang = $langs->getDefaultLang();
|
|
|
|
|
|
$sql = "SELECT lang, label, description, note as other";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_lang";
|
|
|
$sql .= " WHERE fk_product = ".((int) $this->id);
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
@@ -1743,7 +1743,7 @@ class Product extends CommonObject
|
|
|
}
|
|
|
|
|
|
// Add new price
|
|
|
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,";
|
|
|
+ $sql = "INSERT INTO ".$this->db->prefix()."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,";
|
|
|
$sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) ";
|
|
|
$sql .= " VALUES(".($level ? ((int) $level) : 1).", '".$this->db->idate($now)."', ".((int) $this->id).", ".((int) $user->id).", ".((float) price2num($this->price)).", ".((float) price2num($this->price_ttc)).",'".$this->db->escape($this->price_base_type)."',".((int) $this->status).", ".((float) price2num($this->tva_tx)).", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").", ".((int) $this->tva_npr).",";
|
|
|
$sql .= " ".price2num($this->localtax1_tx).", ".price2num($this->localtax2_tx).", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".price2num($this->price_min).", ".price2num($this->price_min_ttc).", ".price2num($this->price_by_qty).", ".((int) $conf->entity).",".($this->fk_price_expression > 0 ? ((int) $this->fk_price_expression) : 'null');
|
|
@@ -1772,11 +1772,11 @@ class Product extends CommonObject
|
|
|
public function log_price_delete($user, $rowid)
|
|
|
{
|
|
|
// phpcs:enable
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty";
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix()."product_price_by_qty";
|
|
|
$sql .= " WHERE fk_product_price = ".((int) $rowid);
|
|
|
$resql = $this->db->query($sql);
|
|
|
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price";
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix()."product_price";
|
|
|
$sql .= " WHERE rowid=".((int) $rowid);
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql) {
|
|
@@ -1924,7 +1924,7 @@ class Product extends CommonObject
|
|
|
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
|
|
|
$sql .= ", pfp.packaging";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_fournisseur_price as pfp";
|
|
|
$sql .= " WHERE pfp.rowid = ".((int) $prodfournprice);
|
|
|
if ($qty > 0) {
|
|
|
$sql .= " AND pfp.quantity <= ".((float) $qty);
|
|
@@ -1978,7 +1978,7 @@ class Product extends CommonObject
|
|
|
$sql .= " pfp.default_vat_code,";
|
|
|
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
|
|
|
$sql .= " pfp.packaging";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_fournisseur_price as pfp";
|
|
|
$sql .= " WHERE pfp.fk_product = ".((int) $product_id);
|
|
|
if ($fourn_ref != 'none') {
|
|
|
$sql .= " AND pfp.ref_fourn = '".$this->db->escape($fourn_ref)."'";
|
|
@@ -2158,7 +2158,7 @@ class Product extends CommonObject
|
|
|
|
|
|
// Ne pas mettre de quote sur les numeriques decimaux.
|
|
|
// Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes.
|
|
|
- $sql = "UPDATE ".MAIN_DB_PREFIX."product SET";
|
|
|
+ $sql = "UPDATE ".$this->db->prefix()."product SET";
|
|
|
$sql .= " price_base_type='".$this->db->escape($newpricebase)."',";
|
|
|
$sql .= " price=".$price.",";
|
|
|
$sql .= " price_ttc=".$price_ttc.",";
|
|
@@ -2288,7 +2288,7 @@ class Product extends CommonObject
|
|
|
$separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses.
|
|
|
if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)) {
|
|
|
if (!empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
|
|
|
- $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity);
|
|
|
+ $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity);
|
|
|
if ($this->db->num_rows($checkPMPPerEntity)>0) {
|
|
|
$separatedEntityPMP = true;
|
|
|
}
|
|
@@ -2312,12 +2312,12 @@ class Product extends CommonObject
|
|
|
} else {
|
|
|
$sql .= " p.stock";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product as p";
|
|
|
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) || $separatedEntityPMP) {
|
|
|
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
|
|
|
+ $sql .= " LEFT JOIN " . $this->db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
|
|
|
}
|
|
|
if ($separatedStock) {
|
|
|
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM ".MAIN_DB_PREFIX."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))";
|
|
|
+ $sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM ".$this->db->prefix()."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))";
|
|
|
}
|
|
|
|
|
|
if ($id) {
|
|
@@ -2467,7 +2467,7 @@ class Product extends CommonObject
|
|
|
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
|
|
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
|
|
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_price";
|
|
|
$sql .= " WHERE entity IN (".getEntity('productprice').")";
|
|
|
$sql .= " AND price_level=".((int) $i);
|
|
|
$sql .= " AND fk_product = ".((int) $this->id);
|
|
@@ -2494,7 +2494,7 @@ class Product extends CommonObject
|
|
|
if ($this->prices_by_qty[$i] == 1)
|
|
|
{
|
|
|
$sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type";
|
|
|
- $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
|
|
|
+ $sql.= " FROM ".$this->db->prefix()."product_price_by_qty";
|
|
|
$sql.= " WHERE fk_product_price = ".((int) $this->prices_by_qty_id[$i]);
|
|
|
$sql.= " ORDER BY quantity ASC";
|
|
|
$resultat=array();
|
|
@@ -2531,7 +2531,7 @@ class Product extends CommonObject
|
|
|
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) && empty($ignore_price_load)) { // prices per quantity
|
|
|
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
|
|
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_price";
|
|
|
$sql .= " WHERE fk_product = ".((int) $this->id);
|
|
|
$sql .= " ORDER BY date_price DESC, rowid DESC";
|
|
|
$sql .= " LIMIT 1";
|
|
@@ -2545,7 +2545,7 @@ class Product extends CommonObject
|
|
|
// Récuperation de la liste des prix selon qty si flag positionné
|
|
|
if ($this->prices_by_qty[0] == 1) {
|
|
|
$sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_price_by_qty";
|
|
|
$sql .= " WHERE fk_product_price = ".((int) $this->prices_by_qty_id[0]);
|
|
|
$sql .= " ORDER BY quantity ASC";
|
|
|
$resultat = array();
|
|
@@ -2577,7 +2577,7 @@ class Product extends CommonObject
|
|
|
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
|
|
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
|
|
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_price";
|
|
|
$sql .= " WHERE entity IN (".getEntity('productprice').")";
|
|
|
$sql .= " AND price_level=".((int) $i);
|
|
|
$sql .= " AND fk_product = ".((int) $this->id);
|
|
@@ -2602,7 +2602,7 @@ class Product extends CommonObject
|
|
|
// Récuperation de la liste des prix selon qty si flag positionné
|
|
|
if ($this->prices_by_qty[$i] == 1) {
|
|
|
$sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_price_by_qty";
|
|
|
$sql .= " WHERE fk_product_price = ".((int) $this->prices_by_qty_id[$i]);
|
|
|
$sql .= " ORDER BY quantity ASC";
|
|
|
$resultat = array();
|
|
@@ -2680,10 +2680,10 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
|
|
$sql .= " SUM(mp.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c";
|
|
|
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."mrp_production as mp ON mp.fk_mo=c.rowid";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."mrp_mo as c";
|
|
|
+ $sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
|
|
|
+ $sql .= "INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
|
|
|
}
|
|
|
$sql .= " WHERE ";
|
|
|
$sql .= " c.entity IN (".getEntity('mo').")";
|
|
@@ -2740,8 +2740,8 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT b.rowid) as nb_toproduce,";
|
|
|
$sql .= " SUM(b.qty) as qty_toproduce";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b";
|
|
|
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."bom_bom as b";
|
|
|
+ $sql .= " INNER JOIN ".$this->db->prefix()."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
|
|
$sql .= " WHERE ";
|
|
|
$sql .= " b.entity IN (".getEntity('bom').")";
|
|
|
$sql .= " AND b.fk_product =".((int) $this->id);
|
|
@@ -2759,8 +2759,8 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT bl.rowid) as nb_toconsume,";
|
|
|
$sql .= " SUM(bl.qty) as qty_toconsume";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b";
|
|
|
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."bom_bom as b";
|
|
|
+ $sql .= " INNER JOIN ".$this->db->prefix()."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
|
|
$sql .= " WHERE ";
|
|
|
$sql .= " b.entity IN (".getEntity('bom').")";
|
|
|
$sql .= " AND bl.fk_product =".((int) $this->id);
|
|
@@ -2802,11 +2802,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_customers, COUNT(DISTINCT p.rowid) as nb,";
|
|
|
$sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."propal as p";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."propaldet as pd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."propal as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE p.rowid = pd.fk_propal";
|
|
|
$sql .= " AND p.fk_soc = s.rowid";
|
|
@@ -2877,11 +2877,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,";
|
|
|
$sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."supplier_proposaldet as pd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."supplier_proposal as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE p.rowid = pd.fk_supplier_proposal";
|
|
|
$sql .= " AND p.fk_soc = s.rowid";
|
|
@@ -2933,11 +2933,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
|
|
$sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."commande as c";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."commandedet as cd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."commande as c";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE c.rowid = cd.fk_commande";
|
|
|
$sql .= " AND c.fk_soc = s.rowid";
|
|
@@ -2988,10 +2988,10 @@ class Product extends CommonObject
|
|
|
if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
|
|
|
if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) {
|
|
|
$adeduire = 0;
|
|
|
- $sql = "SELECT sum(fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet fd ";
|
|
|
- $sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON fd.fk_facture = f.rowid ";
|
|
|
- $sql .= " JOIN ".MAIN_DB_PREFIX."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'";
|
|
|
- $sql .= " JOIN ".MAIN_DB_PREFIX."commande c ON el.fk_source = c.rowid ";
|
|
|
+ $sql = "SELECT sum(fd.qty) as count FROM ".$this->db->prefix()."facturedet fd ";
|
|
|
+ $sql .= " JOIN ".$this->db->prefix()."facture f ON fd.fk_facture = f.rowid ";
|
|
|
+ $sql .= " JOIN ".$this->db->prefix()."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'";
|
|
|
+ $sql .= " JOIN ".$this->db->prefix()."commande c ON el.fk_source = c.rowid ";
|
|
|
$sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id);
|
|
|
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);
|
|
|
|
|
@@ -3035,11 +3035,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,";
|
|
|
$sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."commande_fournisseurdet as cd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."commande_fournisseur as c";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE c.rowid = cd.fk_commande";
|
|
|
$sql .= " AND c.fk_soc = s.rowid";
|
|
@@ -3093,13 +3093,13 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,";
|
|
|
$sql .= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."commandedet as cd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."commande as c";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."expedition as e";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."expeditiondet as ed";
|
|
|
+ $sql .= ", ".$this->db->prefix()."commandedet as cd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."commande as c";
|
|
|
+ $sql .= ", ".$this->db->prefix()."expedition as e";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE e.rowid = ed.fk_expedition";
|
|
|
$sql .= " AND c.rowid = cd.fk_commande";
|
|
@@ -3178,11 +3178,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_suppliers, COUNT(DISTINCT cf.rowid) as nb,";
|
|
|
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as fd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."commande_fournisseur as cf";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE cf.rowid = fd.fk_commande";
|
|
|
$sql .= " AND cf.fk_soc = s.rowid";
|
|
@@ -3235,11 +3235,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT m.fk_soc) as nb_customers, COUNT(DISTINCT m.rowid) as nb,";
|
|
|
$sql .= " COUNT(mp.rowid) as nb_rows, SUM(mp.qty) as qty, role";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."mrp_production as mp";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as m";
|
|
|
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = m.fk_soc";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."mrp_production as mp";
|
|
|
+ $sql .= ", ".$this->db->prefix()."mrp_mo as m";
|
|
|
+ $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = m.fk_soc";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE m.rowid = mp.fk_mo";
|
|
|
$sql .= " AND m.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mrp').")";
|
|
@@ -3328,11 +3328,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
|
|
$sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."contratdet as cd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."contrat as c";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE c.rowid = cd.fk_contrat";
|
|
|
$sql .= " AND c.fk_soc = s.rowid";
|
|
@@ -3402,11 +3402,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,";
|
|
|
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(".$this->db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."facturedet as fd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."facture as f";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE f.rowid = fd.fk_facture";
|
|
|
$sql .= " AND f.fk_soc = s.rowid";
|
|
@@ -3476,11 +3476,11 @@ class Product extends CommonObject
|
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,";
|
|
|
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."facture_fourn_det as fd";
|
|
|
+ $sql .= ", ".$this->db->prefix()."facture_fourn as f";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe as s";
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE f.rowid = fd.fk_facture_fourn";
|
|
|
$sql .= " AND f.fk_soc = s.rowid";
|
|
@@ -3607,12 +3607,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT f.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."facturedet as d, ".$this->db->prefix()."facture as f, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as p";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE f.rowid = d.fk_facture";
|
|
|
if ($this->id > 0) {
|
|
@@ -3660,12 +3660,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT f.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."facture_fourn_det as d, ".$this->db->prefix()."facture_fourn as f, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as p";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE f.rowid = d.fk_facture_fourn";
|
|
|
if ($this->id > 0) {
|
|
@@ -3711,12 +3711,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT p.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."propaldet as d, ".$this->db->prefix()."propal as p, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as prod";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as prod";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE p.rowid = d.fk_propal";
|
|
|
if ($this->id > 0) {
|
|
@@ -3763,12 +3763,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT p.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."supplier_proposaldet as d, ".$this->db->prefix()."supplier_proposal as p, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as prod";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as prod";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE p.rowid = d.fk_supplier_proposal";
|
|
|
if ($this->id > 0) {
|
|
@@ -3814,12 +3814,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT c.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."commandedet as d, ".$this->db->prefix()."commande as c, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as p";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE c.rowid = d.fk_commande";
|
|
|
if ($this->id > 0) {
|
|
@@ -3865,12 +3865,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT c.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."commande_fournisseurdet as d, ".$this->db->prefix()."commande_fournisseur as c, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as p";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
$sql .= " WHERE c.rowid = d.fk_commande";
|
|
|
if ($this->id > 0) {
|
|
@@ -3916,12 +3916,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT c.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."contratdet as d, ".$this->db->prefix()."contrat as c, ".$this->db->prefix()."societe as s";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as p";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
|
|
|
$sql .= " WHERE c.entity IN (".getEntity('contract').")";
|
|
@@ -3970,12 +3970,12 @@ class Product extends CommonObject
|
|
|
if ($mode == 'bynumber') {
|
|
|
$sql .= ", count(DISTINCT d.rowid)";
|
|
|
}
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as d LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON d.fk_soc = s.rowid";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."mrp_mo as d LEFT JOIN ".$this->db->prefix()."societe as s ON d.fk_soc = s.rowid";
|
|
|
if ($filteronproducttype >= 0) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= ", ".$this->db->prefix()."product as p";
|
|
|
}
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
+ $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
|
|
|
}
|
|
|
|
|
|
$sql .= " WHERE d.entity IN (".getEntity('mo').")";
|
|
@@ -4033,21 +4033,21 @@ class Product extends CommonObject
|
|
|
}
|
|
|
|
|
|
// Check not already father of id_pere (to avoid father -> child -> father links)
|
|
|
- $sql = "SELECT fk_product_pere from ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql = "SELECT fk_product_pere from ".$this->db->prefix()."product_association";
|
|
|
$sql .= " WHERE fk_product_pere = ".((int) $id_fils)." AND fk_product_fils = ".((int) $id_pere);
|
|
|
if (!$this->db->query($sql)) {
|
|
|
dol_print_error($this->db);
|
|
|
return -1;
|
|
|
} else {
|
|
|
//Selection of the highest row
|
|
|
- $sql = "SELECT MAX(rang) as max_rank FROM ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql = "SELECT MAX(rang) as max_rank FROM ".$this->db->prefix()."product_association";
|
|
|
$sql .= " WHERE fk_product_pere = ".((int) $id_pere);
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql > 0) {
|
|
|
$obj = $this->db->fetch_object($resql);
|
|
|
$rank = $obj->max_rank + 1;
|
|
|
//Addition of a product with the highest rank +1
|
|
|
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)";
|
|
|
+ $sql = "INSERT INTO ".$this->db->prefix()."product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)";
|
|
|
$sql .= " VALUES (".((int) $id_pere).", ".((int) $id_fils).", ".price2num($qty, 'MS').", ".price2num($incdec, 'MS').", ".((int) $rank).")";
|
|
|
if (! $this->db->query($sql)) {
|
|
|
dol_print_error($this->db);
|
|
@@ -4089,7 +4089,7 @@ class Product extends CommonObject
|
|
|
$qty = 1;
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association SET ';
|
|
|
+ $sql = 'UPDATE '.$this->db->prefix().'product_association SET ';
|
|
|
$sql .= 'qty = '.price2num($qty, 'MS');
|
|
|
$sql .= ',incdec = '.price2num($incdec, 'MS');
|
|
|
$sql .= ' WHERE fk_product_pere = '.((int) $id_pere).' AND fk_product_fils = '.((int) $id_fils);
|
|
@@ -4120,7 +4120,7 @@ class Product extends CommonObject
|
|
|
$fk_child = 0;
|
|
|
}
|
|
|
|
|
|
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql = "DELETE FROM ".$this->db->prefix()."product_association";
|
|
|
$sql .= " WHERE fk_product_pere = ".((int) $fk_parent);
|
|
|
$sql .= " AND fk_product_fils = ".((int) $fk_child);
|
|
|
|
|
@@ -4131,7 +4131,7 @@ class Product extends CommonObject
|
|
|
}
|
|
|
|
|
|
// Updated ranks so that none are missing
|
|
|
- $sqlrank = "SELECT rowid, rang FROM ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sqlrank = "SELECT rowid, rang FROM ".$this->db->prefix()."product_association";
|
|
|
$sqlrank.= " WHERE fk_product_pere = ".((int) $fk_parent);
|
|
|
$sqlrank.= " ORDER BY rang";
|
|
|
$resqlrank = $this->db->query($sqlrank);
|
|
@@ -4139,7 +4139,7 @@ class Product extends CommonObject
|
|
|
$cpt = 0;
|
|
|
while ($objrank = $this->db->fetch_object($resqlrank)) {
|
|
|
$cpt++;
|
|
|
- $sql = "UPDATE ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql = "UPDATE ".$this->db->prefix()."product_association";
|
|
|
$sql.= " SET rang = ".((int) $cpt);
|
|
|
$sql.= " WHERE rowid = ".((int) $objrank->rowid);
|
|
|
if (! $this->db->query($sql)) {
|
|
@@ -4163,7 +4163,7 @@ class Product extends CommonObject
|
|
|
{
|
|
|
// phpcs:enable
|
|
|
$sql = "SELECT fk_product_pere, qty, incdec";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_association";
|
|
|
$sql .= " WHERE fk_product_pere = ".((int) $fk_parent);
|
|
|
$sql .= " AND fk_product_fils = ".((int) $fk_child);
|
|
|
|
|
@@ -4213,7 +4213,7 @@ class Product extends CommonObject
|
|
|
|
|
|
if ($ref_fourn) {
|
|
|
$sql = "SELECT rowid, fk_product";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_fournisseur_price";
|
|
|
$sql .= " WHERE fk_soc = ".((int) $id_fourn);
|
|
|
$sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'";
|
|
|
$sql .= " AND fk_product <> ".((int) $this->id);
|
|
@@ -4232,7 +4232,7 @@ class Product extends CommonObject
|
|
|
}
|
|
|
|
|
|
$sql = "SELECT rowid";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_fournisseur_price";
|
|
|
$sql .= " WHERE fk_soc = ".((int) $id_fourn);
|
|
|
if ($ref_fourn) {
|
|
|
$sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'";
|
|
@@ -4249,7 +4249,7 @@ class Product extends CommonObject
|
|
|
|
|
|
// The reference supplier does not exist, we create it for this product.
|
|
|
if (empty($obj)) {
|
|
|
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
|
|
|
+ $sql = "INSERT INTO ".$this->db->prefix()."product_fournisseur_price(";
|
|
|
$sql .= "datec";
|
|
|
$sql .= ", entity";
|
|
|
$sql .= ", fk_product";
|
|
@@ -4270,7 +4270,7 @@ class Product extends CommonObject
|
|
|
$sql .= ")";
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
|
- $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
|
|
|
+ $this->product_fourn_price_id = $this->db->last_insert_id($this->db->prefix()."product_fournisseur_price");
|
|
|
return 1;
|
|
|
} else {
|
|
|
$this->error = $this->db->lasterror();
|
|
@@ -4302,7 +4302,7 @@ class Product extends CommonObject
|
|
|
$list = array();
|
|
|
|
|
|
$sql = "SELECT DISTINCT p.fk_soc";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_fournisseur_price as p";
|
|
|
$sql .= " WHERE p.fk_product = ".((int) $this->id);
|
|
|
$sql .= " AND p.entity = ".((int) $conf->entity);
|
|
|
|
|
@@ -4337,7 +4337,7 @@ class Product extends CommonObject
|
|
|
$this->db->begin();
|
|
|
|
|
|
// prices
|
|
|
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price (";
|
|
|
+ $sql = "INSERT INTO ".$this->db->prefix()."product_price (";
|
|
|
$sql .= " entity";
|
|
|
$sql .= ", fk_product";
|
|
|
$sql .= ", date_price";
|
|
@@ -4390,7 +4390,7 @@ class Product extends CommonObject
|
|
|
$sql .= ", multicurrency_tx";
|
|
|
$sql .= ", multicurrency_price";
|
|
|
$sql .= ", multicurrency_price_ttc";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_price";
|
|
|
$sql .= " WHERE fk_product = ".((int) $fromId);
|
|
|
$sql .= " ORDER BY date_price DESC";
|
|
|
if ($conf->global->PRODUIT_MULTIPRICES_LIMIT > 0) {
|
|
@@ -4421,8 +4421,8 @@ class Product extends CommonObject
|
|
|
// phpcs:enable
|
|
|
$this->db->begin();
|
|
|
|
|
|
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)';
|
|
|
- $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association";
|
|
|
+ $sql = 'INSERT INTO '.$this->db->prefix().'product_association (fk_product_pere, fk_product_fils, qty)';
|
|
|
+ $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".$this->db->prefix()."product_association";
|
|
|
$sql .= " WHERE fk_product_pere = ".((int) $fromId);
|
|
|
|
|
|
dol_syslog(get_class($this).'::clone_association', LOG_DEBUG);
|
|
@@ -4451,10 +4451,10 @@ class Product extends CommonObject
|
|
|
$now = dol_now();
|
|
|
|
|
|
// les fournisseurs
|
|
|
- /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur ("
|
|
|
+ /*$sql = "INSERT ".$this->db->prefix()."product_fournisseur ("
|
|
|
. " datec, fk_product, fk_soc, ref_fourn, fk_user_author )"
|
|
|
. " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author"
|
|
|
- . " FROM ".MAIN_DB_PREFIX."product_fournisseur"
|
|
|
+ . " FROM ".$this->db->prefix()."product_fournisseur"
|
|
|
. " WHERE fk_product = ".((int) $fromId);
|
|
|
|
|
|
if ( ! $this->db->query($sql ) )
|
|
@@ -4464,10 +4464,10 @@ class Product extends CommonObject
|
|
|
}*/
|
|
|
|
|
|
// les prix de fournisseurs.
|
|
|
- $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price (";
|
|
|
+ $sql = "INSERT ".$this->db->prefix()."product_fournisseur_price (";
|
|
|
$sql .= " datec, fk_product, fk_soc, price, quantity, fk_user)";
|
|
|
$sql .= " SELECT '".$this->db->idate($now)."', ".((int) $toId).", fk_soc, price, quantity, fk_user";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_fournisseur_price";
|
|
|
$sql .= " WHERE fk_product = ".((int) $fromId);
|
|
|
|
|
|
dol_syslog(get_class($this).'::clone_fournisseurs', LOG_DEBUG);
|
|
@@ -4585,7 +4585,7 @@ class Product extends CommonObject
|
|
|
$nb = 0;
|
|
|
|
|
|
$sql = "SELECT COUNT(pa.rowid) as nb";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_association as pa";
|
|
|
if ($mode == 0) {
|
|
|
$sql .= " WHERE pa.fk_product_fils = ".((int) $this->id)." OR pa.fk_product_pere = ".((int) $this->id);
|
|
|
} elseif ($mode == -1) {
|
|
@@ -4615,7 +4615,7 @@ class Product extends CommonObject
|
|
|
public function hasVariants()
|
|
|
{
|
|
|
$nb = 0;
|
|
|
- $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".((int) $this->id);
|
|
|
+ $sql = "SELECT count(rowid) as nb FROM ".$this->db->prefix()."product_attribute_combination WHERE fk_product_parent = ".((int) $this->id);
|
|
|
$sql .= " AND entity IN (".getEntity('product').")";
|
|
|
|
|
|
$resql = $this->db->query($sql);
|
|
@@ -4639,7 +4639,7 @@ class Product extends CommonObject
|
|
|
{
|
|
|
global $conf;
|
|
|
if (!empty($conf->variants->enabled)) {
|
|
|
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".((int) $this->id)." AND entity IN (".getEntity('product').")";
|
|
|
+ $sql = "SELECT rowid FROM ".$this->db->prefix()."product_attribute_combination WHERE fk_product_child = ".((int) $this->id)." AND entity IN (".getEntity('product').")";
|
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
@@ -4667,8 +4667,8 @@ class Product extends CommonObject
|
|
|
{
|
|
|
$sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity";
|
|
|
$sql .= ", p.tosell as status, p.tobuy as status_buy";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa,";
|
|
|
- $sql .= " ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_association as pa,";
|
|
|
+ $sql .= " ".$this->db->prefix()."product as p";
|
|
|
$sql .= " WHERE p.rowid = pa.fk_product_pere";
|
|
|
$sql .= " AND pa.fk_product_fils = ".((int) $this->id);
|
|
|
|
|
@@ -4714,8 +4714,8 @@ class Product extends CommonObject
|
|
|
$sql = "SELECT p.rowid, p.ref, p.label as label, p.fk_product_type,";
|
|
|
$sql .= " pa.qty as qty, pa.fk_product_fils as id, pa.incdec,";
|
|
|
$sql .= " pa.rowid as fk_association, pa.rang";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
|
|
|
- $sql .= " ".MAIN_DB_PREFIX."product_association as pa";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product as p,";
|
|
|
+ $sql .= " ".$this->db->prefix()."product_association as pa";
|
|
|
$sql .= " WHERE p.rowid = pa.fk_product_fils";
|
|
|
$sql .= " AND pa.fk_product_pere = ".((int) $id);
|
|
|
$sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens
|
|
@@ -5100,7 +5100,7 @@ class Product extends CommonObject
|
|
|
$langs->load('products');
|
|
|
|
|
|
if (isset($this->finished) && $this->finished >= 0) {
|
|
|
- $sql = "SELECT label, code FROM ".MAIN_DB_PREFIX."c_product_nature where code = ".((int) $this->finished)." AND active=1";
|
|
|
+ $sql = "SELECT label, code FROM ".$this->db->prefix()."c_product_nature where code = ".((int) $this->finished)." AND active=1";
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql && $this->db->num_rows($resql) > 0) {
|
|
|
$res = $this->db->fetch_array($resql);
|
|
@@ -5273,8 +5273,8 @@ class Product extends CommonObject
|
|
|
}
|
|
|
|
|
|
$sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
|
|
- $sql .= ", ".MAIN_DB_PREFIX."entrepot as w";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product_stock as ps";
|
|
|
+ $sql .= ", ".$this->db->prefix()."entrepot as w";
|
|
|
$sql .= " WHERE w.entity IN (".getEntity('stock').")";
|
|
|
$sql .= " AND w.rowid = ps.fk_entrepot";
|
|
|
$sql .= " AND ps.fk_product = ".((int) $this->id);
|
|
@@ -5437,7 +5437,7 @@ class Product extends CommonObject
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
- $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) AS qty FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps";
|
|
|
+ $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) AS qty FROM ".$this->db->prefix()."product_batch as pb, ".$this->db->prefix()."product_stock as ps";
|
|
|
$sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".((int) $this->id)." AND pb.batch = '".$this->db->escape($batch)."'";
|
|
|
$sql .= " GROUP BY pb.batch, pb.eatby, pb.sellby";
|
|
|
dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG);
|
|
@@ -5671,7 +5671,7 @@ class Product extends CommonObject
|
|
|
$this->nb = array();
|
|
|
|
|
|
$sql = "SELECT count(p.rowid) as nb, fk_product_type";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
|
|
|
+ $sql .= " FROM ".$this->db->prefix()."product as p";
|
|
|
$sql .= ' WHERE p.entity IN ('.getEntity($this->element, 1).')';
|
|
|
// Add where from hooks
|
|
|
if (is_object($hookmanager)) {
|
|
@@ -5829,7 +5829,7 @@ class Product extends CommonObject
|
|
|
$label_type = 'short_label';
|
|
|
}
|
|
|
|
|
|
- $sql = "SELECT ".$label_type.", code from ".MAIN_DB_PREFIX."c_units where rowid = ".((int) $this->fk_unit);
|
|
|
+ $sql = "SELECT ".$label_type.", code from ".$this->db->prefix()."c_units where rowid = ".((int) $this->fk_unit);
|
|
|
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql && $this->db->num_rows($resql) > 0) {
|
|
@@ -5937,7 +5937,7 @@ class Product extends CommonObject
|
|
|
{
|
|
|
global $conf, $db;
|
|
|
|
|
|
- $sql = "SELECT rowid, level, fk_level, var_percent, var_min_percent FROM ".MAIN_DB_PREFIX."product_pricerules";
|
|
|
+ $sql = "SELECT rowid, level, fk_level, var_percent, var_min_percent FROM ".$this->db->prefix()."product_pricerules";
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
|
$rules = array();
|
|
@@ -6010,7 +6010,7 @@ class Product extends CommonObject
|
|
|
{
|
|
|
$sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,";
|
|
|
$sql .= " p.fk_user_author, p.fk_user_modif";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
|
|
|
+ $sql .= " FROM ".$this->db->prefix().$this->table_element." as p";
|
|
|
$sql .= " WHERE p.rowid = ".((int) $id);
|
|
|
|
|
|
$result = $this->db->query($sql);
|