From 26b846f0d6d03be4c2b3ecb16621564e4b187eb6 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 May 2020 18:21:49 +0200 Subject: [PATCH] Migliorato filtro tecnico per API --- modules/interventi/src/API/v1/Interventi.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/interventi/src/API/v1/Interventi.php b/modules/interventi/src/API/v1/Interventi.php index bbcb85c4a..1e34ebe4a 100755 --- a/modules/interventi/src/API/v1/Interventi.php +++ b/modules/interventi/src/API/v1/Interventi.php @@ -6,7 +6,7 @@ use API\Interfaces\CreateInterface; use API\Interfaces\RetrieveInterface; use API\Interfaces\UpdateInterface; use API\Resource; -use Auth; +use Modules; use Modules\Anagrafiche\Anagrafica; use Modules\Interventi\Intervento; use Modules\Interventi\Stato; @@ -47,13 +47,23 @@ class Interventi extends Resource implements RetrieveInterface, CreateInterface, INNER JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento` = `in_statiintervento`.`idstatointervento` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` LEFT JOIN `an_sedi` ON `in_interventi`.`idsede_destinazione` = `an_sedi`.`id` - WHERE EXISTS(SELECT `orario_fine` FROM `in_interventi_tecnici` WHERE `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` AND `orario_fine` BETWEEN :period_start AND :period_end AND idtecnico = :idtecnico )"; + WHERE EXISTS(SELECT `orario_fine` FROM `in_interventi_tecnici` WHERE `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` AND `orario_fine` BETWEEN :period_start AND :period_end)"; + + $query .= ' + HAVING 2=2 + ORDER BY `in_interventi`.`data_richiesta` DESC'; $parameters = [ ':period_end' => $period_end, ':period_start' => $period_start, - ':idtecnico' => $user->idanagrafica, ]; + + + $module = Modules::get('Interventi'); + $query = Modules::replaceAdditionals($module->id, $query); + + + return [ 'query' => $query,