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

Ajout du corps et numero de poste

parent dbfff4ed
Loading
Loading
Loading
Loading
+47 −2
Changes for module/Application/config/merged/ressource-rh.config.php: 47 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@ use Application\Controller\RessourceRh\RessourceRhControllerFactory;
use Application\Form\RessourceRh\AgentStatusForm;
use Application\Form\RessourceRh\AgentStatusFormFactory;
use Application\Form\RessourceRh\AgentStatusHydrator;
use Application\Form\RessourceRh\CorpsForm;
use Application\Form\RessourceRh\CorpsFormFactory;
use Application\Form\RessourceRh\CorpsHydrator;
use Application\Form\RessourceRh\CorrespondanceForm;
use Application\Form\RessourceRh\CorrespondanceFormFactory;
use Application\Form\RessourceRh\CorrespondanceHydrator;
@@ -30,6 +33,9 @@ return [
                        'creer-correspondance',
                        'modifier-correspondance',
                        'effacer-correspondance',
                        'creer-corps',
                        'modifier-corps',
                        'effacer-corps',
                    ],
                    'roles' => [],
                ],
@@ -128,9 +134,46 @@ return [
                            ],
                        ],
                    ],

                    'corps' => [
                        'type' => Literal::class,
                        'options' => [
                            'route'    => '/corps',
                        ],
                        'may_terminate' => false,
                        'child_routes' => [
                            'creer' => [
                                'type'  => Literal::class,
                                'options' => [
                                    'route'    => '/creer',
                                    'defaults' => [
                                        'controller' => RessourceRhController::class,
                                        'action'     => 'creer-corps',
                                    ],
                                ],
                            ],
                            'modifier' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/modifier/:id',
                                    'defaults' => [
                                        'controller' => RessourceRhController::class,
                                        'action'     => 'modifier-corps',
                                    ],
                                ],
                            ],
                            'effacer' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/effacer/:id',
                                    'defaults' => [
                                        'controller' => RessourceRhController::class,
                                        'action'     => 'effacer-corps',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],

            ],
        ],
    ],
@@ -150,12 +193,14 @@ return [
    'form_elements' => [
        'factories' => [
            AgentStatusForm::class => AgentStatusFormFactory::class,
            CorpsForm::class => CorpsFormFactory::class,
            CorrespondanceForm::class => CorrespondanceFormFactory::class,
        ],
    ],
    'hydrators' => [
        'invokable' => [
            AgentStatusHydrator::class => AgentStatusHydrator::class,
            CorpsHydrator::class => CorpsHydrator::class,
            CorrespondanceHydrator::class => CorrespondanceHydrator::class,
        ]
    ]
+70 −0
Changes for module/Application/src/Application/Controller/RessourceRh/RessourceRhController.php: 70 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,8 +3,10 @@
namespace Application\Controller\RessourceRh;

use Application\Entity\Db\AgentStatus;
use Application\Entity\Db\Corps;
use Application\Entity\Db\Correspondance;
use Application\Form\RessourceRh\AgentStatusForm;
use Application\Form\RessourceRh\CorpsForm;
use Application\Form\RessourceRh\CorrespondanceForm;
use Application\Service\Metier\MetierServiceAwareTrait;
use Application\Service\RessourceRh\RessourceRhServiceAwareTrait;
@@ -21,11 +23,13 @@ class RessourceRhController extends AbstractActionController {
        $status = $this->getRessourceRhService()->getAgentStatusListe('libelle');
        $correspondances = $this->getRessourceRhService()->getCorrespondances('libelle');
        $metiers = $this->getMetierService()->getMetiers('libelle');
        $corps = $this->getRessourceRhService()->getCorpsListe('libelle');

        return new ViewModel([
            'status' => $status,
            'correspondances' => $correspondances,
            'metiers' => $metiers,
            'corps' => $corps,
        ]);
    }

@@ -158,4 +162,70 @@ class RessourceRhController extends AbstractActionController {

        $this->redirect()->toRoute('ressource-rh', [], [], true);
    }

    /** CORPS *********************************************************************************************************/

    public function creerCorpsAction()
    {
        $corps = new Corps();

        /** @var CorpsForm $form */
        $form = $this->getServiceLocator()->get('FormElementManager')->get(CorpsForm::class);
        $form->setAttribute('action', $this->url()->fromRoute('ressource-rh/corps/creer', [], [], true));
        $form->bind($corps);

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

        return new ViewModel([
            'title' => 'Ajouter un nouveau corps',
            'form' => $form,
        ]);
    }

    public function modifierCorpsAction()
    {
        $corpsId = $this->params()->fromRoute('id');
        $corps = $this->getRessourceRhService()->getCorps($corpsId);

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

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

        return new ViewModel([
            'title' => 'Modifier un corps',
            'form' => $form,
        ]);
    }

    public function effacerCorpsAction()
    {
        $corpsId = $this->params()->fromRoute('id');
        $corps = $this->getRessourceRhService()->getCorps($corpsId);

        if ($corps !== null) {
            $this->getRessourceRhService()->deleteCorps($corps);
        }

        $this->redirect()->toRoute('ressource-rh', [], [], true);
    }

}
 No newline at end of file
+42 −0
Changes for module/Application/src/Application/Entity/Db/Agent.php: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ class Agent {
    private $nom;
    /** @var string */
    private $prenom;
    /** @var string */
    private $numeroPoste;

    // categorie, corps, et grade (devrait correspondre à des infos en bases pour une meilleures structuration ...

@@ -25,6 +27,10 @@ class Agent {
    private $status;
    /** @var Correspondance */
    private $correspondance;
    /** @var Corps */
    private $corps;



    /**
     * @return int
@@ -160,6 +166,42 @@ class Agent {
        return $this;
    }

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

    /**
     * @param string $numeroPoste
     * @return Agent
     */
    public function setNumeroPoste($numeroPoste)
    {
        $this->numeroPoste = $numeroPoste;
        return $this;
    }

    /**
     * @return Corps
     */
    public function getCorps()
    {
        return $this->corps;
    }

    /**
     * @param Corps $corps
     * @return Agent
     */
    public function setCorps($corps)
    {
        $this->corps = $corps;
        return $this;
    }



}
 No newline at end of file
+74 −0
Changes for module/Application/src/Application/Entity/Db/Corps.php: 74 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Entity\Db;

class Corps {

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

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

    /**
     * @param int $id
     * @return Corps
     */
    public function setId($id)
    {
        $this->id = $id;
        return $this;
    }

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

    /**
     * @param string $code
     * @return Corps
     */
    public function setCode($code)
    {
        $this->code = $code;
        return $this;
    }

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

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

    public function __toString()
    {
        return "(".$this->getCode().") ".$this->getLibelle();
    }


}
 No newline at end of file
+4 −0
Changes for module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Agent.dcm.xml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
        <field name="dateDebut"         type="datetime"                 column="date_debut"               nullable="true"/>
        <field name="dateFin"           type="datetime"                 column="date_fin"                 nullable="true"/>
        <field name="quotite"           type="integer"                  column="quotite"                  nullable="true"/>
        <field name="numeroPoste"       type="string" length="256"      column="numero_poste"             nullable="true"/>

        <many-to-one target-entity="Application\Entity\Db\AgentStatus" field="status">
            <join-column name="status" referenced-column-name="id" />
@@ -18,5 +19,8 @@
        <many-to-one target-entity="Application\Entity\Db\Correspondance" field="correspondance">
            <join-column name="correspondance" referenced-column-name="id" />
        </many-to-one>
        <many-to-one target-entity="Application\Entity\Db\Corps" field="corps">
            <join-column name="corps" referenced-column-name="id" />
        </many-to-one>
    </entity>
</doctrine-mapping>
Loading