sortie etat done
This commit is contained in:
@@ -110,7 +110,7 @@ class SortieController extends AbstractController
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'La sortie a été créée avec succès.');
|
||||
return $this->redirectToRoute('home');
|
||||
return $this->redirectToRoute('sortie_view', ['id'=> $sortie->getIdSortie()]);
|
||||
}
|
||||
|
||||
return $this->render('sortie/create.html.twig', [
|
||||
@@ -136,6 +136,14 @@ class SortieController extends AbstractController
|
||||
return $this->redirectToRoute('home');
|
||||
}
|
||||
|
||||
// Changer l'état si date de début commencé.
|
||||
if($sortie->getDateLimiteInscription() < new DateTime()){
|
||||
$sortie->setEtat($entityManager->getRepository(Etat::class)->findOneBy(['libelle' => 'Clôturée']));
|
||||
}
|
||||
if ($sortie->getDateHeureDebut() <= (new DateTime())) {
|
||||
$sortie->setEtat($entityManager->getRepository(Etat::class)->findOneBy(['libelle' => 'En cours']));
|
||||
}
|
||||
|
||||
return $this->render('sortie/view.html.twig', [
|
||||
'sortie' => $sortie,
|
||||
'profile' => $tokenStorage->getToken()?->getUser(),
|
||||
@@ -280,4 +288,22 @@ class SortieController extends AbstractController
|
||||
return $this->redirectToRoute('home');
|
||||
}
|
||||
|
||||
#[Route('/confirm/{id}', name: 'confirm', methods: ['POST'])]
|
||||
public function confirm(string $id, EntityManagerInterface $entityManager, TokenStorageInterface $tokenStorage)
|
||||
{
|
||||
$user = $tokenStorage->getToken()?->getUser();
|
||||
$sortie = $entityManager->getRepository(Sortie::class)->find($id);
|
||||
|
||||
if (!$sortie || $sortie->getOrganisateur()->getIdParticipant() !== $user->getIdParticipant()) {
|
||||
$this->addFlash('error', 'Vous n\'avez pas l\'autorisation de démarrer les inscriptions pour cette sortie.');
|
||||
return $this->redirectToRoute('sortie_view', ['id' => $id]);
|
||||
}
|
||||
|
||||
$sortie->setEtat($entityManager->getRepository(Etat::class)->findOneBy(['libelle' => 'Ouverte']));
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Les inscriptions sont ouvertes pour cette sortie');
|
||||
return $this->redirectToRoute('sortie_view', ['id' => $id]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user