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

Accompagnement

parent f77d4c09
Loading
Loading
Loading
Loading
+85 −0
Original line number Diff line number Diff line
@@ -6,6 +6,10 @@ use Application\Assertion\AgentAssertion;
use Application\Assertion\AgentAssertionFactory;
use Application\Controller\AgentController;
use Application\Controller\AgentControllerFactory;
use Application\Form\AgentAccompagnement\AgentAccompagnementForm;
use Application\Form\AgentAccompagnement\AgentAccompagnementFormFactory;
use Application\Form\AgentAccompagnement\AgentAccompagnementHydrator;
use Application\Form\AgentAccompagnement\AgentAccompagnementHydratorFactory;
use Application\Form\AgentPPP\AgentPPPForm;
use Application\Form\AgentPPP\AgentPPPFormFactory;
use Application\Form\AgentPPP\AgentPPPHydrator;
@@ -25,6 +29,8 @@ use Application\Form\SelectionAgent\SelectionAgentHydratorFactory;
use Application\Provider\Privilege\AgentPrivileges;
use Application\Service\Agent\AgentService;
use Application\Service\Agent\AgentServiceFactory;
use Application\Service\AgentAccompagnement\AgentAccompagnementService;
use Application\Service\AgentAccompagnement\AgentAccompagnementServiceFactory;
use Application\Service\AgentPPP\AgentPPPService;
use Application\Service\AgentPPP\AgentPPPServiceFactory;
use Application\Service\AgentStageObservation\AgentStageObservationService;
@@ -166,6 +172,19 @@ return [
                        AgentPrivileges::AGENT_GESTION_CCC,
                    ],
                ],
                [
                    'controller' => AgentController::class,
                    'action' => [
                        'ajouter-accompagnement',
                        'modifier-accompagnement',
                        'historiser-accompagnement',
                        'restaurer-accompagnement',
                        'detruire-accompagnement',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_GESTION_CCC,
                    ],
                ],
            ],
        ],
    ],
@@ -508,6 +527,69 @@ return [
                            ],
                        ],
                    ],

                    'accompagnement' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/accompagnement',
                            'defaults' => [
                                'controller' => AgentController::class,
                            ],
                        ],
                        'may_terminate' => 'false',
                        'child_routes' => [
                            'ajouter' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/ajouter/:agent',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'ajouter-accompagnement'
                                    ],
                                ],
                            ],
                            'modifier' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/modifier/:accompagnement',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'modifier-accompagnement'
                                    ],
                                ],
                            ],
                            'historiser' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/historiser/:accompagnement',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'historiser-accompagnement'
                                    ],
                                ],
                            ],
                            'restaurer' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/restaurer/:accompagnement',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'restaurer-accompagnement'
                                    ],
                                ],
                            ],
                            'detruire' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/detruire/:accompagnement',
                                    'defaults' => [
                                        'controller' => AgentController::class,
                                        'action' => 'detruire-accompagnement'
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
@@ -543,6 +625,7 @@ return [
        'factories' => [
            AgentAssertion::class => AgentAssertionFactory::class,
            AgentService::class => AgentServiceFactory::class,
            AgentAccompagnementService::class => AgentAccompagnementServiceFactory::class,
            AgentPPPService::class => AgentPPPServiceFactory::class,
            AgentStageObservationService::class => AgentStageObservationServiceFactory::class,
            AgentTutoratService::class => AgentTutoratServiceFactory::class,
@@ -556,6 +639,7 @@ return [
    'form_elements' => [
        'factories' => [
            SelectionAgentForm::class => SelectionAgentFormFactory::class,
            AgentAccompagnementForm::class => AgentAccompagnementFormFactory::class,
            AgentPPPForm::class => AgentPPPFormFactory::class,
            AgentStageObservationForm::class => AgentStageObservationFormFactory::class,
            AgentTutoratForm::class => AgentTutoratFormFactory::class,
@@ -564,6 +648,7 @@ return [
    'hydrators' => [
        'factories' => [
            SelectionAgentHydrator::class => SelectionAgentHydratorFactory::class,
            AgentAccompagnementHydrator::class => AgentAccompagnementHydratorFactory::class,
            AgentPPPHydrator::class => AgentPPPHydratorFactory::class,
            AgentStageObservationHydrator::class => AgentStageObservationHydratorFactory::class,
            AgentTutoratHydrator::class => AgentTutoratHydratorFactory::class,
+109 −0
Original line number Diff line number Diff line
@@ -3,10 +3,12 @@
namespace Application\Controller;

use Application\Constant\RoleConstant;
use Application\Entity\Db\AgentAccompagnement;
use Application\Entity\Db\AgentPPP;
use Application\Entity\Db\AgentStageObservation;
use Application\Entity\Db\AgentTutorat;
use Application\Entity\Db\ApplicationElement;
use Application\Form\AgentAccompagnement\AgentAccompagnementFormAwareTrait;
use Application\Form\AgentPPP\AgentPPPFormAwareTrait;
use Application\Form\AgentStageObservation\AgentStageObservationFormAwareTrait;
use Application\Form\AgentTutorat\AgentTutoratFormAwareTrait;
@@ -14,6 +16,7 @@ use Application\Form\ApplicationElement\ApplicationElementFormAwareTrait;
use Application\Form\CompetenceElement\CompetenceElementFormAwareTrait;
use Application\Form\SelectionApplication\SelectionApplicationFormAwareTrait;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\AgentAccompagnement\AgentAccompagnementServiceAwareTrait;
use Application\Service\AgentPPP\AgentPPPServiceAwareTrait;
use Application\Service\AgentStageObservation\AgentStageObservationServiceAwareTrait;
use Application\Service\AgentTutorat\AgentTutoratServiceAwareTrait;
@@ -85,6 +88,8 @@ class AgentController extends AbstractActionController
    use AgentStageObservationFormAwareTrait;
    use AgentTutoratServiceAwareTrait;
    use AgentTutoratFormAwareTrait;
    use AgentAccompagnementServiceAwareTrait;
    use AgentAccompagnementFormAwareTrait;

    public function indexAction()
    {
@@ -147,6 +152,7 @@ class AgentController extends AbstractActionController
            'ppps' => $this->getAgentPPPService()->getAgentPPPsByAgent($agent),
            'stages' => $this->getAgentStageObservationService()->getAgentStageObservationsByAgent($agent),
            'tutorats' => $this->getAgentTutoratService()->getAgentTutoratsByAgent($agent),
            'accompagnements' => $this->getAgentAccompagnementService()->getAgentAccompagnementsByAgent($agent),
        ]);
    }

@@ -683,4 +689,107 @@ class AgentController extends AbstractActionController
        return $vm;
    }

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

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

        $accompagnement = new AgentAccompagnement();
        $accompagnement->setAgent($agent);

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

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

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

    public function modifierAccompagnementAction()
    {
        $accompagnement = $this->getAgentAccompagnementService()->getRequestedAgentAccompagnement($this);

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

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

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

    public function historiserAccompagnementAction()
    {
        $accompagnement = $this->getAgentAccompagnementService()->getRequestedAgentAccompagnement($this);
        $retour = $this->params()->fromQuery('retour');

        $this->getAgentAccompagnementService()->historise($accompagnement);

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

    public function restaurerAccompagnementAction()
    {
        $accompagnement = $this->getAgentAccompagnementService()->getRequestedAgentAccompagnement($this);
        $retour = $this->params()->fromQuery('retour');

        $this->getAgentAccompagnementService()->restore($accompagnement);

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

    public function detruireAccompagnementAction()
    {
        $accompagnement = $this->getAgentAccompagnementService()->getRequestedAgentAccompagnement($this);

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

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

}
+8 −0
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@

namespace Application\Controller;

use Application\Form\AgentAccompagnement\AgentAccompagnementForm;
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\AgentAccompagnement\AgentAccompagnementService;
use Application\Service\AgentPPP\AgentPPPService;
use Application\Service\AgentStageObservation\AgentStageObservationService;
use Application\Service\AgentTutorat\AgentTutoratService;
@@ -129,6 +131,8 @@ class AgentControllerFactory {
         * @var AgentStageObservationForm $agentStageObservationForm
         * @var AgentTutoratService $agentTutoratService
         * @var AgentTutoratForm $agentTutoratForm
         * @var AgentAccompagnementService $agentAccompagnementService
         * @var AgentAccompagnementForm $agentAccompagnementForm
         */
        $agentPPPService = $container->get(AgentPPPService::class);
        $agentPPPForm = $container->get('FormElementManager')->get(AgentPPPForm::class);
@@ -136,6 +140,8 @@ class AgentControllerFactory {
        $agentStageObservationForm = $container->get('FormElementManager')->get(AgentStageObservationForm::class);
        $agentTutoratService = $container->get(AgentTutoratService::class);
        $agentTutoratForm = $container->get('FormElementManager')->get(AgentTutoratForm::class);
        $agentAccompagnementService = $container->get(AgentAccompagnementService::class);
        $agentAccompagnementForm = $container->get('FormElementManager')->get(AgentAccompagnementForm::class);

        $controller->setAgentPPPService($agentPPPService);
        $controller->setAgentPPPForm($agentPPPForm);
@@ -143,6 +149,8 @@ class AgentControllerFactory {
        $controller->setAgentStageObservationForm($agentStageObservationForm);
        $controller->setAgentTutoratService($agentTutoratService);
        $controller->setAgentTutoratForm($agentTutoratForm);
        $controller->setAgentAccompagnementService($agentAccompagnementService);
        $controller->setAgentAccompagnementForm($agentAccompagnementForm);
        return $controller;
    }
}
 No newline at end of file
+176 −0
Original line number Diff line number Diff line
<?php

namespace Application\Entity\Db;

use Application\Entity\Db\Interfaces\HasPeriodeInterface;
use Application\Entity\Db\Traits\HasPeriodeTrait;
use UnicaenEtat\Entity\Db\Etat;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;

class AgentAccompagnement implements HasPeriodeInterface, HistoriqueAwareInterface {
    use HasPeriodeTrait;
    use HistoriqueAwareTrait;

    /** @var int */
    private $id;
    /** @var Agent */
    private $agent;
    /** @var Agent|null */
    private $cible;
    /** @var Correspondance|null */
    private $bap;
    /** @var Corps|null */
    private $corps;
    /** @var string|null */
    private $complement;
    /** @var bool|null */
    private $resultat;
    /** @var Etat|null */
    private $etat;

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @param int $id
     * @return AgentAccompagnement
     */
    public function setId(int $id): AgentAccompagnement
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @return Agent
     */
    public function getAgent(): Agent
    {
        return $this->agent;
    }

    /**
     * @param Agent $agent
     * @return AgentAccompagnement
     */
    public function setAgent(Agent $agent): AgentAccompagnement
    {
        $this->agent = $agent;
        return $this;
    }

    /**
     * @return Agent|null
     */
    public function getCible(): ?Agent
    {
        return $this->cible;
    }

    /**
     * @param Agent|null $cible
     * @return AgentAccompagnement
     */
    public function setCible(?Agent $cible): AgentAccompagnement
    {
        $this->cible = $cible;
        return $this;
    }

    /**
     * @return Correspondance|null
     */
    public function getBap(): ?Correspondance
    {
        return $this->bap;
    }

    /**
     * @param Correspondance|null $bap
     * @return AgentAccompagnement
     */
    public function setBap(?Correspondance $bap): AgentAccompagnement
    {
        $this->bap = $bap;
        return $this;
    }

    /**
     * @return Corps|null
     */
    public function getCorps(): ?Corps
    {
        return $this->corps;
    }

    /**
     * @param Corps|null $corps
     * @return AgentAccompagnement
     */
    public function setCorps(?Corps $corps): AgentAccompagnement
    {
        $this->corps = $corps;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getComplement(): ?string
    {
        return $this->complement;
    }

    /**
     * @param string|null $complement
     * @return AgentAccompagnement
     */
    public function setComplement(?string $complement): AgentAccompagnement
    {
        $this->complement = $complement;
        return $this;
    }

    /**
     * @return bool|null
     */
    public function getResultat(): ?bool
    {
        return $this->resultat;
    }

    /**
     * @param bool|null $resultat
     * @return AgentAccompagnement
     */
    public function setResultat(?bool $resultat): AgentAccompagnement
    {
        $this->resultat = $resultat;
        return $this;
    }

    /**
     * @return Etat|null
     */
    public function getEtat(): ?Etat
    {
        return $this->etat;
    }

    /**
     * @param Etat|null $etat
     * @return AgentAccompagnement
     */
    public function setEtat(?Etat $etat): AgentAccompagnement
    {
        $this->etat = $etat;
        return $this;
    }

}
 No newline at end of file
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Application\Entity\Db\AgentAccompagnement" table="agent_accompagnement">

        <id name="id" type="integer" column="id">
            <generator strategy="IDENTITY"/>
        </id>

        <many-to-one target-entity="Application\Entity\Db\Agent"  field="agent">
            <join-column name="agent_id" referenced-column-name="c_individu"/>
        </many-to-one>
        <many-to-one target-entity="Application\Entity\Db\Agent"  field="cible">
            <join-column name="cible_id" referenced-column-name="c_individu"/>
        </many-to-one>
        <many-to-one target-entity="Application\Entity\Db\Correspondance"  field="bap">
            <join-column name="bap_id" referenced-column-name="id"/>
        </many-to-one>
        <many-to-one target-entity="Application\Entity\Db\Corps"  field="corps">
            <join-column name="corps_id" referenced-column-name="id"/>
        </many-to-one>
        <field name="complement"              column="complement"            type="string"   length="9999"/>
        <field name="resultat"                column="resultat"             type="boolean"/>
        <field name="dateDebut"               column="date_debut"           type="datetime"/>
        <field name="dateFin"                 column="date_fin"             type="datetime"/>
        <many-to-one target-entity="UnicaenEtat\Entity\Db\Etat"  field="etat">
            <join-column name="etat_id" referenced-column-name="id"/>
        </many-to-one>

        <!-- HISTORISATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <field name="histoCreation"     type="datetime"                 column="histo_creation"     nullable="false"/>
        <field name="histoModification" type="datetime"                 column="histo_modification" nullable="false"/>
        <field name="histoDestruction"  type="datetime"                 column="histo_destruction"  nullable="true"/>
        <many-to-one target-entity="UnicaenUtilisateur\Entity\Db\User"  field="histoCreateur">
            <join-column name="histo_createur_id" referenced-column-name="id"/>
        </many-to-one>
        <many-to-one target-entity="UnicaenUtilisateur\Entity\Db\User"  field="histoModificateur">
            <join-column name="histo_modificateur_id" referenced-column-name="id"/>
        </many-to-one>
        <many-to-one target-entity="UnicaenUtilisateur\Entity\Db\User"  field="histoDestructeur">
            <join-column name="histo_destructeur_id" referenced-column-name="id"/>
        </many-to-one>
    </entity>
</doctrine-mapping>
Loading