inscription done
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Form\SortieType;
|
|||||||
use App\Repository\EtatRepository;
|
use App\Repository\EtatRepository;
|
||||||
use App\Repository\LieuRepository;
|
use App\Repository\LieuRepository;
|
||||||
use App\Repository\ParticipantRepository;
|
use App\Repository\ParticipantRepository;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -120,6 +121,8 @@ class SortieController extends AbstractController
|
|||||||
$this->addFlash('error', 'Vous êtes déjà inscrit à cette sortie.');
|
$this->addFlash('error', 'Vous êtes déjà inscrit à cette sortie.');
|
||||||
} elseif ($sortie->getParticipants()->count() >= $sortie->getNbInscriptionsMax()) {
|
} elseif ($sortie->getParticipants()->count() >= $sortie->getNbInscriptionsMax()) {
|
||||||
$this->addFlash('error', 'Cette sortie est complète.');
|
$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 {
|
} else {
|
||||||
$sortie->addParticipant($userConnect);
|
$sortie->addParticipant($userConnect);
|
||||||
$entityManager->persist($sortie);
|
$entityManager->persist($sortie);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% 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() %}
|
||||||
<form action="{{ path('sortie_inscription', { id: sortie.idSortie }) }}" method="post" class="mt-6">
|
<form action="{{ path('sortie_inscription', { id: sortie.idSortie }) }}" method="post" class="mt-6">
|
||||||
<button type="submit" class="px-6 py-3 bg-green-500 text-white rounded-md shadow hover:bg-green-600">
|
<button type="submit" class="px-6 py-3 bg-green-500 text-white rounded-md shadow hover:bg-green-600">
|
||||||
✅ S'inscrire
|
✅ S'inscrire
|
||||||
|
|||||||
Reference in New Issue
Block a user