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

Formulaire pour la specificite

parent ed7b59d1
Loading
Loading
Loading
Loading
+1 −53
Changes for module/Application/config/merged/fiche-metier.config.php: 1 added line, 53 removed lines.
Original line number Diff line number Diff line
@@ -170,17 +170,6 @@ return [
                        ],
                        'may_terminate' => true,
                    ],
                    'associer-agent' => [
                        'type' => Segment::class,
                        'options' => [
                            'route'    => '/associer-agent/:fiche',
                            'defaults' => [
                                'controller' => FicheMetierController::class,
                                'action'     => 'associer-agent',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'associer-poste' => [
                        'type' => Segment::class,
                        'options' => [
@@ -247,47 +236,7 @@ return [
                        ],
                        'may_terminate' => true,
                    ],
                    'specificite' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/specificite/:fiche',
                            'defaults' => [
                                'controller' => FicheMetierController::class,
                                'action'     => 'editer-specificite-poste',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'historiser' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/historiser/:id',
                            'defaults' => [
                                'controller' => FicheMetierController::class,
                                'action'     => 'historiser',
                            ],
                        ],
                    ],
                    'restaurer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/restaurer/:id',
                            'defaults' => [
                                'controller' => FicheMetierController::class,
                                'action'     => 'restaurer',
                            ],
                        ],
                    ],
                    'editer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/editer/:id/:section',
                            'defaults' => [
                                'controller' => FicheMetierController::class,
                                'action'     => 'editer',
                            ],
                        ],
                    ],

                    'creer' => [
                        'type'  => Literal::class,
                        'options' => [
@@ -514,7 +463,6 @@ return [
            LibelleForm::class => LibelleFormFactory::class,
            MissionsPrincipalesForm::class => MissionsPrincipalesFormFactory::class,

            SpecificitePosteForm::class => SpecificitePosteFormFactory::class,
            AssocierMetierTypeForm::class => AssocierMetierTypeFormFactory::class,
            AssocierPosteForm::class => AssocierPosteFormFactory::class,

+20
Changes for module/Application/config/merged/fiche-poste.config.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ use Application\Form\AssocierAgent\AssocierAgentForm;
use Application\Form\AssocierAgent\AssocierAgentFormFactory;
use Application\Form\AssocierAgent\AssocierAgentHydrator;
use Application\Form\AssocierAgent\AssocierAgentHydratorFactory;
use Application\Form\SpecificitePoste\SpecificitePosteForm;
use Application\Form\SpecificitePoste\SpecificitePosteFormFactory;
use Application\Form\SpecificitePoste\SpecificitePosteHydrator;
use Application\Service\FichePoste\FichePosteService;
use Application\Service\FichePoste\FichePosteServiceFactory;
use UnicaenAuth\Guard\PrivilegeController;
@@ -29,6 +32,7 @@ return [
                        'restaurer',
                        'detruire',
                        'associer-agent',
                        'editer-specificite',
                    ],
                    'roles' => [
                    ],
@@ -118,6 +122,7 @@ return [
                    ],
                    'associer-agent' => [
                        'type' => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'    => '/associer-agent/:fiche-poste',
                            'defaults' => [
@@ -125,7 +130,18 @@ return [
                                'action'     => 'associer-agent',
                            ],
                        ],

                    ],
                    'editer-specificite' => [
                        'type'  => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'    => '/editer-specificite/:fiche-poste',
                            'defaults' => [
                                'controller' => FichePosteController::class,
                                'action'     => 'editer-specificite',
                            ],
                        ],
                    ],
                ],
            ],
@@ -145,9 +161,13 @@ return [
    'form_elements' => [
        'factories' => [
            AssocierAgentForm::class => AssocierAgentFormFactory::class,
            SpecificitePosteForm::class => SpecificitePosteFormFactory::class,
        ],
    ],
    'hydrators' => [
        'invokables' => [
            SpecificitePosteHydrator::class => SpecificitePosteHydrator::class,
        ],
        'factories' => [
            AssocierAgentHydrator::class => AssocierAgentHydratorFactory::class,
        ],
−74
Changes for module/Application/src/Application/Controller/FicheMetier/FicheMetierController.php: 0 added lines, 74 removed lines.
Original line number Diff line number Diff line
@@ -119,40 +119,6 @@ class FicheMetierController extends AbstractActionController

    }

    /** AGENT *********************************************************************************************************/

    public function associerAgentAction()
    {
        $ficheId = $this->params()->fromRoute('fiche');
        $fiche = $this->getFicheMetierService()->getFicheMetier($ficheId);

        /** @var AssocierAgentForm $form */
        $form = $this->getAssocierAgentForm();
        $form->setAttribute('action', $this->url()->fromRoute('fiche-metier/associer-agent', ['fiche' => $fiche->getId()], [], true));
        $form->bind($fiche);

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


        $vm = new ViewModel();
//        $vm->setTemplate('application/default/default-form');
        $vm->setVariables([
            'title' => 'Associer un agent',
            'form' => $form,
            'agents' => $this->getAgentService()->getAgents(),
        ]);
        return $vm;

    }

    /** POSTE *********************************************************************************************************/

    public function associerPosteAction()
@@ -185,46 +151,6 @@ class FicheMetierController extends AbstractActionController
        return $vm;

    }
    /** SPECIFICITE POSTE *********************************************************************************************/

    public function editerSpecificitePosteAction()
    {
        $ficheId = $this->params()->fromRoute('fiche');
        $fiche = $this->getFicheMetierService()->getFicheMetier($ficheId);

        $specificite = null;
        if ($fiche->getSpecificite()) {
            $specificite = $fiche->getSpecificite();
        } else {
            $specificite = new SpecificitePoste();
            $fiche->setSpecificite($specificite);
            $this->getFicheMetierService()->createSpecificitePoste($specificite);
        }

        /** @var SpecificitePosteForm $form */
        $form = $form = $this->getSpecificitePosteForm();
        $form->setAttribute('action', $this->url()->fromRoute('fiche-metier/specificite', ['fiche' => $fiche->getId()], [], true));
        $form->bind($specificite);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $specificite->setFiche($fiche);
                $this->getFicheMetierService()->updateSpecificitePoste($specificite);
                $this->getFicheMetierService()->update($fiche);
            }
        }

        return new ViewModel([
            'title' => 'Éditer spécificité du poste',
            'form' => $form,
        ]);

    }

    /** FicheTypeExterne **********************************************************************************************/

    public function ajouterFicheTypeAction() {
+40
Changes for module/Application/src/Application/Controller/FichePoste/FichePosteController.php: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,8 +2,11 @@

namespace Application\Controller\FichePoste;

use Application\Entity\Db\SpecificitePoste;
use Application\Form\AssocierAgent\AssocierAgentForm;
use Application\Form\AssocierAgent\AssocierAgentFormAwareTrait;
use Application\Form\SpecificitePoste\SpecificitePosteForm;
use Application\Form\SpecificitePoste\SpecificitePosteFormAwareTrait;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\FichePoste\FichePosteServiceAwareTrait;
use Zend\Http\Request;
@@ -16,6 +19,7 @@ class FichePosteController extends AbstractActionController {
    use FichePosteServiceAwareTrait;
    /** Form **/
    use AssocierAgentFormAwareTrait;
    use SpecificitePosteFormAwareTrait;

    public function indexAction()
    {
@@ -69,6 +73,7 @@ class FichePosteController extends AbstractActionController {
        $this->redirect()->toRoute('fiche-poste', [], [], true);
    }

    /** Actions associés à l'édition d'une fiche de poste  ************************************************************/
    public function associerAgentAction()
    {
        $fiche = $this->getFichePosteService()->getRequestedFichePoste($this, 'fiche-poste');
@@ -98,4 +103,39 @@ class FichePosteController extends AbstractActionController {
        return $vm;

    }

    public function editerSpecificiteAction()
    {
        $fiche = $this->getFichePosteService()->getRequestedFichePoste($this, 'fiche-poste');

        $specificite = $fiche->getSpecificite();
        if ($specificite === null) {
            $specificite = new SpecificitePoste();
            $fiche->setSpecificite($specificite);
            $this->getFichePosteService()->createSpecificitePoste($specificite);
        }

        /** @var SpecificitePosteForm $form */
        $form = $form = $this->getSpecificitePosteForm();
        $form->setAttribute('action', $this->url()->fromRoute('fiche-poste/editer-specificite', ['fiche' => $fiche->getId()], [], true));
        $form->bind($specificite);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $specificite->setFiche($fiche);
                $this->getFichePosteService()->updateSpecificitePoste($specificite);
                $this->getFichePosteService()->update($fiche);
            }
        }

        return new ViewModel([
            'title' => 'Éditer spécificité du poste',
            'form' => $form,
        ]);

    }
}
 No newline at end of file
+4
Changes for module/Application/src/Application/Controller/FichePoste/FichePosteControllerFactory.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Controller\FichePoste;

use Application\Form\AssocierAgent\AssocierAgentForm;
use Application\Form\SpecificitePoste\SpecificitePosteForm;
use Application\Service\Agent\AgentService;
use Application\Service\FichePoste\FichePosteService;
use Zend\Mvc\Controller\ControllerManager;
@@ -20,8 +21,10 @@ class FichePosteControllerFactory {

        /**
         * @var AssocierAgentForm $associerAgentForm
         * @var SpecificitePosteForm $specificiftePosteForm
         */
        $associerAgentForm = $manager->getServiceLocator()->get('FormElementManager')->get(AssocierAgentForm::class);
        $specificiftePosteForm = $manager->getServiceLocator()->get('FormElementManager')->get(SpecificitePosteForm::class);

        /** @var FichePosteController $controller */
        $controller = new FichePosteController();
@@ -30,6 +33,7 @@ class FichePosteControllerFactory {
        $controller->setFichePosteService($fichePosteService);

        $controller->setAssocierAgentForm($associerAgentForm);
        $controller->setSpecificitePosteForm($specificiftePosteForm);
        return $controller;
    }
}
 No newline at end of file
Loading