1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 06:55:05 +01:00

Fix ricerca per articoli eliminati

This commit is contained in:
Pek5892 2024-03-15 14:58:14 +01:00
parent 897b29e60a
commit 82204f66dc

View File

@ -26,11 +26,11 @@ $prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico')); $show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
$fields = [ $fields = [
'Codice' => 'codice', 'codice' => 'mg_articoli.codice',
'Barcode' => 'barcode', 'barcode' => 'mg_articoli.barcode',
'Descrizione' => 'descrizione', 'descrizione' => 'mg_articoli_lang.name',
'Categoria' => '(SELECT `name` FROM `mg_categorie` LEFT JOIN `mg_categorie_lang` ON (`mg_categorie`.`id` = `mg_categorie_lang`.`id_record` AND `mg_categorie_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `mg_categorie`.`id` = `mg_articoli`.`id_categoria`)', 'categoria' => '(SELECT `name` FROM `mg_categorie` LEFT JOIN `mg_categorie_lang` ON (`mg_categorie`.`id` = `mg_categorie_lang`.`id_record` AND `mg_categorie_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `mg_categorie`.`id` = `mg_articoli`.`id_categoria`)',
'Subcategoria' => '(SELECT `name` FROM `mg_categorie` LEFT JOIN `mg_categorie_lang` ON (`mg_categorie`.`id` = `mg_categorie_lang`.`id_record` AND `mg_categorie_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `mg_categorie`.`id` = `mg_articoli`.`id_sottocategoria`)', 'subcategoria' => '(SELECT `name` FROM `mg_categorie` LEFT JOIN `mg_categorie_lang` ON (`mg_categorie`.`id` = `mg_categorie_lang`.`id_record` AND `mg_categorie_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE `mg_categorie`.`id` = `mg_articoli`.`id_sottocategoria`)',
'Note' => 'note', 'Note' => 'note',
]; ];
@ -40,11 +40,12 @@ foreach ($fields as $name => $value) {
$query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'"; $query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'";
} }
$query .= ' FROM `mg_articoli` WHERE 1=0 '; $query .= ' FROM `mg_articoli` LEFT JOIN `mg_articoli_lang` ON (`mg_articoli`.`id` = `mg_articoli_lang`.`id_record` AND `mg_articoli_lang`.`id_lang` = '.prepare(\App::getLang()).') WHERE deleted_at IS NULL AND (1=0 ';
foreach ($fields as $name => $value) { foreach ($fields as $name => $value) {
$query .= ' OR '.$value.' LIKE "%'.$term.'%"'; $query .= ' OR '.$value.' LIKE "%'.$term.'%"';
} }
$query .= ')';
$query .= Modules::getAdditionalsQuery('Articoli'); $query .= Modules::getAdditionalsQuery('Articoli');