Commit 99658c82f01debeeb668cda8d7c662518489e6f1
Exists in
master
and in
1 other branch
Merge remote-tracking branch 'origin/master'
Showing
12 changed files
with
291 additions
and
32 deletions
Show diff stats
src/Cacic/CommonBundle/Controller/LocalController.php
| ... | ... | @@ -136,7 +136,7 @@ class LocalController extends Controller |
| 136 | 136 | /** |
| 137 | 137 | * Primeiramente, remove as configurações aplicadas ao Local |
| 138 | 138 | */ |
| 139 | - $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->removerConfiguracoesDoLocal( $local ); | |
| 139 | + $this->getDoctrine()->getManager()->getRepository('CacicCommonBundle:Local')->excluirLocal( $local ); | |
| 140 | 140 | |
| 141 | 141 | $em->remove( $local ); // Tenta excluir o registro da base de dados |
| 142 | 142 | $em->flush(); |
| ... | ... | @@ -147,6 +147,7 @@ class LocalController extends Controller |
| 147 | 147 | } |
| 148 | 148 | catch ( \Doctrine\DBAL\DBALException $e ) |
| 149 | 149 | { |
| 150 | + $this->get('logger')->error("Erro na exclusão do local\n".$e->getMessage()); | |
| 150 | 151 | $out = array('status' => 'error', 'code' => false); |
| 151 | 152 | if ( preg_match('#SQLSTATE\[(\d+)\]#', $e->getMessage(), $tmp) ) |
| 152 | 153 | $out['code'] = $tmp[1]; | ... | ... |
src/Cacic/CommonBundle/Controller/UorgController.php
src/Cacic/CommonBundle/Entity/ComputadorColetaRepository.php
| ... | ... | @@ -46,7 +46,7 @@ class ComputadorColetaRepository extends EntityRepository |
| 46 | 46 | public function gerarRelatorioConfiguracoes( $filtros ) |
| 47 | 47 | { |
| 48 | 48 | $qb = $this->createQueryBuilder('coleta') |
| 49 | - ->select('IDENTITY(coleta.computador), coleta.teClassPropertyValue, comp.nmComputador, comp.teNodeAddress, comp.teIpComputador, so.idSo, so.inMswindows, so.sgSo, rede.idRede, local.nmLocal, local.idLocal') | |
| 49 | + ->select('IDENTITY(coleta.computador), coleta.teClassPropertyValue, comp.nmComputador, comp.teNodeAddress, comp.teIpComputador, so.idSo, so.inMswindows, so.sgSo, so.teDescSo, rede.idRede, local.nmLocal, local.idLocal') | |
| 50 | 50 | ->innerJoin('coleta.classProperty', 'property') |
| 51 | 51 | ->innerJoin('property.idClass', 'classe') |
| 52 | 52 | ->innerJoin('coleta.computador', 'comp') |
| ... | ... | @@ -244,7 +244,7 @@ class ComputadorColetaRepository extends EntityRepository |
| 244 | 244 | public function gerarRelatorioWMI( $filtros, $classe ) |
| 245 | 245 | { |
| 246 | 246 | $qb = $this->createQueryBuilder('coleta') |
| 247 | - ->select('property.nmPropertyName', 'coleta.teClassPropertyValue', 'so.idSo', 'so.inMswindows', 'so.sgSo', 'rede.idRede', 'rede.nmRede', 'rede.teIpRede', 'local.nmLocal', 'local.idLocal', 'count(DISTINCT coleta.computador) as numComp') | |
| 247 | + ->select('property.nmPropertyName', 'coleta.teClassPropertyValue', 'so.idSo', 'so.inMswindows', 'so.sgSo', 'so.teDescSo', 'rede.idRede', 'rede.nmRede', 'rede.teIpRede', 'local.nmLocal', 'local.idLocal', 'count(DISTINCT coleta.computador) as numComp') | |
| 248 | 248 | ->innerJoin('coleta.classProperty', 'property') |
| 249 | 249 | ->innerJoin('property.idClass', 'classe') |
| 250 | 250 | ->innerJoin('coleta.computador', 'comp') | ... | ... |
src/Cacic/CommonBundle/Entity/LocalRepository.php
| ... | ... | @@ -43,5 +43,73 @@ class LocalRepository extends EntityRepository |
| 43 | 43 | |
| 44 | 44 | return $this->getEntityManager()->createQuery( $_dql )->getArrayResult(); |
| 45 | 45 | } |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Retorna o último local cadastrado | |
| 49 | + * | |
| 50 | + * @return mixed | |
| 51 | + */ | |
| 52 | + | |
| 53 | + public function getMaxLocal($local) { | |
| 54 | + $_dql = "SELECT l | |
| 55 | + FROM CacicCommonBundle:Local l | |
| 56 | + WHERE l.idLocal <> :local | |
| 57 | + ORDER BY l.idLocal desc | |
| 58 | + "; | |
| 59 | + | |
| 60 | + return $this->getEntityManager() | |
| 61 | + ->createQuery( $_dql ) | |
| 62 | + ->setMaxResults(1) | |
| 63 | + ->setParameter('local', $local) | |
| 64 | + ->getSingleResult(); | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Move os usuários de local | |
| 69 | + * | |
| 70 | + * @param $local | |
| 71 | + */ | |
| 72 | + | |
| 73 | + public function moveUsuarios($local) { | |
| 74 | + $em = $this->getEntityManager(); | |
| 75 | + $usuarios = $local->getUsuarios(); | |
| 76 | + $maxLocal = $em->getRepository('CacicCommonBundle:Local')->getMaxLocal($local->getIdLocal()); | |
| 77 | + // Coloca cada usuário em no último local cadastrado | |
| 78 | + foreach ($usuarios as $modificar) { | |
| 79 | + $modificar->setIdLocal($maxLocal); | |
| 80 | + $em->persist($modificar); | |
| 81 | + } | |
| 82 | + $em->flush(); | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * Excluir local | |
| 87 | + * | |
| 88 | + * @param $local | |
| 89 | + */ | |
| 90 | + | |
| 91 | + public function excluirLocal($local) { | |
| 92 | + $em = $this->getEntityManager(); | |
| 93 | + $em->getRepository('CacicCommonBundle:ConfiguracaoLocal')->removerConfiguracoesDoLocal( $local ); | |
| 94 | + $em->getRepository('CacicCommonBundle:Local')->moveUsuarios( $local ); | |
| 95 | + | |
| 96 | + $config = $em->getRepository('CacicCommonBundle:PatrimonioConfigInterface')->findBy(array('local' => $local->getIdLocal())); | |
| 97 | + foreach ($config as $excluir) { | |
| 98 | + $em->remove($excluir); | |
| 99 | + } | |
| 100 | + | |
| 101 | + $config = $em->getRepository('CacicCommonBundle:UnidOrganizacionalNivel2')->findBy(array('idLocal' => $local->getIdLocal())); | |
| 102 | + foreach ($config as $excluir) { | |
| 103 | + $em->remove($excluir); | |
| 104 | + } | |
| 105 | + | |
| 106 | + $config = $em->getRepository('CacicCommonBundle:Rede')->findBy(array('idLocal' => $local->getIdLocal())); | |
| 107 | + foreach ($config as $excluir) { | |
| 108 | + $excluir->setIdLocal(null); | |
| 109 | + $em->persist($excluir); | |
| 110 | + } | |
| 111 | + | |
| 112 | + $em->flush(); | |
| 113 | + } | |
| 46 | 114 | |
| 47 | 115 | } |
| 48 | 116 | \ No newline at end of file | ... | ... |
src/Cacic/CommonBundle/Entity/RedeRepository.php
| ... | ... | @@ -38,13 +38,13 @@ class RedeRepository extends EntityRepository |
| 38 | 38 | { |
| 39 | 39 | $qb = $this->createQueryBuilder('r') |
| 40 | 40 | ->select('r.idRede','r.nmRede','r.teIpRede','r.teServCacic', 'r.teServUpdates', |
| 41 | - 'r.teMascaraRede', 'l.nmLocal', 'COUNT(comp.idComputador) AS numComp', 's.nmServidorAutenticacao','uorg.nmUorg') | |
| 41 | + 'r.teMascaraRede', 'l.sgLocal', 'COUNT(comp.idComputador) AS numComp', 's.nmServidorAutenticacao','uorg.nmUorg') | |
| 42 | 42 | ->innerJoin('CacicCommonBundle:Local', 'l', 'WITH', 'l.idLocal = r.idLocal') |
| 43 | 43 | ->leftJoin('CacicCommonBundle:ServidorAutenticacao', 's', 'WITH', 's.idServidorAutenticacao = r.idServidorAutenticacao') |
| 44 | 44 | ->leftJoin('CacicCommonBundle:Computador', 'comp', 'WITH', 'comp.idRede = r.idRede') |
| 45 | 45 | ->leftJoin('CacicCommonBundle:Uorg', 'uorg', 'WITH', 'uorg.rede = r.idRede') |
| 46 | - ->groupBy('r.idRede, r.nmRede, r.teIpRede, r.teServCacic, r.teServUpdates, r.teMascaraRede, l.nmLocal, s.nmServidorAutenticacao, uorg.nmUorg') | |
| 47 | - ->orderBy('r.teIpRede, l.nmLocal'); | |
| 46 | + ->groupBy('r.idRede, r.nmRede, r.teIpRede, r.teServCacic, r.teServUpdates, r.teMascaraRede, l.sgLocal, s.nmServidorAutenticacao, uorg.nmUorg') | |
| 47 | + ->orderBy('r.teIpRede, l.sgLocal'); | |
| 48 | 48 | |
| 49 | 49 | return $paginator->paginate( |
| 50 | 50 | $qb->getQuery()->execute(), | ... | ... |
src/Cacic/CommonBundle/Entity/UorgRepository.php
| ... | ... | @@ -42,12 +42,13 @@ class UorgRepository extends EntityRepository |
| 42 | 42 | */ |
| 43 | 43 | public function getFolhasDoNo( $idUorgPai ) |
| 44 | 44 | { |
| 45 | - $_dql = "SELECT uorg.idUorg, uorg.nmUorg, COUNT(filhas.idUorg) AS numFilhas | |
| 45 | + $_dql = "SELECT uorg.idUorg, uorg.nmUorg, r.idRede, COUNT(filhas.idUorg) AS numFilhas | |
| 46 | 46 | FROM CacicCommonBundle:Uorg uorg |
| 47 | 47 | INNER JOIN uorg.uorgPai pai |
| 48 | 48 | LEFT JOIN uorg.uorgFilhas filhas |
| 49 | + LEFT JOIN uorg.rede r | |
| 49 | 50 | WHERE pai.idUorg = :idUorgPai |
| 50 | - GROUP BY uorg.idUorg, uorg.nmUorg"; | |
| 51 | + GROUP BY uorg.idUorg, uorg.nmUorg, r.idRede"; | |
| 51 | 52 | |
| 52 | 53 | return $this->getEntityManager()->createQuery( $_dql ) |
| 53 | 54 | ->setParameter('idUorgPai', $idUorgPai) | ... | ... |
src/Cacic/CommonBundle/Resources/views/Rede/index.html.twig
| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 | <tr id="item_{{ rede['idRede'] }}" class="{{ cycle(['row0', 'row1'], loop.index) }}"> |
| 40 | 40 | <td>{{ rede['teIpRede'] }}/{{ rede['teMascaraRede']}}</td> |
| 41 | 41 | <td id="item_desc_{{ rede['idRede'] }}">{{ rede['nmRede'] }}</td> |
| 42 | - <td style="text-align: center">{{ rede['nmLocal']}}</td> | |
| 42 | + <td style="text-align: center">{{ rede['sgLocal']}}</td> | |
| 43 | 43 | <td style="text-align: center">{{ rede['numComp'] }}</td> |
| 44 | 44 | <td style="text-align: center">{{ rede['nmServidorAutenticacao'] }}</td> |
| 45 | 45 | <td style="text-align: center">{{ rede['teServCacic'] }}</td> |
| ... | ... | @@ -121,13 +121,20 @@ |
| 121 | 121 | <script type="text/javascript" src="{{ asset('bundles/caciccommon/jqTree-0.15/tree.jquery.js') }}"></script> |
| 122 | 122 | |
| 123 | 123 | <script type="text/javascript"> |
| 124 | + $( ".bt-vincular" ).click(function(){ | |
| 125 | + | |
| 126 | + var id = $( this ).parent().parent().attr( 'id' ).replace( /.*?(\d+)$/, '$1' ); | |
| 127 | + | |
| 128 | + $( "#vincularUORGs" ).data( 'id', id ).dialog( "open" ); | |
| 129 | + | |
| 124 | 130 | |
| 125 | - var _dados = [ // Unidades de primeiro nível | |
| 131 | + var _dados = [ // Unidades de primeiro nível | |
| 126 | 132 | {% for uorg in uorgs %} |
| 127 | 133 | { |
| 128 | 134 | label: '{{ uorg.nmUorg }}', |
| 129 | 135 | id: {{ uorg.idUorg }}, |
| 130 | - filha:{{ uorg.numFilhas }}, | |
| 136 | + rede: {% if uorg.idRede > 0%}{{ uorg.idRede }}{% else %}0{% endif %}, | |
| 137 | + filha: {{ uorg.numFilhas }}, | |
| 131 | 138 | load_on_demand: {% if uorg.numFilhas %}true {% else %}false{% endif %} |
| 132 | 139 | |
| 133 | 140 | }{% if loop.last != true %},{% endif %} |
| ... | ... | @@ -136,8 +143,6 @@ |
| 136 | 143 | ]; |
| 137 | 144 | |
| 138 | 145 | $(function() { |
| 139 | - | |
| 140 | - | |
| 141 | 146 | $('#vincularUORGs').tree({ |
| 142 | 147 | data: _dados, |
| 143 | 148 | dataUrl: function( node ) { |
| ... | ... | @@ -145,15 +150,21 @@ |
| 145 | 150 | }, |
| 146 | 151 | onCreateLi: function(node, $li) { |
| 147 | 152 | |
| 153 | + console.log(id); | |
| 148 | 154 | if(node.filha <= 0){ |
| 149 | - | |
| 150 | - var _acoesNode = ' <a onclick="('+ node.id +');"> <input type="checkbox" name="uorg" value="'+node.id+'" /></a> ' | |
| 151 | - } | |
| 155 | + if(node.rede == id){ | |
| 156 | + var _acoesNode = ' <a onclick="('+ node.id +');"> <input type="checkbox" checked name="uorg" value="'+node.id+'" /></a> ' | |
| 157 | + }else{ | |
| 158 | + var _acoesNode = ' <a onclick="('+ node.id +');"> <input type="checkbox" name="uorg" value="'+node.id+'" /></a> ' | |
| 159 | + } | |
| 160 | + } | |
| 152 | 161 | |
| 153 | 162 | if(node.filho <= 0){ |
| 154 | - | |
| 155 | - var _acoesNode = ' <a onclick="('+ node.id +');"> <input type="checkbox" name="uorg" value="'+node.id+'" /></a> ' | |
| 156 | - | |
| 163 | + if(node.rede == id){ | |
| 164 | + var _acoesNode = ' <a onclick="('+ node.id +');"> <input type="checkbox" checked name="uorg" value="'+node.id+'" /></a> ' | |
| 165 | + }else{ | |
| 166 | + var _acoesNode = ' <a onclick="('+ node.id +');"> <input type="checkbox" name="uorg" value="'+node.id+'" /></a> ' | |
| 167 | + } | |
| 157 | 168 | } |
| 158 | 169 | |
| 159 | 170 | $li.find('span.jqtree-title').after( _acoesNode ); |
| ... | ... | @@ -176,7 +187,7 @@ |
| 176 | 187 | }); |
| 177 | 188 | var senha = $( '#uorg' ).val(); |
| 178 | 189 | $( "#vincularUORGs" ).dialog({ |
| 179 | - autoOpen: false, | |
| 190 | + autoOpen: true, | |
| 180 | 191 | height: 550, |
| 181 | 192 | width: 550, |
| 182 | 193 | modal: true, |
| ... | ... | @@ -217,10 +228,7 @@ |
| 217 | 228 | |
| 218 | 229 | }); |
| 219 | 230 | |
| 220 | - $( ".bt-vincular" ).click(function(){ | |
| 221 | 231 | |
| 222 | - var id = $( this ).parent().parent().attr( 'id' ).replace( /.*?(\d+)$/, '$1' ); | |
| 223 | - $( "#vincularUORGs" ).data( 'id', id ).dialog( "open" ); | |
| 224 | 232 | }); |
| 225 | 233 | </script> |
| 226 | 234 | {% endblock %} | ... | ... |
src/Cacic/RelatorioBundle/Controller/HardwareController.php
| ... | ... | @@ -6,6 +6,12 @@ use Doctrine\Common\Util\Debug; |
| 6 | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 7 | 7 | use Symfony\Component\HttpFoundation\Request; |
| 8 | 8 | |
| 9 | +use Ddeboer\DataImport\Workflow; | |
| 10 | +use Ddeboer\DataImport\Reader\ArrayReader; | |
| 11 | +use Ddeboer\DataImport\Writer\CsvWriter; | |
| 12 | +use Ddeboer\DataImport\ValueConverter\CallbackValueConverter; | |
| 13 | +use Symfony\Component\HttpFoundation\BinaryFileResponse; | |
| 14 | + | |
| 9 | 15 | class HardwareController extends Controller |
| 10 | 16 | { |
| 11 | 17 | |
| ... | ... | @@ -75,9 +81,12 @@ class HardwareController extends Controller |
| 75 | 81 | */ |
| 76 | 82 | public function wmiRelatorioAction( Request $request, $classe ) |
| 77 | 83 | { |
| 84 | + $filtros = $request->get('rel_filtro_hardware'); | |
| 85 | + | |
| 78 | 86 | $dados = $this->getDoctrine() |
| 79 | 87 | ->getRepository('CacicCommonBundle:ComputadorColeta') |
| 80 | - ->gerarRelatorioWMI( $filtros = $request->get('rel_filtro_hardware'), $classe = $classe ); | |
| 88 | + ->gerarRelatorioWMI($filtros , $classe = $classe ); | |
| 89 | + | |
| 81 | 90 | |
| 82 | 91 | $locale = $request->getLocale(); |
| 83 | 92 | return $this->render( |
| ... | ... | @@ -85,6 +94,7 @@ class HardwareController extends Controller |
| 85 | 94 | array( |
| 86 | 95 | 'idioma'=> $locale, |
| 87 | 96 | 'dados' => $dados, |
| 97 | + 'filtros' => $filtros, | |
| 88 | 98 | 'classe' => $classe |
| 89 | 99 | ) |
| 90 | 100 | ); |
| ... | ... | @@ -117,18 +127,159 @@ class HardwareController extends Controller |
| 117 | 127 | |
| 118 | 128 | $dados = $this->getDoctrine() |
| 119 | 129 | ->getRepository('CacicCommonBundle:ComputadorColeta') |
| 120 | - ->gerarRelatorioWMIDetalhe( $filtros = $filtros, $classe = $classe ); | |
| 130 | + ->gerarRelatorioWMIDetalhe( $filtros, $classe ); | |
| 121 | 131 | |
| 122 | 132 | $locale = $request->getLocale(); |
| 133 | + | |
| 134 | + // Pega o idClassProperty | |
| 135 | + $idClassProperty = $this | |
| 136 | + ->getDoctrine() | |
| 137 | + ->getManager() | |
| 138 | + ->createQuery("SELECT p.idClassProperty FROM CacicCommonBundle:ClassProperty p WHERE p.nmPropertyName = :propriedade") | |
| 139 | + ->setParameter('propriedade', $propriedade) | |
| 140 | + ->getArrayResult(); | |
| 141 | + | |
| 142 | + // Corrige para fazer o parsing da variável | |
| 143 | + $item = array(); | |
| 144 | + foreach ($idClassProperty as $elm) { | |
| 145 | + array_push($item, $elm['idClassProperty']); | |
| 146 | + } | |
| 147 | + $filtros['conf'] = join($item, ","); | |
| 148 | + | |
| 123 | 149 | return $this->render( |
| 124 | 150 | 'CacicRelatorioBundle:Hardware:rel_wmi_detalhe.html.twig', |
| 125 | 151 | array( |
| 126 | 152 | 'idioma'=> $locale, |
| 127 | 153 | 'dados' => $dados, |
| 128 | 154 | 'propriedade' => $propriedade, |
| 155 | + 'filtros' => $filtros, | |
| 129 | 156 | 'classe' => $classe |
| 130 | 157 | ) |
| 131 | 158 | ); |
| 132 | 159 | } |
| 160 | + | |
| 161 | + /** | |
| 162 | + * [RELATÓRIO] Relatório CSV de atributos da classe WMI gerado à partir dos filtros informados | |
| 163 | + */ | |
| 164 | + public function csvWMIRelatorioAction( Request $request, $classe ) | |
| 165 | + { | |
| 166 | + $conf = $request->get('conf'); | |
| 167 | + $rede = $request->get('rede'); | |
| 168 | + $local = $request->get('local'); | |
| 169 | + $so = $request->get('so'); | |
| 170 | + | |
| 171 | + // Adiciona rede à lista de filtros se for fornecido | |
| 172 | + if (!empty($rede)) { | |
| 173 | + $filtros['redes'] = $rede; | |
| 174 | + } | |
| 175 | + | |
| 176 | + // Adiciona local à lista de filtros se for fornecido | |
| 177 | + if (!empty($local)) { | |
| 178 | + $filtros['locais'] = $local; | |
| 179 | + } | |
| 180 | + | |
| 181 | + // Adiciona SO à lista de filtros se for fornecido | |
| 182 | + if (!empty($so)) { | |
| 183 | + $filtros['so'] = $so; | |
| 184 | + } | |
| 185 | + | |
| 186 | + // Adiciona Propriedades à lista de filtros se for fornecido | |
| 187 | + if (!empty($conf)) { | |
| 188 | + $filtros['conf'] = $conf; | |
| 189 | + } | |
| 190 | + | |
| 191 | + $dados = $this->getDoctrine() | |
| 192 | + ->getRepository('CacicCommonBundle:ComputadorColeta') | |
| 193 | + ->gerarRelatorioWMI( $filtros, $classe ); | |
| 194 | + | |
| 195 | + $locale = $request->getLocale(); | |
| 196 | + | |
| 197 | + // Gera cabeçalho | |
| 198 | + $cabecalho = array(); | |
| 199 | + foreach($dados as $elm) { | |
| 200 | + array_push($cabecalho, array_keys($elm)); | |
| 201 | + break; | |
| 202 | + } | |
| 203 | + // Gera CSV | |
| 204 | + $reader = new ArrayReader(array_merge($cabecalho, $dados)); | |
| 205 | + | |
| 206 | + // Create the workflow from the reader | |
| 207 | + $workflow = new Workflow($reader); | |
| 208 | + | |
| 209 | + // Add the writer to the workflow | |
| 210 | + $tmpfile = tempnam(sys_get_temp_dir(), $classe.".csv"); | |
| 211 | + $file = new \SplFileObject($tmpfile, 'w'); | |
| 212 | + $writer = new CsvWriter($file); | |
| 213 | + $workflow->addWriter($writer); | |
| 214 | + | |
| 215 | + // Process the workflow | |
| 216 | + $workflow->process(); | |
| 217 | + | |
| 218 | + // Retorna o arquivo | |
| 219 | + $response = new BinaryFileResponse($tmpfile); | |
| 220 | + $response->headers->set('Content-Type', 'text/csv'); | |
| 221 | + $response->headers->set('Content-Disposition', "attachment; filename=$classe.csv"); | |
| 222 | + $response->headers->set('Content-Transfer-Encoding', 'binary'); | |
| 223 | + | |
| 224 | + return $response; | |
| 225 | + } | |
| 226 | + | |
| 227 | + public function csvWMIRelatorioDetalheAction( Request $request, $classe, $propriedade ) | |
| 228 | + { | |
| 229 | + $filtros['conf'] = $propriedade; | |
| 230 | + $rede = $request->get('rede'); | |
| 231 | + $local = $request->get('local'); | |
| 232 | + $so = $request->get('so'); | |
| 233 | + | |
| 234 | + // Adiciona rede à lista de filtros se for fornecido | |
| 235 | + if (!empty($rede)) { | |
| 236 | + $filtros['redes'] = $rede; | |
| 237 | + } | |
| 238 | + | |
| 239 | + // Adiciona local à lista de filtros se for fornecido | |
| 240 | + if (!empty($local)) { | |
| 241 | + $filtros['locais'] = $local; | |
| 242 | + } | |
| 243 | + | |
| 244 | + // Adiciona SO à lista de filtros se for fornecido | |
| 245 | + if (!empty($so)) { | |
| 246 | + $filtros['so'] = $so; | |
| 247 | + } | |
| 248 | + | |
| 249 | + $dados = $this->getDoctrine() | |
| 250 | + ->getRepository('CacicCommonBundle:ComputadorColeta') | |
| 251 | + ->gerarRelatorioWMIDetalhe( $filtros, $classe ); | |
| 252 | + | |
| 253 | + $locale = $request->getLocale(); | |
| 254 | + | |
| 255 | + // Gera cabeçalho | |
| 256 | + $cabecalho = array(); | |
| 257 | + foreach($dados as $elm) { | |
| 258 | + array_push($cabecalho, array_keys($elm)); | |
| 259 | + break; | |
| 260 | + } | |
| 261 | + // Gera CSV | |
| 262 | + $reader = new ArrayReader(array_merge($cabecalho, $dados)); | |
| 263 | + | |
| 264 | + // Create the workflow from the reader | |
| 265 | + $workflow = new Workflow($reader); | |
| 266 | + | |
| 267 | + // Add the writer to the workflow | |
| 268 | + $tmpfile = tempnam(sys_get_temp_dir(), $propriedade.".csv"); | |
| 269 | + $file = new \SplFileObject($tmpfile, 'w'); | |
| 270 | + $writer = new CsvWriter($file); | |
| 271 | + $workflow->addWriter($writer); | |
| 272 | + | |
| 273 | + // Process the workflow | |
| 274 | + $workflow->process(); | |
| 275 | + | |
| 276 | + // Retorna o arquivo | |
| 277 | + $response = new BinaryFileResponse($tmpfile); | |
| 278 | + $response->headers->set('Content-Type', 'text/csv'); | |
| 279 | + $response->headers->set('Content-Disposition', "attachment; filename=$propriedade.csv"); | |
| 280 | + $response->headers->set('Content-Transfer-Encoding', 'binary'); | |
| 281 | + | |
| 282 | + return $response; | |
| 283 | + } | |
| 133 | 284 | |
| 134 | 285 | } | ... | ... |
src/Cacic/RelatorioBundle/Resources/config/routing.yml
| ... | ... | @@ -166,4 +166,12 @@ cacic_inativos_listar_csv: |
| 166 | 166 | pattern: /inativos/listar/csv/{idRede}/{dtAcaoInicio}/{dtAcaoFim} |
| 167 | 167 | defaults: { _controller: CacicRelatorioBundle:Faturamento:listarInativosCsv, idRede: null, dtAcaoInicio: null, dtAcaoFim: null } |
| 168 | 168 | requirements: |
| 169 | - idRede: \d+ | |
| 170 | 169 | \ No newline at end of file |
| 170 | + idRede: \d+ | |
| 171 | + | |
| 172 | +cacic_relatorio_csv_hardware_wmi: | |
| 173 | + pattern: /csv/hardware/{classe} | |
| 174 | + defaults: { _controller: CacicRelatorioBundle:Hardware:csvWMIRelatorio } | |
| 175 | + | |
| 176 | +cacic_relatorio_csv_hardware_wmi_detalhe: | |
| 177 | + pattern: /csv/hardware/{classe}/{propriedade} | |
| 178 | + defaults: { _controller: CacicRelatorioBundle:Hardware:csvWMIRelatorioDetalhe } | |
| 171 | 179 | \ No newline at end of file | ... | ... |
src/Cacic/RelatorioBundle/Resources/views/Hardware/rel_wmi.html.twig
| ... | ... | @@ -5,14 +5,25 @@ |
| 5 | 5 | <h2>{{ 'Relatório de Configurações da Classe '|trans }} {{ classe }}</h2> |
| 6 | 6 | <h5>{{ 'Relatório gerado em'|trans }} {% if idioma == 'pt_BR' %}{{ "now"|date("d/m/Y H\\hi") }}{% else %}{{ "now"|date("m/d/Y H\\hi") }}{% endif %}</h5> |
| 7 | 7 | |
| 8 | + <form id="csv" action="{{ path('cacic_relatorio_csv_hardware_wmi', {'classe': classe}) }}" method="post"> | |
| 9 | + {% for elm, value in filtros %} | |
| 10 | + <input type="hidden" name="{{ elm }}" value="{{ value }}"> | |
| 11 | + {% endfor %} | |
| 12 | + <button class="btn btn-primary" type="submit"> | |
| 13 | + <i class="icon-bar-chart"></i> | |
| 14 | + Gerar CSV | |
| 15 | + </button> | |
| 16 | + </form> | |
| 17 | + | |
| 8 | 18 | <hr /> |
| 9 | 19 | |
| 10 | -<table class="table table-striped table-bordered"> | |
| 20 | + | |
| 21 | +<table class="display datatable" id="datatable"> | |
| 11 | 22 | <thead> |
| 12 | 23 | <tr> |
| 13 | - <th width="10%">{{ "Sistema Operacional"|trans }}</th> | |
| 24 | + <th width="20%">{{ "Sistema Operacional"|trans }}</th> | |
| 14 | 25 | <th width="10%">{{ "Local"|trans }}</th> |
| 15 | - <th width="10%">{{ "Subrede"|trans }}</th> | |
| 26 | + <th width="20%">{{ "Subrede"|trans }}</th> | |
| 16 | 27 | <th width="10%">{{ "Propriedade"|trans }}</th> |
| 17 | 28 | <th width="10%">{{ "Computadores"|trans }}</th> |
| 18 | 29 | <th>{{ "Valor"|trans }}</th> |
| ... | ... | @@ -22,7 +33,7 @@ |
| 22 | 33 | <tbody> |
| 23 | 34 | {% for reg in dados %} |
| 24 | 35 | <tr> |
| 25 | - <td><span class="{% if reg.inMswindows == 'S' %}red{% else %}blue{% endif %}"><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName, 'so': reg.idSo}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.sgSo }}</a></span></td> | |
| 36 | + <td><span class="{% if reg.inMswindows == 'S' %}red{% else %}blue{% endif %}"><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName, 'so': reg.idSo}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.teDescSo }}</a></span></td> | |
| 26 | 37 | <td><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName, 'local': reg.idLocal}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.nmLocal }}</a></td> |
| 27 | 38 | <td><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName, 'rede': reg.idRede}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.nmRede }} / {{ reg.teIpRede }}</a></td> |
| 28 | 39 | <td><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.nmPropertyName }}</a></td> | ... | ... |
src/Cacic/RelatorioBundle/Resources/views/Hardware/rel_wmi_detalhe.html.twig
| ... | ... | @@ -6,9 +6,19 @@ |
| 6 | 6 | <h3>{{ 'Dados relativos à Propriedade '|trans }}{{ propriedade }}</h3> |
| 7 | 7 | <h5>{{ 'Relatório gerado em'|trans }} {% if idioma == 'pt_BR' %}{{ "now"|date("d/m/Y H\\hi") }}{% else %}{{ "now"|date("m/d/Y H\\hi") }}{% endif %}</h5> |
| 8 | 8 | |
| 9 | + <form id="csv" action="{{ path('cacic_relatorio_csv_hardware_wmi_detalhe', { 'classe': classe, 'propriedade': propriedade }) }}" method="post"> | |
| 10 | + {% for elm, value in filtros %} | |
| 11 | + <input type="hidden" name="{{ elm }}" value="{{ value }}"> | |
| 12 | + {% endfor %} | |
| 13 | + <button class="btn btn-primary" type="submit"> | |
| 14 | + <i class="icon-bar-chart"></i> | |
| 15 | + Gerar CSV | |
| 16 | + </button> | |
| 17 | + </form> | |
| 18 | + | |
| 9 | 19 | <hr /> |
| 10 | 20 | |
| 11 | -<table class="table table-striped table-bordered"> | |
| 21 | +<table class="display datatable" id="datatable"> | |
| 12 | 22 | <thead> |
| 13 | 23 | <tr> |
| 14 | 24 | <th width="10%">{{ "Computador"|trans }}</th> | ... | ... |
src/Cacic/RelatorioBundle/Resources/views/Software/rel_inventariados.html.twig