From 8465bec2675d2f6b96b60a9ef59a95f4c25ef54e Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Sat, 29 Mar 2014 02:16:50 -0300 Subject: [PATCH] Corrige relatório de impressoras que msotrava data errada --- Entity/PrinterCounterRepository.php | 16 ++++++---------- Resources/views/Printer/index.html.twig | 12 ++++++++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Entity/PrinterCounterRepository.php b/Entity/PrinterCounterRepository.php index c16998f..4850187 100755 --- a/Entity/PrinterCounterRepository.php +++ b/Entity/PrinterCounterRepository.php @@ -23,20 +23,18 @@ class PrinterCounterRepository extends EntityRepository $_dql = "SELECT printer.id, - max(pc1.prints) as printsEnd, pc1.blackInk, pc1.coloredInk, max(pc1.date) as endDate, - min(pc2.prints) as printsStart, + max(pc1.prints) as printsEnd, min(pc2.date) as startDate, + min(pc2.prints) as printsStart, printer.name, printer.description, printer.host FROM CocarBundle:Printer printer - LEFT JOIN CocarBundle:PrinterCounter pc1 WITH pc1.printer = printer.id - LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc1.printer = pc2.printer AND pc2.date >= :start) - WHERE pc1.date <= :end - OR pc1.date IS NULL + LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) + LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc2.printer = printer.id AND pc2.date BETWEEN :start AND :end) GROUP BY printer.id, pc1.blackInk, pc1.coloredInk, @@ -71,10 +69,8 @@ class PrinterCounterRepository extends EntityRepository printer.host, (max(pc1.prints) - min(pc2.prints)) as totalPrints FROM CocarBundle:Printer printer - LEFT JOIN CocarBundle:PrinterCounter pc1 WITH pc1.printer = printer.id - LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc1.printer = pc2.printer AND pc2.date >= :start) - WHERE pc1.date <= :end - OR pc1.date IS NULL + LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) + LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc2.printer = printer.id AND pc2.date BETWEEN :start AND :end) GROUP BY printer.id, printer.name, printer.description, diff --git a/Resources/views/Printer/index.html.twig b/Resources/views/Printer/index.html.twig index 906fda2..eba89c5 100755 --- a/Resources/views/Printer/index.html.twig +++ b/Resources/views/Printer/index.html.twig @@ -36,9 +36,17 @@ {{ entity.name }} {{ entity.host }} {{ entity.printsStart }} - {{ entity.startDate|date("d/m/Y") }} + {% if entity.startDate %} + {{ entity.startDate|date("d/m/Y") }} + {% else %} + + {% endif %} {{ entity.printsEnd }} - {{ entity.endDate|date("d/m/Y") }} + {% if entity.endDate %} + {{ entity.endDate|date("d/m/Y") }} + {% else %} + + {% endif %} {{ (entity.printsEnd - entity.printsStart) }}