FIX sql error on strict mysql
This commit is contained in:
parent
19ddfc8fc6
commit
ac1e6c9966
@ -2253,8 +2253,8 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
//For MultiCompany
|
//For MultiCompany
|
||||||
//PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity
|
//PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity
|
||||||
$separatedEntityPMP = false;
|
$separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product.
|
||||||
$separatedStock = false;
|
$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_PRODUCT_SHARING_ENABLED)) {
|
||||||
if (!empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_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 " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity);
|
||||||
@ -2269,17 +2269,18 @@ class Product extends CommonObject
|
|||||||
$visibleWarehousesEntities .= "," . implode(",", $mc->sharings['stock']);
|
$visibleWarehousesEntities .= "," . implode(",", $mc->sharings['stock']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($separatedStock) {
|
|
||||||
$sql .= " SUM(sp.reel) as stock,";
|
|
||||||
} else {
|
|
||||||
$sql .= " p.stock,";
|
|
||||||
}
|
|
||||||
if ($separatedEntityPMP) {
|
if ($separatedEntityPMP) {
|
||||||
$sql .= " ppe.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,";
|
$sql .= " ppe.pmp,";
|
||||||
} else {
|
} else {
|
||||||
$sql .= " p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,";
|
$sql .= " p.pmp,";
|
||||||
|
}
|
||||||
|
$sql .= " p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,";
|
||||||
|
$sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf,";
|
||||||
|
if ($separatedStock) {
|
||||||
|
$sql .= " SUM(sp.reel) as stock";
|
||||||
|
} else {
|
||||||
|
$sql .= " p.stock";
|
||||||
}
|
}
|
||||||
$sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) || $separatedEntityPMP) {
|
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 " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
|
||||||
@ -2300,11 +2301,30 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($separatedStock) {
|
if ($separatedStock) {
|
||||||
$sql .= " AND sp.fk_entrepot IN (
|
$sql .= " AND sp.fk_entrepot IN (SELECT rowid FROM ".MAIN_DB_PREFIX."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))";
|
||||||
SELECT rowid
|
}
|
||||||
FROM ".MAIN_DB_PREFIX."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))";
|
if ($separatedStock) {
|
||||||
|
$sql .= " GROUP BY p.rowid, p.ref, p.ref_ext, p.label, p.description, p.url, p.note_public, p.note, p.customcode, p.fk_country, p.fk_state, p.lifetime, p.qc_frequency, p.price, p.price_ttc,";
|
||||||
|
$sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,";
|
||||||
|
$sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,";
|
||||||
|
$sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,";
|
||||||
|
$sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished,";
|
||||||
|
if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||||
|
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
|
||||||
|
} else {
|
||||||
|
$sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export, ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,";
|
||||||
|
}
|
||||||
|
if ($separatedEntityPMP) {
|
||||||
|
$sql .= " ppe.pmp,";
|
||||||
|
} else {
|
||||||
|
$sql .= " p.pmp,";
|
||||||
|
}
|
||||||
|
$sql .= " p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,";
|
||||||
|
$sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf";
|
||||||
|
if (!$separatedStock) {
|
||||||
|
$sql .= ", p.stock";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -2601,7 +2621,7 @@ class Product extends CommonObject
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->error = $this->db->lasterror;
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user