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

Stage + tutorat

parent c14da39c
Loading
Loading
Loading
Loading
+169 −0
Original line number Diff line number Diff line
@@ -10,6 +10,14 @@ use Application\Form\AgentPPP\AgentPPPForm;
use Application\Form\AgentPPP\AgentPPPFormFactory;
use Application\Form\AgentPPP\AgentPPPHydrator;
use Application\Form\AgentPPP\AgentPPPHydratorFactory;
use Application\Form\AgentStageObservation\AgentStageObservationForm;
use Application\Form\AgentStageObservation\AgentStageObservationFormFactory;
use Application\Form\AgentStageObservation\AgentStageObservationHydrator;
use Application\Form\AgentStageObservation\AgentStageObservationHydratorFactory;
use Application\Form\AgentTutorat\AgentTutoratForm;
use Application\Form\AgentTutorat\AgentTutoratFormFactory;
use Application\Form\AgentTutorat\AgentTutoratHydrator;
use Application\Form\AgentTutorat\AgentTutoratHydratorFactory;
use Application\Form\SelectionAgent\SelectionAgentForm;
use Application\Form\SelectionAgent\SelectionAgentFormFactory;
use Application\Form\SelectionAgent\SelectionAgentHydrator;
@@ -19,6 +27,10 @@ use Application\Service\Agent\AgentService;
use Application\Service\Agent\AgentServiceFactory;
use Application\Service\AgentPPP\AgentPPPService;
use Application\Service\AgentPPP\AgentPPPServiceFactory;
use Application\Service\AgentStageObservation\AgentStageObservationService;
use Application\Service\AgentStageObservation\AgentStageObservationServiceFactory;
use Application\Service\AgentTutorat\AgentTutoratService;
use Application\Service\AgentTutorat\AgentTutoratServiceFactory;
use Application\View\Helper\AgentAffectationViewHelper;
use Application\View\Helper\AgentGradeViewHelper;
use Application\View\Helper\AgentStatutViewHelper;
@@ -128,6 +140,32 @@ return [
                        AgentPrivileges::AGENT_GESTION_CCC,
                    ],
                ],
                [
                    'controller' => AgentController::class,
                    'action' => [
                        'ajouter-stage-observation',
                        'modifier-stage-observation',
                        'historiser-stage-observation',
                        'restaurer-stage-observation',
                        'detruire-stage-observation',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_GESTION_CCC,
                    ],
                ],
                [
                    'controller' => AgentController::class,
                    'action' => [
                        'ajouter-tutorat',
                        'modifier-tutorat',
                        'historiser-tutorat',
                        'restaurer-tutorat',
                        'detruire-tutorat',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_GESTION_CCC,
                    ],
                ],
            ],
        ],
    ],
@@ -345,6 +383,131 @@ return [
                            ],
                        ],
                    ],
                    'stageobs' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/stage-observation',
                            'defaults' => [
                                'controller' => AgentController::class,
                            ],
                        ],
                        'may_terminate' => 'false',
                        'child_routes' => [
                            'ajouter' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/ajouter/:agent',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'ajouter-stage-observation'
                                    ],
                                ],
                            ],
                            'modifier' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/modifier/:stageobs',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'modifier-stage-observation'
                                    ],
                                ],
                            ],
                            'historiser' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/historiser/:stageobs',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'historiser-stage-observation'
                                    ],
                                ],
                            ],
                            'restaurer' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/restaurer/:stageobs',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'restaurer-stage-observation'
                                    ],
                                ],
                            ],
                            'detruire' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/detruire/:stageobs',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'detruire-stage-observation'
                                    ],
                                ],
                            ],
                        ],
                    ],

                    'tutorat' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/stage-tutorat',
                            'defaults' => [
                                'controller' => AgentController::class,
                            ],
                        ],
                        'may_terminate' => 'false',
                        'child_routes' => [
                            'ajouter' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/ajouter/:agent',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'ajouter-tutorat'
                                    ],
                                ],
                            ],
                            'modifier' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/modifier/:tutorat',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'modifier-tutorat'
                                    ],
                                ],
                            ],
                            'historiser' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/historiser/:tutorat',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'historiser-tutorat'
                                    ],
                                ],
                            ],
                            'restaurer' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/restaurer/:tutorat',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'restaurer-tutorat'
                                    ],
                                ],
                            ],
                            'detruire' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/detruire/:tutorat',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'detruire-tutorat'
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
@@ -381,6 +544,8 @@ return [
            AgentAssertion::class => AgentAssertionFactory::class,
            AgentService::class => AgentServiceFactory::class,
            AgentPPPService::class => AgentPPPServiceFactory::class,
            AgentStageObservationService::class => AgentStageObservationServiceFactory::class,
            AgentTutoratService::class => AgentTutoratServiceFactory::class,
        ],
    ],
    'controllers'     => [
@@ -392,12 +557,16 @@ return [
        'factories' => [
            SelectionAgentForm::class => SelectionAgentFormFactory::class,
            AgentPPPForm::class => AgentPPPFormFactory::class,
            AgentStageObservationForm::class => AgentStageObservationFormFactory::class,
            AgentTutoratForm::class => AgentTutoratFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [
            SelectionAgentHydrator::class => SelectionAgentHydratorFactory::class,
            AgentPPPHydrator::class => AgentPPPHydratorFactory::class,
            AgentStageObservationHydrator::class => AgentStageObservationHydratorFactory::class,
            AgentTutoratHydrator::class => AgentTutoratHydratorFactory::class,
        ],
    ],
    'view_helpers' => [
+220 −1
Original line number Diff line number Diff line
@@ -4,13 +4,19 @@ namespace Application\Controller;

use Application\Constant\RoleConstant;
use Application\Entity\Db\AgentPPP;
use Application\Entity\Db\AgentStageObservation;
use Application\Entity\Db\AgentTutorat;
use Application\Entity\Db\ApplicationElement;
use Application\Form\AgentPPP\AgentPPPFormAwareTrait;
use Application\Form\AgentStageObservation\AgentStageObservationFormAwareTrait;
use Application\Form\AgentTutorat\AgentTutoratFormAwareTrait;
use Application\Form\ApplicationElement\ApplicationElementFormAwareTrait;
use Application\Form\CompetenceElement\CompetenceElementFormAwareTrait;
use Application\Form\SelectionApplication\SelectionApplicationFormAwareTrait;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\AgentPPP\AgentPPPServiceAwareTrait;
use Application\Service\AgentStageObservation\AgentStageObservationServiceAwareTrait;
use Application\Service\AgentTutorat\AgentTutoratServiceAwareTrait;
use Application\Service\Application\ApplicationServiceAwareTrait;
use Application\Service\ApplicationElement\ApplicationElementServiceAwareTrait;
use Application\Service\Categorie\CategorieServiceAwareTrait;
@@ -75,6 +81,10 @@ class AgentController extends AbstractActionController

    use AgentPPPServiceAwareTrait;
    use AgentPPPFormAwareTrait;
    use AgentStageObservationServiceAwareTrait;
    use AgentStageObservationFormAwareTrait;
    use AgentTutoratServiceAwareTrait;
    use AgentTutoratFormAwareTrait;

    public function indexAction()
    {
@@ -135,6 +145,8 @@ class AgentController extends AbstractActionController
            'missions' => $missions,

            'ppps' => $this->getAgentPPPService()->getAgentPPPsByAgent($agent),
            'stages' => $this->getAgentStageObservationService()->getAgentStageObservationsByAgent($agent),
            'tutorats' => $this->getAgentTutoratService()->getAgentTutoratsByAgent($agent),
        ]);
    }

@@ -464,4 +476,211 @@ class AgentController extends AbstractActionController
        }
        return $vm;
    }

    /** * * * * * * * **/

    public function ajouterStageObservationAction()
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);

        $stageObservation = new AgentStageObservation();
        $stageObservation->setAgent($agent);

        $form = $this->getAgentStageObservationForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/stageobs/ajouter', ['agent' => $agent->getId()], [], true));
        $form->bind($stageObservation);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAgentStageObservationService()->create($stageObservation);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Ajouter un stage d'observation",
            'form' => $form,
        ]);
        return $vm;
    }

    public function modifierStageObservationAction()
    {
        $stageObservation = $this->getAgentStageObservationService()->getRequestedAgentStageObservation($this);

        $form = $this->getAgentStageObservationForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/stageobs/modifier', ['stageobs' => $stageObservation->getId()], [], true));
        $form->bind($stageObservation);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAgentStageObservationService()->update($stageObservation);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Modifier un stage d'observation",
            'form' => $form,
        ]);
        return $vm;
    }

    public function historiserStageObservationAction()
    {
        $stageObservation = $this->getAgentStageObservationService()->getRequestedAgentStageObservation($this);
        $retour = $this->params()->fromQuery('retour');

        $this->getAgentStageObservationService()->historise($stageObservation);

        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('agent/afficher', ['agent' => $stageObservation->getAgent()->getId()], ['fragment' => 'ppp'], true);
    }

    public function restaurerStageObservationAction()
    {
        $stageObservation = $this->getAgentStageObservationService()->getRequestedAgentStageObservation($this);
        $retour = $this->params()->fromQuery('retour');

        $this->getAgentStageObservationService()->restore($stageObservation);

        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('agent/afficher', ['agent' => $stageObservation->getAgent()->getId()], ['fragment' => 'ppp'], true);
    }

    public function detruireStageObservationAction()
    {
        $stageObservation = $this->getAgentStageObservationService()->getRequestedAgentStageObservation($this);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getAgentStageObservationService()->delete($stageObservation);
            exit();
        }

        $vm = new ViewModel();
        if ($stageObservation !== null) {
            $vm->setTemplate('application/default/confirmation');
            $vm->setVariables([
                'title' => "Suppression du stage d'observation #" . $stageObservation->getId(),
                'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('agent/stageobs/detruire', ["ppp" => $stageObservation->getId()], [], true),
            ]);
        }
        return $vm;
    }

    /** * * * * * * * **/

    public function ajouterTutoratAction()
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);

        $tutorat = new AgentTutorat();
        $tutorat->setAgent($agent);

        $form = $this->getAgentTutoratForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/tutorat/ajouter', ['agent' => $agent->getId()], [], true));
        $form->bind($tutorat);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAgentTutoratService()->create($tutorat);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Ajouter un tutorat",
            'form' => $form,
        ]);
        return $vm;
    }

    public function modifierTutoratAction()
    {
        $tutorat = $this->getAgentTutoratService()->getRequestedAgentTutorat($this);

        $form = $this->getAgentTutoratForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/tutorat/modifier', ['tutorat' => $tutorat->getId()], [], true));
        $form->bind($tutorat);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAgentTutoratService()->update($tutorat);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Modifier un tutorat",
            'form' => $form,
        ]);
        return $vm;
    }

    public function historiserTutoratAction()
    {
        $tutorat = $this->getAgentTutoratService()->getRequestedAgentTutorat($this);
        $retour = $this->params()->fromQuery('retour');

        $this->getAgentTutoratService()->historise($tutorat);

        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('agent/afficher', ['agent' => $tutorat->getAgent()->getId()], ['fragment' => 'tutorat'], true);
    }

    public function restaurerTutoratAction()
    {
        $tutorat = $this->getAgentTutoratService()->getRequestedAgentTutorat($this);
        $retour = $this->params()->fromQuery('retour');

        $this->getAgentTutoratService()->restore($tutorat);

        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('agent/afficher', ['agent' => $tutorat->getAgent()->getId()], ['fragment' => 'tutorat'], true);
    }

    public function detruireTutoratAction()
    {
        $tutorat = $this->getAgentTutoratService()->getRequestedAgentTutorat($this);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getAgentTutoratService()->delete($tutorat);
            exit();
        }

        $vm = new ViewModel();
        if ($tutorat !== null) {
            $vm->setTemplate('application/default/confirmation');
            $vm->setVariables([
                'title' => "Suppression du tutorat #" . $tutorat->getId(),
                'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('agent/tutorat/detruire', ["tutorat" => $tutorat->getId()], [], true),
            ]);
        }
        return $vm;
    }

}
+23 −5
Original line number Diff line number Diff line
@@ -3,10 +3,14 @@
namespace Application\Controller;

use Application\Form\AgentPPP\AgentPPPForm;
use Application\Form\AgentStageObservation\AgentStageObservationForm;
use Application\Form\AgentTutorat\AgentTutoratForm;
use Application\Form\ApplicationElement\ApplicationElementForm;
use Application\Form\CompetenceElement\CompetenceElementForm;
use Application\Service\Agent\AgentService;
use Application\Service\AgentPPP\AgentPPPService;
use Application\Service\AgentStageObservation\AgentStageObservationService;
use Application\Service\AgentTutorat\AgentTutoratService;
use Application\Service\Application\ApplicationService;
use Application\Service\ApplicationElement\ApplicationElementService;
use Application\Service\Categorie\CategorieService;
@@ -56,8 +60,6 @@ class AgentControllerFactory {
         *
         * @var FichePosteService $fichePosteService
         *
         * @var AgentPPPService $agentPPPService
         * @var AgentPPPForm $agentPPPForm
         */
        $agentService = $container->get(AgentService::class);
        $applicationElementService = $container->get(ApplicationElementService::class);
@@ -90,9 +92,6 @@ class AgentControllerFactory {
        $formationElementForm = $container->get('FormElementManager')->get(FormationElementForm::class);
        $uploadForm = $container->get('FormElementManager')->get(UploadForm::class);

        $agentPPPService = $container->get(AgentPPPService::class);
        $agentPPPForm = $container->get('FormElementManager')->get(AgentPPPForm::class);

        /** @var AgentController $controller */
        $controller = new AgentController();

@@ -123,8 +122,27 @@ class AgentControllerFactory {
        $controller->setFormationElementForm($formationElementForm);
        $controller->setUploadForm($uploadForm);

        /**
         * @var AgentPPPService $agentPPPService
         * @var AgentPPPForm $agentPPPForm
         * @var AgentStageObservationService $agentStageObservationService
         * @var AgentStageObservationForm $agentStageObservationForm
         * @var AgentTutoratService $agentTutoratService
         * @var AgentTutoratForm $agentTutoratForm
         */
        $agentPPPService = $container->get(AgentPPPService::class);
        $agentPPPForm = $container->get('FormElementManager')->get(AgentPPPForm::class);
        $agentStageObservationService = $container->get(AgentStageObservationService::class);
        $agentStageObservationForm = $container->get('FormElementManager')->get(AgentStageObservationForm::class);
        $agentTutoratService = $container->get(AgentTutoratService::class);
        $agentTutoratForm = $container->get('FormElementManager')->get(AgentTutoratForm::class);

        $controller->setAgentPPPService($agentPPPService);
        $controller->setAgentPPPForm($agentPPPForm);
        $controller->setAgentStageObservationService($agentStageObservationService);
        $controller->setAgentStageObservationForm($agentStageObservationForm);
        $controller->setAgentTutoratService($agentTutoratService);
        $controller->setAgentTutoratForm($agentTutoratForm);
        return $controller;
    }
}
 No newline at end of file
+127 −0

File added.

Preview size limit exceeded, changes collapsed.

+146 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading