Commit 92dbffae255387158a65ecf5c859b158e420c9af
Exists in
master
and in
2 other branches
Conserta bug das impressoras que permitia mais de um registro na mesma data
Showing
1 changed file
with
11 additions
and
2 deletions
Show diff stats
Controller/PrinterController.php
... | ... | @@ -599,11 +599,20 @@ class PrinterController extends Controller |
599 | 599 | { |
600 | 600 | try |
601 | 601 | { |
602 | - $counter = new PrinterCounter; | |
602 | + // First try to find printer on the same date | |
603 | + $time = time(); | |
604 | + $counter = $this->getDoctrine()->getManager()->getRepository('CocarBundle:PrinterCounter')->findBy(array( | |
605 | + 'printer' => $printer, | |
606 | + 'date' => $time | |
607 | + )); | |
608 | + | |
609 | + if(empty($counter)) { | |
610 | + $counter = new PrinterCounter; | |
611 | + } | |
603 | 612 | |
604 | 613 | $counter->setPrinter($printer); |
605 | 614 | $counter->setPrints($prints); |
606 | - $counter->setDate(time()); | |
615 | + $counter->setDate($time); | |
607 | 616 | |
608 | 617 | $this->em->persist($counter); |
609 | 618 | $this->em->flush(); | ... | ... |