1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainConsignmentBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
6
|
|
|
use Loevgaard\DandomainConsignment\Entity\Report; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
|
11
|
|
|
class ReportController extends Controller |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param Request $request |
15
|
|
|
* @return Response |
16
|
|
|
*/ |
17
|
|
|
public function indexAction(Request $request) |
18
|
|
|
{ |
19
|
|
|
/** @var EntityManager $em */ |
20
|
|
|
$em = $this->getDoctrine()->getManager(); |
21
|
|
|
$paginator = $this->get('knp_paginator'); |
22
|
|
|
|
23
|
|
|
$qb = $em->createQueryBuilder(); |
24
|
|
|
$qb->select('r, s') |
25
|
|
|
->from('Loevgaard\DandomainConsignment\Entity\Report', 'r') |
26
|
|
|
->leftJoin('r.stockMovements', 's') |
27
|
|
|
->addOrderBy('r.createdAt', 'desc') |
28
|
|
|
; |
29
|
|
|
|
30
|
|
|
/** @var Report[] $reports */ |
31
|
|
|
$reports = $paginator->paginate( |
32
|
|
|
$qb->getQuery(), |
33
|
|
|
$request->query->getInt('page', 1), |
34
|
|
|
$request->query->getInt('limit', 50) |
35
|
|
|
); |
36
|
|
|
|
37
|
|
|
return $this->render('@LoevgaardDandomainConsignment/report/index.html.twig', [ |
38
|
|
|
'reports' => $reports |
39
|
|
|
]); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param ConsignmentReport $consignmentReport |
44
|
|
|
* @return Response |
45
|
|
|
* |
46
|
|
|
* @Method("GET") |
47
|
|
|
* @Route("/{id}", name="admin_consignment_report_show") |
48
|
|
|
*/ |
49
|
|
|
public function showAction(ConsignmentReport $consignmentReport) |
50
|
|
|
{ |
51
|
|
|
return $this->render('admin/consignmentreport/show.html.twig', [ |
52
|
|
|
'consignmentReport' => $consignmentReport |
53
|
|
|
]); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|