diff --git a/documentation/release/3.1.2.md b/documentation/release/3.1.2.md index be1dbad0f2019f79ce26bd50b266d2ff832709e5..40d5d8193abf7a40a97e329b69ab004d2cbcc081 100644 --- a/documentation/release/3.1.2.md +++ b/documentation/release/3.1.2.md @@ -5,6 +5,7 @@ **Changements** * Ajout d'un parametre indiquant le chamin d'installation pour la partie Vérification +* [FIX] correction du choix de l'échelon (si plusieurs échelons actifs alors selection du plus récent "en terme de date de passage") * [FIX] propagation d'un renommage de variable sur l'interface des supérieurs hiérarchique **Modifications de la base de donnée** diff --git a/module/Application/src/Application/Entity/Db/Agent.php b/module/Application/src/Application/Entity/Db/Agent.php index fdb27b1b56d7a1ea04676886d738e7aa9b34b00b..c13fa469919ad4a743383d54f83e765ee74aa70b 100644 --- a/module/Application/src/Application/Entity/Db/Agent.php +++ b/module/Application/src/Application/Entity/Db/Agent.php @@ -416,18 +416,21 @@ class Agent implements $echelons = $this->echelons->toArray(); $grades = array_filter($echelons, function (AgentEchelon $ag) { return !$ag->isDeleted();}); usort($grades, function (AgentEchelon $a, AgentEchelon $b) { - return $a->getDate() > $b->getDate(); + return $a->getDateDebut() > $b->getDateDebut(); }); return $grades; } - /** - * @return AgentEchelon|null - */ - public function getEchelonActif() : ?AgentEchelon + public function getEchelonActif(?DateTime $date = null) : ?AgentEchelon { + if ($date === null) $date = new DateTime(); $echelons = $this->getEchelons(); - $echelon = (!empty($echelons))?$echelons[0]:null; + $echelons = array_filter($echelons, function (AgentEchelon $a) use ($date) {return $a->estEnCours($date);}); + + $echelon = null; + foreach ($echelons as $echelon_) { + if ($echelon === null OR $echelon_->getDateDebut() > $echelon->getDateDebut()) $echelon = $echelon_; + } return $echelon; } diff --git a/module/Application/src/Application/Entity/Db/AgentEchelon.php b/module/Application/src/Application/Entity/Db/AgentEchelon.php index 9575e0a41562d1ba66ba583ef4a9b41fb9e24b0f..8c25981b49e38844b7fded365263d4873f6c1db7 100644 --- a/module/Application/src/Application/Entity/Db/AgentEchelon.php +++ b/module/Application/src/Application/Entity/Db/AgentEchelon.php @@ -15,77 +15,27 @@ use Structure\Entity\Db\Structure; * Données synchronisées depuis Octopus : * - pas de setter sur les données ainsi remontées */ -class AgentEchelon { +class AgentEchelon implements HasPeriodeInterface { use DbImportableAwareTrait; + use HasPeriodeTrait; - /** @var int */ - private $id; - /** @var Agent */ - private $agent; - /** @var int */ - private $echelon; - /** @var DateTime */ - private $date; + private ?int $id = -1; + private ?Agent $agent = null; + private ?int $echelon = null; - /** - * @return int|null - */ public function getId() : ?int { return $this->id; } - /** - * @return Agent|null - */ public function getAgent(): ?Agent { return $this->agent; } - /** - * @param Agent $agent - * @return AgentEchelon - */ - public function setAgent(Agent $agent): AgentEchelon - { - $this->agent = $agent; - return $this; - } - - /** - * @return int|null - */ public function getEchelon(): ?int { return $this->echelon; } - /** - * @param int $echelon - * @return AgentEchelon - */ - public function setEchelon(int $echelon): AgentEchelon - { - $this->echelon = $echelon; - return $this; - } - - /** - * @return DateTime|null - */ - public function getDate(): ?DateTime - { - return $this->date; - } - - /** - * @param DateTime $date - * @return AgentEchelon - */ - public function setDate(DateTime $date): AgentEchelon - { - $this->date = $date; - return $this; - } } \ No newline at end of file diff --git a/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php b/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php index ff6de595484fb94f8680f5d7cc9132d1a97308ed..d94c5d854e69e8c12ba45bb6ef537ff8dccc4bb7 100644 --- a/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php +++ b/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php @@ -343,7 +343,7 @@ trait AgentMacroTrait $echelon = $agent->getEchelonActif(); if ($echelon) { - return $echelon->getDate()->format('d/m/Y'); + return $echelon->getDateDebut()->format('d/m/Y'); } return ""; } diff --git a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.AgentEchelon.dcm.xml b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.AgentEchelon.dcm.xml index abff70457a12012baf736b2a6bacea855f74c76a..e7389366428a120f4660d26c11db6d91cc067161 100644 --- a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.AgentEchelon.dcm.xml +++ b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.AgentEchelon.dcm.xml @@ -8,8 +8,9 @@ <join-column name="agent_id" referenced-column-name="c_individu"/> </many-to-one> - <field name="date" type="datetime" column="d_debut" nullable="false"/> <field name="echelon" type="integer" column="echelon" nullable="false"/> + <field name="dateDebut" type="datetime" column="d_debut" nullable="false"/> + <field name="dateFin" type="datetime" column="d_fin" nullable="true"/> <!-- DB IMPORT ############################# --> <field name="created_on" column="created_on" type="datetime"/> diff --git a/module/Application/src/Application/Entity/Db/Traits/HasPeriodeTrait.php b/module/Application/src/Application/Entity/Db/Traits/HasPeriodeTrait.php index 8e0f3b414502d71b8d7373b6d0502ad0050fc40b..a87bed5b45c5dc05dc79e1871788bc4579dabec1 100644 --- a/module/Application/src/Application/Entity/Db/Traits/HasPeriodeTrait.php +++ b/module/Application/src/Application/Entity/Db/Traits/HasPeriodeTrait.php @@ -7,45 +7,27 @@ use Doctrine\ORM\QueryBuilder; trait HasPeriodeTrait { - /** @var DateTime|null */ - private $dateDebut; - /** @var DateTime|null */ - private $dateFin; + private ?DateTime $dateDebut = null; + private ?DateTime $dateFin = null; - /** - * @return DateTime|null - */ public function getDateDebut() : ?DateTime { return $this->dateDebut; } - /** - * @param DateTime|null $date - * @return self - */ - public function setDateDebut(?DateTime $date) : self + public function setDateDebut(?DateTime $date) : void { $this->dateDebut = $date; - return $this; } - /** - * @return DateTime|null - */ public function getDateFin() : ?DateTime { return $this->dateFin; } - /** - * @param DateTime|null $date - * @return self - */ - public function setDateFin(?DateTime $date) : self + public function setDateFin(?DateTime $date) : void { $this->dateFin = $date; - return $this; } /** diff --git a/module/Application/src/Application/View/Helper/partial/agent-grade.phtml b/module/Application/src/Application/View/Helper/partial/agent-grade.phtml index 976d187dd15ed6d72b38def8778d7e151b1bf170..acab514bfd457c381b41310073cefef48d9755fd 100644 --- a/module/Application/src/Application/View/Helper/partial/agent-grade.phtml +++ b/module/Application/src/Application/View/Helper/partial/agent-grade.phtml @@ -103,7 +103,7 @@ $displayCorrespondance = (isset($options['correspondance']) and $options['corres <?php if ($echelon and $echelon->getEchelon() !== 0) : ?> <dt class="col-md-3"> Échelon</dt> <dd class="col-md-9"> <?php echo $echelon->getEchelon(); ?> (date de passage - : <?php echo $echelon->getDate()->format('d/m/Y'); ?>) + : <?php echo $echelon->getDateDebut()->format('d/m/Y'); ?>) </dd> <?php endif; ?> </dl> diff --git a/module/Application/view/application/verification/index.phtml b/module/Application/view/application/verification/index.phtml index a8cbbe2e428fb5ed6726115dcbf09d9adbc7deff..c1cd3b03ce8356584a9231c53bb36c49b99516d0 100644 --- a/module/Application/view/application/verification/index.phtml +++ b/module/Application/view/application/verification/index.phtml @@ -97,7 +97,7 @@ $this->headTitle("Vérification de l'installation"); </div> <!-- PARAMETRE ----------------------------------------------------------------------------------------------------> - <?php $path = file_exists($installation_path . '/module/' . $module . '/src/' . $module . '/Provider/Parametre'); ?> + <?php $path = $installation_path . '/module/' . $module . '/src/' . $module . '/Provider/Parametre'; ?> <?php $exist = (file_exists($installation_path . '/module/' . $module . '/src/' . $module . '/Provider/Parametre')); ?> <div class="card bg-default "> <div class="card-header">