Skip to content

Commit

Permalink
Fix: Correzione filtro per tipologia in statistiche
Browse files Browse the repository at this point in the history
  • Loading branch information
BeppeJQ committed Nov 6, 2024
1 parent f7fa2d6 commit d82afe3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/statistiche/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function init_calendar(calendar) {
</div>';

// Numero interventi per tipologia
$tipi = $dbo->fetchArray('SELECT * FROM `in_tipiintervento` LEFT JOIN `in_tipiintervento_lang` ON (`in_tipiintervento`.`id` = `in_tipiintervento_lang`.`id_record` AND `in_tipiintervento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')');
$tipi = $dbo->fetchArray('SELECT *, in_tipiintervento.id AS idtipointervento FROM `in_tipiintervento` LEFT JOIN `in_tipiintervento_lang` ON (`in_tipiintervento`.`id` = `in_tipiintervento_lang`.`id_record` AND `in_tipiintervento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')');

$dataset = '';
foreach ($tipi as $tipo) {
Expand All @@ -368,7 +368,7 @@ function init_calendar(calendar) {
`in_interventi`
LEFT JOIN(SELECT `in_interventi_tecnici`.`idintervento`, MAX(`orario_fine`) AS orario_fine FROM `in_interventi_tecnici` GROUP BY `idintervento`) sessioni ON `in_interventi`.`id` = `sessioni`.`idintervento`
WHERE
`in_interventi`.`idtipointervento` = '.prepare($tipo['id']).'
`in_interventi`.`idtipointervento` = '.prepare($tipo['idtipointervento']).'
AND `sessioni`.`orario_fine` BETWEEN '.prepare($start).' AND '.prepare($end).'
GROUP BY
YEAR(`sessioni`.`orario_fine`),
Expand Down Expand Up @@ -431,7 +431,7 @@ function init_calendar(calendar) {
// Ore interventi per tipologia
$dataset = '';
foreach ($tipi as $tipo) {
$interventi = $dbo->fetchArray('SELECT ROUND(SUM(in_interventi_tecnici.ore), 2) AS result, YEAR(in_interventi_tecnici.orario_fine) AS year, MONTH(in_interventi_tecnici.orario_fine) AS month FROM in_interventi INNER JOIN in_interventi_tecnici ON in_interventi.id=in_interventi_tecnici.idintervento WHERE in_interventi.idtipointervento = '.prepare($tipo['id']).' AND in_interventi.data_richiesta BETWEEN '.prepare($start).' AND '.prepare($end).' AND in_interventi_tecnici.orario_fine BETWEEN '.prepare($start).' AND '.prepare($end).' GROUP BY YEAR(in_interventi_tecnici.orario_fine), MONTH(in_interventi_tecnici.orario_fine) ORDER BY YEAR(in_interventi_tecnici.orario_fine) ASC, MONTH(in_interventi_tecnici.orario_fine) ASC');
$interventi = $dbo->fetchArray('SELECT ROUND(SUM(in_interventi_tecnici.ore), 2) AS result, YEAR(in_interventi_tecnici.orario_fine) AS year, MONTH(in_interventi_tecnici.orario_fine) AS month FROM in_interventi INNER JOIN in_interventi_tecnici ON in_interventi.id=in_interventi_tecnici.idintervento WHERE in_interventi.idtipointervento = '.prepare($tipo['idtipointervento']).' AND in_interventi.data_richiesta BETWEEN '.prepare($start).' AND '.prepare($end).' AND in_interventi_tecnici.orario_fine BETWEEN '.prepare($start).' AND '.prepare($end).' GROUP BY YEAR(in_interventi_tecnici.orario_fine), MONTH(in_interventi_tecnici.orario_fine) ORDER BY YEAR(in_interventi_tecnici.orario_fine) ASC, MONTH(in_interventi_tecnici.orario_fine) ASC');

$interventi = Stats::monthly($interventi, $start, $end);

Expand Down

0 comments on commit d82afe3

Please sign in to comment.