1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-26 07:44:02 +01:00
openstamanager/templates/automezzi_inventario/init.php

62 lines
2.5 KiB
PHP
Raw Normal View History

2023-11-30 12:57:03 +01:00
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
2023-12-01 17:21:47 +01:00
$azienda = $dbo->fetchOne('SELECT * FROM an_anagrafiche WHERE idanagrafica='.prepare(setting('Azienda predefinita')));
2023-11-30 12:57:03 +01:00
$where = [];
$search_targa = get('search_targa');
2023-12-01 17:21:47 +01:00
$search_nome = get('search_nome');
2023-11-30 12:57:03 +01:00
2023-12-01 17:21:47 +01:00
$where[] = 'movimenti.qta > 0';
$where[] = 'movimenti.qta > 0';
if ($search_targa) {
$where[] = 'an_sedi.targa like '.prepare('%'.$search_targa.'%');
2023-11-30 12:57:03 +01:00
}
2023-12-01 17:21:47 +01:00
if ($search_nome) {
$where[] = 'an_sedi.nome like '.prepare('%'.$search_nome.'%');
2023-11-30 12:57:03 +01:00
}
2024-01-15 15:30:45 +01:00
// Ciclo tra gli articoli selezionati
2024-02-29 15:10:55 +01:00
$query = 'SELECT
`an_sedi`.`targa`,
`an_sedi`.`nome`,
`mg_articoli`.`codice`,
`mg_articoli_lang`.`name` as descrizione,
2024-03-01 09:08:08 +01:00
`mg_categorie_lang`.`name` AS subcategoria,
2024-02-29 15:10:55 +01:00
SUM(`mg_movimenti`.`qta`) AS qta,
`mg_articoli`.`um`
FROM
`an_sedi`
INNER JOIN `mg_movimenti` ON `mg_movimenti`.`idsede` = `an_sedi`.`id`
INNER JOIN `mg_articoli` ON `mg_movimenti`.`idarticolo` = `mg_articoli`.`id`
LEFT JOIN `mg_articoli_lang` ON (`mg_articoli`.`id`=`mg_articoli_lang`.`id_record` AND `mg_articoli_lang`.`id_lang` = '.prepare(setting('Lingua')).')
LEFT JOIN `mg_categorie` ON `mg_categorie`.`id` = `mg_articoli`.`id_sottocategoria`
2024-03-01 09:08:08 +01:00
LEFT JOIN `mg_categorie_lang` ON (`mg_categorie`.`id`=`mg_categorie_lang`.`id_record` AND `mg_categorie_lang`.`id_lang` = '.prepare(setting('Lingua')).')
2024-02-29 15:10:55 +01:00
WHERE
2023-12-01 17:21:47 +01:00
'.implode(' AND ', $where).'
2024-02-29 15:10:55 +01:00
GROUP BY
2024-03-01 09:08:08 +01:00
`an_sedi`.`targa`, `an_sedi`.`nome`, `an_sedi`.`descrizione`, `mg_articoli`.`codice`, `mg_articoli_lang`.`name`, `mg_categorie_lang`.`name`, `mg_articoli`.`um`
2023-11-30 12:57:03 +01:00
ORDER BY
2024-02-29 15:10:55 +01:00
`an_sedi`.`targa`, `an_sedi`.`descrizione`';
2023-11-30 12:57:03 +01:00
$rs = $dbo->fetchArray($query);
$totrows = sizeof($rs);