Loading module/Application/src/Application/Service/Agent/AgentService.php +25 −5 Original line number Diff line number Diff line Loading @@ -294,15 +294,15 @@ class AgentService { ->andWhere('affectation.dateDebut <= :today') ->andWhere('affectation.principale = :true') //STATUS ->addSelect('statut')->join('agent.statuts', 'statut') ->addSelect('statut')->leftjoin('agent.statuts', 'statut') ->andWhere('statut.dateFin >= :today OR statut.dateFin IS NULL') ->andWhere('statut.dateDebut <= :today') ->andWhere('statut.dispo = :false') ->andWhere('statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false') ->andWhere('(statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false)') //GRADE ->addSelect('grade')->join('agent.grades', 'grade') ->addSelect('gstructure')->join('grade.structure', 'gstructure') ->addSelect('ggrade')->join('grade.grade', 'ggrade') ->addSelect('grade')->leftjoin('agent.grades', 'grade') ->addSelect('gstructure')->leftjoin('grade.structure', 'gstructure') ->addSelect('ggrade')->leftjoin('grade.grade', 'ggrade') ->addSelect('gcorrespondance')->leftjoin('grade.bap', 'gcorrespondance') ->addSelect('gcorps')->leftjoin('grade.corps', 'gcorps') ->andWhere('grade.dateFin >= :today OR grade.dateFin IS NULL') Loading @@ -328,6 +328,26 @@ class AgentService { return $result; } /** * @param Structure[] $structures * @return Agent[] */ public function getAgentsForcesByStructures(array $structures) { $qb = $this->getEntityManager()->getRepository(Agent::class)->createQueryBuilder('agent') ->addSelect('forcage')->join('agent.structuresForcees', 'forcage') ->andWhere('forcage.histoDestruction IS NULL'); if ($structures !== null) { $qb = $qb->andWhere('forcage.structure IN (:structures)') ->setParameter('structures', $structures); } $result = $qb->getQuery()->getResult(); return $result; } public function getAgentByHarp(string $st_harp_id) { $qb = $this->createQueryBuilder() Loading module/Application/src/Application/Service/FichePoste/FichePosteService.php +10 −33 Original line number Diff line number Diff line Loading @@ -10,13 +10,13 @@ use Application\Entity\Db\FichePoste; use Application\Entity\Db\FicheposteApplicationRetiree; use Application\Entity\Db\FicheTypeExterne; use Application\Entity\Db\Structure; use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\GestionEntiteHistorisationTrait; use Application\Service\Structure\StructureServiceAwareTrait; use DateTime; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\ORMException; use Doctrine\ORM\QueryBuilder; use Exception; use UnicaenApp\Exception\RuntimeException; use UnicaenUtilisateur\Entity\Db\User; use Zend\Mvc\Controller\AbstractActionController; Loading @@ -24,6 +24,7 @@ use Zend\Mvc\Controller\AbstractActionController; class FichePosteService { use GestionEntiteHistorisationTrait; use StructureServiceAwareTrait; use AgentServiceAwareTrait; /** GESTION DES ENTITES *******************************************************************************************/ Loading Loading @@ -277,41 +278,17 @@ class FichePosteService { */ public function getFichesPostesByStructures(array $structures = [], bool $sousstructure = true) { try { $today = new DateTime(); //$noEnd = DateTime::createFromFormat('d/m/Y H:i:s', '31/12/1999 00:00:00'); } catch (Exception $e) { throw new RuntimeException("Problème lors de la création des dates"); } $agentsStd = $this->getAgentService()->getAgentsByStructures($structures); $agentForcees = $this->getAgentService()->getAgentsForcesByStructures($structures); $agents = array_merge($agentsStd, $agentForcees); $qb = $this->getEntityManager()->getRepository(FichePoste::class)->createQueryBuilder('fiche') ->andWhere('fiche.agent in (:agents)') ->setParameter('agents', $agents) ->addSelect('agent')->join('fiche.agent', 'agent') ->addSelect('poste')->leftJoin('fiche.poste', 'poste') ->addSelect('statut')->join('agent.statuts', 'statut') ->addSelect('grade')->join('agent.grades', 'grade') ->addSelect('fichemetier')->leftJoin('fiche.fichesMetiers', 'fichemetier') ->addSelect('fichemetiertype')->leftJoin('fichemetier.ficheType', 'fichemetiertype') ->addSelect('metier')->leftJoin('fichemetiertype.metier', 'metier') ->addSelect('affectation')->join('agent.affectations', 'affectation') ->andWhere('statut.dateFin >= :today OR statut.dateFin IS NULL') ->andWhere('statut.dispo = :false') ->andWhere('statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false') ->andWhere('grade.dateFin >= :today OR grade.dateFin IS NULL') ->andWhere('affectation.dateFin >= :today OR affectation.dateFin IS NULL') ->setParameter('today', $today) //->setParameter('noEnd', $noEnd) ->setParameter('false', 'N') ->orderBy('agent.nomUsuel, agent.prenom') ; if ($sousstructure) { $qb = $qb ->andWhere('affectation.structure IN (:structures)') ->setParameter('structures', $structures); } ->addSelect('statut')->leftJoin('agent.statuts', 'statut') ->addSelect('grade')->leftJoin('agent.grades', 'grade') ->orderBy('agent.nomUsuel, agent.prenom'); $result = $qb->getQuery()->getResult(); return $result; } Loading module/Application/src/Application/Service/FichePoste/FichePosteServiceFactory.php +4 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Service\FichePoste; use Application\Service\Agent\AgentService; use Application\Service\Structure\StructureService; use Doctrine\ORM\EntityManager; use Interop\Container\ContainerInterface; Loading @@ -13,16 +14,19 @@ class FichePosteServiceFactory { { /** * @var EntityManager $entityManager * @var AgentService $agentService * @var StructureService $structureService * @var UserService $userService */ $entityManager = $container->get('doctrine.entitymanager.orm_default'); $agentService = $container->get(AgentService::class); $structureService = $container->get(StructureService::class); $userService = $container->get(UserService::class); /** @var FichePosteService $service */ $service = new FichePosteService(); $service->setEntityManager($entityManager); $service->setAgentService($agentService); $service->setStructureService($structureService); $service->setUserService($userService); Loading Loading
module/Application/src/Application/Service/Agent/AgentService.php +25 −5 Original line number Diff line number Diff line Loading @@ -294,15 +294,15 @@ class AgentService { ->andWhere('affectation.dateDebut <= :today') ->andWhere('affectation.principale = :true') //STATUS ->addSelect('statut')->join('agent.statuts', 'statut') ->addSelect('statut')->leftjoin('agent.statuts', 'statut') ->andWhere('statut.dateFin >= :today OR statut.dateFin IS NULL') ->andWhere('statut.dateDebut <= :today') ->andWhere('statut.dispo = :false') ->andWhere('statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false') ->andWhere('(statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false)') //GRADE ->addSelect('grade')->join('agent.grades', 'grade') ->addSelect('gstructure')->join('grade.structure', 'gstructure') ->addSelect('ggrade')->join('grade.grade', 'ggrade') ->addSelect('grade')->leftjoin('agent.grades', 'grade') ->addSelect('gstructure')->leftjoin('grade.structure', 'gstructure') ->addSelect('ggrade')->leftjoin('grade.grade', 'ggrade') ->addSelect('gcorrespondance')->leftjoin('grade.bap', 'gcorrespondance') ->addSelect('gcorps')->leftjoin('grade.corps', 'gcorps') ->andWhere('grade.dateFin >= :today OR grade.dateFin IS NULL') Loading @@ -328,6 +328,26 @@ class AgentService { return $result; } /** * @param Structure[] $structures * @return Agent[] */ public function getAgentsForcesByStructures(array $structures) { $qb = $this->getEntityManager()->getRepository(Agent::class)->createQueryBuilder('agent') ->addSelect('forcage')->join('agent.structuresForcees', 'forcage') ->andWhere('forcage.histoDestruction IS NULL'); if ($structures !== null) { $qb = $qb->andWhere('forcage.structure IN (:structures)') ->setParameter('structures', $structures); } $result = $qb->getQuery()->getResult(); return $result; } public function getAgentByHarp(string $st_harp_id) { $qb = $this->createQueryBuilder() Loading
module/Application/src/Application/Service/FichePoste/FichePosteService.php +10 −33 Original line number Diff line number Diff line Loading @@ -10,13 +10,13 @@ use Application\Entity\Db\FichePoste; use Application\Entity\Db\FicheposteApplicationRetiree; use Application\Entity\Db\FicheTypeExterne; use Application\Entity\Db\Structure; use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\GestionEntiteHistorisationTrait; use Application\Service\Structure\StructureServiceAwareTrait; use DateTime; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\ORMException; use Doctrine\ORM\QueryBuilder; use Exception; use UnicaenApp\Exception\RuntimeException; use UnicaenUtilisateur\Entity\Db\User; use Zend\Mvc\Controller\AbstractActionController; Loading @@ -24,6 +24,7 @@ use Zend\Mvc\Controller\AbstractActionController; class FichePosteService { use GestionEntiteHistorisationTrait; use StructureServiceAwareTrait; use AgentServiceAwareTrait; /** GESTION DES ENTITES *******************************************************************************************/ Loading Loading @@ -277,41 +278,17 @@ class FichePosteService { */ public function getFichesPostesByStructures(array $structures = [], bool $sousstructure = true) { try { $today = new DateTime(); //$noEnd = DateTime::createFromFormat('d/m/Y H:i:s', '31/12/1999 00:00:00'); } catch (Exception $e) { throw new RuntimeException("Problème lors de la création des dates"); } $agentsStd = $this->getAgentService()->getAgentsByStructures($structures); $agentForcees = $this->getAgentService()->getAgentsForcesByStructures($structures); $agents = array_merge($agentsStd, $agentForcees); $qb = $this->getEntityManager()->getRepository(FichePoste::class)->createQueryBuilder('fiche') ->andWhere('fiche.agent in (:agents)') ->setParameter('agents', $agents) ->addSelect('agent')->join('fiche.agent', 'agent') ->addSelect('poste')->leftJoin('fiche.poste', 'poste') ->addSelect('statut')->join('agent.statuts', 'statut') ->addSelect('grade')->join('agent.grades', 'grade') ->addSelect('fichemetier')->leftJoin('fiche.fichesMetiers', 'fichemetier') ->addSelect('fichemetiertype')->leftJoin('fichemetier.ficheType', 'fichemetiertype') ->addSelect('metier')->leftJoin('fichemetiertype.metier', 'metier') ->addSelect('affectation')->join('agent.affectations', 'affectation') ->andWhere('statut.dateFin >= :today OR statut.dateFin IS NULL') ->andWhere('statut.dispo = :false') ->andWhere('statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false') ->andWhere('grade.dateFin >= :today OR grade.dateFin IS NULL') ->andWhere('affectation.dateFin >= :today OR affectation.dateFin IS NULL') ->setParameter('today', $today) //->setParameter('noEnd', $noEnd) ->setParameter('false', 'N') ->orderBy('agent.nomUsuel, agent.prenom') ; if ($sousstructure) { $qb = $qb ->andWhere('affectation.structure IN (:structures)') ->setParameter('structures', $structures); } ->addSelect('statut')->leftJoin('agent.statuts', 'statut') ->addSelect('grade')->leftJoin('agent.grades', 'grade') ->orderBy('agent.nomUsuel, agent.prenom'); $result = $qb->getQuery()->getResult(); return $result; } Loading
module/Application/src/Application/Service/FichePoste/FichePosteServiceFactory.php +4 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Service\FichePoste; use Application\Service\Agent\AgentService; use Application\Service\Structure\StructureService; use Doctrine\ORM\EntityManager; use Interop\Container\ContainerInterface; Loading @@ -13,16 +14,19 @@ class FichePosteServiceFactory { { /** * @var EntityManager $entityManager * @var AgentService $agentService * @var StructureService $structureService * @var UserService $userService */ $entityManager = $container->get('doctrine.entitymanager.orm_default'); $agentService = $container->get(AgentService::class); $structureService = $container->get(StructureService::class); $userService = $container->get(UserService::class); /** @var FichePosteService $service */ $service = new FichePosteService(); $service->setEntityManager($entityManager); $service->setAgentService($agentService); $service->setStructureService($structureService); $service->setUserService($userService); Loading