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

Formation dans le nouveau système + retouche parcours de formation

parent 564e6d14
Loading
Loading
Loading
Loading
+24 −30
Original line number Diff line number Diff line
@@ -6,10 +6,6 @@ use Application\Assertion\AgentAssertion;
use Application\Assertion\AgentAssertionFactory;
use Application\Controller\AgentController;
use Application\Controller\AgentControllerFactory;
use Application\Form\AgentFormation\AgentFormationForm;
use Application\Form\AgentFormation\AgentFormationFormFactory;
use Application\Form\AgentFormation\AgentFormationHydrator;
use Application\Form\AgentFormation\AgentFormationHydratorFactory;
use Application\Form\SelectionAgent\SelectionAgentForm;
use Application\Form\SelectionAgent\SelectionAgentFormFactory;
use Application\Form\SelectionAgent\SelectionAgentHydrator;
@@ -85,7 +81,7 @@ return [
                        'afficher-statuts-grades',
                        'afficher-application',
                        'afficher-competence',
                        'afficher-agent-formation',
                        'afficher-formation',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_ELEMENT_VOIR,
@@ -106,7 +102,7 @@ return [
                    'action' => [
                        'ajouter-application',
                        'ajouter-competence',
                        'ajouter-agent-formation',
                        'ajouter-formation',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_ELEMENT_AJOUTER,
@@ -118,7 +114,7 @@ return [
                    'action' => [
                        'modifier-application',
                        'modifier-competence',
                        'modifier-agent-formation',
                        'modifier-formation',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_ELEMENT_MODIFIER,
@@ -132,8 +128,8 @@ return [
                        'restaurer-application',
                        'historiser-competence',
                        'restaurer-competence',
                        'historiser-agent-formation',
                        'restaurer-agent-formation',
                        'historiser-formation',
                        'restaurer-formation',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_ELEMENT_MODIFIER,
@@ -143,7 +139,7 @@ return [
                [
                    'controller' => AgentController::class,
                    'action' => [
                        'detruire-agent-formation',
                        'detruire-formation',
                        'detruire-competence',
                        'detruire-application',
                    ],
@@ -350,63 +346,63 @@ return [

                    /** Route des AgentFormation **********************************************************************/

                    'ajouter-agent-formation' => [
                    'ajouter-formation' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/ajouter-agent-formation/:agent[/:formation]',
                            'route'    => '/ajouter-formation/:agent',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'ajouter-agent-formation',
                                'action'     => 'ajouter-formation',
                            ],
                        ],
                    ],
                    'afficher-agent-formation' => [
                    'afficher-formation' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher-agent-formation/:agent-formation',
                            'route'    => '/afficher-formation/:agent/:formation-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'afficher-agent-formation',
                                'action'     => 'afficher-formation',
                            ],
                        ],
                    ],
                    'modifier-agent-formation' => [
                    'modifier-formation' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/modifier-agent-formation/:agent-formation',
                            'route'    => '/modifier-formation/:agent/:formation-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'modifier-agent-formation',
                                'action'     => 'modifier-formation',
                            ],
                        ],
                    ],
                    'historiser-agent-formation' => [
                    'historiser-formation' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/historiser-agent-formation/:agent-formation',
                            'route'    => '/historiser-formation/:agent/:formation-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'historiser-agent-formation',
                                'action'     => 'historiser-formation',
                            ],
                        ],
                    ],
                    'restaurer-agent-formation' => [
                    'restaurer-formation' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/restaurer-agent-formation/:agent-formation',
                            'route'    => '/restaurer-formation/:agent/:formation-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'restaurer-agent-formation',
                                'action'     => 'restaurer-formation',
                            ],
                        ],
                    ],
                    'detruire-agent-formation' => [
                    'detruire-formation' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/detruire-agent-formation/:agent-formation',
                            'route'    => '/detruire-formation/:agent/:formation-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'detruire-agent-formation',
                                'action'     => 'detruire-formation',
                            ],
                        ],
                    ],
@@ -504,13 +500,11 @@ return [
    ],
    'form_elements' => [
        'factories' => [
            AgentFormationForm::class => AgentFormationFormFactory::class,
            SelectionAgentForm::class => SelectionAgentFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [
            AgentFormationHydrator::class => AgentFormationHydratorFactory::class,
            SelectionAgentHydrator::class => SelectionAgentHydratorFactory::class,
        ],
    ],
+55 −43
Original line number Diff line number Diff line
@@ -4,10 +4,8 @@ namespace Application\Controller;

use Application\Constant\RoleConstant;
use Application\Entity\Db\Agent;
use Application\Entity\Db\AgentFormation;
use Application\Entity\Db\ApplicationElement;
use Application\Entity\Db\CompetenceElement;
use Application\Form\AgentFormation\AgentFormationFormAwareTrait;
use Application\Form\ApplicationElement\ApplicationElementForm;
use Application\Form\ApplicationElement\ApplicationElementFormAwareTrait;
use Application\Form\CompetenceElement\CompetenceElementForm;
@@ -27,7 +25,12 @@ use Fichier\Entity\Db\Fichier;
use Fichier\Form\Upload\UploadFormAwareTrait;
use Fichier\Service\Fichier\FichierServiceAwareTrait;
use Fichier\Service\Nature\NatureServiceAwareTrait;
use Formation\Entity\Db\FormationElement;
use Formation\Form\FormationElement\FormationElementForm;
use Formation\Form\FormationElement\FormationElementFormAwareTrait;
use Formation\Service\Formation\FormationServiceAwareTrait;
use Formation\Service\FormationElement\FormationElementServiceAwareTrait;
use Formation\Service\HasFormationCollection\HasFormationCollectionServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use UnicaenValidation\Entity\Db\ValidationInstance;
@@ -41,10 +44,13 @@ use Zend\View\Model\ViewModel;
class AgentController extends AbstractActionController
{
    use AgentServiceAwareTrait;

    use ApplicationElementServiceAwareTrait;
    use HasApplicationCollectionServiceAwareTrait;
    use CompetenceElementServiceAwareTrait;
    use HasCompetenceCollectionServiceAwareTrait;
    use FormationElementServiceAwareTrait;
    use HasFormationCollectionServiceAwareTrait;

    use EntretienProfessionnelServiceAwareTrait;
    use ValidationInstanceServiceAwareTrait;
@@ -59,7 +65,7 @@ class AgentController extends AbstractActionController

    use ApplicationElementFormAwareTrait;
    use CompetenceElementFormAwareTrait;
    use AgentFormationFormAwareTrait;
    use FormationElementFormAwareTrait;
    use SelectionApplicationFormAwareTrait;
    use UploadFormAwareTrait;

@@ -354,19 +360,17 @@ class AgentController extends AbstractActionController
        return $vm;
    }

    /** Gestion des formations ****************************************************************************************/
    /** Gestion des formation ***************************************************************************************/

    public function ajouterAgentFormationAction()
    public function ajouterFormationAction()
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $formation = $this->getFormationService()->getRequestedFormation($this);
        $formationElement = new FormationElement();

        $agentFormation = new AgentFormation();
        $agentFormation->setAgent($agent);
        $agentFormation->setFormation($formation);
        $form = $this->getAgentFormationForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/ajouter-agent-formation', ['agent' => $agent->getId(), 'formation' => ($formation) ? $formation->getId() : null]));
        $form->bind($agentFormation);
        /** @var FormationElementForm $form */
        $form = $this->getFormationElementForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/ajouter-formation', ['agent' => $agent->getId()], [], true));
        $form->bind($formationElement);

        /** @var Request $request */
        $request = $this->getRequest();
@@ -374,34 +378,39 @@ class AgentController extends AbstractActionController
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAgentService()->createAgentFormation($agentFormation);
                $this->getHasFormationCollectionService()->addFormation($agent, $formationElement);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Ajout d'une formation associée à un agent",
            'title' => "Ajout d'une formation suivie par l'agent",
            'form' => $form,
        ]);
        return $vm;
    }

    public function afficherAgentFormationAction()
    public function afficherFormationAction()
    {
        $agentFormation = $this->getAgentService()->getRequestedAgentFormation($this);
        $formationElement = $this->getFormationElementService()->getRequestedFormationElement($this);
        $agent = $this->getAgentService()->getRequestedAgent($this);

        return new ViewModel([
            'title' => "Affichage d'une formation",
            'agentFormation' => $agentFormation,
            'title' => "Affichage d'une formation suivie par un agent",
            'formationElement' => $formationElement,
            'agent' => $agent,
        ]);
    }

    public function modifierAgentFormationAction()
    public function modifierFormationAction()
    {
        $agentFormation = $this->getAgentService()->getRequestedAgentFormation($this);
        $form = $this->getAgentFormationForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/modifier-agent-formation', ['agent-formation' => $agentFormation->getId()]));
        $form->bind($agentFormation);
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $formationElement = $this->getFormationElementService()->getRequestedFormationElement($this);

        $form = $this->getFormationElementForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/modifier-formation', ['agent' => $agent->getId(), 'formation-element' => $formationElement->getId()]));
        $form->bind($formationElement);

        /** @var Request $request */
        $request = $this->getRequest();
@@ -409,61 +418,64 @@ class AgentController extends AbstractActionController
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getAgentService()->updateAgentFormation($agentFormation);
                $this->getFormationElementService()->update($formationElement);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Modification d'une formation associée à un agent",
            'title' => "Modification d'une formation suivie par un agent",
            'form' => $form,
        ]);
        return $vm;
    }

    public function historiserAgentFormationAction()
    public function historiserFormationAction()
    {
        $retour = $this->params()->fromQuery('retour');

        $agentFormation = $this->getAgentService()->getRequestedAgentFormation($this);
        $this->getAgentService()->historiserAgentFormation($agentFormation);
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $formationElement = $this->getFormationElementService()->getRequestedFormationElement($this);
        $this->getFormationElementService()->historise($formationElement);

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

    public function restaurerAgentFormationAction()
    public function restaurerFormationAction()
    {
        $retour = $this->params()->fromQuery('retour');

        $agentFormation = $this->getAgentService()->getRequestedAgentFormation($this);
        $this->getAgentService()->restoreAgentFormation($agentFormation);
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $formationElement = $this->getFormationElementService()->getRequestedFormationElement($this);
        $this->getFormationElementService()->restore($formationElement);

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

    public function detruireAgentFormationAction()
    public function detruireFormationAction()
    {
        $agentFormation = $this->getAgentService()->getRequestedAgentFormation($this);
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $formationElement = $this->getFormationElementService()->getRequestedFormationElement($this);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getAgentService()->deleteAgentFormation($agentFormation);
            //return $this->redirect()->toRoute('home');
            //la cascade doit gérer l'affaire
            if ($data["reponse"] === "oui") $this->getFormationElementService()->delete($formationElement);
            exit();
        }

        $vm = new ViewModel();
        if ($agentFormation !== null) {
        if ($formationElement !== null) {
            $vm->setTemplate('application/default/confirmation');
            $vm->setVariables([
                'title' => "Suppression de la formation  de " . $agentFormation->getAgent()->getDenomination(),
                'title' => "Suppression de la formation de " . $formationElement->getFormation()->getLibelle(),
                'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('agent/detruire-agent-formation', ["agent-formation" => $agentFormation->getId()], [], true),
                'action' => $this->url()->fromRoute('agent/detruire-formation', ["agent" => $agent->getId(), "formation-element" => $formationElement->getId()], [], true),
            ]);
        }
        return $vm;
@@ -491,7 +503,7 @@ class AgentController extends AbstractActionController
                $elementText = "la compétence [" . $entity->getCompetence()->getLibelle() . "]";
                break;
            case 'AgentFormation' :
                $entity = $this->getAgentService()->getAgentFormation($entityId);
                $entity = $this->getFormationElementService()->getFormationElement($entityId);
                $validationType = $this->getValidationTypeService()->getValidationTypeByCode("AGENT_FORMATION");
                $elementText = "la formation [" . $entity->getFormation()->getLibelle() . "]";
                break;
@@ -523,10 +535,10 @@ class AgentController extends AbstractActionController
                        $this->getApplicationElementService()->update($entity);
                        break;
                    case 'AgentCompetence' :
                        $this->getAgentService()->updateAgentCompetence($entity);
                        $this->getCompetenceElementService()->update($entity);
                        break;
                    case 'AgentFormation' :
                        $this->getAgentService()->updateAgentFormation($entity);
                        $this->getFormationElementService()->update($entity);
                        break;
                }
            }
+16 −6
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Application\Controller;

use Application\Form\AgentFormation\AgentFormationForm;
use Application\Form\ApplicationElement\ApplicationElementForm;
use Application\Form\CompetenceElement\CompetenceElementForm;
use Application\Service\Agent\AgentService;
@@ -17,7 +16,10 @@ use Application\Service\Structure\StructureService;
use Fichier\Form\Upload\UploadForm;
use Fichier\Service\Fichier\FichierService;
use Fichier\Service\Nature\NatureService;
use Formation\Form\FormationElement\FormationElementForm;
use Formation\Service\Formation\FormationService;
use Formation\Service\FormationElement\FormationElementService;
use Formation\Service\HasFormationCollection\HasFormationCollectionService;
use Interop\Container\ContainerInterface;
use UnicaenUtilisateur\Service\User\UserService;
use UnicaenValidation\Service\ValidationInstance\ValidationInstanceService;
@@ -34,6 +36,8 @@ class AgentControllerFactory {
         * @var CategorieService $categorieService
         * @var CompetenceElementService $competenceElementService
         * @var HasCompetenceCollectionService $hasCompetenceCollectionService
         * @var FormationElementService $formationElementService
         * @var HasFormationCollectionService $hasFormationElementService
         * @var EntretienProfessionnelService $entretienService
         * @var ParcoursDeFormationService $parcoursService
         * @var ValidationInstanceService $validationInstanceService
@@ -50,6 +54,8 @@ class AgentControllerFactory {
        $hasApplicationCollectionService = $container->get(HasApplicationCollectionService::class);
        $competenceElementService = $container->get(CompetenceElementService::class);
        $hasCompetenceCollectionService = $container->get(HasCompetenceCollectionService::class);
        $formationElementService = $container->get(FormationElementService::class);
        $hasFormationElementService = $container->get(HasFormationCollectionService::class);
        $categorieService = $container->get(CategorieService::class);
        $entretienService = $container->get(EntretienProfessionnelService::class);
        $parcoursService = $container->get(ParcoursDeFormationService::class);
@@ -64,24 +70,28 @@ class AgentControllerFactory {
        /**
         * @var ApplicationElementForm $applicationElementForm
         * @var CompetenceElementForm $competenceElementForm
         * @var AgentFormationForm $agentFormationForm
         * @var FormationElementForm $formationElementForm
         * @var UploadForm $uploadForm
         */
        $applicationElementForm = $container->get('FormElementManager')->get(ApplicationElementForm::class);
        $competenceElementForm = $container->get('FormElementManager')->get(CompetenceElementForm::class);
        $agentFormationForm = $container->get('FormElementManager')->get(AgentFormationForm::class);
        $formationElementForm = $container->get('FormElementManager')->get(FormationElementForm::class);
        $uploadForm = $container->get('FormElementManager')->get(UploadForm::class);

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

        $controller->setAgentService($agentService);

        $controller->setApplicationElementService($applicationElementService);
        $controller->setCategorieService($categorieService);
        $controller->setParcoursDeFormationService($parcoursService);
        $controller->setHasApplicationCollectionService($hasApplicationCollectionService);
        $controller->setCompetenceElementService($competenceElementService);
        $controller->setHasCompetenceCollectionService($hasCompetenceCollectionService);
        $controller->setFormationElementService($formationElementService);
        $controller->setHasFormationCollectionService($hasFormationElementService);

        $controller->setParcoursDeFormationService($parcoursService);
        $controller->setCategorieService($categorieService);
        $controller->setEntretienProfessionnelService($entretienService);
        $controller->setValidationInstanceService($validationInstanceService);
        $controller->setValidationTypeService($validationTypeService);
@@ -93,7 +103,7 @@ class AgentControllerFactory {

        $controller->setApplicationElementForm($applicationElementForm);
        $controller->setCompetenceElementForm($competenceElementForm);
        $controller->setAgentFormationForm($agentFormationForm);
        $controller->setFormationElementForm($formationElementForm);
        $controller->setUploadForm($uploadForm);

        return $controller;
+8 −48

File changed.

Preview size limit exceeded, changes collapsed.

+10 −1
Original line number Diff line number Diff line
@@ -43,8 +43,17 @@
                </inverse-join-columns>
            </join-table>
        </many-to-many>
        <many-to-many field="formations" target-entity="Formation\Entity\Db\FormationElement">
            <join-table name="agent_formation">
                <join-columns>
                    <join-column name="agent_id" referenced-column-name="c_individu" />
                </join-columns>
                <inverse-join-columns>
                    <join-column name="formation_element_id" referenced-column-name="id" />
                </inverse-join-columns>
            </join-table>
        </many-to-many>

        <one-to-many target-entity="Application\Entity\Db\AgentFormation" mapped-by="agent" field="formations"/>
        <one-to-many target-entity="Application\Entity\Db\EntretienProfessionnel" mapped-by="agent" field="entretiens"/>
        <one-to-many target-entity="Application\Entity\Db\StructureAgentForce" mapped-by="agent" field="structuresForcees"/>

Loading