openstamanager/templates/automezzi_carico/init.php

67 lines
3.3 KiB
PHP
Raw Permalink 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';
2024-03-12 16:39:34 +01:00
use Modules\Anagrafiche\Anagrafica;
2023-11-30 12:57:03 +01:00
$search_targa = get('search_targa');
$search_nome = get('search_nome');
$dt_carico = get('data_carico');
2023-12-01 17:21:47 +01:00
$data_carico = strtotime(str_replace('/', '-', $dt_carico));
$startTM = date('Y-m-d', $data_carico).' 00:00:00';
$endTM = date('Y-m-d', $data_carico).' 23:59:59';
2023-11-30 12:57:03 +01:00
2024-04-12 09:53:02 +02:00
$query = '
2023-11-30 12:57:03 +01:00
SELECT
2024-02-06 17:36:05 +01:00
`mg_movimenti`.`data`,
`an_sedi`.`targa`,
`an_sedi`.`nome`,
`mg_articoli`.`codice`,
`mg_articoli`.`prezzo_vendita`,
2024-02-29 15:10:55 +01:00
`co_iva`.`percentuale` AS iva,
2024-04-18 17:44:05 +02:00
`mg_categorie_lang`.`title` AS subcategoria,
`mg_articoli_lang`.`title` AS descrizione,
2024-02-23 09:48:01 +01:00
`mg_movimenti`.`qta`,
2024-02-06 17:36:05 +01:00
`mg_movimenti`.`idutente`,
`zz_users`.`username`,
`mg_articoli`.`um`,
2024-04-18 17:44:05 +02:00
`zz_groups_lang`.`title` as gruppo
2023-11-30 12:57:03 +01:00
FROM
2024-02-06 17:36:05 +01:00
`mg_movimenti`
INNER JOIN `mg_articoli` ON `mg_movimenti`.`idarticolo`=`mg_articoli`.`id`
INNER JOIN `co_iva` ON `mg_articoli`.`idiva_vendita` = `co_iva`.`id`
2024-04-12 09:35:30 +02:00
INNER JOIN `zz_users` ON `mg_movimenti`.`idutente`=`zz_users`.`id`
INNER JOIN `zz_groups` ON `zz_users`.`idgruppo`=`zz_groups`.`id`
2024-04-12 09:53:02 +02:00
LEFT JOIN `zz_groups_lang` ON (`zz_groups`.`id` = `zz_groups_lang`.`id_record` AND `zz_groups_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
2024-02-06 17:36:05 +01:00
INNER JOIN `an_sedi` ON `mg_movimenti`.`idsede`=`an_sedi`.`id`
2024-03-22 15:52:24 +01:00
LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
2024-02-29 15:10:55 +01:00
LEFT JOIN `mg_categorie` ON `mg_categorie`.`id`=`mg_articoli`.`id_sottocategoria`
2024-03-22 15:52:24 +01:00
LEFT JOIN `mg_categorie_lang` ON (`mg_categorie`.`id`=`mg_categorie_lang`.`id_record` AND `mg_categorie_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
LEFT JOIN `mg_articoli_lang` ON (`mg_articoli`.`id`=`mg_articoli_lang`.`id_record` AND `mg_articoli_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
2023-11-30 12:57:03 +01:00
WHERE
2024-02-29 15:10:55 +01:00
`mg_movimenti`.`qta`>0 AND (`mg_movimenti`.`idsede` > 0) AND (`mg_movimenti`.`idintervento` IS NULL) AND
2024-04-18 17:44:05 +02:00
((`mg_movimenti`.`data` BETWEEN '.prepare($startTM).' AND '.prepare($endTM).") AND (`zz_groups_lang`.`title` = 'Amministratori'))";
2023-11-30 12:57:03 +01:00
2024-02-06 17:36:05 +01:00
$query .= ' AND (`an_sedi`.`targa` LIKE '.prepare('%'.$search_targa.'%').') AND (`an_sedi`.`nome` LIKE '.prepare('%'.$search_nome.'%').') ';
2024-04-18 17:44:05 +02:00
$query .= ' ORDER BY `an_sedi`.`targa`, `mg_articoli_lang`.`title`';
2023-11-30 12:57:03 +01:00
$rs = $dbo->fetchArray($query);
$totrows = sizeof($rs);
2024-04-12 09:35:30 +02:00
$azienda = Anagrafica::where('idanagrafica', '=', setting('Azienda predefinita'))->first();