1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* DeliveriesController controller des livraisons. |
4
|
|
|
* |
5
|
|
|
* PHP Version 5 |
6
|
|
|
* |
7
|
|
|
* @author Quétier Laurent <[email protected]> |
8
|
|
|
* @copyright 2014 Dev-Int GLSR |
9
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
10
|
|
|
* |
11
|
|
|
* @version since 1.0.0 |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/Dev-Int/glsr |
14
|
|
|
*/ |
15
|
|
|
namespace AppBundle\Controller; |
16
|
|
|
|
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
18
|
|
|
use AppBundle\Controller\AbstractOrdersController; |
19
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
20
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
21
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
22
|
|
|
|
23
|
|
|
use AppBundle\Entity\Orders; |
24
|
|
|
use AppBundle\Form\Type\OrdersEditType; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Deliveries controller. |
28
|
|
|
* |
29
|
|
|
* @Route("/deliveries") |
30
|
|
|
*/ |
31
|
|
|
class DeliveriesController extends AbstractOrdersController |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Lists all Orders entities. |
35
|
|
|
* |
36
|
|
|
* @Route("/", name="deliveries") |
37
|
|
|
* @Method("GET") |
38
|
|
|
* @Template() |
39
|
|
|
*/ |
40
|
|
|
public function indexAction(Request $request) |
41
|
|
|
{ |
42
|
|
|
$etm = $this->getDoctrine()->getManager(); |
43
|
|
|
$item = $this->container->getParameter('knp_paginator.page_range'); |
44
|
|
|
$qbd = $etm->getRepository('AppBundle:Orders')->createQueryBuilder('o'); |
45
|
|
|
$qbd->where('o.delivdate <= ' . date('Y-m-d')); |
46
|
|
|
$qbd->andWhere('o.status = 1'); |
47
|
|
|
|
48
|
|
|
$paginator = $this->get('knp_paginator')->paginate($qbd, $request->query->get('page', 1), $item); |
49
|
|
|
return array( |
50
|
|
|
'paginator' => $paginator, |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Finds and displays a Orders entity. |
56
|
|
|
* |
57
|
|
|
* @Route("/{id}/show", name="deliveries_show", requirements={"id"="\d+"}) |
58
|
|
|
* @Method("GET") |
59
|
|
|
* @Template() |
60
|
|
|
*/ |
61
|
|
|
public function showAction(Orders $orders) |
62
|
|
|
{ |
63
|
|
|
return array( |
64
|
|
|
'orders' => $orders, |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Displays a form to edit an existing Orders entity. |
70
|
|
|
* |
71
|
|
|
* @Route("/admin/{id}/edit", name="deliveries_edit", requirements={"id"="\d+"}) |
72
|
|
|
* @Method("GET") |
73
|
|
|
* @Template() |
74
|
|
|
*/ |
75
|
|
|
public function editAction(Orders $orders) |
76
|
|
|
{ |
77
|
|
|
$return = $this->abstractEditAction($orders, 'deliveries', OrdersEditType::class); |
78
|
|
|
|
79
|
|
|
return $return; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Edits an existing Orders entity. |
84
|
|
|
* |
85
|
|
|
* @Route("/admin/{id}/update", name="deliveries_update", requirements={"id"="\d+"}) |
86
|
|
|
* @Method("PUT") |
87
|
|
|
* @Template("AppBundle:Deliveries:edit.html.twig") |
88
|
|
|
*/ |
89
|
|
|
public function updateAction(Orders $orders, Request $request) |
90
|
|
|
{ |
91
|
|
|
$return = $this->abstractUpdateAction( |
92
|
|
|
$orders, |
93
|
|
|
$request, |
94
|
|
|
'deliveries', |
95
|
|
|
OrdersEditType::class |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
return $return; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Print the current delivery.<br />Creating a `PDF` file for viewing on paper |
103
|
|
|
* |
104
|
|
|
* @Route("/{id}/print/", name="deliveries_print", requirements={"id"="\d+"}) |
105
|
|
|
* @Method("GET") |
106
|
|
|
* @Template() |
107
|
|
|
* |
108
|
|
|
* @param \AppBundle\Entity\Orders $orders Order item to print |
109
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
110
|
|
|
*/ |
111
|
|
|
public function printAction(Orders $orders) |
112
|
|
|
{ |
113
|
|
|
$return = $this->abstractPrintAction($orders, 'Deliveries'); |
114
|
|
|
|
115
|
|
|
return $return; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|