Commit 2fc869b73608ed4d7821e7a2752cd555fc912dfd
1 parent
8465bec2
Exists in
master
and in
2 other branches
inclusao de campos local e série
Showing
10 changed files
with
99 additions
and
6 deletions
Show diff stats
Controller/PrinterController.php
| @@ -25,8 +25,6 @@ use Doctrine\ORM\EntityManager; | @@ -25,8 +25,6 @@ use Doctrine\ORM\EntityManager; | ||
| 25 | use Symfony\Component\HttpFoundation\StreamedResponse; | 25 | use Symfony\Component\HttpFoundation\StreamedResponse; |
| 26 | 26 | ||
| 27 | use Symfony\Component\HttpFoundation\BinaryFileResponse; | 27 | use Symfony\Component\HttpFoundation\BinaryFileResponse; |
| 28 | - | ||
| 29 | - | ||
| 30 | /** | 28 | /** |
| 31 | * Printer controller. | 29 | * Printer controller. |
| 32 | * | 30 | * |
| @@ -106,12 +104,12 @@ class PrinterController extends Controller | @@ -106,12 +104,12 @@ class PrinterController extends Controller | ||
| 106 | $displayAll = true; | 104 | $displayAll = true; |
| 107 | 105 | ||
| 108 | $printers = $em->getRepository('CocarBundle:PrinterCounter')->relatorioGeral($start, $end); | 106 | $printers = $em->getRepository('CocarBundle:PrinterCounter')->relatorioGeral($start, $end); |
| 109 | - | ||
| 110 | if(!$displayAll) | 107 | if(!$displayAll) |
| 111 | { | 108 | { |
| 112 | $paginator = $this->get('knp_paginator'); | 109 | $paginator = $this->get('knp_paginator'); |
| 113 | $printers = $paginator->paginate($printers, $this->get('request')->query->get('page', 1), 10); | 110 | $printers = $paginator->paginate($printers, $this->get('request')->query->get('page', 1), 10); |
| 114 | } | 111 | } |
| 112 | + | ||
| 115 | return array( | 113 | return array( |
| 116 | "printer" => $printers, | 114 | "printer" => $printers, |
| 117 | //"printerCounter" => $pCounter, | 115 | //"printerCounter" => $pCounter, |
| @@ -120,6 +118,7 @@ class PrinterController extends Controller | @@ -120,6 +118,7 @@ class PrinterController extends Controller | ||
| 120 | "end" => $end, | 118 | "end" => $end, |
| 121 | "displayAll" => $displayAll | 119 | "displayAll" => $displayAll |
| 122 | ); | 120 | ); |
| 121 | + | ||
| 123 | } | 122 | } |
| 124 | 123 | ||
| 125 | /** | 124 | /** |
| @@ -258,7 +257,6 @@ class PrinterController extends Controller | @@ -258,7 +257,6 @@ class PrinterController extends Controller | ||
| 258 | $em = $this->getDoctrine()->getManager(); | 257 | $em = $this->getDoctrine()->getManager(); |
| 259 | 258 | ||
| 260 | $entity = $em->getRepository('CocarBundle:Printer')->find($id); | 259 | $entity = $em->getRepository('CocarBundle:Printer')->find($id); |
| 261 | - | ||
| 262 | if (!$entity) { | 260 | if (!$entity) { |
| 263 | throw $this->createNotFoundException('Unable to find Printer entity.'); | 261 | throw $this->createNotFoundException('Unable to find Printer entity.'); |
| 264 | } | 262 | } |
Entity/Printer.php
| @@ -56,6 +56,20 @@ class Printer | @@ -56,6 +56,20 @@ class Printer | ||
| 56 | private $host; | 56 | private $host; |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | + * @var string | ||
| 60 | + * | ||
| 61 | + * @ORM\Column(name="serie", type="text", nullable=true) | ||
| 62 | + */ | ||
| 63 | + private $serie; | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * @var string | ||
| 67 | + * | ||
| 68 | + * @ORM\Column(name="local", type="text", nullable=true) | ||
| 69 | + */ | ||
| 70 | + private $local; | ||
| 71 | + | ||
| 72 | + /** | ||
| 59 | * Construct | 73 | * Construct |
| 60 | */ | 74 | */ |
| 61 | public function __construct() | 75 | public function __construct() |
| @@ -166,6 +180,52 @@ class Printer | @@ -166,6 +180,52 @@ class Printer | ||
| 166 | } | 180 | } |
| 167 | 181 | ||
| 168 | /** | 182 | /** |
| 183 | + * Set serie | ||
| 184 | + * | ||
| 185 | + * @param string $serie | ||
| 186 | + * @return Printer | ||
| 187 | + */ | ||
| 188 | + public function setSerie($serie) | ||
| 189 | + { | ||
| 190 | + $this->serie = $serie; | ||
| 191 | + | ||
| 192 | + return $this; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * Get serie | ||
| 197 | + * | ||
| 198 | + * @return string | ||
| 199 | + */ | ||
| 200 | + public function getSerie() | ||
| 201 | + { | ||
| 202 | + return $this->serie; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + /** | ||
| 206 | + * Set local | ||
| 207 | + * | ||
| 208 | + * @param string $local | ||
| 209 | + * @return Printer | ||
| 210 | + */ | ||
| 211 | + public function setLocal($local) | ||
| 212 | + { | ||
| 213 | + $this->local = $local; | ||
| 214 | + | ||
| 215 | + return $this; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + /** | ||
| 219 | + * Get local | ||
| 220 | + * | ||
| 221 | + * @return string | ||
| 222 | + */ | ||
| 223 | + public function getLocal() | ||
| 224 | + { | ||
| 225 | + return $this->local; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 169 | * Add printerCounter | 229 | * Add printerCounter |
| 170 | * | 230 | * |
| 171 | * @param \Cocar\CocarBundle\Entity\PrinterCounter $printerCounter | 231 | * @param \Cocar\CocarBundle\Entity\PrinterCounter $printerCounter |
Entity/PrinterCounterRepository.php
| @@ -10,6 +10,7 @@ use Doctrine\ORM\EntityRepository; | @@ -10,6 +10,7 @@ use Doctrine\ORM\EntityRepository; | ||
| 10 | * This class was generated by the Doctrine ORM. Add your own custom | 10 | * This class was generated by the Doctrine ORM. Add your own custom |
| 11 | * repository methods below. | 11 | * repository methods below. |
| 12 | */ | 12 | */ |
| 13 | +//acrescentado serie e local | ||
| 13 | class PrinterCounterRepository extends EntityRepository | 14 | class PrinterCounterRepository extends EntityRepository |
| 14 | { | 15 | { |
| 15 | /** | 16 | /** |
| @@ -31,6 +32,8 @@ class PrinterCounterRepository extends EntityRepository | @@ -31,6 +32,8 @@ class PrinterCounterRepository extends EntityRepository | ||
| 31 | min(pc2.prints) as printsStart, | 32 | min(pc2.prints) as printsStart, |
| 32 | printer.name, | 33 | printer.name, |
| 33 | printer.description, | 34 | printer.description, |
| 35 | + printer.serie, | ||
| 36 | + printer.local, | ||
| 34 | printer.host | 37 | printer.host |
| 35 | FROM CocarBundle:Printer printer | 38 | FROM CocarBundle:Printer printer |
| 36 | LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) | 39 | LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) |
| @@ -40,7 +43,9 @@ class PrinterCounterRepository extends EntityRepository | @@ -40,7 +43,9 @@ class PrinterCounterRepository extends EntityRepository | ||
| 40 | pc1.coloredInk, | 43 | pc1.coloredInk, |
| 41 | printer.name, | 44 | printer.name, |
| 42 | printer.description, | 45 | printer.description, |
| 43 | - printer.host | 46 | + printer.host, |
| 47 | + printer.serie, | ||
| 48 | + printer.local | ||
| 44 | ORDER BY printer.id ASC"; | 49 | ORDER BY printer.id ASC"; |
| 45 | 50 | ||
| 46 | return $this->getEntityManager()->createQuery( $_dql ) | 51 | return $this->getEntityManager()->createQuery( $_dql ) |
| @@ -67,6 +72,8 @@ class PrinterCounterRepository extends EntityRepository | @@ -67,6 +72,8 @@ class PrinterCounterRepository extends EntityRepository | ||
| 67 | min(pc2.date) as startDate, | 72 | min(pc2.date) as startDate, |
| 68 | printer.name, | 73 | printer.name, |
| 69 | printer.host, | 74 | printer.host, |
| 75 | + printer.serie, | ||
| 76 | + printer.local, | ||
| 70 | (max(pc1.prints) - min(pc2.prints)) as totalPrints | 77 | (max(pc1.prints) - min(pc2.prints)) as totalPrints |
| 71 | FROM CocarBundle:Printer printer | 78 | FROM CocarBundle:Printer printer |
| 72 | LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) | 79 | LEFT JOIN CocarBundle:PrinterCounter pc1 WITH (pc1.printer = printer.id AND pc1.date BETWEEN :start AND :end) |
| @@ -74,7 +81,9 @@ class PrinterCounterRepository extends EntityRepository | @@ -74,7 +81,9 @@ class PrinterCounterRepository extends EntityRepository | ||
| 74 | GROUP BY printer.id, | 81 | GROUP BY printer.id, |
| 75 | printer.name, | 82 | printer.name, |
| 76 | printer.description, | 83 | printer.description, |
| 77 | - printer.host | 84 | + printer.host, |
| 85 | + printer.serie, | ||
| 86 | + printer.local | ||
| 78 | ORDER BY printer.id ASC"; | 87 | ORDER BY printer.id ASC"; |
| 79 | 88 | ||
| 80 | return $this->getEntityManager()->createQuery( $_dql ) | 89 | return $this->getEntityManager()->createQuery( $_dql ) |
Form/PrinterType.php
| @@ -19,6 +19,8 @@ class PrinterType extends AbstractType | @@ -19,6 +19,8 @@ class PrinterType extends AbstractType | ||
| 19 | ->add('description') | 19 | ->add('description') |
| 20 | ->add('communitySnmpPrinter') | 20 | ->add('communitySnmpPrinter') |
| 21 | ->add('host') | 21 | ->add('host') |
| 22 | + ->add('serie') | ||
| 23 | + ->add('local') | ||
| 22 | ; | 24 | ; |
| 23 | } | 25 | } |
| 24 | 26 |
Resources/views/Printer/edit.html.twig
| @@ -25,6 +25,14 @@ | @@ -25,6 +25,14 @@ | ||
| 25 | {{ form_widget(edit_form.host) }} | 25 | {{ form_widget(edit_form.host) }} |
| 26 | </div> | 26 | </div> |
| 27 | <div class="item-form"> | 27 | <div class="item-form"> |
| 28 | + <label>Serie:</label> | ||
| 29 | + {{ form_widget(edit_form.serie) }} | ||
| 30 | + </div> | ||
| 31 | + <div class="item-form"> | ||
| 32 | + <label>Local:</label> | ||
| 33 | + {{ form_widget(edit_form.local) }} | ||
| 34 | + </div> | ||
| 35 | + <div class="item-form"> | ||
| 28 | <button type="submit">Editar</button> | 36 | <button type="submit">Editar</button> |
| 29 | </div> | 37 | </div> |
| 30 | </div> | 38 | </div> |
Resources/views/Printer/index.html.twig
| @@ -21,6 +21,8 @@ | @@ -21,6 +21,8 @@ | ||
| 21 | <th>Id</th> | 21 | <th>Id</th> |
| 22 | <th>Nome</th> | 22 | <th>Nome</th> |
| 23 | <th>Host</th> | 23 | <th>Host</th> |
| 24 | + <th>Serie</th> | ||
| 25 | + <th>Local</th> | ||
| 24 | <th>Contador Inicial</th> | 26 | <th>Contador Inicial</th> |
| 25 | <th>Data Inicial</th> | 27 | <th>Data Inicial</th> |
| 26 | <th>Contador Final</th> | 28 | <th>Contador Final</th> |
| @@ -35,6 +37,8 @@ | @@ -35,6 +37,8 @@ | ||
| 35 | <td><a href="{{ path('printer_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td> | 37 | <td><a href="{{ path('printer_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td> |
| 36 | <td>{{ entity.name }}</td> | 38 | <td>{{ entity.name }}</td> |
| 37 | <td>{{ entity.host }}</td> | 39 | <td>{{ entity.host }}</td> |
| 40 | + <td>{{ entity.serie }}</td> | ||
| 41 | + <td>{{ entity.local }}</td> | ||
| 38 | <td>{{ entity.printsStart }}</td> | 42 | <td>{{ entity.printsStart }}</td> |
| 39 | {% if entity.startDate %} | 43 | {% if entity.startDate %} |
| 40 | <td>{{ entity.startDate|date("d/m/Y") }}</td> | 44 | <td>{{ entity.startDate|date("d/m/Y") }}</td> |
Resources/views/Printer/new.html.twig
| @@ -26,6 +26,14 @@ | @@ -26,6 +26,14 @@ | ||
| 26 | {{ form_errors(form.host) }} | 26 | {{ form_errors(form.host) }} |
| 27 | </div> | 27 | </div> |
| 28 | <div class="item-form"> | 28 | <div class="item-form"> |
| 29 | + <label>Serie:</label> | ||
| 30 | + {{ form_widget(form.serie) }} | ||
| 31 | + </div> | ||
| 32 | + <div class="item-form"> | ||
| 33 | + <label>Local:</label> | ||
| 34 | + {{ form_widget(form.local) }} | ||
| 35 | + </div> | ||
| 36 | + <div class="item-form"> | ||
| 29 | <button type="submit">Cadastrar</button> | 37 | <button type="submit">Cadastrar</button> |
| 30 | </div> | 38 | </div> |
| 31 | </div> | 39 | </div> |
Resources/views/Printer/show.html.twig
| @@ -11,6 +11,8 @@ | @@ -11,6 +11,8 @@ | ||
| 11 | <th>Description</th> | 11 | <th>Description</th> |
| 12 | <th>Community</th> | 12 | <th>Community</th> |
| 13 | <th>Host</th> | 13 | <th>Host</th> |
| 14 | + <th>Serie</th> | ||
| 15 | + <th>Local</th> | ||
| 14 | </tr> | 16 | </tr> |
| 15 | </thead> | 17 | </thead> |
| 16 | <tbody> | 18 | <tbody> |
| @@ -20,6 +22,8 @@ | @@ -20,6 +22,8 @@ | ||
| 20 | <td>{{ entity.description }}</td> | 22 | <td>{{ entity.description }}</td> |
| 21 | <td>{{ entity.communitySnmpPrinter }}</td> | 23 | <td>{{ entity.communitySnmpPrinter }}</td> |
| 22 | <td>{{ entity.host }}</td> | 24 | <td>{{ entity.host }}</td> |
| 25 | + <td>{{ entity.serie }}</td> | ||
| 26 | + <td>{{ entity.local }}</td> | ||
| 23 | </tr> | 27 | </tr> |
| 24 | </tbody> | 28 | </tbody> |
| 25 | </table> | 29 | </table> |