Commit b3336210836b6e23f33adc6a2b89de1adf80a76c
Exists in
master
Merge do código da versão 3.1
Showing
20 changed files
with
709 additions
and
16 deletions
Show diff stats
app/config/security.yml
@@ -57,6 +57,7 @@ security: | @@ -57,6 +57,7 @@ security: | ||
57 | path: / | 57 | path: / |
58 | 58 | ||
59 | access_control: | 59 | access_control: |
60 | + - { path: ^/cocar/api, roles: IS_AUTHENTICATED_ANONYMOUSLY } | ||
60 | - { path: ^/ws, roles: IS_AUTHENTICATED_ANONYMOUSLY } | 61 | - { path: ^/ws, roles: IS_AUTHENTICATED_ANONYMOUSLY } |
61 | - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } | 62 | - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } |
62 | - { path: ^/admin, roles: ROLE_ADMIN } | 63 | - { path: ^/admin, roles: ROLE_ADMIN } |
src/Cacic/CommonBundle/Controller/ComputadorController.php
@@ -41,16 +41,22 @@ class ComputadorController extends Controller | @@ -41,16 +41,22 @@ class ComputadorController extends Controller | ||
41 | */ | 41 | */ |
42 | public function detalharAction( $idComputador ) | 42 | public function detalharAction( $idComputador ) |
43 | { | 43 | { |
44 | +// $logger = $this->container->get('logger'); | ||
44 | //if ( ! $request->isXmlHttpRequest() ) // Verifica se é uma requisição AJAX | 45 | //if ( ! $request->isXmlHttpRequest() ) // Verifica se é uma requisição AJAX |
45 | // throw $this->createNotFoundException( 'Página não encontrada!' ); | 46 | // throw $this->createNotFoundException( 'Página não encontrada!' ); |
46 | $d = $this->getDoctrine(); | 47 | $d = $this->getDoctrine(); |
47 | 48 | ||
48 | $computador = $d->getRepository('CacicCommonBundle:Computador')->find( (int) $idComputador ); | 49 | $computador = $d->getRepository('CacicCommonBundle:Computador')->find( (int) $idComputador ); |
50 | + $ultimo_acesso = $d->getRepository('CacicCommonBundle:LogAcesso')->ultimoUserName( $idComputador ); | ||
51 | + | ||
49 | if ( ! $computador ) | 52 | if ( ! $computador ) |
50 | throw $this->createNotFoundException( 'Página não encontrada!' ); | 53 | throw $this->createNotFoundException( 'Página não encontrada!' ); |
51 | 54 | ||
52 | $coleta = $d->getRepository('CacicCommonBundle:ComputadorColeta')->getDadosColetaComputador( $computador ); | 55 | $coleta = $d->getRepository('CacicCommonBundle:ComputadorColeta')->getDadosColetaComputador( $computador ); |
53 | 56 | ||
57 | + //$isNotebook = $computador->getIsNotebook(); | ||
58 | + //$logger->debug("isNotebook%%%%%%%%%%% $isNotebook"); | ||
59 | + | ||
54 | $dadosColeta = array(); // Inicializa o array que agrupa os dados de coleta por Classe | 60 | $dadosColeta = array(); // Inicializa o array que agrupa os dados de coleta por Classe |
55 | $software = array(); // Coloca a coleta de software num array separado | 61 | $software = array(); // Coloca a coleta de software num array separado |
56 | $listaClasses = array(); | 62 | $listaClasses = array(); |
@@ -94,9 +100,10 @@ class ComputadorController extends Controller | @@ -94,9 +100,10 @@ class ComputadorController extends Controller | ||
94 | return $this->render( | 100 | return $this->render( |
95 | 'CacicCommonBundle:Computador:detalhar.html.twig', | 101 | 'CacicCommonBundle:Computador:detalhar.html.twig', |
96 | array( | 102 | array( |
97 | - 'computador' => $computador, | ||
98 | - 'dadosColeta' => $dadosColeta, | ||
99 | - 'software' => $software | 103 | + 'computador' => $computador, |
104 | + 'ultimoAcesso' => $ultimo_acesso, | ||
105 | + 'dadosColeta' => $dadosColeta, | ||
106 | + 'software' => $software | ||
100 | ) | 107 | ) |
101 | ); | 108 | ); |
102 | } | 109 | } |
src/Cacic/CommonBundle/Entity/Computador.php
@@ -689,4 +689,33 @@ class Computador | @@ -689,4 +689,33 @@ class Computador | ||
689 | { | 689 | { |
690 | return $this->software_coletado; | 690 | return $this->software_coletado; |
691 | } | 691 | } |
692 | + | ||
693 | + /** | ||
694 | + * @var string | ||
695 | + */ | ||
696 | + private $isNotebook; | ||
697 | + | ||
698 | + | ||
699 | + /** | ||
700 | + * Set isNotebook | ||
701 | + * | ||
702 | + * @param string $isNotebook | ||
703 | + * @return Computador | ||
704 | + */ | ||
705 | + public function setIsNotebook($isNotebook) | ||
706 | + { | ||
707 | + $this->isNotebook = $isNotebook; | ||
708 | + | ||
709 | + return $this; | ||
710 | + } | ||
711 | + | ||
712 | + /** | ||
713 | + * Get isNotebook | ||
714 | + * | ||
715 | + * @returnn string | ||
716 | + */ | ||
717 | + public function getIsNotebook() | ||
718 | + { | ||
719 | + return $this->isNotebook; | ||
720 | + } | ||
692 | } | 721 | } |
693 | \ No newline at end of file | 722 | \ No newline at end of file |
src/Cacic/CommonBundle/Entity/ComputadorColetaRepository.php
@@ -121,7 +121,7 @@ class ComputadorColetaRepository extends EntityRepository | @@ -121,7 +121,7 @@ class ComputadorColetaRepository extends EntityRepository | ||
121 | public function gerarRelatorioWMIDetalhe( $filtros, $classe ) | 121 | public function gerarRelatorioWMIDetalhe( $filtros, $classe ) |
122 | { | 122 | { |
123 | $qb = $this->createQueryBuilder('coleta') | 123 | $qb = $this->createQueryBuilder('coleta') |
124 | - ->select('IDENTITY(coleta.computador), property.nmPropertyName, coleta.teClassPropertyValue, comp.nmComputador, comp.teNodeAddress, comp.teIpComputador, so.idSo, so.inMswindows, so.sgSo, rede.idRede, rede.nmRede, rede.teIpRede, local.nmLocal, local.idLocal') | 124 | + ->select('IDENTITY(coleta.computador), property.nmPropertyName, coleta.teClassPropertyValue, comp.nmComputador, comp.isNotebook, comp.teNodeAddress, comp.teIpComputador, so.idSo, so.inMswindows, so.sgSo, rede.idRede, rede.nmRede, rede.teIpRede, local.nmLocal, local.idLocal') |
125 | ->innerJoin('coleta.classProperty', 'property') | 125 | ->innerJoin('coleta.classProperty', 'property') |
126 | ->innerJoin('property.idClass', 'classe') | 126 | ->innerJoin('property.idClass', 'classe') |
127 | ->innerJoin('coleta.computador', 'comp') | 127 | ->innerJoin('coleta.computador', 'comp') |
src/Cacic/CommonBundle/Entity/LogAcesso.php
@@ -88,12 +88,12 @@ class LogAcesso | @@ -88,12 +88,12 @@ class LogAcesso | ||
88 | { | 88 | { |
89 | $this->data = new \DateTime(); | 89 | $this->data = new \DateTime(); |
90 | } | 90 | } |
91 | + | ||
91 | /** | 92 | /** |
92 | * @var string | 93 | * @var string |
93 | */ | 94 | */ |
94 | private $usuario; | 95 | private $usuario; |
95 | 96 | ||
96 | - | ||
97 | /** | 97 | /** |
98 | * Set usuario | 98 | * Set usuario |
99 | * | 99 | * |
@@ -110,7 +110,7 @@ class LogAcesso | @@ -110,7 +110,7 @@ class LogAcesso | ||
110 | /** | 110 | /** |
111 | * Get usuario | 111 | * Get usuario |
112 | * | 112 | * |
113 | - * @return string | 113 | + * @return string |
114 | */ | 114 | */ |
115 | public function getUsuario() | 115 | public function getUsuario() |
116 | { | 116 | { |
src/Cacic/CommonBundle/Entity/LogAcessoRepository.php
@@ -29,6 +29,22 @@ class LogAcessoRepository extends EntityRepository | @@ -29,6 +29,22 @@ class LogAcessoRepository extends EntityRepository | ||
29 | return $qb->getQuery()->getOneOrNullResult(); | 29 | return $qb->getQuery()->getOneOrNullResult(); |
30 | } | 30 | } |
31 | 31 | ||
32 | + /** | ||
33 | + * Função que retorna o último usuário logado para o computador solicitado | ||
34 | + * | ||
35 | + * @param $id_computador | ||
36 | + */ | ||
37 | + public function ultimoUserName( $id_computador ) { | ||
38 | + $qb = $this->createQueryBuilder('usuario') | ||
39 | + ->select('usuario') | ||
40 | + ->where('usuario.idComputador = :computador') | ||
41 | + ->orderBy('usuario.data', 'desc') | ||
42 | + ->setMaxResults(1) | ||
43 | + ->setParameter('computador', $id_computador ); | ||
44 | + | ||
45 | + return $qb->getQuery()->getOneOrNullResult(); | ||
46 | + } | ||
47 | + | ||
32 | 48 | ||
33 | /** | 49 | /** |
34 | * | 50 | * |
@@ -144,10 +160,99 @@ GROUP BY c0_.te_node_address, | @@ -144,10 +160,99 @@ GROUP BY c0_.te_node_address, | ||
144 | return $query->execute(); | 160 | return $query->execute(); |
145 | } | 161 | } |
146 | 162 | ||
163 | + /* | ||
164 | + * Consulta para relatório de contendo ultimo usuário logado | ||
165 | + */ | ||
166 | + public function gerarRelatorioUsuario( $filtros, $filtroLocais, $dataInicio, $dataFim, $usuario ) | ||
167 | + { | ||
168 | + $rsm = new ResultSetMapping(); | ||
169 | + $rsm->addScalarResult('te_node_address', 'teNodeAddress'); | ||
170 | + $rsm->addScalarResult('id_computador', 'idComputador'); | ||
171 | + $rsm->addScalarResult('te_ip_computador', 'teIpComputador'); | ||
172 | + $rsm->addScalarResult('nm_computador', 'nmComputador'); | ||
173 | + $rsm->addScalarResult('id_so', 'idSo'); | ||
174 | + $rsm->addScalarResult('sg_so', 'sgSo'); | ||
175 | + $rsm->addScalarResult('id_rede', 'idRede'); | ||
176 | + $rsm->addScalarResult('nm_rede', 'nmRede'); | ||
177 | + $rsm->addScalarResult('te_ip_rede', 'teIpRede'); | ||
178 | + $rsm->addScalarResult('max_data', 'data'); | ||
179 | + $rsm->addScalarResult('nm_local', 'nmLocal'); | ||
180 | + $rsm->addScalarResult('id_local', 'idLocal'); | ||
181 | + $rsm->addScalarResult('usuario', 'usuario'); | ||
182 | + | ||
183 | + $sql = " | ||
184 | +SELECT c0_.te_node_address AS te_node_address, | ||
185 | + string_agg(DISTINCT CAST(c0_.id_computador AS text), ', ') as id_computador, | ||
186 | + string_agg(DISTINCT c0_.te_ip_computador, ', ') as te_ip_computador, | ||
187 | + string_agg(DISTINCT c0_.nm_computador, ', ') AS nm_computador, | ||
188 | + string_agg(DISTINCT CAST(s2_.id_so AS text), ', ') AS id_so, | ||
189 | + string_agg(DISTINCT s2_.sg_so, ', ') AS sg_so, | ||
190 | + string_agg(DISTINCT CAST(r3_.id_rede AS text), ', ') AS id_rede, | ||
191 | + string_agg(DISTINCT r3_.nm_rede, ', ') AS nm_rede, | ||
192 | + string_agg(DISTINCT r3_.te_ip_rede, ', ') AS te_ip_rede, | ||
193 | + string_agg(DISTINCT la5_.usuario, ', ') AS usuario, | ||
194 | + max(l1_.data) AS max_data, | ||
195 | + l4_.nm_local AS nm_local, | ||
196 | + l4_.id_local AS id_local | ||
197 | +FROM log_acesso l1_ | ||
198 | +INNER JOIN computador c0_ ON l1_.id_computador = c0_.id_computador | ||
199 | +INNER JOIN so s2_ ON c0_.id_so = s2_.id_so | ||
200 | +INNER JOIN rede r3_ ON c0_.id_rede = r3_.id_rede | ||
201 | +INNER JOIN local l4_ ON r3_.id_local = l4_.id_local | ||
202 | +INNER JOIN log_acesso la5_ ON c0_.id_computador = la5_.id_computador | ||
203 | +WHERE 1 = 1 | ||
204 | +"; | ||
205 | + | ||
206 | + /** | ||
207 | + * Verifica os filtros que foram parametrizados | ||
208 | + */ | ||
209 | + if ( $dataInicio ) { | ||
210 | + $sql .= " AND l1_.data >= ? "; | ||
211 | + } | ||
212 | + | ||
213 | + if ( $dataFim ) { | ||
214 | + $sql .= " AND l1_.data <= ?"; | ||
215 | + } | ||
216 | + | ||
217 | + if ( $usuario ) { | ||
218 | + $sql .= " AND lower(l1_.usuario) LIKE lower(?)"; | ||
219 | + } | ||
220 | + | ||
221 | + if ( $filtroLocais ) { | ||
222 | + $sql .= " AND r3_.id_local IN (?)"; | ||
223 | + } | ||
224 | + | ||
225 | + $sql .= " | ||
226 | +GROUP BY c0_.te_node_address, | ||
227 | + l4_.nm_local, | ||
228 | + l4_.id_local | ||
229 | + "; | ||
230 | + | ||
231 | + $query = $this->getEntityManager()->createNativeQuery($sql, $rsm); | ||
232 | + | ||
233 | + /** | ||
234 | + * Verifica os filtros que foram parametrizados | ||
235 | + */ | ||
236 | + if ( $dataInicio ) { | ||
237 | + $query->setParameter(1, ( $dataInicio.' 00:00:00' )); | ||
238 | + } | ||
239 | + | ||
240 | + | ||
241 | + if ( $dataFim ) | ||
242 | + $query->setParameter(2, ( $dataFim.' 23:59:59' )); | ||
243 | + | ||
244 | + if ( $usuario ) | ||
245 | + $query->setParameter(3, "%$usuario%" ); | ||
246 | + | ||
247 | + if ( $filtroLocais ) | ||
248 | + $query->setParameter(4, $filtroLocais); | ||
249 | + | ||
250 | + | ||
251 | + return $query->execute(); | ||
252 | + } | ||
253 | + | ||
147 | /** | 254 | /** |
148 | - * | ||
149 | * Total de computadores monitorados nos últimos 30 dias | 255 | * Total de computadores monitorados nos últimos 30 dias |
150 | - * | ||
151 | */ | 256 | */ |
152 | 257 | ||
153 | public function countPorComputador() { | 258 | public function countPorComputador() { |
@@ -0,0 +1,119 @@ | @@ -0,0 +1,119 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace Cacic\CommonBundle\Entity; | ||
4 | + | ||
5 | +use Doctrine\ORM\Mapping as ORM; | ||
6 | +use Symfony\Component\Validator\Constraints\DateTime; | ||
7 | + | ||
8 | +/** | ||
9 | + * LogAcesso | ||
10 | + */ | ||
11 | +class LogUserLogado | ||
12 | +{ | ||
13 | + /** | ||
14 | + * @var integer | ||
15 | + */ | ||
16 | + private $idLogUserLogado; | ||
17 | + | ||
18 | + /** | ||
19 | + * @var \DateTime | ||
20 | + */ | ||
21 | + private $data; | ||
22 | + | ||
23 | + /** | ||
24 | + * @var \Cacic\CommonBundle\Entity\Computador | ||
25 | + */ | ||
26 | + private $idComputador; | ||
27 | + | ||
28 | + /** | ||
29 | + * Get idLogUserLogado | ||
30 | + * | ||
31 | + * @return integer | ||
32 | + */ | ||
33 | + public function getIdLogUserLogado() | ||
34 | + { | ||
35 | + return $this->idLogUserLogado; | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Set data | ||
40 | + * | ||
41 | + * @param \DateTime $data | ||
42 | + * @return LogUserLogado | ||
43 | + */ | ||
44 | + public function setData($data) | ||
45 | + { | ||
46 | + $this->data = $data; | ||
47 | + | ||
48 | + return $this; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * Get data | ||
53 | + * | ||
54 | + * @return \DateTime | ||
55 | + */ | ||
56 | + public function getData() | ||
57 | + { | ||
58 | + return $this->data; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Set idComputador | ||
63 | + * | ||
64 | + * @param \Cacic\CommonBundle\Entity\Computador $idComputador | ||
65 | + * @return LogUserLogado | ||
66 | + */ | ||
67 | + public function setIdComputador(\Cacic\CommonBundle\Entity\Computador $idComputador = null) | ||
68 | + { | ||
69 | + $this->idComputador = $idComputador; | ||
70 | + | ||
71 | + return $this; | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Get idComputador | ||
76 | + * | ||
77 | + * @return \Cacic\CommonBundle\Entity\Computador | ||
78 | + */ | ||
79 | + public function getIdComputador() | ||
80 | + { | ||
81 | + return $this->idComputador; | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * @PrePersist | ||
86 | + */ | ||
87 | + public function onPrePersistSetRegistrationDate() | ||
88 | + { | ||
89 | + $this->data = new \DateTime(); | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * @var string | ||
94 | + */ | ||
95 | + private $usuario; | ||
96 | + | ||
97 | + /** | ||
98 | + * Set usuario | ||
99 | + * | ||
100 | + * @param string $usuario | ||
101 | + * @return LogUserLogado | ||
102 | + */ | ||
103 | + public function setUsuario($usuario) | ||
104 | + { | ||
105 | + $this->usuario = $usuario; | ||
106 | + | ||
107 | + return $this; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * Get usuario | ||
112 | + * | ||
113 | + * @return string | ||
114 | + */ | ||
115 | + public function getUsuario() | ||
116 | + { | ||
117 | + return $this->usuario; | ||
118 | + } | ||
119 | +} | ||
0 | \ No newline at end of file | 120 | \ No newline at end of file |
src/Cacic/CommonBundle/Entity/LogUserLogadoRepository.php
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace Cacic\CommonBundle\Entity; | ||
4 | + | ||
5 | +use Doctrine\ORM\EntityRepository; | ||
6 | + | ||
7 | +/** | ||
8 | + * LogAcessoRepository | ||
9 | + * | ||
10 | + * Métodos de repositório | ||
11 | + */ | ||
12 | +class LogUserLogadoRepository extends EntityRepository | ||
13 | +{ | ||
14 | + /** | ||
15 | + * Função que retorna o último acesso para o computador solicitado | ||
16 | + * | ||
17 | + * @param $computador | ||
18 | + */ | ||
19 | + public function ultimoAcesso( $computador ) { | ||
20 | + $qb = $this->createQueryBuilder('acesso') | ||
21 | + ->select('acesso') | ||
22 | + ->where('acesso.idComputador = :computador') | ||
23 | + ->orderBy('acesso.data', 'desc') | ||
24 | + ->setMaxResults(1) | ||
25 | + ->setParameter('computador', $computador ); | ||
26 | + | ||
27 | + return $qb->getQuery()->getOneOrNullResult(); | ||
28 | + } | ||
29 | + | ||
30 | +} |
src/Cacic/CommonBundle/Form/Type/LogPesquisaType.php
@@ -53,6 +53,12 @@ class LogPesquisaType extends AbstractType | @@ -53,6 +53,12 @@ class LogPesquisaType extends AbstractType | ||
53 | 'label'=> 'Selecione o Local:' | 53 | 'label'=> 'Selecione o Local:' |
54 | ) | 54 | ) |
55 | ); | 55 | ); |
56 | + | ||
57 | + $builder->add( | ||
58 | + 'usuario', | ||
59 | + null, | ||
60 | + array( 'label'=>'', 'max_length'=>30, 'required' => true) | ||
61 | + ); | ||
56 | } | 62 | } |
57 | 63 | ||
58 | /** | 64 | /** |
src/Cacic/CommonBundle/Resources/config/doctrine/Computador.orm.yml
@@ -85,6 +85,11 @@ Cacic\CommonBundle\Entity\Computador: | @@ -85,6 +85,11 @@ Cacic\CommonBundle\Entity\Computador: | ||
85 | fixed: true | 85 | fixed: true |
86 | nullable: true | 86 | nullable: true |
87 | column: dt_debug | 87 | column: dt_debug |
88 | + isNotebook: | ||
89 | + type: text | ||
90 | + length: 3 | ||
91 | + nullable: true | ||
92 | + column: is_notebook | ||
88 | oneToMany: | 93 | oneToMany: |
89 | softwares: | 94 | softwares: |
90 | targetEntity: SoftwareEstacao | 95 | targetEntity: SoftwareEstacao |
src/Cacic/CommonBundle/Resources/config/doctrine/LogUserLogado.orm.yml
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +Cacic\CommonBundle\Entity\LogUserLogado: | ||
2 | + type: entity | ||
3 | + table: log_user_logado | ||
4 | + repositoryClass: Cacic\CommonBundle\Entity\LogUserLogadoRepository | ||
5 | + fields: | ||
6 | + idLogUserLogado: | ||
7 | + id: true | ||
8 | + type: integer | ||
9 | + unsigned: false | ||
10 | + nullable: false | ||
11 | + column: id_log_user_logado | ||
12 | + generator: | ||
13 | + strategy: IDENTITY | ||
14 | + data: | ||
15 | + type: datetime | ||
16 | + nullable: false | ||
17 | + column: data | ||
18 | + usuario: | ||
19 | + type: text | ||
20 | + nullable: true | ||
21 | + manyToOne: | ||
22 | + idComputador: | ||
23 | + targetEntity: Computador | ||
24 | + cascade: { } | ||
25 | + mappedBy: null | ||
26 | + inversedBy: null | ||
27 | + joinColumns: | ||
28 | + id_computador: | ||
29 | + referencedColumnName: id_computador | ||
30 | + orphanRemoval: false | ||
0 | \ No newline at end of file | 31 | \ No newline at end of file |
src/Cacic/CommonBundle/Resources/views/Computador/detalhar.html.twig
@@ -29,11 +29,15 @@ | @@ -29,11 +29,15 @@ | ||
29 | <tbody> | 29 | <tbody> |
30 | <tr> | 30 | <tr> |
31 | <th width="20%">{{ 'Nome do Computador'|trans }}</th> | 31 | <th width="20%">{{ 'Nome do Computador'|trans }}</th> |
32 | - <td colspan="3">{{ computador.nmComputador }}</td> | 32 | + <td width="30%">{{ computador.nmComputador }}</td> |
33 | + <th width="20%">{{ 'Notebook'|trans }}</th> | ||
34 | + <td width="30%">{{ computador.isNotebook }}</td> | ||
33 | </tr> | 35 | </tr> |
34 | <tr> | 36 | <tr> |
35 | - <th width="20%">{{ 'Sistema Operacional'|trans }}</th> | ||
36 | - <td colspan="3">{{ computador.idSo }}</td> | 37 | + <th>{{ 'Sistema Operacional'|trans }}</th> |
38 | + <td>{{ computador.idSo }}</td> | ||
39 | + <th>{{ 'Último usuário logado'|trans }}</th> | ||
40 | + <td>{{ ultimoAcesso.usuario }}</td> | ||
37 | </tr> | 41 | </tr> |
38 | <tr> | 42 | <tr> |
39 | <th width="10%">{{ 'Endereço TCP/IP'|trans }}</th> | 43 | <th width="10%">{{ 'Endereço TCP/IP'|trans }}</th> |
src/Cacic/CommonBundle/Resources/views/base.html.twig
@@ -142,6 +142,7 @@ | @@ -142,6 +142,7 @@ | ||
142 | </a> | 142 | </a> |
143 | {{ knp_menu_render('CacicRelatorioBundle:Builder:relatorioMenu') }} | 143 | {{ knp_menu_render('CacicRelatorioBundle:Builder:relatorioMenu') }} |
144 | </li> | 144 | </li> |
145 | + <li><a class="round_top" href="{{ path('cacic_relatorio_usuario') }}">{{ "Usuário Logado"|trans }}</a></li> | ||
145 | <li><a class="round_top" href="{{ path('cacic_relatorio_autorizacoes') }}">{{ "Autorizações"|trans }}</a></li> | 146 | <li><a class="round_top" href="{{ path('cacic_relatorio_autorizacoes') }}">{{ "Autorizações"|trans }}</a></li> |
146 | <li><a class="round_top" href="{{ path('cacic_relatorio_faturamento') }}">{{ "Faturamento"|trans }}</a></li> | 147 | <li><a class="round_top" href="{{ path('cacic_relatorio_faturamento') }}">{{ "Faturamento"|trans }}</a></li> |
147 | <li><a class="round_top" href="{{ path('cacic_relatorio_inativos') }}">{{ "Sem Coleta"|trans }}</a></li> | 148 | <li><a class="round_top" href="{{ path('cacic_relatorio_inativos') }}">{{ "Sem Coleta"|trans }}</a></li> |
src/Cacic/RelatorioBundle/Controller/FaturamentoController.php
@@ -417,4 +417,117 @@ | @@ -417,4 +417,117 @@ | ||
417 | ) | 417 | ) |
418 | ); | 418 | ); |
419 | } | 419 | } |
420 | + | ||
421 | + /* | ||
422 | + * Página inicial do Relatório de usuário logado | ||
423 | + */ | ||
424 | + public function usuarioAction(Request $request) { | ||
425 | + | ||
426 | + $locale = $request->getLocale(); | ||
427 | + | ||
428 | + $form = $this->createForm( new LogPesquisaType() ); | ||
429 | + return $this->render( 'CacicRelatorioBundle:Faturamento:usuario.html.twig', | ||
430 | + array( | ||
431 | + 'locale'=> $locale, | ||
432 | + 'form' => $form->createView() | ||
433 | + ) | ||
434 | + ); | ||
435 | + } | ||
436 | + | ||
437 | + /* | ||
438 | + * Página que exibe o resultado da consulta de usuário logado | ||
439 | + */ | ||
440 | + public function usuarioDetalharAction( Request $request) { | ||
441 | + | ||
442 | + $locale = $request->getLocale(); | ||
443 | + $form = $this->createForm( new LogPesquisaType() ); | ||
444 | + | ||
445 | + if ( $request->isMethod('POST') ) | ||
446 | + { | ||
447 | + $form->bind( $request ); | ||
448 | + $data = $form->getData(); | ||
449 | + | ||
450 | + $filtroLocais = array(); // Inicializa array com locais a pesquisar | ||
451 | + foreach ( $data['idLocal'] as $locais ) { | ||
452 | + array_push( $filtroLocais, $locais->getIdLocal() ); | ||
453 | + } | ||
454 | + | ||
455 | + $dataInicio = $data['dtAcaoInicio']; | ||
456 | + $dataFim = $data['dtAcaoFim']; | ||
457 | + $usuario = $data['usuario']; | ||
458 | + | ||
459 | + $dados = $this->getDoctrine() | ||
460 | + ->getRepository('CacicCommonBundle:LogAcesso') | ||
461 | + ->gerarRelatorioUsuario($filtros = array(),$filtroLocais, $dataInicio, $dataFim, $usuario); | ||
462 | + | ||
463 | + } | ||
464 | + | ||
465 | + return $this->render( | ||
466 | + 'CacicRelatorioBundle:Faturamento:usuarioDetalhar.html.twig', | ||
467 | + array( | ||
468 | + 'idioma' => $locale, | ||
469 | + 'dados' => ( isset( $dados ) ? $dados : null ), | ||
470 | + 'idRede' => $filtroLocais, | ||
471 | + 'dtAcaoInicio' => $dataInicio, | ||
472 | + 'dtAcaoFim' => $dataFim, | ||
473 | + 'usuario' => $usuario | ||
474 | + | ||
475 | + ) | ||
476 | + ); | ||
477 | + } | ||
478 | + | ||
479 | + /* | ||
480 | + * Gera o CSV do relatório de usuário logado | ||
481 | + */ | ||
482 | + public function usuarioCsvAction( Request $request) { | ||
483 | + | ||
484 | + $locale = $request->getLocale(); | ||
485 | + $form = $this->createForm( new LogPesquisaType() ); | ||
486 | + | ||
487 | + if ( $request->isMethod('POST') ) | ||
488 | + { | ||
489 | + $form->bind( $request ); | ||
490 | + $data = $form->getData(); | ||
491 | + | ||
492 | + $filtroLocais = array(); // Inicializa array com locais a pesquisar | ||
493 | + foreach ( $data['idLocal'] as $locais ) { | ||
494 | + array_push( $filtroLocais, $locais->getIdLocal() ); | ||
495 | + } | ||
496 | + | ||
497 | + $dataInicio = $data['dtAcaoInicio']; | ||
498 | + $dataFim = $data['dtAcaoFim']; | ||
499 | + $usuario = $data['usuario']; | ||
500 | + | ||
501 | + $dados = $this->getDoctrine() | ||
502 | + ->getRepository('CacicCommonBundle:LogAcesso') | ||
503 | + ->gerarRelatorioUsuario($filtros = array(),$filtroLocais, $dataInicio, $dataFim, $usuario); | ||
504 | + | ||
505 | + } | ||
506 | + | ||
507 | + // Gera CSV | ||
508 | + $reader = new ArrayReader($dados); | ||
509 | + | ||
510 | + // Create the workflow from the reader | ||
511 | + $workflow = new Workflow($reader); | ||
512 | + | ||
513 | + $workflow->addValueConverter("reader",new CharsetValueConverter('UTF-8',$reader)); | ||
514 | + | ||
515 | + // Add the writer to the workflow | ||
516 | + $tmpfile = tempnam(sys_get_temp_dir(), 'Máquinas sem Coletas'); | ||
517 | + $file = new \SplFileObject($tmpfile, 'w'); | ||
518 | + $writer = new CsvWriter($file); | ||
519 | + $writer->writeItem(array('Local', 'Subrede','Endereço IP','Estações')); | ||
520 | + $workflow->addWriter($writer); | ||
521 | + | ||
522 | + // Process the workflow | ||
523 | + $workflow->process(); | ||
524 | + | ||
525 | + // Retorna o arquivo | ||
526 | + $response = new BinaryFileResponse($tmpfile); | ||
527 | + $response->headers->set('Content-Type', 'text/csv'); | ||
528 | + $response->headers->set('Content-Disposition', 'attachment; filename="Não_Coletadas.csv"'); | ||
529 | + $response->headers->set('Content-Transfer-Encoding', 'binary'); | ||
530 | + | ||
531 | + return $response; | ||
532 | + } | ||
420 | } | 533 | } |
421 | \ No newline at end of file | 534 | \ No newline at end of file |
src/Cacic/RelatorioBundle/Resources/config/routing.yml
@@ -192,4 +192,16 @@ cacic_relatorio_csv_hardware_wmi_detalhe: | @@ -192,4 +192,16 @@ cacic_relatorio_csv_hardware_wmi_detalhe: | ||
192 | 192 | ||
193 | cacic_faturamento_computador: | 193 | cacic_faturamento_computador: |
194 | pattern: /faturamento/computador | 194 | pattern: /faturamento/computador |
195 | - defaults: { _controller: CacicRelatorioBundle:Faturamento:computador } | ||
196 | \ No newline at end of file | 195 | \ No newline at end of file |
196 | + defaults: { _controller: CacicRelatorioBundle:Faturamento:computador } | ||
197 | + | ||
198 | +cacic_relatorio_usuario: | ||
199 | + pattern: /usuario | ||
200 | + defaults: { _controller: CacicRelatorioBundle:Faturamento:usuario } | ||
201 | + | ||
202 | +cacic_relatorio_usuario_detalhar: | ||
203 | + pattern: /usuario/detalhar | ||
204 | + defaults: { _controller: CacicRelatorioBundle:Faturamento:usuarioDetalhar } | ||
205 | + | ||
206 | +cacic_relatorio_usuario_csv: | ||
207 | + pattern: /usuario/csv | ||
208 | + defaults: { _controller: CacicRelatorioBundle:Faturamento:usuarioCsv } | ||
197 | \ No newline at end of file | 209 | \ No newline at end of file |
src/Cacic/RelatorioBundle/Resources/views/Faturamento/usuario.html.twig
0 → 100644
@@ -0,0 +1,106 @@ | @@ -0,0 +1,106 @@ | ||
1 | +{% extends 'CacicCommonBundle::base.html.twig' %} | ||
2 | + | ||
3 | +{% block breadcrumb %} | ||
4 | + <li class="active">{{ 'Usuário Logado'|trans }}</li> | ||
5 | +{% endblock %} | ||
6 | + | ||
7 | +{% block body %} | ||
8 | + | ||
9 | + <div class="row-fluid"> | ||
10 | + | ||
11 | + <div class="span8"> | ||
12 | + <div class="box grad_colour_black"> | ||
13 | + | ||
14 | + <h2 class="box_head round_top"><i class="icon-search"></i> {{'Relatório de usuário logado' |trans }}</h2> | ||
15 | + | ||
16 | + <div class="block box_content round_bottom padding_10"> | ||
17 | + | ||
18 | + <h4>{{ "Filtros para consulta de usuário logado"|trans }}</h4><br /> | ||
19 | + | ||
20 | + <form id="{{ 'formFaturamento'|trans }}" action="{{ path('cacic_relatorio_usuario_detalhar') }}" class="form-horizontal" method="POST" target="_blank"> | ||
21 | + | ||
22 | + <div class="control-group"> | ||
23 | + <label for="log_acesso_periodo" class="control-label">{{ 'Período'|trans }}</label> | ||
24 | + <div class="controls"> | ||
25 | + {{ form_widget(form.dtAcaoInicio, { 'attr': {'class': 'datepicker_on'} }) }} a {{ form_widget(form.dtAcaoFim, { 'attr': {'class': 'datepicker_on'} }) }} | ||
26 | + <p class="help-block">{{ "Informe o período no qual deseja realizar a faturar."|trans }}</p> | ||
27 | + </div> | ||
28 | + </div> | ||
29 | + | ||
30 | + <label class="control-label">{{ 'Usuário'|trans }}</label> | ||
31 | + <div class="control-group" > | ||
32 | + <div class="controls"> | ||
33 | + {{ form_widget(form.usuario) }} | ||
34 | + </div> | ||
35 | + </div> | ||
36 | + | ||
37 | + <div class="control-group _cad_block_opcao"> | ||
38 | + <label class="control-label">{{ 'Local'|trans }}</label> | ||
39 | + <div class="controls"> | ||
40 | + | ||
41 | + | ||
42 | + <input type="checkbox" class="toggleCheck" name="toggleCheck[]" value="id.Local" id="toggleLocal"> | ||
43 | + <label for="toggleLocal"><b>{{ 'Marcar/desmarcar tudo'|trans }}</b></label> | ||
44 | + <div style="height: 165px; overflow: auto;"> | ||
45 | + | ||
46 | + <div class="modulo-opt-block"> | ||
47 | + {{ form_widget(form.idLocal, {'form_type': 'horizontal'}) }} | ||
48 | + </div> | ||
49 | + </div> | ||
50 | + </div> | ||
51 | + </div> | ||
52 | + | ||
53 | + <div class="control-group"> | ||
54 | + <div class="controls"> | ||
55 | + <button type="reset" class="btn"> | ||
56 | + <i class="icon-refresh"></i> | ||
57 | + {{ "Resetar"|trans }} | ||
58 | + </button> | ||
59 | + <button type="submit" class="btn btn-primary"> | ||
60 | + <i class="icon-search"></i> | ||
61 | + {{ 'Gerar relatório'|trans }} | ||
62 | + </button> | ||
63 | + <button type="submit" class="btn btn-success" formaction="{{ path('cacic_faturamento_csv') }}"> | ||
64 | + <i class="icon-download-alt"></i> | ||
65 | + {{'Gerar CSV'|trans }} | ||
66 | + </button> | ||
67 | + </div> | ||
68 | + </div> | ||
69 | + | ||
70 | + </form> | ||
71 | + </div> <!-- /block --> | ||
72 | + </div> <!-- /box --> | ||
73 | + </div> <!-- /span8 --> | ||
74 | + | ||
75 | + <div class="span4"> | ||
76 | + <div class="box grad_colour_black"> | ||
77 | + | ||
78 | + <h2 class="box_head round_top"><i class="icon-info-sign"></i> {{ "Informações Adicionais"|trans }}</h2> | ||
79 | + | ||
80 | + <div class="block box_content round_bottom padding_10"> | ||
81 | + <p> | ||
82 | + {{ "Nesta consulta o possível obter um relatório contendo o registro do último usuário logado na estação"|trans }}. | ||
83 | + </p> | ||
84 | + <p> | ||
85 | + {{ "O campos PERIODO e USUARIO são de preenchimento obrigatório para a realização da consulta"|trans }}. | ||
86 | + </p> | ||
87 | + <p> | ||
88 | + {{ "Não selecionar nenhum valor em LOCAL é o mesmo que selecionar todos"|trans }}. | ||
89 | + </p> | ||
90 | + </div> <!-- /block --> | ||
91 | + </div> <!-- /box --> | ||
92 | + </div> <!-- span4 --> | ||
93 | + | ||
94 | + </div> <!-- /row --> | ||
95 | + | ||
96 | +{% endblock %} | ||
97 | + | ||
98 | +{% block javascripts %} | ||
99 | + | ||
100 | + {{ parent() }} | ||
101 | + | ||
102 | + <script type="text/javascript"> | ||
103 | + System.Form.toggleCheck(); // Ativa o monitoramento de Clique no checkbox para marcar/desmarcar todos | ||
104 | + </script> | ||
105 | + | ||
106 | +{% endblock %} | ||
0 | \ No newline at end of file | 107 | \ No newline at end of file |
src/Cacic/RelatorioBundle/Resources/views/Faturamento/usuarioDetalhar.html.twig
0 → 100644
@@ -0,0 +1,78 @@ | @@ -0,0 +1,78 @@ | ||
1 | +{% extends 'CacicRelatorioBundle::base.html.twig' %} | ||
2 | + | ||
3 | +{% block body %} | ||
4 | + | ||
5 | + <h2>{{ 'Relatório de usuário logado -'|trans }} {{ usuario }}</h2> | ||
6 | + <h5 class="">{{ 'Período: '|trans }}{{ dtAcaoInicio|date("d/m/Y") }} a {{ dtAcaoFim|date("d/m/Y") }}</h5> | ||
7 | + <h5>{{ 'Relatório gerado em'|trans }} {% if idioma == 'pt_BR' %}{{ "now"|date("d/m/Y H\\hi") }}{% else %}{{ "now"|date("d/m/Y H\\hi") }}{% endif %}</h5> | ||
8 | + <hr /> | ||
9 | + | ||
10 | + <!--Botão CSV --> | ||
11 | + <a class="btn btn-primary" type="submit" href="{{ path('cacic_relatorio_usuario_csv',{'dataInicio':dtAcaoInicio|trim,'dataFim':dtAcaoFim|trim})}}" title="{{ "Máquinas faturadas"|trans }}" target="_self"> | ||
12 | + <i class="icon-bar-chart"></i> | ||
13 | + Gerar CSV | ||
14 | + </a> | ||
15 | + <!--Botão CSV --> | ||
16 | + | ||
17 | + <P /> | ||
18 | + | ||
19 | + {% if dados %} | ||
20 | + | ||
21 | + <table class="display datatable" id="datatable"> | ||
22 | + | ||
23 | + <thead> | ||
24 | + <tr> | ||
25 | + <th width="15%">{{ "Computador"|trans }}</th> | ||
26 | + <th width="9%">{{ "MAC Address"|trans }}</th> | ||
27 | + <th width="9%">{{ "Endereço IP"|trans }}</th> | ||
28 | + <th width="7%">{{ "Sistema Operacional"|trans }}</th> | ||
29 | + <th width="10%">{{ "Local"|trans }}</th> | ||
30 | + <th width="20%">{{ "Subrede"|trans }}</th> | ||
31 | + <th width="10%">{{ "Usuário"|trans }}</th> | ||
32 | + <th width="13%">{{ "Data/Hora da Última coleta"|trans }}</th> | ||
33 | + </tr> | ||
34 | + </thead> | ||
35 | + | ||
36 | + <tbody> | ||
37 | + {% for reg in dados %} | ||
38 | + {% set computadores = reg.idComputador|split(',') %} | ||
39 | + {% set nomes = reg.nmComputador|split(',') %} | ||
40 | + {% set ips = reg.teIpComputador|split(',') %} | ||
41 | + <tr> | ||
42 | + <td> | ||
43 | + {% for comp in nomes %} | ||
44 | + <b><a href="{{ path('cacic_faturamento_computador', {'nmComputador' : comp|trim }) }}" title="{{ 'Detalhar computador'|trans }}" target="_blank">{{ comp }}</a></b> | ||
45 | + {% else %} | ||
46 | + <b>{{ reg.nmComputador }}</b> | ||
47 | + {% endfor %} | ||
48 | + </td> | ||
49 | + <td><a href="{{ path('cacic_faturamento_computador', {'teNodeAddress' : reg.teNodeAddress|trim }) }}" title="{{ 'Detalhar computador'|trans }}" target="_blank">{{ reg.teNodeAddress }}</a></td> | ||
50 | + <td> | ||
51 | + {% for comp in ips %} | ||
52 | + <b><a href="{{ path('cacic_faturamento_computador', {'teIpComputador' : comp|trim }) }}" title="{{ 'Detalhar computador'|trans }}" target="_blank">{{ comp }}</a></b> | ||
53 | + {% else %} | ||
54 | + <b>{{ reg.teIpComputador }}</b> | ||
55 | + {% endfor %} | ||
56 | + </td> | ||
57 | + <td>{{ reg.sgSo }}</td> | ||
58 | + <td>{{ reg.nmLocal }}</td> | ||
59 | + <td>{{ reg.nmRede }} / {{ reg.teIpRede }}</td> | ||
60 | + <td>{{ reg.usuario }}</td> | ||
61 | + <td>{{ reg.data|date(' d, M, Y H:m:s') }}</td> | ||
62 | + </tr> | ||
63 | + | ||
64 | + {% endfor %} | ||
65 | + </tbody> | ||
66 | + </table> | ||
67 | + | ||
68 | + {% else %} | ||
69 | + | ||
70 | + <div class="row-fluid"> | ||
71 | + <table class="table table-striped"> | ||
72 | + <tr><td colspan="3" style="text-align: center"><b>{{ 'NENHUM REGISTRO ENCONTRADO'|trans }}</b></td></tr> | ||
73 | + </table> | ||
74 | + </div> | ||
75 | + | ||
76 | + {% endif %} | ||
77 | + | ||
78 | +{% endblock %} |
src/Cacic/RelatorioBundle/Resources/views/Hardware/rel_wmi_detalhe.html.twig
@@ -28,10 +28,11 @@ | @@ -28,10 +28,11 @@ | ||
28 | <th width="10%">{{ "Local"|trans }}</th> | 28 | <th width="10%">{{ "Local"|trans }}</th> |
29 | <th width="10%">{{ "Subrede"|trans }}</th> | 29 | <th width="10%">{{ "Subrede"|trans }}</th> |
30 | <th width="10%">{{ "Propriedade"|trans }}</th> | 30 | <th width="10%">{{ "Propriedade"|trans }}</th> |
31 | + <th width="10%">{{ "Notebook"|trans }}</th> | ||
31 | <th>{{ "Valor"|trans }}</th> | 32 | <th>{{ "Valor"|trans }}</th> |
32 | </tr> | 33 | </tr> |
33 | </thead> | 34 | </thead> |
34 | - | 35 | + |
35 | <tbody> | 36 | <tbody> |
36 | {% for reg in dados %} | 37 | {% for reg in dados %} |
37 | <tr> | 38 | <tr> |
@@ -44,7 +45,9 @@ | @@ -44,7 +45,9 @@ | ||
44 | <td>{{ reg.nmLocal }}</td> | 45 | <td>{{ reg.nmLocal }}</td> |
45 | <td>{{ reg.nmRede }} / {{ reg.teIpRede }}</td> | 46 | <td>{{ reg.nmRede }} / {{ reg.teIpRede }}</td> |
46 | <td>{{ reg.nmPropertyName }}</td> | 47 | <td>{{ reg.nmPropertyName }}</td> |
48 | + <td>{{ reg.isNotebook }}</td> | ||
47 | <td>{{ reg.teClassPropertyValue }}</td> | 49 | <td>{{ reg.teClassPropertyValue }}</td> |
50 | + | ||
48 | </tr> | 51 | </tr> |
49 | {% else %} | 52 | {% else %} |
50 | <tr> | 53 | <tr> |
src/Cacic/WSBundle/Controller/ColetaController.php
@@ -105,17 +105,24 @@ class ColetaController extends Controller | @@ -105,17 +105,24 @@ class ColetaController extends Controller | ||
105 | 105 | ||
106 | foreach( $request->request->all() as $strClassName => $strClassValues) | 106 | foreach( $request->request->all() as $strClassName => $strClassValues) |
107 | { | 107 | { |
108 | + // Descriptografando os valores da requisição | ||
109 | + $strNewClassValues = OldCacicHelper::deCrypt($request, $strClassValues); | ||
110 | + | ||
108 | //$teste = OldCacicHelper::deCrypt($request, $strClassValues); | 111 | //$teste = OldCacicHelper::deCrypt($request, $strClassValues); |
109 | //$logger->debug("444444444444444444444444444444444444444444444444444444444: $strClassName | \n $teste"); | 112 | //$logger->debug("444444444444444444444444444444444444444444444444444444444: $strClassName | \n $teste"); |
110 | //$logger->debug("444444444444444444444444444444444444444444444444444444444: $strClassName"); | 113 | //$logger->debug("444444444444444444444444444444444444444444444444444444444: $strClassName"); |
111 | - //error_log("444444444444444444444444444444444444444444444444444444: $strClassName"); | 114 | + //error_log("44444444444444444444444444444444444444444444444444444: $strClassName"); |
112 | 115 | ||
116 | + //Verifica se é notebook ou não o computador através da bateria | ||
117 | + if ($strClassName == "isNotebook"){ | ||
118 | + $computador->setIsNotebook($strNewClassValues); | ||
119 | + $this->getDoctrine()->getManager()->persist($computador); | ||
120 | + $this->getDoctrine()->getManager()->flush(); | ||
121 | + } | ||
113 | 122 | ||
114 | // Verifico se o atributo sendo verificado é uma classe de coleta. | 123 | // Verifico se o atributo sendo verificado é uma classe de coleta. |
115 | // Se for, insiro os dados da coleta no objeto | 124 | // Se for, insiro os dados da coleta no objeto |
116 | if (in_array($strClassName, $arrClassesNames)) { | 125 | if (in_array($strClassName, $arrClassesNames)) { |
117 | - // Descriptografando os valores da requisição | ||
118 | - $strNewClassValues = OldCacicHelper::deCrypt($request, $strClassValues); | ||
119 | 126 | ||
120 | // A propriedade da coleta de software é multi valorada. Preciso tratar diferente | 127 | // A propriedade da coleta de software é multi valorada. Preciso tratar diferente |
121 | if ($strClassName == "SoftwareList") { | 128 | if ($strClassName == "SoftwareList") { |
src/Cacic/WSBundle/Controller/DefaultController.php
@@ -7,6 +7,7 @@ use Cacic\CommonBundle\Entity\Computador; | @@ -7,6 +7,7 @@ use Cacic\CommonBundle\Entity\Computador; | ||
7 | use Cacic\CommonBundle\Entity\ComputadorColeta; | 7 | use Cacic\CommonBundle\Entity\ComputadorColeta; |
8 | use Cacic\CommonBundle\Entity\ConfiguracaoLocal; | 8 | use Cacic\CommonBundle\Entity\ConfiguracaoLocal; |
9 | use Cacic\CommonBundle\Entity\ConfiguracaoPadrao; | 9 | use Cacic\CommonBundle\Entity\ConfiguracaoPadrao; |
10 | +use Cacic\CommonBundle\Entity\LogUserLogado; | ||
10 | use Cacic\CommonBundle\Entity\Rede; | 11 | use Cacic\CommonBundle\Entity\Rede; |
11 | use Cacic\CommonBundle\Entity\RedeGrupoFtp; | 12 | use Cacic\CommonBundle\Entity\RedeGrupoFtp; |
12 | use Doctrine\Common\Util\Debug; | 13 | use Doctrine\Common\Util\Debug; |
@@ -144,6 +145,8 @@ class DefaultController extends Controller | @@ -144,6 +145,8 @@ class DefaultController extends Controller | ||
144 | $hoje = $data_acesso->format('Y-m-d'); | 145 | $hoje = $data_acesso->format('Y-m-d'); |
145 | 146 | ||
146 | $ultimo_acesso = $this->getDoctrine()->getRepository('CacicCommonBundle:LogAcesso')->ultimoAcesso( $computador->getIdComputador() ); | 147 | $ultimo_acesso = $this->getDoctrine()->getRepository('CacicCommonBundle:LogAcesso')->ultimoAcesso( $computador->getIdComputador() ); |
148 | + $ultimo_user_logado = $this->getDoctrine()->getRepository('CacicCommonBundle:LogUserLogado')->ultimoAcesso( $computador->getIdComputador() ); | ||
149 | + | ||
147 | if (empty($ultimo_acesso)) { | 150 | if (empty($ultimo_acesso)) { |
148 | // Se for o primeiro registro grava o acesso do computador | 151 | // Se for o primeiro registro grava o acesso do computador |
149 | $logger->debug("Último acesso não encontrado. Registrando acesso para o computador $computador em $hoje"); | 152 | $logger->debug("Último acesso não encontrado. Registrando acesso para o computador $computador em $hoje"); |
@@ -152,6 +155,21 @@ class DefaultController extends Controller | @@ -152,6 +155,21 @@ class DefaultController extends Controller | ||
152 | $log_acesso->setIdComputador($computador); | 155 | $log_acesso->setIdComputador($computador); |
153 | $log_acesso->setData($data_acesso); | 156 | $log_acesso->setData($data_acesso); |
154 | 157 | ||
158 | + /* | ||
159 | + * Grava os registros na Tabela Log_User_Logado | ||
160 | + */ | ||
161 | + $ultimo_user_logado = new LogUserLogado(); | ||
162 | + $ultimo_user_logado->setIdComputador($computador); | ||
163 | + $ultimo_user_logado->setData($data_acesso); | ||
164 | + | ||
165 | + /* | ||
166 | + * Grava o último usuário logado no banco apenas se não estiver vazio | ||
167 | + */ | ||
168 | + if (!empty($ultimo_login)) | ||
169 | + $log_acesso->setUsuario($ultimo_login); | ||
170 | + $ultimo_user_logado->setUsuario($ultimo_login); | ||
171 | + | ||
172 | + | ||
155 | // Grava o log | 173 | // Grava o log |
156 | $this->getDoctrine()->getManager()->persist($log_acesso); | 174 | $this->getDoctrine()->getManager()->persist($log_acesso); |
157 | $this->getDoctrine()->getManager()->flush(); | 175 | $this->getDoctrine()->getManager()->flush(); |
@@ -166,9 +184,28 @@ class DefaultController extends Controller | @@ -166,9 +184,28 @@ class DefaultController extends Controller | ||
166 | $log_acesso->setIdComputador($computador); | 184 | $log_acesso->setIdComputador($computador); |
167 | $log_acesso->setData($data_acesso); | 185 | $log_acesso->setData($data_acesso); |
168 | 186 | ||
187 | + /* | ||
188 | + * Grava os registros na Tabela Log_User_Logado | ||
189 | + */ | ||
190 | + $ultimo_user_logado = new LogUserLogado(); | ||
191 | + $ultimo_user_logado->setIdComputador($computador); | ||
192 | + $ultimo_user_logado->setData($data_acesso); | ||
193 | + | ||
194 | + /* | ||
195 | + * Grava o último usuário logado no banco apenas se não estiver vazio | ||
196 | + */ | ||
197 | + if (!empty($ultimo_login)) | ||
198 | + $log_acesso->setUsuario($ultimo_login); | ||
199 | + $ultimo_user_logado->setUsuario($ultimo_login); | ||
200 | + | ||
201 | + | ||
169 | // Grava o log | 202 | // Grava o log |
170 | $this->getDoctrine()->getManager()->persist($log_acesso); | 203 | $this->getDoctrine()->getManager()->persist($log_acesso); |
171 | $this->getDoctrine()->getManager()->flush(); | 204 | $this->getDoctrine()->getManager()->flush(); |
205 | + | ||
206 | + // Grava em log_user_logado | ||
207 | + $this->getDoctrine()->getManager()->persist($ultimo_user_logado); | ||
208 | + $this->getDoctrine()->getManager()->flush(); | ||
172 | } | 209 | } |
173 | } | 210 | } |
174 | 211 |