Commit b8d8857538e3f5b11a2f17aab1d7c87b29ad3ffe
1 parent
3e549e7c
Exists in
master
Relatório de usuário logado
Showing
1 changed file
with
34 additions
and
3 deletions
Show diff stats
src/Cacic/CommonBundle/Entity/LogUserLogadoRepository.php
| ... | ... | @@ -5,15 +5,14 @@ namespace Cacic\CommonBundle\Entity; |
| 5 | 5 | use Doctrine\ORM\EntityRepository; |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | - * LogAcessoRepository | |
| 8 | + * LogUserLogadoRepository | |
| 9 | 9 | * |
| 10 | 10 | * Métodos de repositório |
| 11 | 11 | */ |
| 12 | 12 | class LogUserLogadoRepository extends EntityRepository |
| 13 | 13 | { |
| 14 | - /** | |
| 14 | + /* | |
| 15 | 15 | * Função que retorna o último acesso para o computador solicitado |
| 16 | - * | |
| 17 | 16 | * @param $computador |
| 18 | 17 | */ |
| 19 | 18 | public function ultimoAcesso( $computador ) { |
| ... | ... | @@ -27,4 +26,36 @@ class LogUserLogadoRepository extends EntityRepository |
| 27 | 26 | return $qb->getQuery()->getOneOrNullResult(); |
| 28 | 27 | } |
| 29 | 28 | |
| 29 | + /* | |
| 30 | + * Função que retorna a busca por usuário logago | |
| 31 | + */ | |
| 32 | + public function selectUserLogado( $teIpComputador , $nmComputador ,$usuario, $dtHrInclusao ,$dtHrInclusaoFim ) | |
| 33 | + { | |
| 34 | + | |
| 35 | + $query = $this->createQueryBuilder('c') | |
| 36 | + ->select('c.nmComputador', 'c.teIpComputador', 'log.data', 'log.usuario') | |
| 37 | + ->from('computador', 'c') | |
| 38 | + ->innerJoin('log.idComputador', 'WITH', 'c.idComputador'); | |
| 39 | + | |
| 40 | + if ( $teIpComputador != null){ | |
| 41 | + | |
| 42 | + $query->Where("c.teIpComputador LIKE '%$teIpComputador%'"); | |
| 43 | + | |
| 44 | + } | |
| 45 | + if ( $nmComputador != null){ | |
| 46 | + $query->Where("c.nmComputador LIKE '%$nmComputador%'"); | |
| 47 | + } | |
| 48 | + if ( $usuario != null){ | |
| 49 | + $query->Where("log.usuario LIKE '%$usuario%'"); | |
| 50 | + } | |
| 51 | + if ( $dtHrInclusao != null){ | |
| 52 | + $query->andWhere( 'log.data >= (:dtHrInclusao)' )->setParameter('dtHrInclusao', ( $dtHrInclusao.' 00:00:00' )); | |
| 53 | + } | |
| 54 | + if ( $dtHrInclusaoFim != null){ | |
| 55 | + $query->andWhere( 'log.data<= (:dtHrInclusaoFim)' )->setParameter('dtHrInclusaoFim', ( $dtHrInclusaoFim.' 23:59:59' )); | |
| 56 | + } | |
| 57 | + | |
| 58 | + | |
| 59 | + return $query->getQuery()->execute(); | |
| 60 | + } | |
| 30 | 61 | } | ... | ... |