Skip to content
Snippets Groups Projects
Commit 81ffa22e authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Correction mineure et ajout de fonction de recherche

parent 80572f2a
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
<field name="cCommuneNaissance" type="string" length="5" column="C_COMMUNE_NAISSANCE" nullable="false"/> <field name="cCommuneNaissance" type="string" length="5" column="C_COMMUNE_NAISSANCE" nullable="false"/>
<field name="cDeptNaissance" type="string" length="3" column="C_DEPT_NAISSANCE" nullable="false"/> <field name="cDeptNaissance" type="string" length="3" column="C_DEPT_NAISSANCE" nullable="false"/>
<field name="cPaysNaissance" type="string" length="3" column="C_PAYS_NAISSANCE" nullable="false"/> <field name="cPaysNaissance" type="string" length="3" column="C_PAYS_NAISSANCE" nullable="false"/>
<!--<many-to-one target-entity="Octopus\Entity\Db\Pays" field="cPaysNaissance">-->
<!--<join-column name="C_PAYS_NAISSANCE" referenced-column-name="CODE_PAYS" />-->
<!--</many-to-one>-->
<field name="cPaysNationalite" type="string" length="3" column="C_PAYS_NATIONALITE" nullable="false"/> <field name="cPaysNationalite" type="string" length="3" column="C_PAYS_NATIONALITE" nullable="false"/>
<field name="telPersonnelle" type="string" length="20" column="TEL_PERSO" nullable="false"/> <field name="telPersonnelle" type="string" length="20" column="TEL_PERSO" nullable="false"/>
<field name="emailPersonnelle" type="string" length="255" column="EMAIL_PERSO" nullable="false"/> <field name="emailPersonnelle" type="string" length="255" column="EMAIL_PERSO" nullable="false"/>
......
...@@ -4,6 +4,7 @@ namespace Octopus\Service\Individu; ...@@ -4,6 +4,7 @@ namespace Octopus\Service\Individu;
use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NonUniqueResultException;
use Octopus\Entity\Db\Individu; use Octopus\Entity\Db\Individu;
use Octopus\Entity\Db\Source;
use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait; use UnicaenApp\Service\EntityManagerAwareTrait;
...@@ -54,7 +55,7 @@ class IndividuService { ...@@ -54,7 +55,7 @@ class IndividuService {
public function getIndividusByTerm($term, $sourceCode = null) public function getIndividusByTerm($term, $sourceCode = null)
{ {
$qb = $this->getEntityManager()->getRepository(Individu::class)->createQueryBuilder('individu') $qb = $this->getEntityManager()->getRepository(Individu::class)->createQueryBuilder('individu')
->addSelect('source')->join('individu.source', 'source') ->addSelect('source')->join('individu.cSource', 'source')
->andWhere('individu.nomUsage LIKE :search') ->andWhere('individu.nomUsage LIKE :search')
->setParameter('search', '%'.$term.'%') ->setParameter('search', '%'.$term.'%')
->orderBy('individu.nomUsage, individu.prenom') ->orderBy('individu.nomUsage, individu.prenom')
...@@ -68,4 +69,26 @@ class IndividuService { ...@@ -68,4 +69,26 @@ class IndividuService {
$result = $qb->getQuery()->getResult(); $result = $qb->getQuery()->getResult();
return $result; return $result;
} }
/**
* @param integer $numeroEtudiant
* @return Individu
*/
public function getEtudiantByNumero($numeroEtudiant)
{
$qb = $this->getEntityManager()->getRepository(Individu::class)->createQueryBuilder('individu')
->addSelect('source')->join('individu.cSource', 'source')
->andWhere('individu.cEtu = :numero')
->andWhere('source.cSource = :sourceCode')
->setParameter('numero', $numeroEtudiant)
->setParameter('sourceCode', Source::SOURCE_APOGEE)
;
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
throw new RuntimeException("Plusieurs étudiants partagent le même numéro étudiant [".$numeroEtudiant."].",$e);
}
return $result;
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment