UorgRepository.php
2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace Cacic\CommonBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* UorgRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class UorgRepository extends EntityRepository
{
public function listar()
{
$_dql = "SELECT uorg.idUorg, uorg.nmUorg
FROM CacicCommonBundle:Uorg uorg
ORDER BY uorg.uorgPai DESC, uorg.idUorg DESC ";
return $this->getEntityManager()->createQuery( $_dql )->getArrayResult();
}
/**
*
* Recupera as Unidades Organizacionais do primeiro nível
*/
public function getPrimeiroNivel()
{
$_dql = "SELECT uorg.idUorg, uorg.nmUorg, COUNT(filhas.idUorg) AS numFilhas
FROM CacicCommonBundle:Uorg uorg
LEFT JOIN uorg.uorgFilhas filhas
WHERE uorg.uorgPai IS NULL
GROUP BY uorg.idUorg, uorg.nmUorg";
return $this->getEntityManager()->createQuery( $_dql )->getArrayResult();
}
/**
*
* Recupera as folhas de determinado nó
* - Recupera as Unidades Organizacionais relacionadas (filhas) da Unidade Organizacional parametrizada
* @param int $idUorgPai
*/
public function getFolhasDoNo( $idUorgPai )
{
$_dql = "SELECT uorg.idUorg, uorg.nmUorg, r.idRede, COUNT(filhas.idUorg) AS numFilhas
FROM CacicCommonBundle:Uorg uorg
INNER JOIN uorg.uorgPai pai
LEFT JOIN uorg.uorgFilhas filhas
LEFT JOIN uorg.rede r
WHERE pai.idUorg = :idUorgPai
GROUP BY uorg.idUorg, uorg.nmUorg, r.idRede";
return $this->getEntityManager()->createQuery( $_dql )
->setParameter('idUorgPai', $idUorgPai)
->getArrayResult();
}
/**
*
* Gera estrutura de árvores com as Unidades Organizacionais cadastradas à partir do primeiro nível
*/
public function getArvores()
{
}
/**
*
* Gera estrutura de árvore a partir do nó (Unidade Organizacional) parametrizado
* @param int $idUorgPai
*/
public function getArvoreDoNo( $idUorgPai )
{
}
public function vincular()
{
$_dql = "SELECT uorg.idUorg, r.idRede, uorg.nmUorg, COUNT(filhas.idUorg) AS numFilhas
FROM CacicCommonBundle:Uorg uorg
LEFT JOIN uorg.uorgFilhas filhas
LEFT JOIN uorg.rede r
WHERE uorg.uorgPai IS NULL
GROUP BY uorg.idUorg, uorg.nmUorg, r.idRede";
return $this->getEntityManager()->createQuery( $_dql )->getArrayResult();
}
}