Fix set serial

This commit is contained in:
MatteoPistorello 2024-03-13 17:00:21 +01:00
parent afa646c36a
commit 8622ad9da0
1 changed files with 16 additions and 2 deletions

View File

@ -316,9 +316,23 @@ switch ($resource) {
break;
case 'serial-articolo':
$query = 'SELECT serial AS id, serial AS descrizione FROM mg_prodotti |where| AND mg_prodotti.dir=\'uscita\' AND id=(SELECT MAX(id) FROM mg_prodotti AS prodotti WHERE prodotti.id_articolo=mg_prodotti.id_articolo AND prodotti.serial=mg_prodotti.serial)';
$query = 'SELECT serial AS id, serial AS descrizione FROM mg_prodotti |where|';
$where[] = 'id_articolo='.prepare($superselect['idarticolo']);
foreach ($elements as $element) {
$filter[] = 'serial='.prepare($element);
}
if (!empty($filter)) {
$query .= ' OR (('.implode(' OR ', $filter).') AND mg_prodotti.dir=\'entrata\')';
}
$where[] = 'mg_prodotti.id_articolo='.prepare($superselect['idarticolo']);
$where[] = 'mg_prodotti.dir=\'uscita\'';
$where[] = 'mg_prodotti.id=(SELECT MAX(id) FROM mg_prodotti AS prodotti WHERE prodotti.id_articolo=mg_prodotti.id_articolo AND prodotti.serial=mg_prodotti.serial)';
if (!empty($search)) {
$search_fields[] = '`mg_prodotti`.`serial` LIKE '.prepare('%'.$search.'%');
}
break;
}