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

Fix etat

parent 141cb3f9
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -155,7 +155,10 @@ class Seance implements HistoriqueAwareInterface
    public function isPremiereSeance(): bool
    {
        $session = $this->getSession();
        return ($session->getSeances() === null OR $session->getSeances() === [] OR $this->getDateTimeDebut()->format('d/m/Y H:i') === $session->getDebut());
        $premiere = $session->getPremiereSeance();
        $res =  ($session->getSeances() === null OR $session->getSeances() === []
            OR $this->getDateTimeDebut() <= $premiere->getDateTimeDebut());
        return $res;
    }

    public function isDerniereSeance(): bool
@@ -163,8 +166,9 @@ class Seance implements HistoriqueAwareInterface
        $session = $this->getSession();
        $derniere = $session->getDerniereSeance();
        if ($derniere === null) return true;
        return ($session->getSeances() === null OR $session->getSeances() === []
                OR $derniere->getDateTimeFin() >= $session->getDateTimeFin());
        $res = ($session->getSeances() === null OR $session->getSeances() === []
                OR $this->getDateTimeFin() >= $derniere->getDateTimeFin());
        return $res;
    }


+21 −0
Original line number Diff line number Diff line
@@ -204,6 +204,27 @@ class Session implements HistoriqueAwareInterface, HasEtatsInterface, HasEveneme
        return $maximum;
    }

    public function getDateTimeDebut(bool $datetime = false): string|DateTime|null
    {
        $minimum = null;
        foreach ($this->seances as $seance) {
            if ($seance->estNonHistorise()) {
                if ($seance->getType() === Seance::TYPE_SEANCE) {
                    $date = $seance->getDateTimeDebut();
                    if ($date !== null and ($minimum === null or $date < $minimum)) $minimum = $date;
                }
                if ($seance->getType() === Seance::TYPE_VOLUME) {
                    if ($seance->getVolumeFin()) {
                        $debut = $seance->getVolumeDebut();
                        if ($minimum === null or $debut < $minimum) $minimum = $debut;
                    }
                }
            }
        }
        if ($minimum === null) return null;
        if ($datetime) return $minimum;
        return $minimum->format('d/m/Y H:i');
    }

    public function getDateTimeFin(bool $datetime = false): string|DateTime|null
    {
+4 −4
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class ConvoquerSessionEvenement extends EvenementService

    public function creer(Session $session, DateTime $dateTraitement = null) : Evenement
    {
        $type = $this->getTypeService()->findByCode(SessionEvenements::CLOTURER_EVENEMENT);
        $type = $this->getTypeService()->findByCode(SessionEvenements::CONVOQUER_EVENEMENT);
        $etat = $this->getEtatEvenementService()->findByCode(Etat::EN_ATTENTE);

        $parametres = [
@@ -48,8 +48,8 @@ class ConvoquerSessionEvenement extends EvenementService
            $session = $this->getSessionService()->getSession($parametres['session']);

            if ($session AND $session->estNonHistorise()
                AND $session->getEtatActif() AND $session->getEtatActif()->getType()->getCode() === SessionEtats::ETAT_ATTENTE_RETOURS) {
                $this->getSessionService()->cloturer($session);
                AND $session->getEtatActif() AND $session->getEtatActif()->getType()->getCode() === SessionEtats::ETAT_INSCRIPTION_FERMEE) {
                $this->getSessionService()->envoyerConvocation($session);
                $log = "Session #".$session->getId()." ".$session->getAtelier()->getLibelle()." : Convocation ";
            }

@@ -89,7 +89,7 @@ class ConvoquerSessionEvenement extends EvenementService
            }
        }
        if (!$dateTraitement instanceof DateTime) {
            throw new RuntimeException("La date de traitement de l'evenement [".SessionEvenements::CLOTURER_EVENEMENT."] n'a pas pu être déterminée.");
            throw new RuntimeException("La date de traitement de l'evenement [".SessionEvenements::CONVOQUER_EVENEMENT."] n'a pas pu être déterminée.");
        }
        $event = $this->creer($session, $dateTraitement);
        $session->addEvenement($event);
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class RetourSessionEvenement extends EvenementService
    {
        //NETTOYAGE
        $evenements = $session->getEvenements()->toArray();
        $evenements = array_filter($evenements, function (Evenement $e) { return $e->getType()->getCode() === SessionEvenements::CLOTURER_EVENEMENT;});
        $evenements = array_filter($evenements, function (Evenement $e) { return $e->getType()->getCode() === SessionEvenements::RETOUR_EVENEMENT;});
        foreach ($evenements as $evenement) {
            $session->removeEvenement($evenement);
            $this->getSessionService()->update($session);
+3 −1
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ class SeanceService
        $message = "";
        $session = $seance->getSession();

        if ($seance->isPremiereSeance() OR $seance->isDerniereSeance()) $message .= "<strong>Modification des événements </strong><br><br>";
        if ($seance->isPremiereSeance()) {
            $message .= "<strong>Modification de la première séance</strong><br>";
            $event = $this->getConvoquerSessionEvenement()->updateEvent($session);
@@ -191,8 +192,9 @@ class SeanceService
                $message .= "Plus de séance : retrait de la cloture automatique";
            }
            $message .= "<br>";
            $flashMessenger?->addInfoMessage($message);

        }
        if ($seance->isPremiereSeance() OR $seance->isDerniereSeance()) $flashMessenger?->addInfoMessage($message);
    }

}
 No newline at end of file