|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Entité Orders. |
|
5
|
|
|
* |
|
6
|
|
|
* PHP Version 5 |
|
7
|
|
|
* |
|
8
|
|
|
* @author Quétier Laurent <[email protected]> |
|
9
|
|
|
* @copyright 2014 Dev-Int GLSR |
|
10
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
11
|
|
|
* |
|
12
|
|
|
* @version GIT: <git_id> |
|
13
|
|
|
* |
|
14
|
|
|
* @link https://github.com/Dev-Int/glsr |
|
15
|
|
|
*/ |
|
16
|
|
|
namespace AppBundle\Repository\Orders; |
|
17
|
|
|
|
|
18
|
|
|
use Doctrine\ORM\EntityRepository; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* OrdersRepository |
|
22
|
|
|
* |
|
23
|
|
|
* @category Entity |
|
24
|
|
|
*/ |
|
25
|
|
|
class OrdersRepository extends EntityRepository |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Renvoi les dernières commandes. |
|
29
|
|
|
* |
|
30
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
31
|
|
|
* @return array Query result |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getLastOrder($count) |
|
34
|
|
|
{ |
|
35
|
|
|
$query = $this->getAllItems() |
|
36
|
|
|
->setMaxResults($count) |
|
37
|
|
|
->getQuery(); |
|
38
|
|
|
|
|
39
|
|
|
return $query->getResult(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Renvoi les dernières commandes. |
|
44
|
|
|
* |
|
45
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
46
|
|
|
* @return array Query result |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getLastDelivery($count) |
|
49
|
|
|
{ |
|
50
|
|
|
$query = $this->findDeliveries() |
|
51
|
|
|
->setMaxResults($count) |
|
52
|
|
|
->getQuery(); |
|
53
|
|
|
|
|
54
|
|
|
return $query->getResult(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Renvoi les dernières commandes. |
|
59
|
|
|
* |
|
60
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
61
|
|
|
* @return array Query result |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getLastInvoice($count) |
|
64
|
|
|
{ |
|
65
|
|
|
$query = $this->getItems() |
|
66
|
|
|
->setMaxResults($count) |
|
67
|
|
|
->where('o.status = 2') |
|
68
|
|
|
->getQuery(); |
|
69
|
|
|
|
|
70
|
|
|
return $query->getResult(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Find Orders before delivering. |
|
75
|
|
|
* |
|
76
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getAllItems() |
|
79
|
|
|
{ |
|
80
|
|
|
$query = $this->getItems() |
|
81
|
|
|
->where('o.delivdate > :date') |
|
82
|
|
|
->setParameter('date', date('Y-m-d')); |
|
83
|
|
|
|
|
84
|
|
|
return $query; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Find Orders for delivering. |
|
89
|
|
|
* |
|
90
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
91
|
|
|
*/ |
|
92
|
|
|
public function findDeliveries() |
|
93
|
|
|
{ |
|
94
|
|
|
$query = $this->getItems() |
|
95
|
|
|
->where('o.delivdate <= :date') |
|
96
|
|
|
->setParameter('date', date('Y-m-d')) |
|
97
|
|
|
->andWhere('o.status = 1'); |
|
98
|
|
|
|
|
99
|
|
|
return $query; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Find Orders for billing. |
|
104
|
|
|
* |
|
105
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
106
|
|
|
*/ |
|
107
|
|
|
public function findInvoices() |
|
108
|
|
|
{ |
|
109
|
|
|
$query = $this->getItems() |
|
110
|
|
|
->where('o.delivdate < :date') |
|
111
|
|
|
->setParameter('date', date('Y-m-d')) |
|
112
|
|
|
->andWhere('o.status > 1'); |
|
113
|
|
|
|
|
114
|
|
|
return $query; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Find Orders before delivering. |
|
119
|
|
|
* |
|
120
|
|
|
* @return \Doctrine\ORM\QueryBuilder |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getItems() |
|
123
|
|
|
{ |
|
124
|
|
|
$query = $this->createQueryBuilder('o') |
|
125
|
|
|
->orderBy('o.id', 'DESC') |
|
126
|
|
|
->where('o.status = 1'); |
|
127
|
|
|
|
|
128
|
|
|
return $query; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|