Loading module/Formation/src/Formation/Service/Inscription/InscriptionService.php +29 −1 Changes for module/Formation/src/Formation/Service/Inscription/InscriptionService.php: 29 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Formation\Service\Inscription; use DateTime; use Doctorant\Entity\Db\Doctorant; use Doctrine\ORM\ORMException; use Formation\Entity\Db\Inscription; use Formation\Entity\Db\Repository\InscriptionRepository; Loading Loading @@ -97,5 +99,31 @@ class InscriptionService { return $seance; } /** FACADE ********************************************************************************************************/ /** Querying ******************************************************************************************************/ /** @return Inscription[] */ public function getInscriptionByDoctorantAndAnnee(Doctorant $doctorant, ?string $type = null, ?int $annee = null): array { $qb = $this->getRepository()->createQueryBuilder('inscription') ->join('inscription.doctorant', 'doctorant')->addSelect('doctorant') ->join('inscription.session', 'session')->addSelect('session') ->andWhere('inscription.doctorant = :doctorant')->setParameter('doctorant', $doctorant); if ($type !== null) { $qb = $qb->join('session.formation', 'formation')->addSelect('formation') ->andWhere('formation.type = :type')->setParameter('type', $type); } if ($annee !== null) { $debut = DateTime::createFromFormat('d/m/Y','01/09/'.($annee-1)); $fin = DateTime::createFromFormat('d/m/Y','31/08/'.($annee)); $qb = $qb->join('session.seances', 'seance') ->andWhere('seance.debut >= :debut')->setParameter('debut', $debut) ->andWhere('seance.fin <= :fin')->setParameter('fin', $fin); } $result = $qb->getQuery()->getResult(); return $result; } } No newline at end of file Loading
module/Formation/src/Formation/Service/Inscription/InscriptionService.php +29 −1 Changes for module/Formation/src/Formation/Service/Inscription/InscriptionService.php: 29 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Formation\Service\Inscription; use DateTime; use Doctorant\Entity\Db\Doctorant; use Doctrine\ORM\ORMException; use Formation\Entity\Db\Inscription; use Formation\Entity\Db\Repository\InscriptionRepository; Loading Loading @@ -97,5 +99,31 @@ class InscriptionService { return $seance; } /** FACADE ********************************************************************************************************/ /** Querying ******************************************************************************************************/ /** @return Inscription[] */ public function getInscriptionByDoctorantAndAnnee(Doctorant $doctorant, ?string $type = null, ?int $annee = null): array { $qb = $this->getRepository()->createQueryBuilder('inscription') ->join('inscription.doctorant', 'doctorant')->addSelect('doctorant') ->join('inscription.session', 'session')->addSelect('session') ->andWhere('inscription.doctorant = :doctorant')->setParameter('doctorant', $doctorant); if ($type !== null) { $qb = $qb->join('session.formation', 'formation')->addSelect('formation') ->andWhere('formation.type = :type')->setParameter('type', $type); } if ($annee !== null) { $debut = DateTime::createFromFormat('d/m/Y','01/09/'.($annee-1)); $fin = DateTime::createFromFormat('d/m/Y','31/08/'.($annee)); $qb = $qb->join('session.seances', 'seance') ->andWhere('seance.debut >= :debut')->setParameter('debut', $debut) ->andWhere('seance.fin <= :fin')->setParameter('fin', $fin); } $result = $qb->getQuery()->getResult(); return $result; } } No newline at end of file