1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Entity Supplier. |
5
|
|
|
* |
6
|
|
|
* PHP Version 7 |
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 App\Repository\Settings; |
17
|
|
|
|
18
|
|
|
use Doctrine\ORM\EntityRepository; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* SupplierRepository Entity. |
22
|
|
|
* |
23
|
|
|
* @category Entity |
24
|
|
|
*/ |
25
|
|
|
class SupplierRepository extends EntityRepository |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Displays all suppliers. |
29
|
|
|
* |
30
|
|
|
* @return \Doctrine\ORM\QueryBuilder Requête DQL |
31
|
|
|
*/ |
32
|
|
|
public function getAllItems() |
33
|
|
|
{ |
34
|
|
|
$query = $this->createQueryBuilder('s') |
35
|
|
|
->join('s.familyLog', 'fl') |
36
|
|
|
->addSelect('fl') |
37
|
|
|
; |
38
|
|
|
|
39
|
|
|
return $query; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Displays active suppliers. |
45
|
|
|
* |
46
|
|
|
* @return \Doctrine\ORM\QueryBuilder Requête DQL |
47
|
|
|
*/ |
48
|
|
|
public function getItems() |
49
|
|
|
{ |
50
|
|
|
$query = $this->getAllItems() |
51
|
|
|
->where('s.active = 1') |
52
|
|
|
; |
53
|
|
|
|
54
|
|
|
return $query; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns the active suppliers matching logistic family of the article in parameter. |
59
|
|
|
* |
60
|
|
|
* @param App\Entity\Settings\Supplier $supplier Selected supplier |
61
|
|
|
* |
62
|
|
|
* @return \Doctrine\ORM\QueryBuilder Requête DQL |
63
|
|
|
*/ |
64
|
|
|
public function getSupplierForReassign($supplier) |
65
|
|
|
{ |
66
|
|
|
$query = $this->createQueryBuilder('s'); |
67
|
|
|
$query |
68
|
|
|
->select('s') |
69
|
|
|
->where($query->expr()->neq('s.name', ':idname')) |
70
|
|
|
->andWhere('s.familyLog = :flname') |
71
|
|
|
->andWhere('s.active = true') |
72
|
|
|
->setParameters(['idname' => $supplier->getName(), 'flname' => $supplier->getFamilyLog(),]) |
73
|
|
|
->orderBy('s.name', 'ASC'); |
74
|
|
|
|
75
|
|
|
return $query; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|