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

Gestion des postes

parent 0754fca9
Loading
Loading
Loading
Loading
+27 −17
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Application\Provider\Privilege\ActivitePrivileges;
use Application\Provider\Privilege\AffectationPrivileges;
use Application\Provider\Privilege\ApplicationPrivileges;
use Application\Provider\Privilege\FicheMetierPrivileges;
use Application\Provider\Privilege\PostePrivileges;
use Application\Provider\Privilege\UtilisateurPrivileges;
use Mailing\Provider\Privilege\MailingPrivileges;

@@ -73,47 +74,56 @@ return [
                        'roles' => [], //PrivilegeController::getResourceId(__NAMESPACE__ . '\Controller\Administration', 'index'),
                        'pages' => [
                            [
                                'label' => 'Les agents',
                                'route' => 'agent',
                                'privileges' => FicheMetierPrivileges::AFFICHER,
                                'label' => 'Les activités',
                                'route' => 'activite',
                                'privileges' => ActivitePrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les fiches métiers',
                                'route' => 'fiche-metier',
                                'privileges' => FicheMetierPrivileges::AFFICHER,
                                'label' => 'Les affectations',
                                'route' => 'affectation',
                                'privileges' => AffectationPrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les fiches types',
                                'route' => 'fiche-metier-type',
                                'label' => 'Les agents',
                                'route' => 'agent',
                                'privileges' => FicheMetierPrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les activités',
                                'route' => 'activite',
                                'privileges' => ActivitePrivileges::AFFICHER,
                                'label' => 'Les applications',
                                'route' => 'application',
                                'privileges' => ApplicationPrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les affectations',
                                'route' => 'affectation',
                                'privileges' => AffectationPrivileges::AFFICHER,
                                'label' => 'Les fiches métiers',
                                'route' => 'fiche-metier',
                                'privileges' => FicheMetierPrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les applications',
                                'route' => 'application',
                                'privileges' => ApplicationPrivileges::AFFICHER,
                                'label' => 'Les fiches types',
                                'route' => 'fiche-metier-type',
                                'privileges' => FicheMetierPrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],
                            [
                                'label' => 'Les postes',
                                'route' => 'poste',
                                'privileges' => PostePrivileges::AFFICHER,
                                'dropdown-header' => true,
                                'icon' => 'fas fa-angle-right'
                            ],


                        ],
                    ],
                ],
+144 −0
Original line number Diff line number Diff line
<?php

namespace Application;

use Application\Controller\Poste\PosteController;
use Application\Controller\Poste\PosteControllerFactory;
use Application\Form\Poste\PosteForm;
use Application\Form\Poste\PosteFormFactory;
use Application\Form\Poste\PosteHydrator;
use Application\Form\Poste\PosteHydratorFactory;
use Application\Provider\Privilege\PostePrivileges;
use Application\Service\Poste\PosteService;
use Application\Service\Poste\PosteServiceFactory;
use UnicaenAuth\Guard\PrivilegeController;
use Zend\Mvc\Router\Http\Literal;
use Zend\Mvc\Router\Http\Segment;

return [
    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'index',
                        'afficher',
                    ],
                    'privileges' => [
                        PostePrivileges::AFFICHER,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'ajouter',
                    ],
                    'privileges' => [
                        PostePrivileges::AJOUTER,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'modifier',
                    ],
                    'privileges' => [
                        PostePrivileges::EDITER,
                    ],
                ],
                [
                    'controller' => PosteController::class,
                    'action' => [
                        'supprimer',
                    ],
                    'privileges' => [
                        PostePrivileges::EFFACER,
                    ],
                ],
            ],
        ],
    ],

    'router'          => [
        'routes' => [
            'poste' => [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/poste',
                    'defaults' => [
                        'controller' => PosteController::class,
                        'action'     => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'modifier' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/modifier/:poste',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'modifier',
                            ],
                        ],
                    ],
                    'supprimer' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/supprimer/:poste',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'supprimer',
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/ajouter',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'ajouter',
                            ],
                        ],
                    ],
                    'afficher' => [
                        'type'  => Segment::class,
                        'options' => [
                            'route'    => '/afficher/:poste',
                            'defaults' => [
                                'controller' => PosteController::class,
                                'action'     => 'afficher',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'service_manager' => [
        'invokables' => [
        ],
        'factories' => [
            PosteService::class => PosteServiceFactory::class,
        ],
    ],
    'controllers'     => [
        'factories' => [
            PosteController::class => PosteControllerFactory::class,
        ],
    ],
    'form_elements' => [
        'factories' => [
            PosteForm::class => PosteFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [
            PosteHydrator::class => PosteHydratorFactory::class,
        ]
    ]

];
 No newline at end of file
+106 −0
Original line number Diff line number Diff line
<?php

namespace Application\Controller\Poste;

use Application\Entity\Db\Poste;
use Application\Form\Poste\PosteForm;
use Application\Service\Poste\PosteServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class PosteController extends AbstractActionController {
    use PosteServiceAwareTrait;

    public function indexAction()
    {
        $postes = $this->getPosteService()->getPostes();
        
        return new ViewModel([
            'postes' => $postes,
        ]);
    }

    public function afficherAction()
    {
        /** @var Poste $poste */
        $posteId = $this->params()->fromRoute('poste');
        $poste = $this->getPosteService()->getPoste($posteId);

        return new ViewModel([
            'title' => 'Affichage du poste',
            'poste' => $poste,
        ]);
    }

    public function ajouterAction()
    {
        /** @var Poste $poste */
        $poste = new Poste();

        /** @var PosteForm $form */
        $form = $this->getServiceLocator()->get('FormElementManager')->get(PosteForm::class);
        $form->setAttribute('action', $this->url()->fromRoute('poste/ajouter', [], [], true));
        $form->bind($poste);

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

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

    public function modifierAction()
    {
        /** @var Poste $poste */
        $posteId = $this->params()->fromRoute('poste');
        $poste = $this->getPosteService()->getPoste($posteId);

        /** @var PosteForm $form */
        $form = $this->getServiceLocator()->get('FormElementManager')->get(PosteForm::class);
        $form->setAttribute('action', $this->url()->fromRoute('poste/modifier', ['poste' => $poste->getId()], [], true));
        $form->bind($poste);

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

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

    public function supprimerAction()
    {
        $posteId = $this->params()->fromRoute('poste');
        $poste = $this->getPosteService()->getPoste($posteId);

        if ($poste) {
            $this->getPosteService()->delete($poste);
        }

        $this->redirect()->toRoute('poste', [], [], true);
    }
}
 No newline at end of file
+22 −0
Original line number Diff line number Diff line
<?php

namespace Application\Controller\Poste;

use Application\Service\Poste\PosteService;
use Zend\Mvc\Controller\ControllerManager;

class PosteControllerFactory {

    public function __invoke(ControllerManager $controllerManager)
    {
        /**
         * @var PosteService $posteService
         */
        $posteService    = $controllerManager->getServiceLocator()->get(PosteService::class);

        /** @var PosteController $controller */
        $controller = new PosteController();
        $controller->setPosteService($posteService);
        return $controller;
    }
}
 No newline at end of file
+39 −0
Original line number Diff line number Diff line
<?php

namespace Application\Entity\Db;

class Domaine {

    /** @var integer */
    private $id;
    /** @var string */
    private $libelle;

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

    /**
     * @return string
     */
    public function getLibelle()
    {
        return $this->libelle;
    }

    /**
     * @param string $libelle
     * @return Domaine
     */
    public function setLibelle($libelle)
    {
        $this->libelle = $libelle;
        return $this;
    }


}
 No newline at end of file
Loading