Commit f408a131bc8948d00a4b08301220b3b14d9505f4

Authored by Eduardo Santos
1 parent 07a057ab
Exists in master and in 1 other branch 3.1

Conserta bug das impressoras que permitia mais de um registro na mesma data

src/Cacic/CommonBundle/DoctrineMigrations/Version20140801004047.php 0 → 100644
... ... @@ -0,0 +1,79 @@
  1 +<?php
  2 +
  3 +namespace Cacic\CommonBundle\Migrations;
  4 +
  5 +use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  6 +use Symfony\Component\DependencyInjection\ContainerInterface;
  7 +use Doctrine\DBAL\Migrations\AbstractMigration;
  8 +use Doctrine\DBAL\Schema\Schema;
  9 +
  10 +/**
  11 + * Auto-generated Migration: Please modify to your needs!
  12 + */
  13 +class Version20140801004047 extends AbstractMigration implements ContainerAwareInterface
  14 +{
  15 + private $container;
  16 +
  17 + public function setContainer(ContainerInterface $container = null)
  18 + {
  19 + $this->container = $container;
  20 + }
  21 +
  22 + public function up(Schema $schema)
  23 + {
  24 + // this up() migration is auto-generated, please modify it to your needs
  25 + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql", "Migration can only be executed safely on 'postgresql'.");
  26 + $logger = $this->container->get('logger');
  27 +
  28 + // Função de atualização da tabela de impressoras
  29 + $this->addSql("
  30 + CREATE OR REPLACE FUNCTION conserta_impressoras() RETURNS VOID AS $$
  31 +DECLARE
  32 + impr record;
  33 + v_id integer;
  34 +BEGIN
  35 + FOR impr IN select count(id) as impr,
  36 + date,
  37 + printer_id
  38 + from tb_printer_counter
  39 + group by date,
  40 + printer_id
  41 + having count(id) > 1 LOOP
  42 +
  43 + SELECT max(id) INTO v_id
  44 + FROM tb_printer_counter
  45 + WHERE date = impr.date
  46 + AND printer_id = impr.printer_id;
  47 +
  48 + RAISE NOTICE 'Removing log id = % printer_id = % date = %',v_id,impr.printer_id,impr.date;
  49 +
  50 + DELETE FROM tb_printer_counter
  51 + WHERE id <> v_id
  52 + AND date = impr.date
  53 + AND printer_id = impr.printer_id;
  54 +
  55 + END LOOP;
  56 +
  57 + RETURN;
  58 +END;
  59 +$$ LANGUAGE 'plpgsql';
  60 + ");
  61 +
  62 + $logger->info("Função de atualização das impressoras criada");
  63 +
  64 + $this->addSql("SELECT conserta_impressoras();");
  65 +
  66 + $logger->info("Impressoras arrumadas");
  67 +
  68 + $this->addSql("create unique index tb_printer_counter_date_uq on tb_printer_counter (date, printer_id);");
  69 +
  70 + $logger->info("Índice único criado");
  71 +
  72 + }
  73 +
  74 + public function down(Schema $schema)
  75 + {
  76 + // this down() migration is auto-generated, please modify it to your needs
  77 +
  78 + }
  79 +}
... ...
src/Cacic/RelatorioBundle/Resources/views/Hardware/rel_wmi.html.twig
... ... @@ -37,7 +37,7 @@
37 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>
38 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>
39 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>
40   - <td><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.numComp }}</a></td>
  40 + <td><a href="{{ path('cacic_relatorio_hardware_wmi_detalhe', {'classe': classe, 'propriedade': reg.nmPropertyName, 'so': reg.idSo, 'local': reg.idLocal, 'rede': reg.idRede}) }}" title="{{ "Lista de computadores"|trans }}" target="_blank">{{ reg.numComp }}</a></td>
41 41 <td>{{ reg.teClassPropertyValue }}</td>
42 42 </tr>
43 43 {% else %}
... ...