Merge remote-tracking branch 'origin/main'

# Conflicts:
#	templates/sortie/create.html.twig
This commit is contained in:
mepiphana2023
2024-11-25 12:02:51 +01:00
12 changed files with 113 additions and 219 deletions

2
.env
View File

@@ -37,5 +37,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ### ###< symfony/messenger ###
###> symfony/mailer ### ###> symfony/mailer ###
MAILER_DSN=smtp:// MAILER_DSN=smtp://dev-test@lidge.fr:N2uGKkGa8tQBp5NIvHIt@mail.lidge.fr:587
###< symfony/mailer ### ###< symfony/mailer ###

View File

@@ -1,5 +0,0 @@
-- Doctrine Migration File Generated on 2024-11-21 09:04:49
-- Version DoctrineMigrations\Version20241121085948
ALTER TABLE sortie ADD CONSTRAINT FK_3C3FD3F2D936B2FA FOREIGN KEY (organisateur_id) REFERENCES participant (id_participant);
CREATE INDEX IDX_3C3FD3F2D936B2FA ON sortie (organisateur_id);

View File

@@ -8,6 +8,7 @@ use App\Entity\Site;
use App\Entity\Ville; use App\Entity\Ville;
use App\Repository\ParticipantRepository; use App\Repository\ParticipantRepository;
use App\Repository\SiteRepository; use App\Repository\SiteRepository;
use App\Repository\SortieRepository;
use App\Repository\VilleRepository; use App\Repository\VilleRepository;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@@ -137,6 +138,7 @@ class AdminController extends AbstractController
$participant->setActif(false); $participant->setActif(false);
$participant->setRoles(['ROLE_USER']); $participant->setRoles(['ROLE_USER']);
$participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT));
$participant->setPending(true);
$entityManager->persist($participant); $entityManager->persist($participant);
@@ -202,6 +204,7 @@ class AdminController extends AbstractController
$participant->setActif(false); $participant->setActif(false);
$participant->setRoles(explode('|', $row[7])); $participant->setRoles(explode('|', $row[7]));
$participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT));
$participant->setPending(true);
$em->persist($participant); $em->persist($participant);
// Générer un token unique // Générer un token unique
@@ -278,68 +281,6 @@ class AdminController extends AbstractController
return $response; return $response;
} }
//Gestion des villes
#[Route('/admin/city', name: 'app_adminCity')]
public function adminCity(VilleRepository $villeRepository, TokenStorageInterface $tokenStorage): Response
{
$token = $tokenStorage->getToken();
$userConnect = $token?->getUser();
return $this->render('admin/city.html.twig', [
'profile' => $userConnect,
'citys' => $villeRepository->findAll(),
'controller_name' => 'AdminController',
]);
}
#[Route('/admin/city/add', name: 'app_adminCityAdd', methods: ['POST'])]
public function adminCityAdd(Request $request, EntityManagerInterface $entityManager): Response
{
try {
// Récupérer les données envoyées par le formulaire
$postalCode = $request->request->get('postalCode');
$cityName = $request->request->get('citySelect');
// Vérifier que les champs ne sont pas vides
if (!$postalCode || !$cityName) {
return new Response('Tous les champs sont requis.', Response::HTTP_BAD_REQUEST);
}
// Créer une nouvelle entité City et définir ses propriétés
$city = new Ville();
$city->setNom($cityName);
$city->setCodePostal($postalCode);
// Enregistrer la ville dans la base de données
$entityManager->persist($city);
$entityManager->flush();
$this->addFlash('success', "Ville ajouté !");
return $this->redirectToRoute('app_adminCity');
} catch(\Exception $e) {
$this->addFlash('error', "Erreur : " . $e->getMessage());
return $this->redirectToRoute('app_adminCity');
}
}
#[Route('/admin/city/delete/{id}', name: 'app_adminCityDelete')]
public function adminCityDelete(string $id, VilleRepository $villeRepository, EntityManagerInterface $entityManager): RedirectResponse
{
// Récupérer la ville à supprimer
$city = $villeRepository->find($id);
// Vérifier si la ville existe
if (!$city) {
// Si la ville n'existe pas, rediriger avec un message d'erreur
$this->addFlash('error', 'La ville demandée n\'existe pas.');
return $this->redirectToRoute('app_adminCity'); // Rediriger vers la liste des villes
}
// Supprimer la ville
$entityManager->remove($city);
$entityManager->flush();
// Ajouter un message de succès et rediriger vers la liste des villes
$this->addFlash('success', 'Ville supprimée avec succès.');
return $this->redirectToRoute('app_adminCity');
}
//Gestion des sites //Gestion des sites
#[Route('/admin/site', name: 'app_adminSite')] #[Route('/admin/site', name: 'app_adminSite')]
public function adminSite(SiteRepository $siteRepository, TokenStorageInterface $tokenStorage): Response public function adminSite(SiteRepository $siteRepository, TokenStorageInterface $tokenStorage): Response
@@ -446,4 +387,17 @@ class AdminController extends AbstractController
return $this->redirectToRoute('home'); return $this->redirectToRoute('home');
} }
} }
#[Route('/admin/sortie', name: 'app_adminSortie')]
public function sortie(TokenStorageInterface $tokenStorage, SortieRepository $sortieRepository): Response
{
$token = $tokenStorage->getToken();
$userConnect = $token?->getUser();
return $this->render('admin/sortie.html.twig', [
'profile' => $userConnect,
'controller_name' => 'AdminController',
'sorties' => $sortieRepository->findAll(),
]);
}
} }

View File

@@ -29,11 +29,13 @@ class ProfileController extends AbstractController
$userConnect = $token?->getUser(); $userConnect = $token?->getUser();
$currentProfile = $profileRepo->findOneBy(['idParticipant' => $uuid]); $currentProfile = $profileRepo->findOneBy(['idParticipant' => $uuid]);
if ($userConnect->getIdParticipant() !== $currentProfile->getIdParticipant()) { if ($userConnect->getIdParticipant() !== $currentProfile->getIdParticipant()) {
$this->addFlash('error', "Vous ne pouvez pas consulter un profil qui n'est pas le votre"); $isActiveUser = false;
return $this->redirectToRoute('home'); } else {
$isActiveUser = true;
} }
return $this->render('profile/view.html.twig', [ return $this->render('profile/view.html.twig', [
'profile' => $currentProfile, 'profile' => $currentProfile,
'isActiveUser' => $isActiveUser,
]); ]);
} }

View File

@@ -14,8 +14,8 @@ class SortieFixtures extends Fixture
$sortie->setNom('Sortie 1'); $sortie->setNom('Sortie 1');
$sortie->setInfosSortie('Description de la sortie 1'); $sortie->setInfosSortie('Description de la sortie 1');
$sortie->setDuree(45); $sortie->setDuree(45);
$sortie->setDateHeureDebut(new \DateTime('2024-11-30 09:15:00')); $sortie->setDateHeureDebut(new \DateTimeImmutable('2024-11-30 09:15:00'));
$sortie->setDateLimiteInscription(new \DateTime('2024-12-25 12:30:00')); $sortie->setDateLimiteInscription(new \DateTimeImmutable('2024-12-25 12:30:00'));
$sortie->setNbInscriptionsMax(25); $sortie->setNbInscriptionsMax(25);
$manager->persist($sortie); $manager->persist($sortie);

View File

@@ -23,6 +23,7 @@ class UserFixtures extends Fixture
$olivier->setEmail('olivier@gmail.com'); $olivier->setEmail('olivier@gmail.com');
$olivier->setRoles(['ROLE_USER', 'ROLE_ADMIN']); $olivier->setRoles(['ROLE_USER', 'ROLE_ADMIN']);
$olivier->setAdministrateur(true); $olivier->setAdministrateur(true);
$olivier->setPending(false);
$olivier->setActif(false); $olivier->setActif(false);
$olivier->setPassword($this->userPasswordHasher->hashPassword($olivier, 'test-44')); $olivier->setPassword($this->userPasswordHasher->hashPassword($olivier, 'test-44'));
$manager->persist($olivier); $manager->persist($olivier);
@@ -35,6 +36,7 @@ class UserFixtures extends Fixture
$johan->setEmail('leroyjohan3@gmail.com'); $johan->setEmail('leroyjohan3@gmail.com');
$johan->setRoles(['ROLE_USER', 'ROLE_ADMIN']); $johan->setRoles(['ROLE_USER', 'ROLE_ADMIN']);
$johan->setAdministrateur(true); $johan->setAdministrateur(true);
$johan->setPending(false);
$johan->setActif(false); $johan->setActif(false);
$johan->setPassword($this->userPasswordHasher->hashPassword($johan, 'Vn21pd%6a%Hw5j')); $johan->setPassword($this->userPasswordHasher->hashPassword($johan, 'Vn21pd%6a%Hw5j'));
$manager->persist($johan); $manager->persist($johan);
@@ -47,6 +49,7 @@ class UserFixtures extends Fixture
$marvin->setEmail('marvin@gmail.com'); $marvin->setEmail('marvin@gmail.com');
$marvin->setRoles(['ROLE_USER', 'ROLE_ADMIN']); $marvin->setRoles(['ROLE_USER', 'ROLE_ADMIN']);
$marvin->setAdministrateur(true); $marvin->setAdministrateur(true);
$marvin->setPending(false);
$marvin->setActif(false); $marvin->setActif(false);
$marvin->setPassword($this->userPasswordHasher->hashPassword($marvin, 'test-44')); $marvin->setPassword($this->userPasswordHasher->hashPassword($marvin, 'test-44'));
$manager->persist($marvin); $manager->persist($marvin);

View File

@@ -1,119 +0,0 @@
{% extends 'main/base.html.twig' %}
{% block title %}&#128227; Sortie.com Admin City &#128266;{% endblock %}
{% block content %}
<div class="flex">
{% include 'admin/sidebar.html.twig' %}
<!-- Main Content -->
<div class="ml-64 p-8 w-full">
<h1 class="text-2xl font-semibold mb-4">Gestion des villes</h1>
<!-- Actions: Ajouter -->
<div class="mb-4">
<!-- Bouton pour ouvrir la modale -->
<button id="openModal" class="inline-block bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-700">
Ajouter une ville
</button>
</div>
<!-- Participants Table -->
<div class="overflow-x-auto bg-white rounded shadow">
<table class="min-w-full bg-white divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<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">Code postal</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{% for city in citys %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ city.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ city.codePostal }}</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a href="{{ path('app_adminCityDelete', {'id': city.idVille}) }}" class="text-red-600 hover:text-red-900 ml-4">Supprimer</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Aucune ville trouvée</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<!-- Modale pour ajouter une ville -->
<div id="cityModal" class="fixed inset-0 z-50 hidden bg-gray-900 bg-opacity-50">
<div class="flex justify-center items-center min-h-screen">
<div class="bg-white p-6 rounded shadow-md w-1/3">
<h2 class="text-xl font-semibold mb-4">Ajouter une ville</h2>
<form id="addCityForm" method="POST" action="{{ path('app_adminCityAdd') }}">
<div class="mb-4">
<label for="postalCode" class="block text-sm font-medium text-gray-700">Code postal</label>
<input id="postalCode" name="postalCode" type="text" class="mt-1 block w-full px-4 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" required>
</div>
<div class="mb-4">
<label for="citySelect" class="block text-sm font-medium text-gray-700">Sélectionner une ville</label>
<select id="citySelect" name="citySelect" class="mt-1 block w-full px-4 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" required>
<!-- Options will be populated dynamically based on postal code -->
</select>
</div>
<div class="flex justify-end">
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-700">Ajouter</button>
<button type="button" id="closeModal" class="ml-2 bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-700">Annuler</button>
</div>
</form>
</div>
</div>
</div>
<script>
// Ouvrir la modale
document.getElementById('openModal').addEventListener('click', function() {
document.getElementById('cityModal').classList.remove('hidden');
});
// Fermer la modale
document.getElementById('closeModal').addEventListener('click', function() {
document.getElementById('cityModal').classList.add('hidden');
});
// Fonction pour charger les villes en fonction du code postal en utilisant l'API Carto
document.getElementById('postalCode').addEventListener('input', function() {
const postalCode = this.value;
const citySelect = document.getElementById('citySelect');
if (postalCode.length >= 3) {
// URL de l'API Carto pour récupérer les villes en fonction du code postal
const apiUrl = `https://api-adresse.data.gouv.fr/search/?q=${postalCode}&type=municipality&limit=10`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
// Clear previous options
citySelect.innerHTML = '';
// Ajouter des nouvelles options de villes dans la liste déroulante
data.features.forEach(feature => {
const option = document.createElement('option');
option.value = feature.properties.label;
option.textContent = feature.properties.label; // Nom de la ville
citySelect.appendChild(option);
});
})
.catch(error => console.error('Erreur:', error));
} else {
// Clear options si le code postal est trop court
citySelect.innerHTML = '';
}
});
</script>
</div>
{% endblock %}

View File

@@ -3,11 +3,10 @@
{% block title %}&#128227; Sortie.com Admin &#128266;{% endblock %} {% block title %}&#128227; Sortie.com Admin &#128266;{% endblock %}
{% block content %} {% block content %}
<div class="flex"> <div class="flex flex-col sm:flex-row sm:ml-0 sm:w-full">
{% include 'admin/sidebar.html.twig' %} {% include 'admin/sidebar.html.twig' %}
<div class="ml-64 p-8 w-full"> <div class="ml-64 sm:ml-0 sm:w-full p-8">
<h1 class="text-2xl font-semibold">Bienvenue sur le Panel d'Administration</h1> <h1 class="text-2xl font-semibold">Bienvenue sur le Panel d'Administration</h1>
<p class="text-gray-600 mt-4">Utilisez le menu pour accéder aux différentes sections.</p> <p class="text-gray-600 mt-4">Utilisez le menu pour accéder aux différentes sections.</p>
</div> </div>

View File

@@ -1,4 +1,4 @@
<nav class="bg-gray-800 text-white p-5 w-64 h-screen fixed"> <nav class="bg-gray-800 text-white p-5 w-64 h-screen fixed sm:w-48 md:w-64 lg:w-64 xl:w-64">
<h3 class="text-xl font-bold text-center mb-5">Administration</h3> <h3 class="text-xl font-bold text-center mb-5">Administration</h3>
<ul class="space-y-4"> <ul class="space-y-4">
<li> <li>
@@ -12,8 +12,8 @@
</a> </a>
</li> </li>
<li> <li>
<a href="{{ path('app_adminCity') }}" class="block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded"> <a href="{{ path('app_adminSortie') }}" class="block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded">
🏙 Villes 🚪 Sortie
</a> </a>
</li> </li>
<li> <li>
@@ -21,10 +21,5 @@
📍 Sites 📍 Sites
</a> </a>
</li> </li>
<li>
<a href="#" class="block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded">
⚙ Paramètres
</a>
</li>
</ul> </ul>
</nav> </nav>

View File

@@ -0,0 +1,69 @@
{% extends 'main/base.html.twig' %}
{% block title %}&#128227; Sortie.com Admin User &#128266;{% endblock %}
{% block content %}
<div class="flex">
{% include 'admin/sidebar.html.twig' %}
<!-- Main Content -->
<div class="ml-64 p-8 w-full">
<h1 class="text-2xl font-semibold mb-4">Gestion des sorties</h1>
<!-- Participants Table -->
<form method="POST" action="{{ path('participant_export') }}">
<div class="overflow-x-auto bg-white rounded shadow">
<table class="min-w-full bg-white divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><input type="checkbox" id="selectAll" /></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">Date début</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">durée</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date fin d'inscription</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nombre limite d'inscription</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Organisateur</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">Lieu</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Etat</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{% for sortie in sorties %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900"><span><input type="checkbox" value="{{ sortie.idSortie }}" name="userList[]"></span></td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.dateHeureDebut }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.duree }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.dateLimiteInscription }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.nbInscriptionsMax }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.organisateur.pseudo }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.site.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.lieu.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.etat.libelle }}</td>
<td class="flex flex-row px-6 py-4 whitespace-nowrap items-center font-medium">
{# {% if not sortie.etat %}
{% endif %}
<a href="{{ path('app_adminUserDisable', {'id': participant.idParticipant}) }}" class="items-centerp pr-4">
<img src="{{ participant.actif ? asset('img/user-able.svg') : asset('img/user-disable.svg') }}" alt="Logo" height="32px" width="32px">
</a>
<a href="{{ path('app_adminUserDelete', {'id': participant.idParticipant}) }}" class="items-center">
<img src="{{ asset('img/user-delete.svg') }}" alt="Logo" height="32px" width="32px">
</a> #}
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Aucune sortie trouvé</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@@ -1,15 +1,5 @@
<!DOCTYPE html> <footer class="w-full bg-green-700 text-white py-4">
<html lang="fr"> <div class="flex justify-center">
<head> ENI &copy; Sortie {{ "now"|date("Y") }}
<meta charset="UTF-8"> </div>
{% block stylesheets %} </footer>
{{ encore_entry_link_tags('app') }}
{% endblock %}
</head>
<body>
<div class="flex items-center justify-center" >
ENI &copy; Sortie {{ "now"|date("Y") }}
</div>
</body>
</html>

View File

@@ -28,13 +28,19 @@
<i class="fas fa-map-marker-alt mr-2 text-slate-400 opacity-75"></i>{{ profile.telephone }} - {{ profile.email }} <i class="fas fa-map-marker-alt mr-2 text-slate-400 opacity-75"></i>{{ profile.telephone }} - {{ profile.email }}
</div> </div>
</div> </div>
{% if isActiveUser %}
<div class="mt-6 py-6 border-t border-slate-200 text-center"> <div class="mt-6 py-6 border-t border-slate-200 text-center">
<div class="flex flex-wrap justify-center"> <div class="flex flex-wrap justify-center">
<div class="w-full px-4"> <div class="w-full px-4">
<a href="{{ path('profile_edit', {'uuid': app.user.idParticipant}) }}" class="text-slate-700 hover:text-slate-400">Modifier</a> <a href="{{ path('profile_edit', {'uuid': app.user.idParticipant}) }}" class="text-slate-700 hover:text-slate-400">
<button class="bg-green-500 px-4 py-2 rounded hover:bg-green-700">
Modifier
</button>
</a>
</div> </div>
</div> </div>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}