Completed
Push — Order ( a8dbff...a1a9f7 )
by Laurent
03:52
created

InvoicesController::updateArticles()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 5
eloc 10
nc 4
nop 2
1
<?php
2
/**
3
 * InvoicesController controller de la facturation.
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\InvoicesEditType;
25
26
/**
27
 * Invoices controller.
28
 *
29
 * @Route("/invoices")
30
 */
31
class InvoicesController extends AbstractOrdersController
32
{
33
    /**
34
     * Lists all Orders entities.
35
     *
36
     * @Route("/", name="invoices")
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')->findInvoices();
45
        
46
        $paginator = $this->get('knp_paginator')->paginate($qbd, $request->query->get('page', 1), $item);
47
        return array(
48
            'paginator' => $paginator,
49
        );
50
    }
51
52
    /**
53
     * Finds and displays a Orders entity.
54
     *
55
     * @Route("/{id}/show", name="invoices_show", requirements={"id"="\d+"})
56
     * @Method("GET")
57
     * @Template()
58
     */
59
    public function showAction(Orders $orders)
60
    {
61
        return array(
62
            'orders' => $orders,
63
        );
64
    }
65
66
    /**
67
     * Displays a form to edit an existing Orders entity.
68
     *
69
     * @Route("/admin/{id}/edit", name="invoices_edit", requirements={"id"="\d+"})
70
     * @Method("GET")
71
     * @Template()
72
     */
73
    public function editAction(Orders $orders)
74
    {
75
        $return = $this->abstractEditAction($orders, 'invoices', InvoicesEditType::class);
76
77
        return $return;
78
    }
79
80
    /**
81
     * Edits an existing Orders entity.
82
     *
83
     * @Route("/admin/{id}/update", name="invoices_update", requirements={"id"="\d+"})
84
     * @Method("PUT")
85
     * @Template("AppBundle:Invoices:edit.html.twig")
86
     */
87
    public function updateAction(Orders $orders, Request $request)
88
    {
89
        $return = $this->abstractUpdateAction(
90
            $orders,
91
            $request,
92
            'invoices',
93
            InvoicesEditType::class
94
        );
95
96
        return $return;
97
    }
98
99
    /**
100
     * Print the current invoice.<br />Creating a `PDF` file for viewing on paper
101
     *
102
     * @Route("/{id}/print/", name="invoices_print", requirements={"id"="\d+"})
103
     * @Method("GET")
104
     * @Template()
105
     *
106
     * @param \AppBundle\Entity\Orders $orders Order item to print
107
     * @return \Symfony\Component\HttpFoundation\Response
108
     */
109
    public function printAction(Orders $orders)
110
    {
111
        $return = $this->abstractPrintAction($orders, 'Invoices');
112
        
113
        return $return;
114
    }
115
}
116