Fix sql error

This commit is contained in:
Laurent Destailleur 2021-03-30 02:13:57 +02:00
parent b863b2a3f3
commit 9edb2fd857
3 changed files with 23 additions and 21 deletions

View File

@ -107,6 +107,7 @@ class Canvas
$this->card = $card; $this->card = $card;
$this->dirmodule = $module; $this->dirmodule = $module;
// Correct values if canvas is into an external module // Correct values if canvas is into an external module
$regs = array();
if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) { if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) {
$this->canvas = $regs[1]; $this->canvas = $regs[1];
$this->dirmodule = $regs[2]; $this->dirmodule = $regs[2];

View File

@ -940,20 +940,6 @@ if (empty($reshook)) {
* View * View
*/ */
$title = $langs->trans('ProductServiceCard');
$helpurl = '';
$shortlabel = dol_trunc($object->label, 16);
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card');
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
}
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
}
llxHeader('', $title, $helpurl);
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formproduct = new FormProduct($db); $formproduct = new FormProduct($db);
@ -962,6 +948,21 @@ if (!empty($conf->accounting->enabled)) {
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
} }
$title = $langs->trans('ProductServiceCard');
$help_url = '';
$shortlabel = dol_trunc($object->label, 16);
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card');
$help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
}
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card');
$help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
}
llxHeader('', $title, $help_url);
// Load object modBarCodeProduct // Load object modBarCodeProduct
$res = 0; $res = 0;
if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
@ -984,7 +985,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// When used with CANVAS // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
if (empty($object->error) && $id) { if (empty($object->error) && $id) {
$object = new Product($db);
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) { if ($result <= 0) {
dol_print_error('', $object->error); dol_print_error('', $object->error);
@ -1465,6 +1465,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
/* /*
* Product card * Product card
*/ */
// Fiche en mode edition // Fiche en mode edition
if ($action == 'edit' && $usercancreate) { if ($action == 'edit' && $usercancreate) {
//WYSIWYG Editor //WYSIWYG Editor

View File

@ -2172,20 +2172,20 @@ class Product extends CommonObject
} }
$sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,"; $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,";
$sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf";
$sql .= " FROM ".MAIN_DB_PREFIX."product"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity);
} }
if ($id) { if ($id) {
$sql .= " WHERE rowid = ".(int) $id; $sql .= " WHERE p.rowid = ".((int) $id);
} else { } else {
$sql .= " WHERE entity IN (".getEntity($this->element).")"; $sql .= " WHERE p.entity IN (".getEntity($this->element).")";
if ($ref) { if ($ref) {
$sql .= " AND ref = '".$this->db->escape($ref)."'"; $sql .= " AND p.ref = '".$this->db->escape($ref)."'";
} elseif ($ref_ext) { } elseif ($ref_ext) {
$sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; $sql .= " AND p.ref_ext = '".$this->db->escape($ref_ext)."'";
} elseif ($barcode) { } elseif ($barcode) {
$sql .= " AND barcode = '".$this->db->escape($barcode)."'"; $sql .= " AND p.barcode = '".$this->db->escape($barcode)."'";
} }
} }