|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\CoreBundle\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\ORM\EntityRepository; |
|
14
|
|
|
use LoginCidadao\CoreBundle\Model\PersonInterface; |
|
15
|
|
|
|
|
16
|
|
|
class IdCardRepository extends EntityRepository |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
public function getGridQuery(PersonInterface $person) |
|
20
|
|
|
{ |
|
21
|
|
|
$qb = $this->createQueryBuilder('u') |
|
22
|
|
|
->select('u.id, u.value, right(s.iso6, 2) iso6') |
|
23
|
|
|
->join('LoginCidadaoCoreBundle:State', 's', 'with', |
|
24
|
|
|
'u.state = s') |
|
25
|
|
|
->where('u.person = :person') |
|
26
|
|
|
->setParameters(array('person' => $person)) |
|
27
|
|
|
->orderBy('u.id', 'desc'); |
|
28
|
|
|
|
|
29
|
|
|
return $qb; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function findPersonIdCard(PersonInterface $person, $id) |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->findOneBy(array( |
|
35
|
|
|
'person' => $person, |
|
36
|
|
|
'id' => $id |
|
37
|
|
|
)); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function findByPersonOrderByStateAcronym(PersonInterface $person) |
|
41
|
|
|
{ |
|
42
|
|
|
$qb = $this->createQueryBuilder('i') |
|
43
|
|
|
->join('LoginCidadaoCoreBundle:State', 's', 'with', |
|
44
|
|
|
'i.state = s') |
|
45
|
|
|
->where('i.person = :person') |
|
46
|
|
|
->setParameters(array('person' => $person)) |
|
47
|
|
|
->orderBy('s.acronym', 'asc'); |
|
48
|
|
|
|
|
49
|
|
|
return $qb->getQuery()->getResult(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|