diff --git a/assets/app.js b/assets/app.js index 0db5fd4..2ba6642 100644 --- a/assets/app.js +++ b/assets/app.js @@ -49,6 +49,16 @@ document.addEventListener('DOMContentLoaded', () => { } }); } + const btnClosedCommerce = document.querySelector('#closedCommerce'); + if (btnClosedCommerce) { + btnClosedCommerce.addEventListener('click', () => { + + if (!confirm('Êtes-vous sûr de vouloir signaler ce commerce comme fermé ?')) { + return; + } + window.location.href = '/closed_commerce/' + document.getElementById('app_public_closed_commerce').value; + }); + } }); diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 7a6493b..b52bd57 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -347,4 +347,34 @@ class PublicController extends AbstractController 'commerce_id' => $osm_object_id, ]); } -} + + #route pour signaler que le commerce est fermé + #[Route('/closed_commerce/{osm_object_id}', name: 'app_public_closed_commerce')] + public function closed_commerce($osm_object_id): Response + { + $place = $this->entityManager->getRepository(Place::class)->findOneBy(['osm_id' => $osm_object_id]); + if (!$place) { + $this->addFlash('warning', 'Ce commerce n\'existe pas.'); + return $this->redirectToRoute('app_public_index'); + } + + $place->setClosed(true); + $this->entityManager->flush(); + + return $this->render('public/closed_commerce.html.twig', [ + 'controller_name' => 'PublicController', + ]); + } + + #[Route('/closed_commerces', name: 'app_public_closed_commerces')] + public function closedCommerces(): Response + { + // Récupérer tous les commerces marqués comme fermés + $closedPlaces = $this->entityManager->getRepository(Place::class)->findBy(['dead' => true]); + + return $this->render('public/closed_commerces.html.twig', [ + 'controller_name' => 'PublicController', + 'closed_places' => $closedPlaces + ]); + } +} \ No newline at end of file diff --git a/templates/public/closed_commerces.html.twig b/templates/public/closed_commerces.html.twig new file mode 100644 index 0000000..9c338e8 --- /dev/null +++ b/templates/public/closed_commerces.html.twig @@ -0,0 +1,48 @@ + + {% extends 'base.html.twig' %} + +{% block title %}{{ 'display.title'|trans }} - accueil{% endblock %} + +{% block stylesheets %} + {{ parent() }} + + +{% endblock %} + +{% block body %} +
+

Commerces fermés

+

Voici la liste des commerces fermés :

+
+ + + + + + + + + {% for place in closed_places %} + + + + + {% endfor %} + +
Nom du commerceCode postal
+ + {{ place.name }} + + {{ place.zipCode }}
+ + {% if closed_places|length == 0 %} +

Aucun commerce fermé trouvé.

+ {% endif %} +
+ +
+{% endblock %} diff --git a/templates/public/edit.html.twig b/templates/public/edit.html.twig index aa92c69..483fa81 100644 --- a/templates/public/edit.html.twig +++ b/templates/public/edit.html.twig @@ -184,7 +184,7 @@ container: 'map', style: 'https://api.maptiler.com/maps/basic-v2/style.json?key={{ maptiler_token }}', center: [{{ commerce_overpass['@attributes'].lon }}, {{ commerce_overpass['@attributes'].lat }}], - zoom: 14 + zoom: 17 }); new mapboxgl.Marker() diff --git a/templates/public/nav.html.twig b/templates/public/nav.html.twig index 9b67fcc..f30e100 100644 --- a/templates/public/nav.html.twig +++ b/templates/public/nav.html.twig @@ -20,6 +20,11 @@ {{ 'display.contact_humans'|trans }} + diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 435b168..34f2acd 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -24,6 +24,8 @@ display: opening_hours_description: "De bons horaires d'ouverture sont importants pour que les clients puissent vous trouver." ask_angela_yes: "Oui" ask_angela_no: "Non" + closed_commerces: "Commerces fermés" + values: wheelchair: yes: "le lieu est totalement praticable en fauteuil roulant"