des trucs

This commit is contained in:
mepiphana2023
2024-11-28 15:21:09 +01:00
parent 0c6ac2fa20
commit 32556512eb
11 changed files with 53 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -9,6 +9,7 @@ use App\Repository\EtatRepository;
use App\Repository\LieuRepository;
use App\Repository\ParticipantRepository;
use App\Repository\SortieRepository;
use App\Service\FileUploader;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use OpenAI\Factory;
@@ -25,9 +26,13 @@ class SortieController extends AbstractController
{
#[Route('/sortie/liste', name: 'list', methods: ['GET'])]
public function index(
TokenStorageInterface $tokenStorage,
SortieRepository $sortieRepository,
Request $request
): Response {
$token = $tokenStorage->getToken();
$userConnect = $token?->getUser();
// Récupérer les paramètres de filtre
$search = $request->query->get('search', '');
$siteId = $request->query->get('site', '');
@@ -42,6 +47,7 @@ class SortieController extends AbstractController
$sorties = $sortieRepository->findWithFilters($search, $siteId, $startDate, $endDate, $organisateur, $inscrit, $nonInscrit, $passees, $userConnect);
return $this->render('sortie/list.html.twig', [
'profile' => $userConnect,
'sorties' => $sorties,
'sites' => $sortieRepository->findAllSites(),
]);
@@ -231,10 +237,19 @@ class SortieController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// Vérification et mise à jour du lieu
$lieu = $form->get('lieu')->getData();
if ($lieu) {
$sortie->setLieu($lieu);
}
// Gestion du fichier image
$imageFile = $form->get('imageFile')->getData();
if ($imageFile) {
$sortie->setImageFile($imageFile);
}
// Sauvegarde des modifications
$entityManager->flush();
$this->addFlash('success', 'Les modifications ont été enregistrées.');

View File

@@ -70,6 +70,22 @@
</div>
</div>
<div class="form-group">
<label for="sortie_imageFile">Image de la sortie</label>
{{ form_widget(form.imageFile, { 'attr': { 'class': 'block w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500', 'onchange': 'previewImage(event)' } }) }}
<small class="text-gray-500">Formats acceptés : JPG, PNG (max. 5 Mo).</small>
{% if sortie and sortie.image %}
<div class="mt-4">
<img id="image-preview" src="{{ asset('img/sortie/' ~ sortie.image) }}" alt="Image prévisualisée" class="max-w-xs h-auto rounded-lg border border-gray-300">
</div>
{% else %}
<div class="mt-4">
<img id="image-preview" src="" alt="Aucune image sélectionnée" class="max-w-xs h-auto rounded-lg border border-gray-300 hidden">
</div>
{% endif %}
</div>
<div class="flex justify-end mt-8 space-x-4">
<a href="{{ path('sortie_view', { id: sortie.getIdSortie() }) }}" class="btnAnnule">
❌ Annuler
@@ -81,4 +97,24 @@
{{ form_end(form) }}
</div>
{% block javascripts %}
<script>
function previewImage(event) {
const input = event.target;
const preview = document.getElementById('image-preview');
if (input.files && input.files[0]) {
const reader = new FileReader();
reader.onload = function (e) {
preview.src = e.target.result;
preview.classList.remove('hidden');
};
reader.readAsDataURL(input.files[0]);
} else {
preview.src = '';
preview.classList.add('hidden');
}
}
</script>
{% endblock %}
{% endblock %}

View File

@@ -77,6 +77,7 @@
{% endif %}
</div>
{% 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">
<button type="submit" class="btnPrimary">