|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Entité Article. |
|
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 since 1.0.0 |
|
13
|
|
|
* |
|
14
|
|
|
* @link https://github.com/Dev-Int/glsr |
|
15
|
|
|
*/ |
|
16
|
|
|
namespace AppBundle\Entity; |
|
17
|
|
|
|
|
18
|
|
|
use Doctrine\ORM\EntityRepository; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* ArticleRepository. |
|
22
|
|
|
* |
|
23
|
|
|
* @category Entity |
|
24
|
|
|
*/ |
|
25
|
|
|
class ArticleRepository extends EntityRepository |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Affiche les articles actifs. |
|
29
|
|
|
* |
|
30
|
|
|
* @return QueryBuilder Requête DQL |
|
31
|
|
|
*/ |
|
32
|
|
|
public function getAllItems() |
|
33
|
|
|
{ |
|
34
|
|
|
$query = $this->createQueryBuilder('a') |
|
35
|
|
|
->join('a.supplier', 's') |
|
36
|
|
|
->addSelect('s') |
|
37
|
|
|
->join('a.familyLog', 'fl') |
|
38
|
|
|
->addSelect('fl') |
|
39
|
|
|
->join('a.zoneStorages', 'z') |
|
40
|
|
|
->addSelect('z') |
|
41
|
|
|
; |
|
42
|
|
|
|
|
43
|
|
|
return $query; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Affiche les articles actifs. |
|
48
|
|
|
* |
|
49
|
|
|
* @return QueryBuilder Requête DQL |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getItems() |
|
52
|
|
|
{ |
|
53
|
|
|
$query = $this->createQueryBuilder('a') |
|
54
|
|
|
->join('a.supplier', 's') |
|
55
|
|
|
->addSelect('s') |
|
56
|
|
|
->where('s.active = 1') |
|
57
|
|
|
->join('a.familyLog', 'fl') |
|
58
|
|
|
->addSelect('fl') |
|
59
|
|
|
->join('a.zoneStorages', 'z') |
|
60
|
|
|
->addSelect('z') |
|
61
|
|
|
->where('a.active = 1') |
|
62
|
|
|
; |
|
63
|
|
|
|
|
64
|
|
|
return $query; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Affiche les articles actifs. |
|
69
|
|
|
* |
|
70
|
|
|
* @return array Query result |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getResultArticles() |
|
73
|
|
|
{ |
|
74
|
|
|
$query = $this->getItems()->getQuery(); |
|
75
|
|
|
|
|
76
|
|
|
return $query->getResult(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Renvoi les article du fournisseur en paramètre. |
|
81
|
|
|
* |
|
82
|
|
|
* @param int $supplier Supplier_id |
|
83
|
|
|
* |
|
84
|
|
|
* @return array Query result |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getArticleFromSupplier($supplier) |
|
87
|
|
|
{ |
|
88
|
|
|
$query = $this->getQueryActiveASC() |
|
89
|
|
|
->andWhere('a.supplier = :id') |
|
90
|
|
|
->setParameter('id', $supplier) |
|
91
|
|
|
->getQuery(); |
|
92
|
|
|
|
|
93
|
|
|
return $query->getResult(); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Renvoi les articles en stock d'alerte. |
|
98
|
|
|
* |
|
99
|
|
|
* @param integer $count Nombre d'élément à afficher |
|
100
|
|
|
* @return array Query result |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getStockAlert($count) |
|
103
|
|
|
{ |
|
104
|
|
|
$query = $this->getQueryActiveASC() |
|
105
|
|
|
->andWhere('a.quantity < a.minstock') |
|
106
|
|
|
->setMaxResults($count) |
|
107
|
|
|
->getQuery(); |
|
108
|
|
|
|
|
109
|
|
|
return $query->getResult(); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
private function getQueryActiveASC() |
|
113
|
|
|
{ |
|
114
|
|
|
$query = $this->createQueryBuilder('a') |
|
115
|
|
|
->where('a.active = true') |
|
116
|
|
|
->orderBy('a.name', 'ASC'); |
|
117
|
|
|
|
|
118
|
|
|
return $query; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|