Commit 8465bec2675d2f6b96b60a9ef59a95f4c25ef54e
1 parent
0d187465
Exists in
master
and in
2 other branches
Corrige relatório de impressoras que msotrava data errada
Showing
2 changed files
with
16 additions
and
12 deletions
Show diff stats
Entity/PrinterCounterRepository.php
... | ... | @@ -23,20 +23,18 @@ class PrinterCounterRepository extends EntityRepository |
23 | 23 | |
24 | 24 | |
25 | 25 | $_dql = "SELECT printer.id, |
26 | - max(pc1.prints) as printsEnd, | |
27 | 26 | pc1.blackInk, |
28 | 27 | pc1.coloredInk, |
29 | 28 | max(pc1.date) as endDate, |
30 | - min(pc2.prints) as printsStart, | |
29 | + max(pc1.prints) as printsEnd, | |
31 | 30 | min(pc2.date) as startDate, |
31 | + min(pc2.prints) as printsStart, | |
32 | 32 | printer.name, |
33 | 33 | printer.description, |
34 | 34 | printer.host |
35 | 35 | FROM CocarBundle:Printer printer |
36 | - LEFT JOIN CocarBundle:PrinterCounter pc1 WITH pc1.printer = printer.id | |
37 | - LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc1.printer = pc2.printer AND pc2.date >= :start) | |
38 | - WHERE pc1.date <= :end | |
39 | - OR pc1.date IS NULL | |
36 | + LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) | |
37 | + LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc2.printer = printer.id AND pc2.date BETWEEN :start AND :end) | |
40 | 38 | GROUP BY printer.id, |
41 | 39 | pc1.blackInk, |
42 | 40 | pc1.coloredInk, |
... | ... | @@ -71,10 +69,8 @@ class PrinterCounterRepository extends EntityRepository |
71 | 69 | printer.host, |
72 | 70 | (max(pc1.prints) - min(pc2.prints)) as totalPrints |
73 | 71 | FROM CocarBundle:Printer printer |
74 | - LEFT JOIN CocarBundle:PrinterCounter pc1 WITH pc1.printer = printer.id | |
75 | - LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc1.printer = pc2.printer AND pc2.date >= :start) | |
76 | - WHERE pc1.date <= :end | |
77 | - OR pc1.date IS NULL | |
72 | + LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) | |
73 | + LEFT JOIN CocarBundle:PrinterCounter pc2 WITH (pc2.printer = printer.id AND pc2.date BETWEEN :start AND :end) | |
78 | 74 | GROUP BY printer.id, |
79 | 75 | printer.name, |
80 | 76 | printer.description, | ... | ... |
Resources/views/Printer/index.html.twig
... | ... | @@ -36,9 +36,17 @@ |
36 | 36 | <td>{{ entity.name }}</td> |
37 | 37 | <td>{{ entity.host }}</td> |
38 | 38 | <td>{{ entity.printsStart }}</td> |
39 | - <td>{{ entity.startDate|date("d/m/Y") }}</td> | |
39 | + {% if entity.startDate %} | |
40 | + <td>{{ entity.startDate|date("d/m/Y") }}</td> | |
41 | + {% else %} | |
42 | + <td></td> | |
43 | + {% endif %} | |
40 | 44 | <td>{{ entity.printsEnd }}</td> |
41 | - <td>{{ entity.endDate|date("d/m/Y") }}</td> | |
45 | + {% if entity.endDate %} | |
46 | + <td>{{ entity.endDate|date("d/m/Y") }}</td> | |
47 | + {% else %} | |
48 | + <td></td> | |
49 | + {% endif %} | |
42 | 50 | <td>{{ (entity.printsEnd - entity.printsStart) }}</td> |
43 | 51 | <td> |
44 | 52 | <ul> | ... | ... |