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

Refonte des competence-bloc pour l'agent et retrait de fonctions devenues obsoletes

parent 3f79eb0d
Loading
Loading
Loading
Loading
+0 −71
Changes for module/Application/config/merged/agent.config.php: 0 added lines, 71 removed lines.
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ use Application\Service\Agent\AgentService;
use Application\Service\Agent\AgentServiceFactory;
use Application\View\Helper\AgentAffectationViewHelper;
use Application\View\Helper\AgentApplicationViewHelper;
use Application\View\Helper\AgentCompetenceViewHelper;
use Application\View\Helper\AgentFormationViewHelper;
use Application\View\Helper\AgentGradeViewHelper;
use Application\View\Helper\AgentStatutViewHelper;
@@ -80,7 +79,6 @@ return [
                    'action' => [
                        'afficher-statuts-grades',
                        'afficher-application',
                        'afficher-competence',
                        'afficher-formation',
                    ],
                    'privileges' => [
@@ -101,7 +99,6 @@ return [
                    'controller' => AgentController::class,
                    'action' => [
                        'ajouter-application',
                        'ajouter-competence',
                        'ajouter-formation',
                    ],
                    'privileges' => [
@@ -113,7 +110,6 @@ return [
                    'controller' => AgentController::class,
                    'action' => [
                        'modifier-application',
                        'modifier-competence',
                        'modifier-formation',
                    ],
                    'privileges' => [
@@ -126,8 +122,6 @@ return [
                    'action' => [
                        'historiser-application',
                        'restaurer-application',
                        'historiser-competence',
                        'restaurer-competence',
                        'historiser-formation',
                        'restaurer-formation',
                    ],
@@ -140,7 +134,6 @@ return [
                    'controller' => AgentController::class,
                    'action' => [
                        'detruire-formation',
                        'detruire-competence',
                        'detruire-application',
                    ],
                    'privileges' => [
@@ -281,69 +274,6 @@ return [
                        ],
                    ],

                    /** Route des AgentCompetence *********************************************************************/

                    'ajouter-competence' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/ajouter-competence/:agent',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'ajouter-competence',
                            ],
                        ],
                    ],
                    'afficher-competence' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher-competence/:agent/:competence-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'afficher-competence',
                            ],
                        ],
                    ],
                    'modifier-competence' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/modifier-competence/:agent/:competence-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'modifier-competence',
                            ],
                        ],
                    ],
                    'historiser-competence' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/historiser-competence/:agent/:competence-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'historiser-competence',
                            ],
                        ],
                    ],
                    'restaurer-competence' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/restaurer-competence/:agent/:competence-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'restaurer-competence',
                            ],
                        ],
                    ],
                    'detruire-competence' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/detruire-competence/:agent/:competence-element',
                            'defaults' => [
                                'controller' => AgentController::class,
                                'action'     => 'detruire-competence',
                            ],
                        ],
                    ],

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

                    'ajouter-formation' => [
@@ -520,7 +450,6 @@ return [
            'agent' => AgentViewHelper::class,
            'agentAffectation' => AgentAffectationViewHelper::class,
            'agentApplication' => AgentApplicationViewHelper::class,
            'agentCompetence' => AgentCompetenceViewHelper::class,
            'agentFormation' => AgentFormationViewHelper::class,
            'agentStatut' => AgentStatutViewHelper::class,
            'agentGrade' => AgentGradeViewHelper::class,
+36 −0
Changes for module/Application/config/merged/competence.config.php: 36 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ return [
                        'afficher',
                        'afficher-competence-type',
                        'afficher-competence-theme',
                        'afficher-competence-element',
                    ],
                    'privileges' => [
                        CompetencePrivileges::COMPETENCE_AFFICHER,
@@ -78,6 +79,7 @@ return [
                        'ajouter',
                        'ajouter-competence-type',
                        'ajouter-competence-theme',
                        'ajouter-competence-element',
                    ],
                    'privileges' => [
                        CompetencePrivileges::COMPETENCE_AJOUTER,
@@ -108,6 +110,7 @@ return [
                        'detruire',
                        'detruire-competence-type',
                        'detruire-competence-theme',
                        'supprimer-competence-element',
                    ],
                    'privileges' => [
                        CompetencePrivileges::COMPETENCE_EFFACER,
@@ -232,6 +235,39 @@ return [
                        ],
                        'may_terminate' => true,
                    ],
                    'afficher-competence-element' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher-competence-element/:competence-element',
                            'defaults' => [
                                'controller' => CompetenceController::class,
                                'action'     => 'afficher-competence-element',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'ajouter-competence-element' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/ajouter-competence-element/:type/:id',
                            'defaults' => [
                                'controller' => CompetenceController::class,
                                'action'     => 'ajouter-competence-element',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'supprimer-competence-element' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/supprimer-competence-element/:competence-element',
                            'defaults' => [
                                'controller' => CompetenceController::class,
                                'action'     => 'supprimer-competence-element',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'modifier' => [
                        'type'  => Segment::class,
                        'options' => [
+0 −121
Changes for module/Application/src/Application/Controller/AgentController.php: 0 added lines, 121 removed lines.
Original line number Diff line number Diff line
@@ -245,127 +245,6 @@ class AgentController extends AbstractActionController
        return $vm;
    }

    /** Gestion des compétences ***************************************************************************************/

    public function ajouterCompetenceAction()
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $competenceElement = new CompetenceElement();

        /** @var CompetenceElementForm $form */
        $form = $this->getCompetenceElementForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/ajouter-competence', ['agent' => $agent->getId()], [], true));
        $form->bind($competenceElement);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getHasCompetenceCollectionService()->addCompetence($agent, $competenceElement);
            }
        }

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

    public function afficherCompetenceAction()
    {
        $competenceElement = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);
        $agent = $this->getAgentService()->getRequestedAgent($this);

        return new ViewModel([
            'title' => "Affichage d'une compétence maîtrisée par un agent",
            'competenceElement' => $competenceElement,
            'agent' => $agent,
        ]);
    }

    public function modifierCompetenceAction()
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $competenceElement = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);

        $form = $this->getCompetenceElementForm();
        $form->setAttribute('action', $this->url()->fromRoute('agent/modifier-competence', ['agent' => $agent->getId(), 'competence-element' => $competenceElement->getId()]));
        $form->bind($competenceElement);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getCompetenceElementService()->update($competenceElement);
            }
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => "Modification d'une compétence maîtrisée par un agent",
            'form' => $form,
        ]);
        return $vm;
    }

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

        $agent = $this->getAgentService()->getRequestedAgent($this);
        $competenceElement = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);
        $this->getCompetenceElementService()->historise($competenceElement);

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

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

        $agent = $this->getAgentService()->getRequestedAgent($this);
        $competenceElement = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);
        $this->getCompetenceElementService()->restore($competenceElement);

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

    public function detruireCompetenceAction()
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $competenceElement = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            //la cascade doit gérer l'affaire
            if ($data["reponse"] === "oui") $this->getCompetenceElementService()->delete($competenceElement);
            exit();
        }

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

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

    public function ajouterFormationAction()
+89 −0
Changes for module/Application/src/Application/Controller/CompetenceController.php: 89 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,15 +2,20 @@

namespace Application\Controller;

use Application\Entity\Db\Agent;
use Application\Entity\Db\Competence;
use Application\Entity\Db\CompetenceElement;
use Application\Entity\Db\CompetenceTheme;
use Application\Entity\Db\CompetenceType;
use Application\Entity\Db\FicheMetier;
use Application\Form\Competence\CompetenceFormAwareTrait;
use Application\Form\CompetenceElement\CompetenceElementFormAwareTrait;
use Application\Form\CompetenceType\CompetenceTypeFormAwareTrait;
use Application\Form\ModifierLibelle\ModifierLibelleFormAwareTrait;
use Application\Form\SelectionCompetence\SelectionCompetenceFormAwareTrait;
use Application\Form\SelectionCompetenceMaitrise\SelectionCompetenceMaitriseFormAwareTrait;
use Application\Service\Activite\ActiviteServiceAwareTrait;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\Competence\CompetenceServiceAwareTrait;
use Application\Service\CompetenceElement\CompetenceElementServiceAwareTrait;
use Application\Service\CompetenceMaitrise\CompetenceMaitriseServiceAwareTrait;
@@ -24,6 +29,7 @@ use Zend\View\Model\ViewModel;
class CompetenceController extends AbstractActionController
{
    use ActiviteServiceAwareTrait;
    use AgentServiceAwareTrait;
    use CompetenceServiceAwareTrait;
    use CompetenceMaitriseServiceAwareTrait;
    use CompetenceThemeServiceAwareTrait;
@@ -32,6 +38,7 @@ class CompetenceController extends AbstractActionController
    use FicheMetierServiceAwareTrait;

    use CompetenceFormAwareTrait;
    use CompetenceElementFormAwareTrait;
    use CompetenceTypeFormAwareTrait;
    use ModifierLibelleFormAwareTrait;
    use SelectionCompetenceFormAwareTrait;
@@ -473,4 +480,86 @@ class CompetenceController extends AbstractActionController
        $vm->setTemplate('application/default/default-form');
        return $vm;
    }

    /** GESTION DES COMPETENCES ELEMENTS ==> Faire CONTROLLER ? *******************************************************/

    public function afficherCompetenceElementAction()
    {
        $element = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);
        return new ViewModel([
            'title' => "Affichage de la compétence [".$element->getCompetence()->getLibelle()."]",
            'competenceElement' => $element,
        ]);
    }

    public function ajouterCompetenceElementAction()
    {
        $type = $this->params()->fromRoute('type');
        $hasCompetenceCollection = null;
        switch($type) {
            case Agent::class : $hasCompetenceCollection = $this->getAgentService()->getRequestedAgent($this, 'id');
                break;
            case FicheMetier::class : $hasCompetenceCollection = $this->getFicheMetierService()->getRequestedFicheMetier($this, 'id');
                break;
        }

        if ($hasCompetenceCollection !== null) {
            $element = new CompetenceElement();

            $form = $this->getCompetenceElementForm();
            $form->setAttribute('action', $this->url()->fromRoute('competence/ajouter-competence-element', ['type' => $type, 'id' => $hasCompetenceCollection->getId()], [], true));
            $form->bind($element);

            $request = $this->getRequest();
            if ($request->isPost()) {
                $data = $request->getPost();
                $form->setData($data);
                if ($form->isValid()) {
                    $this->getCompetenceElementService()->create($element);
                    $hasCompetenceCollection->addCompetenceElement($element);
                    switch($type) {
                        case Agent::class :
                            $this->getAgentService()->update($hasCompetenceCollection);
                            break;
                        case FicheMetier::class :
                            $this->getFicheMetierService()->update($hasCompetenceCollection);
                            break;
                    }
                }
            }

            $vm = new ViewModel([
                'title' => "Ajout d'une compétence",
                'form' => $form,
            ]);
            $vm->setTemplate('application/default/default-form');
            return $vm;
        }

    }

    public function supprimerCompetenceElementAction()
    {
        $element = $this->getCompetenceElementService()->getRequestedCompetenceElement($this);

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

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

}
 No newline at end of file
+8 −0
Changes for module/Application/src/Application/Controller/CompetenceControllerFactory.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,11 +3,13 @@
namespace Application\Controller;

use Application\Form\Competence\CompetenceForm;
use Application\Form\CompetenceElement\CompetenceElementForm;
use Application\Form\CompetenceType\CompetenceTypeForm;
use Application\Form\ModifierLibelle\ModifierLibelleForm;
use Application\Form\SelectionCompetence\SelectionCompetenceForm;
use Application\Form\SelectionCompetenceMaitrise\SelectionCompetenceMaitriseForm;
use Application\Service\Activite\ActiviteService;
use Application\Service\Agent\AgentService;
use Application\Service\Competence\CompetenceService;
use Application\Service\CompetenceElement\CompetenceElementService;
use Application\Service\CompetenceMaitrise\CompetenceMaitriseService;
@@ -23,6 +25,7 @@ class CompetenceControllerFactory
    {
        /**
         * @var ActiviteService $activiteService
         * @var AgentService $agentService
         * @var CompetenceService $competenceService
         * @var CompetenceMaitriseService $competenceMaitriseService
         * @var CompetenceThemeService $competenceThemeService
@@ -31,6 +34,7 @@ class CompetenceControllerFactory
         * @var FicheMetierService $ficherMetierService
         */
        $activiteService = $container->get(ActiviteService::class);
        $agentService = $container->get(AgentService::class);
        $competenceService = $container->get(CompetenceService::class);
        $competenceMaitriseService = $container->get(CompetenceMaitriseService::class);
        $competenceThemeService = $container->get(CompetenceThemeService::class);
@@ -40,12 +44,14 @@ class CompetenceControllerFactory

        /**
         * @var CompetenceForm $competenceForm
         * @var CompetenceElementForm $competenceElementForm
         * @var CompetenceTypeForm $competenceTypeForm
         * @var ModifierLibelleForm $modifierLibelleForm
         * @var SelectionCompetenceForm $selectionCompetenceForm
         * @var SelectionCompetenceMaitriseForm $selectionCompetenceMaitriseForm
         */
        $competenceForm = $container->get('FormElementManager')->get(CompetenceForm::class);
        $competenceElementForm = $container->get('FormElementManager')->get(CompetenceElementForm::class);
        $competenceTypeForm = $container->get('FormElementManager')->get(CompetenceTypeForm::class);
        $modifierLibelleForm = $container->get('FormElementManager')->get(ModifierLibelleForm::class);
        $selectionCompetenceForm = $container->get('FormElementManager')->get(SelectionCompetenceForm::class);
@@ -54,6 +60,7 @@ class CompetenceControllerFactory
        /** @var CompetenceController $controller */
        $controller = new CompetenceController();
        $controller->setActiviteService($activiteService);
        $controller->setAgentService($agentService);
        $controller->setCompetenceService($competenceService);
        $controller->setCompetenceMaitriseService($competenceMaitriseService);
        $controller->setCompetenceThemeService($competenceThemeService);
@@ -61,6 +68,7 @@ class CompetenceControllerFactory
        $controller->setCompetenceElementService($competenceElementService);
        $controller->setFicheMetierService($ficherMetierService);
        $controller->setCompetenceForm($competenceForm);
        $controller->setCompetenceElementForm($competenceElementForm);
        $controller->setCompetenceTypeForm($competenceTypeForm);
        $controller->setModifierLibelleForm($modifierLibelleForm);
        $controller->setSelectionCompetenceForm($selectionCompetenceForm);
Loading