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,20 +23,18 @@ class PrinterCounterRepository extends EntityRepository | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | $_dql = "SELECT printer.id, | 25 | $_dql = "SELECT printer.id, |
| 26 | - max(pc1.prints) as printsEnd, | ||
| 27 | pc1.blackInk, | 26 | pc1.blackInk, |
| 28 | pc1.coloredInk, | 27 | pc1.coloredInk, |
| 29 | max(pc1.date) as endDate, | 28 | max(pc1.date) as endDate, |
| 30 | - min(pc2.prints) as printsStart, | 29 | + max(pc1.prints) as printsEnd, |
| 31 | min(pc2.date) as startDate, | 30 | min(pc2.date) as startDate, |
| 31 | + min(pc2.prints) as printsStart, | ||
| 32 | printer.name, | 32 | printer.name, |
| 33 | printer.description, | 33 | printer.description, |
| 34 | printer.host | 34 | printer.host |
| 35 | FROM CocarBundle:Printer printer | 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 | GROUP BY printer.id, | 38 | GROUP BY printer.id, |
| 41 | pc1.blackInk, | 39 | pc1.blackInk, |
| 42 | pc1.coloredInk, | 40 | pc1.coloredInk, |
| @@ -71,10 +69,8 @@ class PrinterCounterRepository extends EntityRepository | @@ -71,10 +69,8 @@ class PrinterCounterRepository extends EntityRepository | ||
| 71 | printer.host, | 69 | printer.host, |
| 72 | (max(pc1.prints) - min(pc2.prints)) as totalPrints | 70 | (max(pc1.prints) - min(pc2.prints)) as totalPrints |
| 73 | FROM CocarBundle:Printer printer | 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 | GROUP BY printer.id, | 74 | GROUP BY printer.id, |
| 79 | printer.name, | 75 | printer.name, |
| 80 | printer.description, | 76 | printer.description, |
Resources/views/Printer/index.html.twig
| @@ -36,9 +36,17 @@ | @@ -36,9 +36,17 @@ | ||
| 36 | <td>{{ entity.name }}</td> | 36 | <td>{{ entity.name }}</td> |
| 37 | <td>{{ entity.host }}</td> | 37 | <td>{{ entity.host }}</td> |
| 38 | <td>{{ entity.printsStart }}</td> | 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 | <td>{{ entity.printsEnd }}</td> | 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 | <td>{{ (entity.printsEnd - entity.printsStart) }}</td> | 50 | <td>{{ (entity.printsEnd - entity.printsStart) }}</td> |
| 43 | <td> | 51 | <td> |
| 44 | <ul> | 52 | <ul> |