Commit af7a1306 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout d'affichage du listing des agents ayant un grade ou un corps

parent bead7211
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -40,6 +40,16 @@ return [
                        CorpsPrivileges::CORPS_INDEX,
                    ],
                ],
                [
                    'controller' => CorpsController::class,
                    'action' => [
                        'afficher-agents-avec-corps',
                        'afficher-agents-avec-grade',
                    ],
                    'privileges' => [
                        CorpsPrivileges::CORPS_AFFICHER,
                    ],
                ],
                [
                    'controller' => CorpsController::class,
                    'action' => [
@@ -99,6 +109,28 @@ return [
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'afficher-agents-avec-corps' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher-agents-avec-corps/:corps',
                            'defaults' => [
                                'controller' => CorpsController::class,
                                'action'     => 'afficher-agents-avec-corps',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'afficher-agents-avec-grade' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher-agents-avec-grade/:grade',
                            'defaults' => [
                                'controller' => CorpsController::class,
                                'action'     => 'afficher-agents-avec-grade',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'modifier-niveau' => [
                        'type'  => Segment::class,
                        'options' => [
+24 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Controller;

use Application\Form\ModifierNiveau\ModifierNiveauFormAwareTrait;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\Categorie\CategorieServiceAwareTrait;
use Application\Service\Corps\CorpsServiceAwareTrait;
use Application\Service\Correspondance\CorrespondanceServiceAwareTrait;
@@ -12,6 +13,7 @@ use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class CorpsController extends AbstractActionController {
    use AgentServiceAwareTrait;
    use CategorieServiceAwareTrait;
    use CorpsServiceAwareTrait;
    use CorrespondanceServiceAwareTrait;
@@ -59,4 +61,26 @@ class CorpsController extends AbstractActionController {
        ]);
        return $vm;
    }

    public function afficherAgentsAvecCorpsAction() {
        $corps = $this->getCorpsService()->getRequestedCorps($this);
        $agents = $this->getAgentService()->getAgentsWithCorps($corps);

        return new ViewModel([
            'title' => 'Agents ayant le corps ['. $corps->getLibelleCourt().']',
            'corps' => $corps,
            'agents' => $agents,
        ]);
    }
    public function afficherAgentsAvecGradeAction() {
        $grade = $this->getGradeService()->getRequestedGrade($this);
        $agents = $this->getAgentService()->getAgentsWithGrade($grade);

        return new ViewModel([
            'title' => 'Agents ayant le grade ['. $grade->getLibelleCourt().']',
            'grade' => $grade,
            'agents' => $agents,
        ]);
    }

}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Controller;

use Application\Form\ModifierNiveau\ModifierNiveauForm;
use Application\Service\Agent\AgentService;
use Application\Service\Categorie\CategorieService;
use Application\Service\Corps\CorpsService;
use Application\Service\Correspondance\CorrespondanceService;
@@ -18,11 +19,13 @@ class CorpsControllerFactory {
    public function __invoke(ContainerInterface $container)
    {
        /**
         * @var AgentService $agentService
         * @var CategorieService $categorieService
         * @var CorpsService $corpsService
         * @var CorrespondanceService $correspondanceService
         * @var GradeService $gradeService
         */
        $agentService = $container->get(AgentService::class);
        $categorieService = $container->get(CategorieService::class);
        $corpsService = $container->get(CorpsService::class);
        $correspondanceService = $container->get(CorrespondanceService::class);
@@ -35,6 +38,7 @@ class CorpsControllerFactory {

        /** @var CorpsController $controller */
        $controller = new CorpsController();
        $controller->setAgentService($agentService);
        $controller->setCategorieService($categorieService);
        $controller->setCorpsService($corpsService);
        $controller->setCorrespondanceService($correspondanceService);
+28 −0
Original line number Diff line number Diff line
@@ -6,7 +6,10 @@ use Application\Entity\Db\Agent;
use Application\Entity\Db\AgentApplication;
use Application\Entity\Db\AgentCompetence;
use Application\Entity\Db\AgentFormation;
use Application\Entity\Db\AgentGrade;
use Application\Entity\Db\AgentMissionSpecifique;
use Application\Entity\Db\Corps;
use Application\Entity\Db\Grade;
use Application\Entity\Db\Structure;
use Application\Service\GestionEntiteHistorisationTrait;
use Application\Service\Structure\StructureServiceAwareTrait;
@@ -627,4 +630,29 @@ class AgentService {
        $this->deleteFromTrait($agentMissionSpecifique);
        return $agentMissionSpecifique;
    }

    public function getAgentsWithGrade(Grade $grade) {
        $qb = $this->getEntityManager()->getRepository(AgentGrade::class)->createQueryBuilder('agentgrade')
            ->addSelect('agent')->join('agentgrade.agent', 'agent')
            ->addSelect('grade')->join('agentgrade.grade', 'grade')
            ->andWhere('grade.id = :id')
            ->setParameter('id', $grade->getId())
            ->orderBy('agent.nomUsuel, agent.prenom', 'ASC')
        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    public function getAgentsWithCorps(Corps $corps) {
        $qb = $this->getEntityManager()->getRepository(AgentGrade::class)->createQueryBuilder('agentgrade')
            ->addSelect('agent')->join('agentgrade.agent', 'agent')
            ->addSelect('corps')->join('agentgrade.corps', 'corps')
            ->andWhere('corps.id = :id')
            ->setParameter('id', $corps->getId())
            ->orderBy('agent.nomUsuel, agent.prenom', 'ASC')
        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }

}
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -96,4 +96,6 @@ class CorpsService {
        $result = $this->getCorp($id);
        return $result;
    }


}
Loading