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

Mes-formations persque ok

parent 27a9122b
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -446,4 +446,20 @@ class AgentStatut implements HasPeriodeInterface {
        $this->retraite = $retraite;
        return $this;
    }

    /**
     * @param AgentStatut[] $agentStatuts
     * @return string[]
     */
    public static function generateStatutsArray(array $agentStatuts) : array
    {
        $statuts = [];
        foreach ($agentStatuts as $agentStatut) {
            if ($agentStatut->isTitulaire()) $statuts['Titulaire'] = 'Titulaire';
            if ($agentStatut->isCdi()) $statuts['C.D.I'] = 'C.D.I.';
            if ($agentStatut->isCdd()) $statuts['C.D.D'] = 'C.D.D.';
            if ($agentStatut->isAdministratif()) $statuts['Administratif'] = 'Administratif';
        }
        return $statuts;
    }
}
 No newline at end of file
+15 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ return [
                    'controller' => AgentController::class,
                    'action' => [
                        'mes-agents',
                        'lister-mes-agents',
                    ],
                    'privilege' => [
                        FormationagentPrivileges::getResourceId(FormationagentPrivileges::FORMATIONAGENT_MESAGENTS),
@@ -111,6 +112,20 @@ return [
                            ],
                        ],
                        'may_terminate' => true,
                        'child_routes' => [
                            'lister' => [
                                'type'  => Literal::class,
                                'options' => [
                                    /** @see AgentController::indexAction() */
                                    'route'    => '/lister',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action'     => 'lister-mes-agents',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                        ],
                    ],
                ],
            ],
+14 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ return [
                    'controller' => StructureController::class,
                    'action' => [
                        'afficher',
                        'lister-les-agents',
                    ],
                    'privilege' => [
                        FormationstructurePrivileges::getResourceId(FormationstructurePrivileges::FORMATIONSTRUCTURE_AFFICHER),
@@ -101,6 +102,19 @@ return [
                            ],
                        ],
                        'may_terminate' => true,
                        'child_routes' => [
                            'lister-les-agents' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/lister-les-agents',
                                    'defaults' => [
                                        'controller' => StructureController::class,
                                        'action'     => 'lister-les-agents',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                        ],
                    ],
                ],
            ],
+33 −1
Original line number Diff line number Diff line
@@ -2,11 +2,13 @@

namespace Formation\Controller;

use Application\Entity\Db\Agent;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\AgentAffectation\AgentAffectationServiceAwareTrait;
use Application\Service\AgentGrade\AgentGradeServiceAwareTrait;
use Application\Service\AgentStatut\AgentStatutServiceAwareTrait;
use Formation\Entity\Db\DemandeExterne;
use Formation\Entity\Db\Formation;
use Formation\Provider\Etat\DemandeExterneEtats;
use Formation\Service\DemandeExterne\DemandeExterneServiceAwareTrait;
use Formation\Service\FormationInstanceInscrit\FormationInstanceInscritServiceAwareTrait;
@@ -48,7 +50,6 @@ class AgentController extends AbstractActionController {
        $formations = $this->getFormationInstanceInscritService()->getFormationsBySuivies($agent);
        $inscriptions = $this->getFormationInstanceInscritService()->getFormationsByInscrit($agent);

        $stages = [];
        $demandes = $this->getDemandeExterneService()->getDemandesExternesByAgent($agent);
        $demandes = array_filter($demandes, function (DemandeExterne $d) { return $d->estNonHistorise() AND $d->getEtat()->getCode() !== DemandeExterneEtats::ETAT_REJETEE AND $d->getEtat()->getCode() !== DemandeExterneEtats::ETAT_TERMINEE;});
//        $demandesValidees    = array_filter($demandes, function (DemandeExterne $d) { return $d->getEtat()->getCode() !== DemandeExterneEtats::ETAT_CREATION_EN_COURS; });
@@ -71,7 +72,38 @@ class AgentController extends AbstractActionController {
        $role = $this->getUserService()->getConnectedRole();

        $agents = $this->getAgentService()->getAgentsByResponsabilite($user, $role);

        $inscriptionsValidees = $this->getFormationInstanceInscritService()->getInscriptionsValideesByAgents($agents, null);
        $inscriptionsNonValidees = $this->getFormationInstanceInscritService()->getInscriptionsNonValideesByAgents($agents, null);
        $demandesValidees =  $this->getDemandeExterneService()->getDemandesExternesValideesByAgents($agents, Formation::getAnnee());
        $demandesNonValidees =  $this->getDemandeExterneService()->getDemandesExternesNonValideesByAgents($agents, Formation::getAnnee());


        return new ViewModel([
            'user' => $user,
            'role' => $role,
            'agents' => $agents,

            'inscriptionsValidees' => $inscriptionsValidees,
            'inscriptionsNonValidees' => $inscriptionsNonValidees,
            'demandesValidees' => $demandesValidees,
            'demandesNonValidees' => $demandesNonValidees,
        ]);
    }

    public function listerMesAgentsAction() : ViewModel
    {
        $user = $this->getUserService()->getConnectedUser();
        $role = $this->getUserService()->getConnectedRole();

        $agents = $this->getAgentService()->getAgentsByResponsabilite($user, $role);
        usort($agents, function (Agent $a, Agent $b) {
            $aaa = $a->getNomUsuel()." ".$a->getPrenom()." ".$a->getId();
            $bbb = $b->getNomUsuel()." ".$b->getPrenom()." ".$b->getId();
            return $aaa > $bbb;
        });
        return new ViewModel([
            'title' => "Liste des agents dont je suis responsable",
            'user' => $user,
            'role' => $role,
            'agents' => $agents,
+20 −0
Original line number Diff line number Diff line
@@ -78,4 +78,24 @@ class StructureController extends AbstractActionController
            'inscriptionsValidees' => $inscriptionsValidees,
        ]);
    }

    public function listerLesAgentsAction() : ViewModel
    {
        /**  Récupération du sous-arbre des structures */
        $structure = $this->getStructureService()->getRequestedStructure($this);

        $structures = $this->getStructureService()->getStructuresFilles($structure);
        $structures[] =  $structure;

        /** Récupération des agents et postes liés aux structures */
        $agents = $this->getAgentService()->getAgentsByStructures($structures);
        $agentsForces = $this->getStructureService()->getAgentsForces($structure);
        $agentsForces = array_map(function (StructureAgentForce $a) { return $a->getAgent(); }, $agentsForces);
        $allAgents = array_merge($agents, $agentsForces);

        return new ViewModel([
            'title' => "Liste des agents liés à la structure",
            'agents' => $allAgents,
        ]);
    }
}
 No newline at end of file
Loading