From 59812d3ffb6e34b55d4ce21f867000c19ea6511c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Metivier <jean-philippe.metivier@unicaen.fr> Date: Mon, 31 Mar 2025 09:44:19 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20des=20=C3=A9v=C3=A9nements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/Formation/src/Formation/Entity/Db/Seance.php | 12 ++++++++---- .../Formation/Event/Convocation/ConvocationEvent.php | 6 +++++- .../Event/DemandeRetour/DemandeRetourEvent.php | 7 ++++++- .../InscriptionCloture/InscriptionClotureEvent.php | 5 +++++ .../Formation/Event/RappelAgent/RappelAgentEvent.php | 5 +++++ .../Event/SessionCloture/SessionClotureEvent.php | 7 ++++++- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/module/Formation/src/Formation/Entity/Db/Seance.php b/module/Formation/src/Formation/Entity/Db/Seance.php index f6c3aac5..fd11532b 100644 --- a/module/Formation/src/Formation/Entity/Db/Seance.php +++ b/module/Formation/src/Formation/Entity/Db/Seance.php @@ -174,7 +174,8 @@ class Seance implements HistoriqueAwareInterface, HasSourceInterface public function setVolumeDebut(?DateTime $volumeDebut): void { - $this->volumeDebut = $volumeDebut; + $newDate = $volumeDebut?DateTime::createFromFormat('d-m-Y H:i:s', $volumeDebut->format('d-m-Y'). " 08:00:00"):null; + $this->volumeDebut = $newDate; } public function getVolumeFin(): ?DateTime @@ -184,7 +185,8 @@ class Seance implements HistoriqueAwareInterface, HasSourceInterface public function setVolumeFin(?DateTime $volumeFin): void { - $this->volumeFin = $volumeFin; + $newDate = $volumeFin?DateTime::createFromFormat('d-m-Y H:i:s', $volumeFin->format('d-m-Y'). " 18:00:00"):null; + $this->volumeFin = $newDate; } /** AUTRE ****************************************************** */ @@ -213,13 +215,15 @@ class Seance implements HistoriqueAwareInterface, HasSourceInterface public function isPremiereSeance(): bool { $session = $this->getInstance(); - return ($session->getSeances() === null OR $session->getSeances() === [] OR $this->getDateDebut()->format('d/m/Y H:i') === $session->getDebut()); + $res = ($session->getSeances() === null OR $session->getSeances() === [] OR $this->getDateDebut()->format('d/m/Y H:i') === $session->getDebut()); + return $res; } public function isDerniereSeance(): bool { $session = $this->getInstance(); - return ($session->getSeances() === null OR $session->getSeances() === [] OR $this->getDateFin()->format('d/m/Y H:i') === $session->getFin()); + $res = ($session->getSeances() === null OR $session->getSeances() === [] OR $this->getDateFin()->format('d/m/Y H:i') === $session->getFin()); + return $res; } /** diff --git a/module/Formation/src/Formation/Event/Convocation/ConvocationEvent.php b/module/Formation/src/Formation/Event/Convocation/ConvocationEvent.php index 91ff222e..6d202f37 100644 --- a/module/Formation/src/Formation/Event/Convocation/ConvocationEvent.php +++ b/module/Formation/src/Formation/Event/Convocation/ConvocationEvent.php @@ -47,7 +47,11 @@ class ConvocationEvent extends EvenementService $parametres = json_decode($evenement->getParametres(), true); /** @var Session|null $session */ $session = $this->getSessionService()->getSession($parametres['session']); - + if (!$session->getParametre()->isEvenementActive()) { + $evenement->setLog("La session est configurée pour ne pas traiter les événements"); + $this->update($evenement); + return Etat::ANNULE; + } if ($session AND $session->estNonHistorise() AND $session->getEtatActif() AND $session->getEtatActif()->getType()->getCode() === SessionEtats::ETAT_INSCRIPTION_FERMEE) { $this->getSessionService()->envoyerConvocation($session); diff --git a/module/Formation/src/Formation/Event/DemandeRetour/DemandeRetourEvent.php b/module/Formation/src/Formation/Event/DemandeRetour/DemandeRetourEvent.php index b38847af..2aeba275 100644 --- a/module/Formation/src/Formation/Event/DemandeRetour/DemandeRetourEvent.php +++ b/module/Formation/src/Formation/Event/DemandeRetour/DemandeRetourEvent.php @@ -47,6 +47,11 @@ class DemandeRetourEvent extends EvenementService $parametres = json_decode($evenement->getParametres(), true); /** @var Session|null $session */ $session = $this->getSessionService()->getSession($parametres['session']); + if (!$session->getParametre()->isEvenementActive()) { + $evenement->setLog("La session est configurée pour ne pas traiter les événements"); + $this->update($evenement); + return Etat::ANNULE; + } if ($session AND $session->estNonHistorise() AND $session->getEtatActif() AND $session->getEtatActif()->getType()->getCode() === SessionEtats::ETAT_FORMATION_CONVOCATION) { @@ -83,7 +88,7 @@ class DemandeRetourEvent extends EvenementService } catch (Exception $e) { throw new RuntimeException("Un problème est survenu lors du calcul de l'interval", 0 ,$e); } - $dateTraitement = $dateFin->sub($interval); + $dateTraitement = $dateFin->add($interval); } if (!$dateTraitement instanceof DateTime) { throw new RuntimeException("La date de traitement de l'evenement [".EvenementProvider::DEMANDE_RETOUR."] n'a pas pu être déterminée."); diff --git a/module/Formation/src/Formation/Event/InscriptionCloture/InscriptionClotureEvent.php b/module/Formation/src/Formation/Event/InscriptionCloture/InscriptionClotureEvent.php index 0ded0326..8d391c36 100644 --- a/module/Formation/src/Formation/Event/InscriptionCloture/InscriptionClotureEvent.php +++ b/module/Formation/src/Formation/Event/InscriptionCloture/InscriptionClotureEvent.php @@ -49,6 +49,11 @@ class InscriptionClotureEvent extends EvenementService $parametres = json_decode($evenement->getParametres(), true); /** @var Session|null $session */ $session = $this->getSessionService()->getSession($parametres['session']); + if (!$session->getParametre()->isEvenementActive()) { + $evenement->setLog("La session est configurée pour ne pas traiter les événements"); + $this->update($evenement); + return Etat::ANNULE; + } if ($session AND $session->estNonHistorise() AND $session->getEtatActif() AND $session->getEtatActif()->getType()->getCode() === SessionEtats::ETAT_INSCRIPTION_OUVERTE) { diff --git a/module/Formation/src/Formation/Event/RappelAgent/RappelAgentEvent.php b/module/Formation/src/Formation/Event/RappelAgent/RappelAgentEvent.php index 7855b6f4..4ae343e1 100644 --- a/module/Formation/src/Formation/Event/RappelAgent/RappelAgentEvent.php +++ b/module/Formation/src/Formation/Event/RappelAgent/RappelAgentEvent.php @@ -49,6 +49,11 @@ class RappelAgentEvent extends EvenementService $parametres = json_decode($evenement->getParametres(), true); /** @var Session|null $session */ $session = $this->getSessionService()->getSession($parametres['session']); + if (!$session->getParametre()->isEvenementActive()) { + $evenement->setLog("La session est configurée pour ne pas traiter les événements"); + $this->update($evenement); + return Etat::ANNULE; + } if ($session and $session->estNonHistorise() and $session->getEtatActif() and $session->estNonHistorise()) { diff --git a/module/Formation/src/Formation/Event/SessionCloture/SessionClotureEvent.php b/module/Formation/src/Formation/Event/SessionCloture/SessionClotureEvent.php index 18b86cfc..34d4edf6 100644 --- a/module/Formation/src/Formation/Event/SessionCloture/SessionClotureEvent.php +++ b/module/Formation/src/Formation/Event/SessionCloture/SessionClotureEvent.php @@ -47,6 +47,11 @@ class SessionClotureEvent extends EvenementService $parametres = json_decode($evenement->getParametres(), true); /** @var Session|null $session */ $session = $this->getSessionService()->getSession($parametres['session']); + if (!$session->getParametre()->isEvenementActive()) { + $evenement->setLog("La session est configurée pour ne pas traiter les événements"); + $this->update($evenement); + return Etat::ANNULE; + } if ($session AND $session->estNonHistorise() AND $session->getEtatActif() AND $session->getEtatActif()->getType()->getCode() === SessionEtats::ETAT_ATTENTE_RETOURS) { @@ -83,7 +88,7 @@ class SessionClotureEvent extends EvenementService } catch (Exception $e) { throw new RuntimeException("Un problème est survenu lors du calcul de l'interval", 0 ,$e); } - $dateTraitement = $dateFin->sub($interval); + $dateTraitement = $dateFin->add($interval); } if (!$dateTraitement instanceof DateTime) { throw new RuntimeException("La date de traitement de l'evenement [".EvenementProvider::SESSION_CLOTURE."] n'a pas pu être déterminée."); -- GitLab