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

Modal de confirmation 'generique' et changement titre

parent d8082d3d
Loading
Loading
Loading
Loading
+18 −2
Changes for module/Application/config/merged/fiche-poste.config.php: 18 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@ use Application\Form\AssocierPoste\AssocierPosteForm;
use Application\Form\AssocierPoste\AssocierPosteFormFactory;
use Application\Form\AssocierPoste\AssocierPosteHydrator;
use Application\Form\AssocierPoste\AssocierPosteHydratorFactory;
use Application\Form\AssocierTitre\AssocierTitreForm;
use Application\Form\AssocierTitre\AssocierTitreFormFactory;
use Application\Form\AssocierTitre\AssocierTitreHydrator;
use Application\Form\AssocierTitre\AssocierTitreHydratorFactory;
use Application\Form\FichePosteCreation\FichePosteCreationForm;
use Application\Form\FichePosteCreation\FichePosteCreationFormFactory;
use Application\Form\FichePosteCreation\FichePosteCreationHydrator;
@@ -45,6 +49,7 @@ return [
                        'detruire',
                        'associer-agent',
                        'associer-poste',
                        'associer-titre',
                        'editer-specificite',
                        'ajouter-fiche-metier',
                        'retirer-fiche-metier',
@@ -159,7 +164,6 @@ return [
                                'action'     => 'associer-agent',
                            ],
                        ],

                    ],
                    'associer-poste' => [
                        'type' => Segment::class,
@@ -171,7 +175,17 @@ return [
                                'action'     => 'associer-poste',
                            ],
                        ],

                    ],
                    'associer-titre' => [
                        'type' => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'    => '/associer-titre/:fiche-poste',
                            'defaults' => [
                                'controller' => FichePosteController::class,
                                'action'     => 'associer-titre',
                            ],
                        ],
                    ],
                    'ajouter-fiche-metier' => [
                        'type'  => Segment::class,
@@ -248,6 +262,7 @@ return [
            AjouterFicheMetierForm::class => AjouterFicheMetierFormFactory::class,
            AssocierAgentForm::class => AssocierAgentFormFactory::class,
            AssocierPosteForm::class => AssocierPosteFormFactory::class,
            AssocierTitreForm::class => AssocierTitreFormFactory::class,
            FichePosteCreationForm::class => FichePosteCreationFormFactory::class,
            SpecificitePosteForm::class => SpecificitePosteFormFactory::class,
        ],
@@ -260,6 +275,7 @@ return [
            AjouterFicheMetierHydrator::class => AjouterFicheMetierHydratorFactory::class,
            AssocierAgentHydrator::class => AssocierAgentHydratorFactory::class,
            AssocierPosteHydrator::class => AssocierPosteHydratorFactory::class,
            AssocierTitreHydrator::class => AssocierTitreHydratorFactory::class,
            FichePosteCreationHydrator::class => FichePosteCreationHydratorFactory::class,
        ],
    ]
+14 −4
Changes for module/Application/config/merged/mes-structures.config.php: 14 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -2,13 +2,10 @@

namespace Application;

use Application\Controller\ImmobilierController;
use Application\Controller\MesStructuresController;
use Application\Controller\MesStructuresControllerFactory;
use Application\Provider\Privilege\MesStructuresPrivileges;
use Application\Provider\Privilege\RessourceRhPrivileges;
use UnicaenAuth\Guard\PrivilegeController;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;

return [
@@ -20,6 +17,7 @@ return [
                    'action' => [
                        'index',
                        'ajouter-fiche-poste',
                        'dupliquer-fiche-poste',
                    ],
                    'privileges' => [
                        MesStructuresPrivileges::GESTION,
@@ -45,7 +43,7 @@ return [
                    'ajouter-fiche-poste' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/ajouter-fiche-poste',
                            'route'    => '/ajouter-fiche-poste[/:agent]',
                            'defaults' => [
                                'controller' => MesStructuresController::class,
                                'action'     => 'ajouter-fiche-poste',
@@ -54,6 +52,18 @@ return [
                        'may_terminate' => true,
                        'child_routes' => []
                    ],
                    'dupliquer-fiche-poste' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/dupliquer-fiche-poste/:agent',
                            'defaults' => [
                                'controller' => MesStructuresController::class,
                                'action'     => 'dupliquer-fiche-poste',
                            ],
                        ],
                        'may_terminate' => true,
                        'child_routes' => []
                    ],
                ],
            ],
        ],
+66 −5
Changes for module/Application/src/Application/Controller/FichePosteController.php: 66 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Application\Form\AssocierAgent\AssocierAgentForm;
use Application\Form\AssocierAgent\AssocierAgentFormAwareTrait;
use Application\Form\AssocierPoste\AssocierPosteForm;
use Application\Form\AssocierPoste\AssocierPosteFormAwareTrait;
use Application\Form\AssocierTitre\AssocierTitreFormAwareTrait;
use Application\Form\FichePosteCreation\FichePosteCreationFormAwareTrait;
use Application\Form\SpecificitePoste\SpecificitePosteForm;
use Application\Form\SpecificitePoste\SpecificitePosteFormAwareTrait;
@@ -31,8 +32,9 @@ class FichePosteController extends AbstractActionController {
    /** Form **/
    use AjouterFicheMetierFormAwareTrait;
    use AssocierAgentFormAwareTrait;
    use FichePosteCreationFormAwareTrait;
    use AssocierPosteFormAwareTrait;
    use AssocierTitreFormAwareTrait;
    use FichePosteCreationFormAwareTrait;
    use SpecificitePosteFormAwareTrait;

    public function indexAction()
@@ -75,8 +77,20 @@ class FichePosteController extends AbstractActionController {
    public function afficherAction()
    {
        $fiche = $this->getFichePosteService()->getRequestedFichePoste($this, 'fiche-poste');
        $titre = 'Fiche de poste <br/>';
        $titre .= '<strong>';
        if ($fiche->getFicheTypeExternePrincipale()) {
            $titre .= $fiche->getFicheTypeExternePrincipale()->getFicheType()->getMetier()->getLibelle();
        } else {
            $titre .= "<span class='icon attention' style='color:darkred;'></span> Aucun fiche principale";
        }
        if($fiche->getLibelle() !== null) {
            $titre .= "(" .$fiche->getLibelle(). ")";
        }
        $titre .= '</strong>';

        return new ViewModel([
            'title' => 'Fiche de poste <br/> <em>'.$fiche->getLibelle().'</em>',
            'title' => $titre,
           'fiche' => $fiche,
        ]);
    }
@@ -110,14 +124,61 @@ class FichePosteController extends AbstractActionController {

    public function detruireAction()
    {
        $fiche = $this->getFichePosteService()->getRequestedFichePoste($this, 'fiche-poste');
        $structureId = $this->params()->fromQuery('structure');
        $structure = $this->getStructureService()->getStructure($structureId);
        $params = [];
        if ($structure !== null) $params["structure"] = $structure->getId();

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getFichePosteService()->delete($fiche);
            //TODO c'est vraiment crade ...
            return $this->redirect()->toRoute('home');
        }

        $vm = new ViewModel();
        if ($fiche !== null) {
            $vm->setTemplate('application/default/confirmation');
            $vm->setVariables([
                'title' => "Suppression de la fiche de poste  de " . $fiche->getAgent()->getDenomination(),
                'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('fiche-poste/detruire', ["affectation" => $fiche->getId()], ["query" => $params], true),
            ]);
        }
        return $vm;
    }

    /** TITRE *********************************************************************************************************/

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

        if ($structure !== null) return $this->redirect()->toRoute('mes-structures', ['structure' => $structure->getId()], [], true);
        return $this->redirect()->toRoute('fiche-poste', [], [], true);
        /** @var AssocierAgentForm $form */
        $form = $this->getAssocierTitreForm();
        $form->setAttribute('action', $this->url()->fromRoute('fiche-poste/associer-titre', ['fiche-poste' => $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->getFichePosteService()->update($fiche);
            }
        }

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

    /** AGENT *********************************************************************************************************/
+4 −0
Changes for module/Application/src/Application/Controller/FichePosteControllerFactory.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Application\Controller;
use Application\Form\AjouterFicheMetier\AjouterFicheMetierForm;
use Application\Form\AssocierAgent\AssocierAgentForm;
use Application\Form\AssocierPoste\AssocierPosteForm;
use Application\Form\AssocierTitre\AssocierTitreForm;
use Application\Form\FichePosteCreation\FichePosteCreationForm;
use Application\Form\SpecificitePoste\SpecificitePosteForm;
use Application\Service\Agent\AgentService;
@@ -28,12 +29,14 @@ class FichePosteControllerFactory {
         * @var AjouterFicheMetierForm $ajouterFicheMetierForm
         * @var AssocierAgentForm $associerAgentForm
         * @var AssocierPosteForm $associerPosteForm
         * @var AssocierTitreForm $associerTitreForm
         * @var FichePosteCreationForm $fichePosteCreation
         * @var SpecificitePosteForm $specificiftePosteForm
         */
        $ajouterFicheMetierForm = $container->get('FormElementManager')->get(AjouterFicheMetierForm::class);
        $associerAgentForm = $container->get('FormElementManager')->get(AssocierAgentForm::class);
        $associerPosteForm = $container->get('FormElementManager')->get(AssocierPosteForm::class);
        $associerTitreForm = $container->get('FormElementManager')->get(AssocierTitreForm::class);
        $fichePosteCreation = $container->get('FormElementManager')->get(FichePosteCreationForm::class);
        $specificiftePosteForm = $container->get('FormElementManager')->get(SpecificitePosteForm::class);

@@ -47,6 +50,7 @@ class FichePosteControllerFactory {
        $controller->setAjouterFicheTypeForm($ajouterFicheMetierForm);
        $controller->setAssocierAgentForm($associerAgentForm);
        $controller->setAssocierPosteForm($associerPosteForm);
        $controller->setAssocierTitreForm($associerTitreForm);
        $controller->setFichePosteCreationForm($fichePosteCreation);
        $controller->setSpecificitePosteForm($specificiftePosteForm);
        return $controller;
+48 −1
Changes for module/Application/src/Application/Controller/MesStructuresController.php: 48 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Application\Service\Poste\PosteServiceAwareTrait;
use Application\Service\Structure\StructureServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;
use Utilisateur\Service\User\UserServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

@@ -68,13 +69,59 @@ class MesStructuresController extends AbstractActionController {
    public function ajouterFichePosteAction()
    {
        $structure = $this->getStructureService()->getRequestedStructure($this);
        $agent = $this->getAgentService()->getRequestedAgent($this);
        if ($structure === null) {
            throw new RuntimeException("L'ajout de fiche ne peut être fait d'avec une structure donnée !");
        }

        $fiche = new FichePoste();
        $fiche->setLibelle("Fiche de poste sans titre");
        if ($agent !== null) {
            $fiche->setAgent($agent);
        }
        $this->getFichePosteService()->create($fiche);
        return $this->redirect()->toRoute('fiche-poste/editer', ['fiche-poste' => $fiche->getId()], ["query" => ["structure" => $structure->getId()]], true);
    }

    public function dupliquerFichePosteAction()
    {
        $structure = $this->getStructureService()->getRequestedStructure($this);
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $fiches = $this->getFichePosteService()->getFichesPostesByStructure($structure);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $ficheId = $data['fiche'];
            $fiche = $this->getFichePosteService()->getFichePoste($ficheId);

            $nouvelleFiche = new FichePoste();
            $nouvelleFiche->setLibelle($fiche->getLibelle());
            $nouvelleFiche->setAgent($agent);

            //dupliquer specificite
            $specifite = $fiche->getSpecificite()->clone_it();
            $this->getFichePosteService()->createSpecificitePoste($specifite);
            $nouvelleFiche->setSpecificite($specifite);

            $nouvelleFiche = $this->getFichePosteService()->create($nouvelleFiche);

            //dupliquer fiche metier externe
            foreach ($fiche->getFichesMetiers() as $ficheMetierExterne) {
                $nouvelleFicheMetier = $ficheMetierExterne->clone_it();
                $nouvelleFicheMetier->setFichePoste($nouvelleFiche);
                $nouvelleFicheMetier = $this->getFichePosteService()->createFicheTypeExterne($nouvelleFicheMetier);
            }

            /**  Commenter pour eviter perte de temps et clignotement de la modal */
            // return $this->redirect()->toRoute('fiche-poste/editer', ['fiche-poste' => $nouvelleFiche->getId()], ["query" => ["structure" => $structure->getId()]], true);
        }

        return new ViewModel([
           'title' => "Duplication d'une fiche de poste pour ".$agent->getDenomination()."",
           'structure' => $structure,
           'agent' => $agent,
           'fiches' => $fiches,
        ]);
    }
}
 No newline at end of file
Loading