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

Ajout des affectations

parent 3781003e
Loading
Loading
Loading
Loading
+2
Changes for module/Application/config/merged/agent.config.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ use Application\Form\AgentFormation\AgentFormationHydratorFactory;
use Application\Provider\Privilege\AgentPrivileges;
use Application\Service\Agent\AgentService;
use Application\Service\Agent\AgentServiceFactory;
use Application\View\Helper\AgentAffectationViewHelper;
use Application\View\Helper\AgentGradeViewHelper;
use Application\View\Helper\AgentStatutViewHelper;
use Application\View\Helper\AgentViewHelper;
@@ -602,6 +603,7 @@ return [
    'view_helpers' => [
        'invokables' => [
            'agent' => AgentViewHelper::class,
            'agentAffectation' => AgentAffectationViewHelper::class,
            'agentStatut' => AgentStatutViewHelper::class,
            'agentGrade' => AgentGradeViewHelper::class,
        ],
+4
Changes for module/Application/src/Application/Controller/AgentController.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Controller;

use Application\Constant\RoleConstant;
use Application\Entity\Db\Agent;
use Application\Entity\Db\AgentAffectation;
use Application\Entity\Db\AgentApplication;
use Application\Entity\Db\AgentCompetence;
use Application\Entity\Db\AgentFormation;
@@ -78,6 +79,8 @@ class AgentController extends AbstractActionController
    public function afficherStatutsGradesAction() {
        $agent = $this->getAgentService()->getRequestedAgent($this);

        $affectations = $agent->getAffectations();
        usort($affectations, function(AgentAffectation $a, AgentAffectation $b) { return $a->getDateDebut() > $b->getDateDebut();});
        $grades = $agent->getGrades();
        usort($grades, function(AgentGrade $a, AgentGrade $b) { return $a->getDateDebut() > $b->getDateDebut();});
        $statuts = $agent->getStatuts();
@@ -86,6 +89,7 @@ class AgentController extends AbstractActionController
        return new ViewModel([
            'title' => 'Listing de tous les statuts et grades de ' . $agent->getDenomination(),
            'agent' => $agent,
            'affectations' => $affectations,
            'statuts' => $statuts,
            'grades' => $grades,
        ]);
+32 −4
Changes for module/Application/src/Application/Entity/Db/Agent.php: 32 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -35,12 +35,18 @@ class Agent implements ResourceInterface{
    /** @var int */
    private $quotite;

    /** @var ArrayCollection (AgentAffectation)  */
    private $affectations;
    /** @var ArrayCollection (AgentGrade) */
    private $grades;
    /** @var ArrayCollection (AgentStatut)*/
    private $statuts;

    /** @var ArrayCollection (FichePoste) */
    private $fiches;
    /** @var ArrayCollection (EntretienProfessionnel) */
    private $entretiens;
    /** @var ArrayCollection (AgentStatut)*/
    private $statuts;

    /** @var ArrayCollection (AgentMissionSpecifique) */
    private $missionsSpecifiques;
    /** @var ArrayCollection (Fichier) */
@@ -51,8 +57,7 @@ class Agent implements ResourceInterface{
    private $competences;
    /** @var ArrayCollection (AgentFormation) */
    private $formations;
    /** @var ArrayCollection (AgentGrade) */
    private $grades;


    public function __construct()
    {
@@ -115,6 +120,29 @@ class Agent implements ResourceInterface{

    }

    /**
     * @return AgentAffectation[]
     */
    public function getAffectations()
    {
        return $this->affectations->toArray();
    }

    /**
     * @return AgentAffectation[]
     */
    public function getAffectationsActifs()
    {
        $date = $this->getDateTime();

        $affectations = [];
        /** @var AgentAffectation $affectation */
        foreach ($this->affectations as $affectation) {
            if ($affectation->getDateDebut() <= $date AND $affectation->getDateFin() >= $date) $affectations[] = $affectation;
        }
        return $affectations;
    }

    /**
     * @return AgentStatut[]
     */
+81
Changes for module/Application/src/Application/Entity/Db/AgentAffectation.php: 81 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Entity\Db;

use DateTime;

class AgentAffectation {

    /** @var integer */
    private $id;
    /** @var Agent */
    private $agent;
    /** @var Structure */
    private $structure;
    /** @var DateTime */
    private $dateDebut;
    /** @var DateTime */
    private $dateFin;
    /** @var string */
    private $idOrig;
    /** @var string */
    private $principale;

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

    /**
     * @return Agent
     */
    public function getAgent()
    {
        return $this->agent;
    }

    /**
     * @return Structure
     */
    public function getStructure()
    {
        return $this->structure;
    }

    /**
     * @return DateTime
     */
    public function getDateDebut()
    {
        return $this->dateDebut;
    }

    /**
     * @return DateTime
     */
    public function getDateFin()
    {
        return $this->dateFin;
    }

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

    /**
     * @return boolean
     */
    public function isPrincipale()
    {
        return ($this->principale === 'O');
    }


}
 No newline at end of file
+4 −2
Changes for module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Agent.dcm.xml: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@
        <field name="prenom"                   column="prenom"              type="string" length="64" />
        <field name="nomUsuel"                 column="nom_usage"           type="string" length="64" />

        <one-to-many target-entity="Application\Entity\Db\AgentAffectation" mapped-by="agent" field="affectations"/>
        <one-to-many target-entity="Application\Entity\Db\AgentGrade" mapped-by="agent" field="grades"/>
        <one-to-many target-entity="Application\Entity\Db\AgentStatut" mapped-by="agent" field="statuts"/>

        <field name="quotite"                  column="quotite"             type="integer" />

        <one-to-one target-entity="UnicaenUtilisateur\Entity\Db\User" field="utilisateur">
@@ -23,8 +27,6 @@
        <one-to-many target-entity="Application\Entity\Db\AgentApplication" mapped-by="agent" field="applications"/>
        <one-to-many target-entity="Application\Entity\Db\AgentCompetence" mapped-by="agent" field="competences"/>
        <one-to-many target-entity="Application\Entity\Db\AgentFormation" mapped-by="agent" field="formations"/>
        <one-to-many target-entity="Application\Entity\Db\AgentGrade" mapped-by="agent" field="grades"/>
        <one-to-many target-entity="Application\Entity\Db\AgentStatut" mapped-by="agent" field="statuts"/>
        <one-to-many target-entity="Application\Entity\Db\EntretienProfessionnel" mapped-by="agent" field="entretiens"/>

        <many-to-many field="fichiers" target-entity="Fichier\Entity\Db\Fichier" inversed-by="fichier" fetch="LAZY">
Loading