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 | 25 | use Symfony\Component\HttpFoundation\StreamedResponse; |
26 | 26 | |
27 | 27 | use Symfony\Component\HttpFoundation\BinaryFileResponse; |
28 | - | |
29 | - | |
30 | 28 | /** |
31 | 29 | * Printer controller. |
32 | 30 | * |
... | ... | @@ -106,12 +104,12 @@ class PrinterController extends Controller |
106 | 104 | $displayAll = true; |
107 | 105 | |
108 | 106 | $printers = $em->getRepository('CocarBundle:PrinterCounter')->relatorioGeral($start, $end); |
109 | - | |
110 | 107 | if(!$displayAll) |
111 | 108 | { |
112 | 109 | $paginator = $this->get('knp_paginator'); |
113 | 110 | $printers = $paginator->paginate($printers, $this->get('request')->query->get('page', 1), 10); |
114 | 111 | } |
112 | + | |
115 | 113 | return array( |
116 | 114 | "printer" => $printers, |
117 | 115 | //"printerCounter" => $pCounter, |
... | ... | @@ -120,6 +118,7 @@ class PrinterController extends Controller |
120 | 118 | "end" => $end, |
121 | 119 | "displayAll" => $displayAll |
122 | 120 | ); |
121 | + | |
123 | 122 | } |
124 | 123 | |
125 | 124 | /** |
... | ... | @@ -258,7 +257,6 @@ class PrinterController extends Controller |
258 | 257 | $em = $this->getDoctrine()->getManager(); |
259 | 258 | |
260 | 259 | $entity = $em->getRepository('CocarBundle:Printer')->find($id); |
261 | - | |
262 | 260 | if (!$entity) { |
263 | 261 | throw $this->createNotFoundException('Unable to find Printer entity.'); |
264 | 262 | } | ... | ... |
Entity/Printer.php
... | ... | @@ -56,6 +56,20 @@ class Printer |
56 | 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 | 73 | * Construct |
60 | 74 | */ |
61 | 75 | public function __construct() |
... | ... | @@ -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 | 229 | * Add printerCounter |
170 | 230 | * |
171 | 231 | * @param \Cocar\CocarBundle\Entity\PrinterCounter $printerCounter | ... | ... |
Entity/PrinterCounterRepository.php
... | ... | @@ -10,6 +10,7 @@ use Doctrine\ORM\EntityRepository; |
10 | 10 | * This class was generated by the Doctrine ORM. Add your own custom |
11 | 11 | * repository methods below. |
12 | 12 | */ |
13 | +//acrescentado serie e local | |
13 | 14 | class PrinterCounterRepository extends EntityRepository |
14 | 15 | { |
15 | 16 | /** |
... | ... | @@ -31,6 +32,8 @@ class PrinterCounterRepository extends EntityRepository |
31 | 32 | min(pc2.prints) as printsStart, |
32 | 33 | printer.name, |
33 | 34 | printer.description, |
35 | + printer.serie, | |
36 | + printer.local, | |
34 | 37 | printer.host |
35 | 38 | FROM CocarBundle:Printer printer |
36 | 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 | 43 | pc1.coloredInk, |
41 | 44 | printer.name, |
42 | 45 | printer.description, |
43 | - printer.host | |
46 | + printer.host, | |
47 | + printer.serie, | |
48 | + printer.local | |
44 | 49 | ORDER BY printer.id ASC"; |
45 | 50 | |
46 | 51 | return $this->getEntityManager()->createQuery( $_dql ) |
... | ... | @@ -67,6 +72,8 @@ class PrinterCounterRepository extends EntityRepository |
67 | 72 | min(pc2.date) as startDate, |
68 | 73 | printer.name, |
69 | 74 | printer.host, |
75 | + printer.serie, | |
76 | + printer.local, | |
70 | 77 | (max(pc1.prints) - min(pc2.prints)) as totalPrints |
71 | 78 | FROM CocarBundle:Printer printer |
72 | 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 | 81 | GROUP BY printer.id, |
75 | 82 | printer.name, |
76 | 83 | printer.description, |
77 | - printer.host | |
84 | + printer.host, | |
85 | + printer.serie, | |
86 | + printer.local | |
78 | 87 | ORDER BY printer.id ASC"; |
79 | 88 | |
80 | 89 | return $this->getEntityManager()->createQuery( $_dql ) | ... | ... |
Form/PrinterType.php
Resources/views/Printer/edit.html.twig
... | ... | @@ -25,6 +25,14 @@ |
25 | 25 | {{ form_widget(edit_form.host) }} |
26 | 26 | </div> |
27 | 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 | 36 | <button type="submit">Editar</button> |
29 | 37 | </div> |
30 | 38 | </div> | ... | ... |
Resources/views/Printer/index.html.twig
... | ... | @@ -21,6 +21,8 @@ |
21 | 21 | <th>Id</th> |
22 | 22 | <th>Nome</th> |
23 | 23 | <th>Host</th> |
24 | + <th>Serie</th> | |
25 | + <th>Local</th> | |
24 | 26 | <th>Contador Inicial</th> |
25 | 27 | <th>Data Inicial</th> |
26 | 28 | <th>Contador Final</th> |
... | ... | @@ -35,6 +37,8 @@ |
35 | 37 | <td><a href="{{ path('printer_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td> |
36 | 38 | <td>{{ entity.name }}</td> |
37 | 39 | <td>{{ entity.host }}</td> |
40 | + <td>{{ entity.serie }}</td> | |
41 | + <td>{{ entity.local }}</td> | |
38 | 42 | <td>{{ entity.printsStart }}</td> |
39 | 43 | {% if entity.startDate %} |
40 | 44 | <td>{{ entity.startDate|date("d/m/Y") }}</td> | ... | ... |
Resources/views/Printer/new.html.twig
... | ... | @@ -26,6 +26,14 @@ |
26 | 26 | {{ form_errors(form.host) }} |
27 | 27 | </div> |
28 | 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 | 37 | <button type="submit">Cadastrar</button> |
30 | 38 | </div> |
31 | 39 | </div> | ... | ... |
Resources/views/Printer/show.html.twig
... | ... | @@ -11,6 +11,8 @@ |
11 | 11 | <th>Description</th> |
12 | 12 | <th>Community</th> |
13 | 13 | <th>Host</th> |
14 | + <th>Serie</th> | |
15 | + <th>Local</th> | |
14 | 16 | </tr> |
15 | 17 | </thead> |
16 | 18 | <tbody> |
... | ... | @@ -20,6 +22,8 @@ |
20 | 22 | <td>{{ entity.description }}</td> |
21 | 23 | <td>{{ entity.communitySnmpPrinter }}</td> |
22 | 24 | <td>{{ entity.host }}</td> |
25 | + <td>{{ entity.serie }}</td> | |
26 | + <td>{{ entity.local }}</td> | |
23 | 27 | </tr> |
24 | 28 | </tbody> |
25 | 29 | </table> | ... | ... |