Commit bf562750d3b08312487dd3347534a11c8cb531fa

Authored by gedeson
1 parent 7e120ab0
Exists in master and in 1 other branch 3.1

Correçao de relatorio de patrimonio.

http://dev.lightbase.cc/issues/56
src/Cacic/CommonBundle/Entity/ComputadorColetaRepository.php
... ... @@ -270,7 +270,76 @@ class ComputadorColetaRepository extends EntityRepository
270 270 if ( array_key_exists('conf', $filtros) && !empty($filtros['conf']) )
271 271 $qb->andWhere('property.idClassProperty IN (:conf)')->setParameter('conf', explode( ',', $filtros['conf'] ));
272 272  
  273 + return $qb->getQuery()->execute();
  274 + }
  275 +
  276 + public function gerarRelatorioPatrimonio($filtros)
  277 + {
  278 + // Monta a Consulta básica...
  279 + $qb = $this->createQueryBuilder('coleta')
  280 + ->select( 'DISTINCT(comp.nmComputador), so.sgSo, class.nmPropertyName, coleta.teClassPropertyValue,
  281 + r.teIpRede, r.idRede, r.nmRede, l.nmLocal, comp.idComputador,so.inMswindows, u.nmUorg')
  282 + ->innerJoin('CacicCommonBundle:Computador', 'comp','WITH','coleta.computador = comp.idComputador')
  283 + ->innerJoin('CacicCommonBundle:PropriedadeSoftware', 'prop', 'WITH', 'comp.idComputador = prop.computador')
  284 + ->innerJoin('CacicCommonBundle:ClassProperty', 'class','WITH', 'coleta.classProperty = class.idClassProperty')
  285 + ->innerJoin('CacicCommonBundle:Classe', 'classe','WITH', 'class.idClass = classe.idClass')
  286 + ->leftJoin('CacicCommonBundle:So', 'so','WITH','comp.idSo = so.idSo')
  287 + ->leftJoin('CacicCommonBundle:Rede', 'r','WITH', 'comp.idRede = r.idRede')
  288 + ->innerJoin('CacicCommonBundle:Uorg','u','WITH', 'r.idRede = u.rede')
  289 + ->innerJoin('CacicCommonBundle:Local','l','WITH', 'r.idLocal = l.idLocal')
  290 + ->groupBy('comp.nmComputador,r.idRede, class.nmPropertyName, u.nmUorg, coleta.teClassPropertyValue,so.sgSo, r.teIpRede, l.nmLocal, r.nmRede, comp.idComputador,so.inMswindows')
  291 + ->orderBy('r.teIpRede, l.nmLocal');
  292 +
  293 + /*
  294 + * Verifica os filtros que foram parametrizados
  295 + */
  296 +
  297 + if ( array_key_exists('locais', $filtros) && !empty($filtros['locais']) )
  298 + $qb->andWhere('l.idLocal IN (:locais)')->setParameter('locais', explode( ',', $filtros['locais'] ));
  299 +
  300 + if ( array_key_exists('so', $filtros) && !empty($filtros['so']) )
  301 + $qb->andWhere('comp.idSo IN (:so)')->setParameter('so', explode( ',', $filtros['so'] ));
  302 +
  303 + if ( array_key_exists('conf', $filtros) && !empty($filtros['conf']) )
  304 + $qb->andWhere('class.idClassProperty IN (:conf)')->setParameter('conf', explode( ',', $filtros['conf'] ));
  305 +
  306 + if ( array_key_exists('uorg', $filtros) && !empty($filtros['uorg']) )
  307 + $qb->andWhere('u.idUorg IN (:uorg)')->setParameter('uorg', explode( ',', $filtros['uorg'] ));
273 308  
274 309 return $qb->getQuery()->execute();
275 310 }
  311 +
  312 + public function gerarRelatorioSemPatrimonio($filtros)
  313 + {
  314 + // Monta a Consulta básica...
  315 + $qb = $this->createQueryBuilder('coleta')
  316 + ->select( 'DISTINCT(comp.nmComputador), so.sgSo,
  317 + r.teIpRede, r.idRede, r.nmRede, l.nmLocal, comp.idComputador,so.inMswindows, u.nmUorg')
  318 + ->innerJoin('CacicCommonBundle:Computador', 'comp','WITH','coleta.computador = comp.idComputador')
  319 + ->innerJoin('CacicCommonBundle:PropriedadeSoftware', 'prop', 'WITH', 'comp.idComputador = prop.computador')
  320 + ->innerJoin('CacicCommonBundle:ClassProperty', 'class','WITH', 'coleta.classProperty = class.idClassProperty')
  321 + ->innerJoin('CacicCommonBundle:Classe', 'classe','WITH', 'class.idClass = classe.idClass')
  322 + ->leftJoin('CacicCommonBundle:So', 'so','WITH','comp.idSo = so.idSo')
  323 + ->leftJoin('CacicCommonBundle:Rede', 'r','WITH', 'comp.idRede = r.idRede')
  324 + ->innerJoin('CacicCommonBundle:Uorg','u','WITH', 'r.idRede = u.rede')
  325 + ->innerJoin('CacicCommonBundle:Local','l','WITH', 'r.idLocal = l.idLocal')
  326 + ->groupBy('comp.nmComputador,r.idRede, u.nmUorg,so.sgSo, r.teIpRede, l.nmLocal, r.nmRede, comp.idComputador,so.inMswindows')
  327 + ->orderBy('r.teIpRede, l.nmLocal');
  328 +
  329 + /*
  330 + * Verifica os filtros que foram parametrizados
  331 + */
  332 +
  333 + if ( array_key_exists('locais', $filtros) && !empty($filtros['locais']) )
  334 + $qb->andWhere('l.idLocal IN (:locais)')->setParameter('locais', explode( ',', $filtros['locais'] ));
  335 +
  336 + if ( array_key_exists('so', $filtros) && !empty($filtros['so']) )
  337 + $qb->andWhere('comp.idSo IN (:so)')->setParameter('so', explode( ',', $filtros['so'] ));
  338 +
  339 +
  340 + if ( array_key_exists('uorg', $filtros) && !empty($filtros['uorg']) )
  341 + $qb->andWhere('u.idUorg IN (:uorg)')->setParameter('uorg', explode( ',', $filtros['uorg'] ));
  342 +
  343 + return $qb->getQuery()->execute();
  344 + }
276 345 }
... ...
src/Cacic/CommonBundle/Entity/UorgRepository.php
... ... @@ -15,7 +15,8 @@ class UorgRepository extends EntityRepository
15 15 public function listar()
16 16 {
17 17 $_dql = "SELECT uorg.idUorg, uorg.nmUorg
18   - FROM CacicCommonBundle:Uorg uorg";
  18 + FROM CacicCommonBundle:Uorg uorg
  19 + ORDER BY uorg.uorgPai DESC, uorg.idUorg DESC ";
19 20  
20 21 return $this->getEntityManager()->createQuery( $_dql )->getArrayResult();
21 22 }
... ...
src/Cacic/RelatorioBundle/Controller/DefaultController.php
... ... @@ -30,15 +30,13 @@ class DefaultController extends Controller
30 30 {
31 31 $locais = $this->getDoctrine()->getRepository('CacicCommonBundle:Local')->listar();
32 32 $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->listar();
33   - $sw = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->listarSoftware();
34 33 $uorg = $this->getDoctrine()->getRepository('CacicCommonBundle:Uorg')->listar();
35 34 $conf = $this->getDoctrine()->getRepository('CacicCommonBundle:ComputadorColeta')->listarPropriedades('Patrimonio');
36   -//
  35 +
37 36  
38 37 return $this->render(
39 38 'CacicRelatorioBundle:Default:patrimonio.html.twig',
40 39 array(
41   - 'sw' => $sw,
42 40 'locais' => $locais,
43 41 'so' => $so,
44 42 'conf' => $conf,
... ... @@ -51,22 +49,26 @@ class DefaultController extends Controller
51 49 */
52 50 public function patrimonioRelatorioAction( Request $request )
53 51 {
54   - $filtros = $request->get('rel_filtro_patrimonio');
55   - $locale = $request->getLocale();
56   - $dados = $this->getDoctrine()
57   - ->getRepository('CacicCommonBundle:Software')
58   - ->gerarRelatorioPatrimonio( $filtros );
  52 + $filtros = $request->get('rel_filtro_patrimonio');
  53 + $locale = $request->getLocale();
  54 +
  55 + if($filtros['conf'] <> ""){
  56 + $dados = $this->getDoctrine()
  57 + ->getRepository('CacicCommonBundle:ComputadorColeta')
  58 + ->gerarRelatorioPatrimonio( $filtros );
  59 + }
  60 + else{
  61 + $dados = $this->getDoctrine()
  62 + ->getRepository('CacicCommonBundle:ComputadorColeta')
  63 + ->gerarRelatorioSemPatrimonio( $filtros );
  64 + }
59 65  
60   - // Debug::dump($filtros);die;
61 66 return $this->render(
62 67 'CacicRelatorioBundle:Default:rel_patrimonio.html.twig',
63 68 array(
64 69 'idioma'=>$locale,
65   - 'dados' => $dados,/*
66   - 'menu' => (bool) strlen( $filtros['pci']),*/
67   - 'exibirColunaSoftware' => (bool) strlen( $filtros['softwares']
68   -
69   - )
  70 + 'dados' => $dados,
  71 + 'menu' => (bool) strlen( $filtros['conf'])
70 72 )
71 73 );
72 74 }
... ...
src/Cacic/RelatorioBundle/Resources/views/Default/patrimonio.html.twig
... ... @@ -14,19 +14,11 @@
14 14 <script src="{{ asset('bundles/cacicrelatorio/libs/bootstrap-transfer-master/js/bootstrap-transfer.js') }}" type="text/javascript"></script>
15 15 <script type="text/javascript">
16 16 $(document).ready(function(){
17   - var tSW = $('#transferSW').bootstrapTransfer({'target_id':'tSw'});
18 17 var tLoc = $('#transferLocais').bootstrapTransfer({'target_id':'tLoc'});
19 18 var tSO = $('#transferSO').bootstrapTransfer({'target_id':'tSo'});
20 19 var tConf = $('#transferConf').bootstrapTransfer({'target_id':'tConf'});
21 20 var tUorg = $('#transferUorg').bootstrapTransfer({'target_id':'tUorg'});
22 21  
23   - tSW.populate([ // Popula o TRANSFER com Softwares
24   - {% for sw in sw %}
25   - {value: "{{ sw['idSoftware'] }}", content:"{{ sw['nmSoftware'] }}"}{% if loop.last != true %},{% endif %}
26   -
27   - {% endfor %}
28   - ]);
29   -
30 22 tLoc.populate([ // Popula o TRANSFER com Locais
31 23 {% for l in locais %}
32 24 {value: "{{ l[0]['idLocal'] }}", content:"{{ l[0]['nmLocal'] ~ '/' ~ l[0]['sgLocal'] }}"}{% if loop.last != true %},{% endif %}
... ... @@ -60,7 +52,6 @@
60 52 'form' : $('#frmFiltroRelatorioPatrimonio'),
61 53 'fieldsPrefix' : 'rel_filtro_patrimonio',
62 54 'elms' : [
63   - { 'transferElement' : tSW , 'inputHiddenName' : 'softwares' },
64 55 { 'transferElement' : tLoc , 'inputHiddenName' : 'locais' },
65 56 { 'transferElement' : tSO , 'inputHiddenName' : 'so' },
66 57 { 'transferElement' : tUorg , 'inputHiddenName' : 'uorg' },
... ... @@ -101,9 +92,6 @@
101 92 <h4>{{ 'Selecione as informações que deseja exibir'|trans }}</h4>
102 93 <div id="transferConf"></div>
103 94  
104   - <h4>{{ 'Selecione os Softwares que deseja exibir'|trans }}</h4>
105   - <div id="transferSW"></div>
106   -
107 95 <h4>{{ 'Selecione os Locais'|trans }}</h4>
108 96 <div id="transferLocais"></div>
109 97  
... ...
src/Cacic/RelatorioBundle/Resources/views/Default/rel_patrimonio.html.twig
... ... @@ -7,7 +7,7 @@
7 7  
8 8 <hr />
9 9  
10   - <table class="table table-striped table-bordered">
  10 + <table class="display datatable" id="datatable">
11 11 <thead>
12 12 <tr>
13 13 <th width="5%" style="text-align: center"></th>
... ... @@ -15,9 +15,11 @@
15 15 <th width="10%">{{ "S.O"|trans }}</th>
16 16 <th width="20%">{{ "Sub-rede"|trans }}</th>
17 17 <th width="10%">{{ "Local"|trans }}</th>
18   - {% if ( exibirColunaSoftware ) %}
19   - <th width="20%">{{ "Software"|trans }}</th>
20   - {% endif %}
  18 + <th width="5%">{{ "Unidade" }}</th>
  19 + {% if menu %}
  20 + <th width="10%">{{ "Propriedade"|trans }}</th>
  21 + <th width="10%">{{ "Valor"|trans }}</th>
  22 + {% endif %}
21 23  
22 24  
23 25 </tr>
... ... @@ -39,16 +41,17 @@
39 41 {{ reg['teIpRede'] }}/{{ reg['nmRede'] }}
40 42 </a></td>
41 43 <td>{{ reg['nmLocal'] }}</td>
42   - {% if ( exibirColunaSoftware ) %}
43   - <td>{{ reg['nmSoftware'] }}</td>
  44 + <td>{{ reg['nmUorg'] }}</td>
  45 + {% if ( menu ) %}
  46 + <td>{{ reg['nmPropertyName'] }}</td>
  47 + <td>{{ reg['teClassPropertyValue'] }}</td>
44 48 {% endif %}
45 49  
46   -
47 50 </tr>
48 51  
49 52 {% else %}
50 53 <tr>
51   - <td style="text-align: center" colspan="{% if ( exibirColunaSoftware ) %}5{% else %}4{% endif %}"><b>{{ "NENHUM REGISTRO ENCONTRADO!"|trans }}</b></td>
  54 + <td style="text-align: center" colspan="{% if ( menu ) %}6{% else %}5{% endif %}"><b>{{ "NENHUM REGISTRO ENCONTRADO!"|trans }}</b></td>
52 55 </tr>
53 56 {% endfor %}
54 57  
... ...