Fix filtro per far visualizzare al tecnico loggato nell'APP

This commit is contained in:
Luca 2020-06-12 13:30:37 +02:00
parent f9ab4ff749
commit 624ca26415
1 changed files with 3 additions and 15 deletions

View File

@ -48,13 +48,7 @@ class Interventi extends Resource implements RetrieveInterface, CreateInterface,
INNER JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento` = `in_statiintervento`.`idstatointervento` INNER JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento` = `in_statiintervento`.`idstatointervento`
INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`
LEFT JOIN `an_sedi` ON `in_interventi`.`idsede_destinazione` = `an_sedi`.`id` LEFT JOIN `an_sedi` ON `in_interventi`.`idsede_destinazione` = `an_sedi`.`id`
LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`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 LIKE :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)";
//Filtro per far visualizzare al tecnico loggato solo le sue attività
$filters = [];
$filters[] = 'in_interventi_tecnici.idtecnico ='.$user->idanagrafica;
$query .= !empty($filters) ? ' AND ('.implode('OR ', $filters).')' : '';
$query .= ' $query .= '
HAVING 2=2 HAVING 2=2
@ -63,24 +57,18 @@ class Interventi extends Resource implements RetrieveInterface, CreateInterface,
$parameters = [ $parameters = [
':period_end' => $period_end, ':period_end' => $period_end,
':period_start' => $period_start, ':period_start' => $period_start,
':idtecnico' => $user->idanagrafica,
]; ];
$module = Modules::get('Interventi'); $module = Modules::get('Interventi');
$query = Modules::replaceAdditionals($module->id, $query); $query = Modules::replaceAdditionals($module->id, $query);
return [ return [
'query' => $query, 'query' => $query,
'parameters' => $parameters, 'parameters' => $parameters,
]; ];
} }
public function create($request) public function create($request)