Completed
Push — sf2.7 ( 0eab0c...d4139d )
by Laurent
03:30
created

SupplierRepository::getSuppliers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/**
4
 * Entité Supplier.
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
 * SupplierRepository Entité Supplier.
22
 *
23
 * @category   Entity
24
 */
25
class SupplierRepository extends EntityRepository
26
{
27
    /**
28
     * Affiche les fournisseurs actifs.
29
     *
30
     * @return QueryBuilder Requête DQL
31
     */
32
    public function getSuppliers()
33
    {
34
        $query = $this->createQueryBuilder('s')
35
            ->where('s.active = 1')
36
            ->orderBy('s.name', 'ASC');
37
        
38
        return $query;
39
    }
40
41
    /**
42
     * Renvoie les fournisseurs actifs correspondant à la famille logistique
43
     * de l'article en paramètre.
44
     *
45
     * @param AppBundle\Entity\Article $article Article sélectionné
46
     *
47
     * @return QueryBuilder Requête DQL
48
     */
49
    public function getSupplierForReassign($article)
50
    {
51
        $query = $this->createQueryBuilder('s')
52
            ->where('s.name != :idname')
53
            ->andWhere('s.family_log = :flname')
54
            ->andWhere('s.active = 1')
55
            ->setParameters(
56
                array(
57
                    'idname' => $article->getSupplier()->getName(),
58
                    'flname' => $article->getFamilyLog(),
59
                )
60
            )
61
            ->orderBy('s.name', 'ASC');
62
63
        return $query;
64
    }
65
}
66