Loading module/Formation/src/Formation/Controller/InscriptionController.php +12 −1 Changes for module/Formation/src/Formation/Controller/InscriptionController.php: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -9,7 +9,9 @@ use Application\Service\Doctorant\DoctorantServiceAwareTrait; use Application\Service\Etablissement\EtablissementServiceAwareTrait; use Application\Service\File\FileServiceAwareTrait; use Application\Service\Individu\IndividuServiceAwareTrait; use Formation\Entity\Db\Etat; use Formation\Entity\Db\Inscription; use Formation\Entity\Db\Module; use Formation\Entity\Db\Session; use Formation\Service\Exporter\Attestation\AttestationExporter; use Formation\Service\Exporter\Convocation\ConvocationExporter; Loading Loading @@ -42,11 +44,20 @@ class InscriptionController extends AbstractController public function indexAction() { $filtres = [ 'session' => $this->params()->fromQuery('session'), 'doctorant' => $this->params()->fromQuery('doctorant'), 'liste' => $this->params()->fromQuery('liste'), ]; $listings = [ ]; /** @var Inscription[] $inscriptions */ $inscriptions = $this->getEntityManager()->getRepository(Inscription::class)->findAll(); $inscriptions = $this->getEntityManager()->getRepository(Inscription::class)->fetchInscriptionsWithFiltres($filtres); return new ViewModel([ 'inscriptions' => $inscriptions, 'filtres' => $filtres, 'listings' => $listings, ]); } Loading module/Formation/src/Formation/Controller/ModuleController.php +17 −27 Changes for module/Formation/src/Formation/Controller/ModuleController.php: 17 added lines, 27 removed lines. Original line number Diff line number Diff line Loading @@ -21,37 +21,27 @@ class ModuleController extends AbstractController public function indexAction() : ViewModel { /** Recupération des paramètres du filtres */ $site = $this->params()->fromQuery('site'); $libelle = $this->params()->fromQuery('libelle'); $responsable = $this->params()->fromQuery('responsable'); $modalite = $this->params()->fromQuery('modalite'); $structure = $this->params()->fromQuery('structure'); $filtres = [ 'site' => $this->params()->fromQuery('site'), 'libelle' => $this->params()->fromQuery('libelle'), 'responsable' => $this->params()->fromQuery('responsable'), 'modalite' => $this->params()->fromQuery('modalite'), 'structure' => $this->params()->fromQuery('structure'), ]; /** Listing pour les filtres */ $sites = $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(); $responsables = $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable(); $structures = $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures(); /** @var Module[] $formations */ //todo appliquer les filtre dans le repository $modules = $this->getEntityManager()->getRepository(Module::class)->findAll(); if ($site !== null AND $site !== '') $modules = array_filter($modules, function(Module $a) use ($site) { return $a->getSite()->getCode() === $site;}); if ($libelle !== null AND $libelle !== '') $modules = array_filter($modules, function(Module $a) use ($libelle) { return str_contains(strtolower($a->getLibelle()), strtolower($libelle));}); if ($responsable !== null AND $responsable !== '') $modules = array_filter($modules, function(Module $a) use ($responsable) { return $a->getResponsable()->getId() == $responsable;}); if ($structure !== null AND $structure !== '') $modules = array_filter($modules, function(Module $a) use ($structure) { return ($a->getTypeStructure() === null OR $a->getTypeStructure()->getId() == $structure);}); if ($modalite !== null AND $modalite !== '') $modules = array_filter($modules, function(Module $a) use ($modalite) { return ($a->getModalite() === null OR $a->getModalite() === $modalite);}); $listings = [ 'sites' => $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(), 'responsables' => $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable(), 'structures' => $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures(), ]; /** @var Module[] $formations */ $modules = $this->getEntityManager()->getRepository(Module::class)->fetchModulesWithFiltres($filtres); return new ViewModel([ 'modules' => $modules, //valeurs sélectionnées 'site' => $site, 'libelle' => $libelle, 'responsable' => $responsable, 'modalite' => $modalite, 'structure' => $structure, //données pour le filtre 'sites' => $sites, 'responsables' => $responsables, 'structures' => $structures, 'filtres' => $filtres, 'listings' => $listings, ]); } Loading module/Formation/src/Formation/Controller/SessionController.php +18 −1 Changes for module/Formation/src/Formation/Controller/SessionController.php: 18 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -44,11 +44,28 @@ class SessionController extends AbstractController public function indexAction() { $filtres = [ 'site' => $this->params()->fromQuery('site'), 'libelle' => $this->params()->fromQuery('libelle'), 'responsable' => $this->params()->fromQuery('responsable'), 'modalite' => $this->params()->fromQuery('modalite'), 'structure' => $this->params()->fromQuery('structure'), 'etat' => $this->params()->fromQuery('etat'), ]; $listings = [ 'sites' => $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(), 'responsables' => $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable(), 'structures' => $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures(), 'etats' => $this->getEntityManager()->getRepository(Etat::class)->findAll(), ]; /** @var Session[] $sessions */ $sessions = $this->getEntityManager()->getRepository(Session::class)->findAll(); $sessions = $this->getEntityManager()->getRepository(Session::class)->fetchSessionsWithFiltres($filtres); return new ViewModel([ 'sessions' => $sessions, 'filtres' => $filtres, 'listings' => $listings, ]); } Loading module/Formation/src/Formation/Entity/Db/Repository/InscriptionRepository.php +33 Changes for module/Formation/src/Formation/Entity/Db/Repository/InscriptionRepository.php: 33 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,39 @@ class InscriptionRepository extends EntityRepository return $qb; } /** * @param array $filtres * @return Session[] */ public function fetchInscriptionsWithFiltres(array $filtres) : array { $alias = 'inscription'; $qb = $this->createQB($alias); if ($filtres['session']) { $libelle = '%' . strtolower($filtres['session']) . '%'; $qb = $qb ->andWhere('lower(module.libelle) like :libelle') ->setParameter('libelle', $libelle); } if ($filtres['doctorant']) { $qb = $qb->leftJoin('doctorant.individu', 'individu')->addSelect('individu') ->andWhere("(lower(individu.nomUsuel)) = :doctorant") ->setParameter('doctorant', strtolower($filtres['doctorant'])); } if ($filtres['liste']) { if ($filtres['liste'] === 'null') { $qb = $qb->andWhere($alias.'.liste IS NULL'); } else { $qb = $qb->andWhere($alias . '.liste = :liste') ->setParameter('liste', $filtres['liste']); } } $result = $qb->getQuery()->getResult(); return $result; } /** * @param Doctorant $doctorant * @return array Loading module/Formation/src/Formation/Entity/Db/Repository/ModuleRepository.php +39 Changes for module/Formation/src/Formation/Entity/Db/Repository/ModuleRepository.php: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Formation\Entity\Db\Repository; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Formation\Entity\Db\Module; use Formation\Entity\Db\Session; use UnicaenApp\Service\EntityManagerAwareTrait; Loading @@ -25,6 +26,44 @@ class ModuleRepository extends EntityRepository return $module; } /** * @param array $filtres * @return Module[] */ public function fetchModulesWithFiltres(array $filtres) : array { $alias = 'module'; $qb = $this->createQueryBuilder($alias); if ($filtres['site']) { $qb = $qb->leftJoin($alias.'.site', 'site')->addSelect('site') ->andWhere('site.code = :site') ->setParameter('site', $filtres['site']); } if ($filtres['responsable']) { $qb = $qb->leftJoin($alias.'.responsable', 'responsable')->addSelect('responsable') ->andWhere('responsable.id = :responsable') ->setParameter('responsable', $filtres['responsable']); } if ($filtres['structure']) { $qb = $qb->leftJoin($alias.'.typeStructure', 'structure')->addSelect('structure') ->andWhere('structure.id = :structure') ->setParameter('structure', $filtres['structure']); } if ($filtres['modalite']) { $qb = $qb->andWhere($alias.'.modalite = :modalite') ->setParameter('modalite', $filtres['modalite']); } if ($filtres['libelle']) { $libelle = '%' . strtolower($filtres['libelle']) . '%'; $qb = $qb->andWhere('lower('.$alias.'.libelle) like :libelle') ->setParameter('libelle', $libelle); } $result = $qb->getQuery()->getResult(); return $result; } public function fetchIndexMax(Module $module) : int { $index = 0; Loading Loading
module/Formation/src/Formation/Controller/InscriptionController.php +12 −1 Changes for module/Formation/src/Formation/Controller/InscriptionController.php: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -9,7 +9,9 @@ use Application\Service\Doctorant\DoctorantServiceAwareTrait; use Application\Service\Etablissement\EtablissementServiceAwareTrait; use Application\Service\File\FileServiceAwareTrait; use Application\Service\Individu\IndividuServiceAwareTrait; use Formation\Entity\Db\Etat; use Formation\Entity\Db\Inscription; use Formation\Entity\Db\Module; use Formation\Entity\Db\Session; use Formation\Service\Exporter\Attestation\AttestationExporter; use Formation\Service\Exporter\Convocation\ConvocationExporter; Loading Loading @@ -42,11 +44,20 @@ class InscriptionController extends AbstractController public function indexAction() { $filtres = [ 'session' => $this->params()->fromQuery('session'), 'doctorant' => $this->params()->fromQuery('doctorant'), 'liste' => $this->params()->fromQuery('liste'), ]; $listings = [ ]; /** @var Inscription[] $inscriptions */ $inscriptions = $this->getEntityManager()->getRepository(Inscription::class)->findAll(); $inscriptions = $this->getEntityManager()->getRepository(Inscription::class)->fetchInscriptionsWithFiltres($filtres); return new ViewModel([ 'inscriptions' => $inscriptions, 'filtres' => $filtres, 'listings' => $listings, ]); } Loading
module/Formation/src/Formation/Controller/ModuleController.php +17 −27 Changes for module/Formation/src/Formation/Controller/ModuleController.php: 17 added lines, 27 removed lines. Original line number Diff line number Diff line Loading @@ -21,37 +21,27 @@ class ModuleController extends AbstractController public function indexAction() : ViewModel { /** Recupération des paramètres du filtres */ $site = $this->params()->fromQuery('site'); $libelle = $this->params()->fromQuery('libelle'); $responsable = $this->params()->fromQuery('responsable'); $modalite = $this->params()->fromQuery('modalite'); $structure = $this->params()->fromQuery('structure'); $filtres = [ 'site' => $this->params()->fromQuery('site'), 'libelle' => $this->params()->fromQuery('libelle'), 'responsable' => $this->params()->fromQuery('responsable'), 'modalite' => $this->params()->fromQuery('modalite'), 'structure' => $this->params()->fromQuery('structure'), ]; /** Listing pour les filtres */ $sites = $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(); $responsables = $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable(); $structures = $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures(); /** @var Module[] $formations */ //todo appliquer les filtre dans le repository $modules = $this->getEntityManager()->getRepository(Module::class)->findAll(); if ($site !== null AND $site !== '') $modules = array_filter($modules, function(Module $a) use ($site) { return $a->getSite()->getCode() === $site;}); if ($libelle !== null AND $libelle !== '') $modules = array_filter($modules, function(Module $a) use ($libelle) { return str_contains(strtolower($a->getLibelle()), strtolower($libelle));}); if ($responsable !== null AND $responsable !== '') $modules = array_filter($modules, function(Module $a) use ($responsable) { return $a->getResponsable()->getId() == $responsable;}); if ($structure !== null AND $structure !== '') $modules = array_filter($modules, function(Module $a) use ($structure) { return ($a->getTypeStructure() === null OR $a->getTypeStructure()->getId() == $structure);}); if ($modalite !== null AND $modalite !== '') $modules = array_filter($modules, function(Module $a) use ($modalite) { return ($a->getModalite() === null OR $a->getModalite() === $modalite);}); $listings = [ 'sites' => $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(), 'responsables' => $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable(), 'structures' => $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures(), ]; /** @var Module[] $formations */ $modules = $this->getEntityManager()->getRepository(Module::class)->fetchModulesWithFiltres($filtres); return new ViewModel([ 'modules' => $modules, //valeurs sélectionnées 'site' => $site, 'libelle' => $libelle, 'responsable' => $responsable, 'modalite' => $modalite, 'structure' => $structure, //données pour le filtre 'sites' => $sites, 'responsables' => $responsables, 'structures' => $structures, 'filtres' => $filtres, 'listings' => $listings, ]); } Loading
module/Formation/src/Formation/Controller/SessionController.php +18 −1 Changes for module/Formation/src/Formation/Controller/SessionController.php: 18 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -44,11 +44,28 @@ class SessionController extends AbstractController public function indexAction() { $filtres = [ 'site' => $this->params()->fromQuery('site'), 'libelle' => $this->params()->fromQuery('libelle'), 'responsable' => $this->params()->fromQuery('responsable'), 'modalite' => $this->params()->fromQuery('modalite'), 'structure' => $this->params()->fromQuery('structure'), 'etat' => $this->params()->fromQuery('etat'), ]; $listings = [ 'sites' => $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(), 'responsables' => $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable(), 'structures' => $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures(), 'etats' => $this->getEntityManager()->getRepository(Etat::class)->findAll(), ]; /** @var Session[] $sessions */ $sessions = $this->getEntityManager()->getRepository(Session::class)->findAll(); $sessions = $this->getEntityManager()->getRepository(Session::class)->fetchSessionsWithFiltres($filtres); return new ViewModel([ 'sessions' => $sessions, 'filtres' => $filtres, 'listings' => $listings, ]); } Loading
module/Formation/src/Formation/Entity/Db/Repository/InscriptionRepository.php +33 Changes for module/Formation/src/Formation/Entity/Db/Repository/InscriptionRepository.php: 33 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,39 @@ class InscriptionRepository extends EntityRepository return $qb; } /** * @param array $filtres * @return Session[] */ public function fetchInscriptionsWithFiltres(array $filtres) : array { $alias = 'inscription'; $qb = $this->createQB($alias); if ($filtres['session']) { $libelle = '%' . strtolower($filtres['session']) . '%'; $qb = $qb ->andWhere('lower(module.libelle) like :libelle') ->setParameter('libelle', $libelle); } if ($filtres['doctorant']) { $qb = $qb->leftJoin('doctorant.individu', 'individu')->addSelect('individu') ->andWhere("(lower(individu.nomUsuel)) = :doctorant") ->setParameter('doctorant', strtolower($filtres['doctorant'])); } if ($filtres['liste']) { if ($filtres['liste'] === 'null') { $qb = $qb->andWhere($alias.'.liste IS NULL'); } else { $qb = $qb->andWhere($alias . '.liste = :liste') ->setParameter('liste', $filtres['liste']); } } $result = $qb->getQuery()->getResult(); return $result; } /** * @param Doctorant $doctorant * @return array Loading
module/Formation/src/Formation/Entity/Db/Repository/ModuleRepository.php +39 Changes for module/Formation/src/Formation/Entity/Db/Repository/ModuleRepository.php: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Formation\Entity\Db\Repository; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Formation\Entity\Db\Module; use Formation\Entity\Db\Session; use UnicaenApp\Service\EntityManagerAwareTrait; Loading @@ -25,6 +26,44 @@ class ModuleRepository extends EntityRepository return $module; } /** * @param array $filtres * @return Module[] */ public function fetchModulesWithFiltres(array $filtres) : array { $alias = 'module'; $qb = $this->createQueryBuilder($alias); if ($filtres['site']) { $qb = $qb->leftJoin($alias.'.site', 'site')->addSelect('site') ->andWhere('site.code = :site') ->setParameter('site', $filtres['site']); } if ($filtres['responsable']) { $qb = $qb->leftJoin($alias.'.responsable', 'responsable')->addSelect('responsable') ->andWhere('responsable.id = :responsable') ->setParameter('responsable', $filtres['responsable']); } if ($filtres['structure']) { $qb = $qb->leftJoin($alias.'.typeStructure', 'structure')->addSelect('structure') ->andWhere('structure.id = :structure') ->setParameter('structure', $filtres['structure']); } if ($filtres['modalite']) { $qb = $qb->andWhere($alias.'.modalite = :modalite') ->setParameter('modalite', $filtres['modalite']); } if ($filtres['libelle']) { $libelle = '%' . strtolower($filtres['libelle']) . '%'; $qb = $qb->andWhere('lower('.$alias.'.libelle) like :libelle') ->setParameter('libelle', $libelle); } $result = $qb->getQuery()->getResult(); return $result; } public function fetchIndexMax(Module $module) : int { $index = 0; Loading