conflict resolved
This commit is contained in:
@@ -8,9 +8,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const longitudeLabel = document.getElementById('longitude-value');
|
const longitudeLabel = document.getElementById('longitude-value');
|
||||||
|
|
||||||
if (villeSelect && lieuSelect) {
|
if (villeSelect && lieuSelect) {
|
||||||
|
// Listener pour la ville
|
||||||
villeSelect.addEventListener('change', function () {
|
villeSelect.addEventListener('change', function () {
|
||||||
const villeId = villeSelect.value;
|
const villeId = villeSelect.value;
|
||||||
|
|
||||||
|
// Réinitialisation des options de lieu
|
||||||
lieuSelect.innerHTML = '<option value="">Sélectionnez un lieu</option>';
|
lieuSelect.innerHTML = '<option value="">Sélectionnez un lieu</option>';
|
||||||
lieuSelect.disabled = true;
|
lieuSelect.disabled = true;
|
||||||
|
|
||||||
@@ -23,12 +25,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// Mise à jour des options dans le menu déroulant
|
||||||
lieuSelect.innerHTML = '<option value="">Sélectionnez un lieu</option>';
|
lieuSelect.innerHTML = '<option value="">Sélectionnez un lieu</option>';
|
||||||
data.forEach(lieu => {
|
data.forEach(lieu => {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.value = lieu.id;
|
option.value = lieu.id; // ID pour soumettre au backend
|
||||||
option.textContent = lieu.nom;
|
option.textContent = lieu.nom; // Nom affiché
|
||||||
option.dataset.details = JSON.stringify(lieu);
|
option.dataset.details = JSON.stringify(lieu); // Stocker les détails pour affichage
|
||||||
lieuSelect.appendChild(option);
|
lieuSelect.appendChild(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,20 +43,27 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listener pour le lieu
|
||||||
lieuSelect.addEventListener('change', function () {
|
lieuSelect.addEventListener('change', function () {
|
||||||
const selectedOption = lieuSelect.options[lieuSelect.selectedIndex];
|
const selectedOption = lieuSelect.options[lieuSelect.selectedIndex];
|
||||||
if (selectedOption && selectedOption.dataset.details) {
|
if (selectedOption && selectedOption.dataset.details) {
|
||||||
const lieuDetails = JSON.parse(selectedOption.dataset.details);
|
const lieuDetails = JSON.parse(selectedOption.dataset.details);
|
||||||
|
|
||||||
|
// Mise à jour des labels avec les détails du lieu sélectionné
|
||||||
rueLabel.textContent = lieuDetails.rue || 'Non renseignée';
|
rueLabel.textContent = lieuDetails.rue || 'Non renseignée';
|
||||||
codePostalLabel.textContent = lieuDetails.codePostal || 'Non renseigné';
|
codePostalLabel.textContent = lieuDetails.codePostal || 'Non renseigné';
|
||||||
latitudeLabel.textContent = lieuDetails.latitude || 'Non renseignée';
|
latitudeLabel.textContent = lieuDetails.latitude || 'Non renseignée';
|
||||||
longitudeLabel.textContent = lieuDetails.longitude || 'Non renseignée';
|
longitudeLabel.textContent = lieuDetails.longitude || 'Non renseignée';
|
||||||
|
|
||||||
|
console.log('Lieu sélectionné:', lieuDetails);
|
||||||
} else {
|
} else {
|
||||||
|
// Réinitialisation des labels si aucun lieu n'est sélectionné
|
||||||
rueLabel.textContent = 'Renseigner avec le lieu';
|
rueLabel.textContent = 'Renseigner avec le lieu';
|
||||||
codePostalLabel.textContent = 'Renseigner avec le lieu';
|
codePostalLabel.textContent = 'Renseigner avec le lieu';
|
||||||
latitudeLabel.textContent = 'Renseigner avec le lieu';
|
latitudeLabel.textContent = 'Renseigner avec le lieu';
|
||||||
longitudeLabel.textContent = 'Renseigner avec le lieu';
|
longitudeLabel.textContent = 'Renseigner avec le lieu';
|
||||||
|
|
||||||
|
console.log('Aucun lieu sélectionné.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|||||||
|
|
||||||
class AdminController extends AbstractController
|
class AdminController extends AbstractController
|
||||||
{
|
{
|
||||||
|
private ParticipantRepository $participantRepository;
|
||||||
|
public function __construct(ParticipantRepository $participantRepository){
|
||||||
|
$this->participantRepository = $participantRepository;
|
||||||
|
}
|
||||||
#[Route('/admin', name: 'app_admin')]
|
#[Route('/admin', name: 'app_admin')]
|
||||||
public function index(TokenStorageInterface $tokenStorage): Response
|
public function index(TokenStorageInterface $tokenStorage): Response
|
||||||
{
|
{
|
||||||
@@ -38,13 +42,14 @@ class AdminController extends AbstractController
|
|||||||
|
|
||||||
//Gestion des utilisateurs
|
//Gestion des utilisateurs
|
||||||
#[Route('/admin/user', name: 'app_adminUser')]
|
#[Route('/admin/user', name: 'app_adminUser')]
|
||||||
public function adminUser(ParticipantRepository $participantRepository, TokenStorageInterface $tokenStorage): Response
|
public function adminUser(TokenStorageInterface $tokenStorage): Response
|
||||||
{
|
{
|
||||||
$token = $tokenStorage->getToken();
|
$token = $tokenStorage->getToken();
|
||||||
$userConnect = $token?->getUser();
|
$userConnect = $token?->getUser();
|
||||||
|
$participants = $this->participantRepository->findAll();
|
||||||
return $this->render('admin/user.html.twig', [
|
return $this->render('admin/user.html.twig', [
|
||||||
'profile' => $userConnect,
|
'profile' => $userConnect,
|
||||||
'participants' => $participantRepository->findAll(),
|
'participants' => $participants,
|
||||||
'controller_name' => 'AdminController',
|
'controller_name' => 'AdminController',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,39 +4,89 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Entity\Sortie;
|
use App\Entity\Sortie;
|
||||||
use App\Form\SortieType;
|
use App\Form\SortieType;
|
||||||
|
use App\Repository\EtatRepository;
|
||||||
use App\Repository\LieuRepository;
|
use App\Repository\LieuRepository;
|
||||||
use App\Repository\VilleRepository;
|
use App\Repository\ParticipantRepository;
|
||||||
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;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
|
||||||
#[Route('/sortie', name: 'sortie_')]
|
#[Route('/sortie', name: 'sortie_')]
|
||||||
class SortieController extends AbstractController
|
class SortieController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/creates', name: 'create', methods: ['GET', 'POST'])]
|
#[Route('/creates', name: 'create', methods: ['GET', 'POST'])]
|
||||||
public function create(Request $request, EntityManagerInterface $entityManager): Response
|
public function create(
|
||||||
{
|
Request $request,
|
||||||
|
EntityManagerInterface $entityManager,
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
LieuRepository $lieuRepository,
|
||||||
|
ParticipantRepository $participantRepository,
|
||||||
|
EtatRepository $etatRepository // Ajout du repository pour les états
|
||||||
|
): Response {
|
||||||
$sortie = new Sortie();
|
$sortie = new Sortie();
|
||||||
|
|
||||||
// Créez le formulaire sans options spéciales
|
// Récupérer l'utilisateur connecté
|
||||||
|
$token = $tokenStorage->getToken();
|
||||||
|
$userConnect = $token?->getUser();
|
||||||
|
|
||||||
|
if (!$userConnect) {
|
||||||
|
$this->addFlash('error', 'Vous devez être connecté pour créer une sortie.');
|
||||||
|
return $this->redirectToRoute('app_login');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer le formulaire
|
||||||
$form = $this->createForm(SortieType::class, $sortie);
|
$form = $this->createForm(SortieType::class, $sortie);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
// Sauvegarde dans la base de données
|
// Récupérer l'ID du lieu depuis le formulaire
|
||||||
|
$lieuId = $form->get('lieu')->getData();
|
||||||
|
$lieu = $lieuRepository->find($lieuId);
|
||||||
|
|
||||||
|
if (!$lieu) {
|
||||||
|
$this->addFlash('error', 'Le lieu sélectionné est invalide.');
|
||||||
|
return $this->redirectToRoute('sortie_create');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Associer le lieu à la sortie
|
||||||
|
$sortie->setLieu($lieu);
|
||||||
|
|
||||||
|
// Associer le site à partir de l'utilisateur connecté
|
||||||
|
$participant = $participantRepository->find($userConnect->getIdParticipant());
|
||||||
|
|
||||||
|
if (!$participant) {
|
||||||
|
$this->addFlash('error', 'Impossible de déterminer le site de l\'utilisateur.');
|
||||||
|
return $this->redirectToRoute('sortie_create');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sortie->setSite($participant->getSite());
|
||||||
|
$sortie->setParticipant($participant);
|
||||||
|
|
||||||
|
// Récupérer l'état "en création" avec l'ID donné
|
||||||
|
$etat = $etatRepository->find('019349ba-38ca-7a39-93c3-62f046671525');
|
||||||
|
if (!$etat) {
|
||||||
|
$this->addFlash('error', 'État non trouvé.');
|
||||||
|
return $this->redirectToRoute('sortie_create');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Associer l'état à la sortie
|
||||||
|
$sortie->setEtat($etat);
|
||||||
|
|
||||||
|
// Sauvegarder la sortie
|
||||||
$entityManager->persist($sortie);
|
$entityManager->persist($sortie);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
|
||||||
$this->addFlash('success', 'La sortie a été créée avec succès.');
|
$this->addFlash('success', 'La sortie a été créée avec succès.');
|
||||||
|
|
||||||
return $this->redirectToRoute('sortie_create');
|
return $this->redirectToRoute('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('sortie/create.html.twig', [
|
return $this->render('sortie/create.html.twig', [
|
||||||
|
'profile' => $userConnect,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ class Sortie
|
|||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $nom = null;
|
private ?string $nom = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||||
private ?\DateTimeInterface $dateHeureDebut = null;
|
private ?\DateTimeInterface $dateHeureDebut = null;
|
||||||
|
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
private ?int $duree = null;
|
private ?int $duree = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||||
private ?\DateTimeInterface $dateLimiteInscription = null;
|
private ?\DateTimeInterface $dateLimiteInscription = null;
|
||||||
|
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class SortieType extends AbstractType
|
|||||||
'class' => Lieu::class,
|
'class' => Lieu::class,
|
||||||
'choice_label' => 'nom',
|
'choice_label' => 'nom',
|
||||||
'label' => 'Lieu',
|
'label' => 'Lieu',
|
||||||
'placeholder' => 'Sélectionnez une ville d\'abord',
|
'placeholder' => 'Sélectionnez un lieu',
|
||||||
'choices' => [],
|
'required' => true,
|
||||||
'attr' => ['id' => 'lieu-select'],
|
'attr' => ['id' => 'lieu-select'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Repository;
|
|||||||
|
|
||||||
use App\Entity\Participant;
|
use App\Entity\Participant;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
|
|
||||||
@@ -33,6 +34,16 @@ class ParticipantRepository extends ServiceEntityRepository
|
|||||||
return $newProfile;
|
return $newProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAll(): Paginator
|
||||||
|
{
|
||||||
|
$qb = $this->createQueryBuilder('p')
|
||||||
|
->addSelect('site')
|
||||||
|
->leftJoin('p.site', 'site')
|
||||||
|
->getQuery();
|
||||||
|
return new Paginator($qb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @return Participant[] Returns an array of Participant objects
|
// * @return Participant[] Returns an array of Participant objects
|
||||||
// */
|
// */
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Prénom</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Prénom</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Pseudo</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Pseudo</th>
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Site</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Téléphone</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Téléphone</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Administrateur</th>
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Administrateur</th>
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.nom }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.nom }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.prenom }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.prenom }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.pseudo }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.pseudo }}</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.site ? participant.site.nom : "N/A" }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.telephone }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.telephone }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.email }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.email }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||||
@@ -91,6 +93,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{# Tableau user en attente #}
|
{# Tableau user en attente #}
|
||||||
<div class="overflow-x-auto bg-white rounded shadow mt-16">
|
<div class="overflow-x-auto bg-white rounded shadow mt-16">
|
||||||
<table class="min-w-full bg-white divide-y divide-gray-200">
|
<table class="min-w-full bg-white divide-y divide-gray-200">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{% block head %}
|
{% block head %}
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<title>Liste des sorties</title>
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{{ encore_entry_link_tags('app') }}
|
{{ encore_entry_link_tags('app') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -9,24 +10,24 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container mt-4">
|
<div class="container mx-auto p-4">
|
||||||
<div class="row">
|
<h1 class="text-2xl font-bold mb-6 text-center">Liste des sorties</h1>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-6 gap-6">
|
||||||
{% for sortie in sorties %}
|
{% for sortie in sorties %}
|
||||||
<div class="grid-cols-4 mb-4">
|
<div class="bg-white rounded-lg shadow-md p-4">
|
||||||
<div class="card shadow-sm">
|
<h2 class="text-lg font-semibold">{{ sortie.nom }}</h2>
|
||||||
<div class="card-body">
|
<p class="mt-2 text-gray-600">
|
||||||
<h5 class="card-title">{{ sortie.nom }}</h5>
|
<strong>Date de début :</strong> {{ sortie.dateHeureDebut|date('d/m/Y H:i') }}<br>
|
||||||
<p class="card-text">
|
<strong>Durée :</strong> {{ sortie.duree }} minutes<br>
|
||||||
<strong>Date de début :</strong> {{ sortie.dateHeureDebut|date('d/m/Y H:i') }}<br>
|
<strong>Inscriptions max :</strong> {{ sortie.nbInscriptionsMax }}<br>
|
||||||
<strong>Durée :</strong> {{ sortie.duree }} minutes<br>
|
<strong>Infos :</strong> {{ sortie.infosSortie }}
|
||||||
<strong>Inscriptions max :</strong> {{ sortie.nbInscriptionsMax }}<br>
|
</p>
|
||||||
<strong>Infos :</strong> {{ sortie.infosSortie }}
|
<div class="mt-4 flex justify-end">
|
||||||
</p>
|
<a href="#" class="text-blue-500 hover:text-blue-700 font-medium">Voir plus</a>
|
||||||
<a href="{{ path('sortie_show', { id: sortie.idSortie }) }}" class="btn btn-primary btn-sm">Voir plus</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user