|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityRepository; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* OrdersRepository |
|
9
|
|
|
* |
|
10
|
|
|
* This class was generated by the Doctrine ORM. Add your own custom |
|
11
|
|
|
* repository methods below. |
|
12
|
|
|
*/ |
|
13
|
|
|
class OrdersRepository extends EntityRepository |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Renvoi les dernières commandes. |
|
17
|
|
|
* |
|
18
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
19
|
|
|
* @return array Query result |
|
20
|
|
|
*/ |
|
21
|
|
|
public function getLastOrder($count) |
|
22
|
|
|
{ |
|
23
|
|
|
$query = $this->findOrders() |
|
24
|
|
|
->setMaxResults($count) |
|
25
|
|
|
->getQuery(); |
|
26
|
|
|
|
|
27
|
|
|
return $query->getResult(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Renvoi les dernières commandes. |
|
32
|
|
|
* |
|
33
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
34
|
|
|
* @return array Query result |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getLastDelivery($count) |
|
37
|
|
|
{ |
|
38
|
|
|
$query = $this->findDeliveries() |
|
39
|
|
|
->setMaxResults($count) |
|
40
|
|
|
->getQuery(); |
|
41
|
|
|
|
|
42
|
|
|
return $query->getResult(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Renvoi les dernières commandes. |
|
47
|
|
|
* |
|
48
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
49
|
|
|
* @return array Query result |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getLastInvoice($count) |
|
52
|
|
|
{ |
|
53
|
|
|
$query = $this->findItem() |
|
54
|
|
|
->setMaxResults($count) |
|
55
|
|
|
->where('o.status = 2') |
|
56
|
|
|
->getQuery(); |
|
57
|
|
|
|
|
58
|
|
|
return $query->getResult(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Find Orders before delivering. |
|
63
|
|
|
* |
|
64
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
65
|
|
|
*/ |
|
66
|
|
|
public function findOrders() |
|
67
|
|
|
{ |
|
68
|
|
|
$query = $this->findItem() |
|
69
|
|
|
->where('o.delivdate > :date') |
|
70
|
|
|
->setParameter('date', date('Y-m-d')); |
|
71
|
|
|
|
|
72
|
|
|
return $query; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Find Orders for delivering. |
|
77
|
|
|
* |
|
78
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
79
|
|
|
*/ |
|
80
|
|
|
public function findDeliveries() |
|
81
|
|
|
{ |
|
82
|
|
|
$query = $this->findItem() |
|
83
|
|
|
->where('o.delivdate <= :date') |
|
84
|
|
|
->setParameter('date', date('Y-m-d')) |
|
85
|
|
|
->andWhere('o.status = 1'); |
|
86
|
|
|
|
|
87
|
|
|
return $query; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Find Orders for billing. |
|
92
|
|
|
* |
|
93
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
94
|
|
|
*/ |
|
95
|
|
|
public function findInvoices() |
|
96
|
|
|
{ |
|
97
|
|
|
$query = $this->findItem() |
|
98
|
|
|
->where('o.delivdate < :date') |
|
99
|
|
|
->setParameter('date', date('Y-m-d')) |
|
100
|
|
|
->andWhere('o.status > 1'); |
|
101
|
|
|
|
|
102
|
|
|
return $query; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
private function findItem() |
|
106
|
|
|
{ |
|
107
|
|
|
$query = $this->createQueryBuilder('o') |
|
108
|
|
|
->orderBy('o.id', 'DESC') |
|
109
|
|
|
->where('o.status = 1'); |
|
110
|
|
|
|
|
111
|
|
|
return $query; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|