diff --git a/src/Controller/SortieController.php b/src/Controller/SortieController.php index 47cf207..54539a0 100644 --- a/src/Controller/SortieController.php +++ b/src/Controller/SortieController.php @@ -7,6 +7,7 @@ use App\Form\SortieType; use App\Repository\EtatRepository; use App\Repository\LieuRepository; use App\Repository\ParticipantRepository; +use DateTime; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -120,6 +121,8 @@ class SortieController extends AbstractController $this->addFlash('error', 'Vous êtes déjà inscrit à cette sortie.'); } elseif ($sortie->getParticipants()->count() >= $sortie->getNbInscriptionsMax()) { $this->addFlash('error', 'Cette sortie est complète.'); + } elseif ($sortie->getDateLimiteInscription() < new DateTime()) { + $this->addFlash('error', "La date limite d'inscription est dépassée"); } else { $sortie->addParticipant($userConnect); $entityManager->persist($sortie); diff --git a/templates/sortie/view.html.twig b/templates/sortie/view.html.twig index e175177..b01f687 100644 --- a/templates/sortie/view.html.twig +++ b/templates/sortie/view.html.twig @@ -65,7 +65,7 @@ {% endif %} - {% if app.user and sortie.etat.libelle == 'Ouverte' and not sortie.participants.contains(app.user) %} + {% if app.user and sortie.etat.libelle == 'Ouverte' and not sortie.participants.contains(app.user) and date(sortie.dateLimiteInscription) > date() %}