mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-06-20 01:44:42 +02:00
ajout recherche par nom
This commit is contained in:
parent
3a73c1adad
commit
ccab916286
11 changed files with 345 additions and 204 deletions
1
public/assets/js/main.js
Normal file
1
public/assets/js/main.js
Normal file
|
@ -0,0 +1 @@
|
|||
console.log('Hello World');
|
|
@ -76,6 +76,29 @@ final class AdminController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/commerce/{id}', name: 'app_admin_commerce')]
|
||||
public function commerce(int $id): Response
|
||||
{
|
||||
|
||||
// Vérifier si on est en prod
|
||||
if ($this->getParameter('kernel.environment') === 'prod') {
|
||||
$this->addFlash('error', 'Vous n\'avez pas accès à cette page en production.');
|
||||
return $this->redirectToRoute('app_public_index');
|
||||
}
|
||||
$commerce = $this->entityManager->getRepository(Place::class)->find($id);
|
||||
|
||||
if (!$commerce) {
|
||||
throw $this->createNotFoundException('Commerce non trouvé');
|
||||
}
|
||||
|
||||
// Redirection vers la page de modification avec les paramètres nécessaires
|
||||
return $this->redirectToRoute('app_public_edit', [
|
||||
'zipcode' => $commerce->getZipCode(),
|
||||
'name' => $commerce->getName() ?? '?',
|
||||
'uuid' => $commerce->getUuidForUrl()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/labourer/{zip_code}', name: 'app_admin_labourer')]
|
||||
public function labourer_zone(string $zip_code): Response
|
||||
{
|
||||
|
@ -201,13 +224,16 @@ final class AdminController extends AbstractController
|
|||
public function delete(int $id): Response
|
||||
{
|
||||
$commerce = $this->entityManager->getRepository(Place::class)->find($id);
|
||||
$name = $commerce->getName();
|
||||
if($commerce) {
|
||||
$this->entityManager->remove($commerce);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Le lieu '.$name.' a été supprimé avec succès de OSM Mes commerces, mais pas dans OpenStreetMap.');
|
||||
$this->addFlash('success', 'Le lieu '.$commerce->getName().' a été supprimé avec succès de OSM Mes commerces, mais pas dans OpenStreetMap.');
|
||||
} else {
|
||||
$this->addFlash('error', 'Le lieu n\'existe pas.');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_admin_dashboard');
|
||||
return $this->redirectToRoute('app_public_dashboard');
|
||||
}
|
||||
|
||||
#[Route('/admin/delete_by_zone/{zip_code}', name: 'app_admin_delete_by_zone')]
|
||||
|
@ -222,7 +248,7 @@ final class AdminController extends AbstractController
|
|||
|
||||
$this->addFlash('success', 'Tous les commerces de la zone '.$zip_code.' ont été supprimés avec succès de OSM Mes commerces, mais pas dans OpenStreetMap.');
|
||||
|
||||
return $this->redirectToRoute('app_admin_dashboard');
|
||||
return $this->redirectToRoute('app_public_dashboard');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use GuzzleHttp\Client;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
|
||||
class PublicController extends AbstractController
|
||||
{
|
||||
|
@ -20,21 +21,100 @@ class PublicController extends AbstractController
|
|||
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private Motocultrice $motocultrice
|
||||
private Motocultrice $motocultrice,
|
||||
private MailerInterface $mailer
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/propose-email/{email}/{type}/{id}', name: 'app_public_propose_email')]
|
||||
public function proposeEmail(string $email, string $type, int $id): Response
|
||||
{
|
||||
|
||||
|
||||
$data = $this->motocultrice->get_osm_object_data($type, $id);
|
||||
// Récupérer le code postal depuis les tags, sinon mettre -1
|
||||
$zipCode = isset($data['tags_converted']['addr:postcode']) ? (int)$data['tags_converted']['addr:postcode'] : -1;
|
||||
$place_name = $data['tags_converted']['name'];
|
||||
|
||||
// Vérifier si une Place existe déjà avec le même osm_kind et osmId
|
||||
$existingPlace = $this->entityManager->getRepository(Place::class)->findOneBy([
|
||||
'osm_kind' => $type,
|
||||
'osmId' => $id
|
||||
]);
|
||||
|
||||
if ($existingPlace) {
|
||||
// Mettre à jour l'email de la Place existante
|
||||
$existingPlace->setEmail($email)->setLastContactAttemptDate(new \DateTime());
|
||||
$this->entityManager->flush();
|
||||
|
||||
$debug = '';
|
||||
if ($this->getParameter('kernel.environment') !== 'prod') {
|
||||
$debug = 'Bonjour, nous sommes des bénévoles d\'OpenStreetMap France et nous vous proposons de modifier les informations de votre commerce. Voici votre lien unique de modification: ' . $this->generateUrl('app_public_edit', [
|
||||
'zipcode' => $zipCode,
|
||||
'name' => $place_name,
|
||||
'uuid' => $existingPlace->getUuidForUrl()
|
||||
], true);
|
||||
}
|
||||
|
||||
$this->addFlash('success', 'L\'email a été mis à jour. Un email vous sera envoyé avec le lien de modification. '.$debug);
|
||||
} else {
|
||||
|
||||
|
||||
// Créer une nouvelle entité Place
|
||||
$place = new Place();
|
||||
$place->setEmail($email)
|
||||
->setOsmId($id)
|
||||
->setOsmKind($type)
|
||||
->setAskedHumainsSupport(false)
|
||||
->setOptedOut(false)
|
||||
->setDead(false)
|
||||
->setNote('')
|
||||
->setModifiedDate(new \DateTime())
|
||||
->setZipCode($zipCode)
|
||||
->setPlaceCount(0)
|
||||
|
||||
->setLastContactAttemptDate(new \DateTime())
|
||||
->setUuidForUrl(uniqid());
|
||||
|
||||
$this->entityManager->persist($place);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$debug = '';
|
||||
if ($this->getParameter('kernel.environment') !== 'prod') {
|
||||
$debug = 'Bonjour, nous sommes des bénévoles d\'OpenStreetMap France et nous vous proposons de modifier les informations de votre commerce. Voici votre lien unique de modification: ' . $this->generateUrl('app_public_edit', [
|
||||
'zipcode' => $zipCode,
|
||||
'name' => $place_name,
|
||||
'uuid' => $place->getUuidForUrl()
|
||||
], true);
|
||||
}
|
||||
$this->addFlash('success', 'Un email vous sera envoyé avec le lien de modification. '.$debug);
|
||||
}
|
||||
|
||||
// Envoyer l'email
|
||||
$destinataire = $this->getParameter('kernel.environment') === 'prod' ? $email : 'contact+essai_osm_commerce@cipherbliss.com';
|
||||
|
||||
$message = (new Email())
|
||||
->from('contact@osm-commerce.fr')
|
||||
->to($destinataire)
|
||||
->subject('Votre lien de modification OpenStreetMap')
|
||||
->text('Bonjour, nous sommes des bénévoles d\'OpenStreetMap France et nous vous proposons de modifier les informations de votre commerce. Voici votre lien unique de modification: ' . $this->generateUrl('app_public_edit', [
|
||||
'zipcode' => $zipCode,
|
||||
'name' => $place_name,
|
||||
'uuid' => $existingPlace ? $existingPlace->getUuidForUrl() : $place->getUuidForUrl()
|
||||
], true));
|
||||
|
||||
$this->mailer->send($message);
|
||||
|
||||
return $this->redirectToRoute('app_public_index');
|
||||
}
|
||||
|
||||
#[Route('/', name: 'app_public_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
$commerce = $this->motocultrice->get_osm_object_data();
|
||||
return $this->render('public/index.html.twig', [
|
||||
|
||||
return $this->render('public/home.html.twig', [
|
||||
'controller_name' => 'PublicController',
|
||||
'commerce' => $commerce,
|
||||
'mapbox_token' => $_ENV['MAPBOX_TOKEN'],
|
||||
'maptiler_token' => $_ENV['MAPTILER_TOKEN'],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -123,13 +203,8 @@ class PublicController extends AbstractController
|
|||
$status = "Erreur : Le code postal doit être composé de 5 chiffres";
|
||||
continue;
|
||||
}
|
||||
} elseif ($tagKey === 'contact:phone' || $tagKey === 'phone') {
|
||||
// Nettoyer le numéro de téléphone
|
||||
$value = preg_replace('/[^0-9+]/', '', $value);
|
||||
} elseif (strpos($value, 'http://') === 0) {
|
||||
$value = str_replace('http://', 'https://', $value);
|
||||
}
|
||||
$tags[$tagKey] = $value;
|
||||
$tags[$tagKey] = trim($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,10 @@
|
|||
<tbody>
|
||||
{% for commerce in stats.places %}
|
||||
<tr>
|
||||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">{{ commerce.name }}</td>
|
||||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">
|
||||
<a href="{{ path('app_admin_commerce', {'id': commerce.id}) }}">{{ commerce.name }}</a>
|
||||
|
||||
</td>
|
||||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">{{ commerce.address }}</td>
|
||||
<td style="background-color: {{ commerce.hasWebsite() ? 'yellowgreen' : 'transparent' }};">{{ commerce.website }}</td>
|
||||
<td style="background-color: {{ commerce.hasWheelchair() ? 'yellowgreen' : 'transparent' }};">{{ commerce.wheelchair }}</td>
|
||||
|
@ -54,139 +57,22 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const headers = document.querySelectorAll('th');
|
||||
headers.forEach(header => {
|
||||
const text = header.textContent;
|
||||
const match = text.match(/\((\d+)\s*\/\s*(\d+)\)/);
|
||||
if (match) {
|
||||
const [_, completed, total] = match;
|
||||
const ratio = completed / total;
|
||||
const alpha = ratio.toFixed(2);
|
||||
header.style.backgroundColor = `rgba(154, 205, 50, ${alpha})`;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
/* Styles spécifiques pour la page stats */
|
||||
.stats-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.5rem;
|
||||
background-color: var(--light-gray);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-weight: 500;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 1.25rem;
|
||||
font-weight: bold;
|
||||
color: var(--secondary-color);
|
||||
}
|
||||
|
||||
.modifications-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.modification-item {
|
||||
padding: 0.75rem;
|
||||
background-color: var(--light-gray);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.modification-header {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.modification-date {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-color);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.modification-details {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modification-type {
|
||||
font-weight: 500;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.shop-types-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.shop-type-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.5rem;
|
||||
background-color: var(--light-gray);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.shop-type-name {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.shop-type-count {
|
||||
background-color: var(--secondary-color);
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.places-table-container {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.places-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.places-table th,
|
||||
.places-table td {
|
||||
padding: 0.75rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.places-table th {
|
||||
background-color: var(--light-gray);
|
||||
font-weight: 500;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.places-table tr:hover {
|
||||
background-color: var(--light-gray);
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 0.25rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.grid-3 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.places-table {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
|
@ -38,12 +38,6 @@
|
|||
padding-bottom: 15rem;
|
||||
margin-top: 5rem;
|
||||
}
|
||||
{# table tr:nth-child(odd){
|
||||
background-color:rgb(235, 235, 235);
|
||||
}
|
||||
table tr:nth-child(even){
|
||||
background-color: #f8f9fa;
|
||||
} #}
|
||||
</style>
|
||||
{% block stylesheets %}
|
||||
|
||||
|
|
|
@ -27,14 +27,22 @@
|
|||
<th>Zone</th>
|
||||
<th>Nombre de commerces</th>
|
||||
<th>Complétude %</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stat in stats %}
|
||||
<tr>
|
||||
<td>{{ stat.zone }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}">{{ stat.zone }}</a>
|
||||
</td>
|
||||
<td>{{ stat.placesCount }}</td>
|
||||
<td style="background : rgba(0 , 255, 0, {{stat.completionPercent / 100 }} )">{{ stat.completionPercent }}</td>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-primary" href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}"><i class="bi bi-eye"></i></a>
|
||||
<a class="btn btn-sm btn-warning" href="{{ path('app_admin_labourer', {'zip_code': stat.zone}) }}"><i class="bi bi-arrow-repeat"></i></a>
|
||||
<a class="btn btn-sm btn-danger" href="{{ path('app_admin_delete_by_zone', {'zip_code': stat.zone}) }}"><i class="bi bi-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
@ -50,6 +58,7 @@
|
|||
<th>Date de dernier contact</th>
|
||||
<th>Date de dernière modification</th>
|
||||
<th>Code postal</th>
|
||||
<th>Actions</th>
|
||||
|
||||
|
||||
|
||||
|
@ -58,21 +67,26 @@
|
|||
<tbody>
|
||||
{% for place in places %}
|
||||
<tr>
|
||||
<td>{{ place.name }}</td>
|
||||
<td>{% if place.name %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name, 'uuid': place.uuidForUrl}) }}">{{ place.name }}</a>
|
||||
{% else %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': '?', 'uuid': place.uuidForUrl}) }}"><i class="bi bi-question-circle"></i></a>
|
||||
{% endif %} </td>
|
||||
<td>{{ place.email }}</td>
|
||||
<td>{{ place.modifiedDate | date('Y-m-d H:i:s') }}</td>
|
||||
<td>{{ place.lastContactAttemptDate | date('Y-m-d H:i:s') }}</td>
|
||||
<td>{{ place.modifiedDate | date('Y-m-d H:i:s') }}</td>
|
||||
<td>{{ place.zipCode }}</td>
|
||||
<td>
|
||||
<a href="https://www.openstreetmap.org/{{place.osmKind}}/{{ place.osmId }}" target="_blank">Voir dans OSM</a>
|
||||
<a href="https://www.openstreetmap.org/{{place.osmKind}}/{{ place.osmId }}" target="_blank"><i class="bi bi-globe"></i></a>
|
||||
|
||||
{% if place.name %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name, 'uuid': place.uuidForUrl}) }}">Modifier</a>
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name, 'uuid': place.uuidForUrl}) }}"><i class="bi bi-pencil"></i></a>
|
||||
{% else %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': '?', 'uuid': place.uuidForUrl}) }}">Modifier</a>
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': '?', 'uuid': place.uuidForUrl}) }}"><i class="bi bi-pencil"></i></a>
|
||||
{% endif %}
|
||||
|
||||
<a href="{{ path('app_admin_delete', {'id': place.id}) }}" onclick="return confirm('Êtes-vous sûr de vouloir supprimer ce lieu ?')"><i class="bi bi-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'display.title'|trans }}{% endblock %}
|
||||
{% block title %}{{ 'display.title'|trans }} {{ commerce_overpass.tags_converted.name }}{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
{{ parent() }}
|
||||
|
@ -58,15 +58,21 @@
|
|||
|
||||
{% if hide_filled_inputs and
|
||||
(commerce_overpass.tags_converted['addr:street']) is defined and commerce_overpass.tags_converted['addr:street'] is not empty
|
||||
and (commerce_overpass.tags_converted['addr:housenumber']) is defined and commerce_overpass.tags_converted['addr:housenumber'] is not empty
|
||||
%}
|
||||
{% include 'public/edit/address.html.twig' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if hide_filled_inputs and (commerce_overpass.tags_converted.opening_hours) is defined and commerce_overpass.tags_converted.opening_hours is not empty %}
|
||||
{% if hide_filled_inputs and (commerce_overpass.tags_converted.opening_hours) is defined and commerce_overpass.tags_converted.opening_hours is empty %}
|
||||
{% include 'public/edit/opening_hours.html.twig' %}
|
||||
{% endif %}
|
||||
{% if hide_filled_inputs and (commerce_overpass.tags_converted.wheelchair) is defined and commerce_overpass.tags_converted.wheelchair is not empty %}
|
||||
|
||||
{% if (commerce_overpass.tags_converted.wheelchair) is defined %}
|
||||
{{ dump(commerce_overpass.tags_converted.wheelchair) }}
|
||||
{% endif %}
|
||||
|
||||
{% if hide_filled_inputs and (commerce_overpass.tags_converted.wheelchair) is defined and commerce_overpass.tags_converted.wheelchair is empty %}
|
||||
{% include 'public/edit/wheelchair.html.twig' %}
|
||||
{% endif %}
|
||||
{% if hide_filled_inputs and (commerce_overpass.tags_converted.ask_angela) is defined and commerce_overpass.tags_converted.ask_angela is not empty %}
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
<div class="row mb-3">
|
||||
<div class="col-md-5">
|
||||
<label for="commerce_tag_value__addr:housenumber">{{'display.keys.addr:housenumber'|trans}}</label>
|
||||
<input type="text" class="form-control" name="commerce_tag_value__addr:housenumber" value="{% if commerce_overpass.tags_converted['addr:housenumber'] is defined %}{{ commerce_overpass.tags_converted['addr:housenumber'] }}{% endif %}">
|
||||
|
||||
<label for="commerce_tag_value__addr:street">{{'display.keys.addr:street'|trans}}</label>
|
||||
<input type="text" class="form-control" name="commerce_tag_value__addr:street" value="{% if commerce_overpass.tags_converted['addr:street'] is defined %}{{ commerce_overpass.tags_converted['addr:street'] }}{% endif %}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -13,32 +13,14 @@
|
|||
{% endif %}
|
||||
|
||||
<div class="examples d-none">
|
||||
|
||||
Exemples :
|
||||
|
||||
<ul>
|
||||
<li>Écrivez "24/7" pour indiquer que le commerce est ouvert 24 heures sur 24</li>
|
||||
<li>Écrivez "Mo-Fr 9:00 - 18:00" pour indiquer que le commerce est ouvert du lundi au vendredi de 9h à 18h</li>
|
||||
<li>Pour des horaires plus complexes, écrivez "Mo-Fr 9:00 - 18:00; Sa 9:00 - 12:00" pour indiquer que le commerce est ouvert du lundi au vendredi de 9h à 18h et le samedi de 9h à 12h</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
{# <input type="checkbox" name="commerce_tag_value__opening_hours_1" value="yes">
|
||||
Lundi de
|
||||
|
||||
<input type="number" name="commerce_tag_value__opening_hours_1_midday_hour" value="">
|
||||
à
|
||||
<input type="number" name="commerce_tag_value__opening_hours_1_midday_minute" value="">.
|
||||
|
||||
<input type="checkbox" name="commerce_tag_value__opening_hours_1_midday" value="yes">
|
||||
et
|
||||
|
||||
<input type="number" name="commerce_tag_value__opening_hours_1_midday_hour" value="">
|
||||
à
|
||||
<input type="number" name="commerce_tag_value__opening_hours_1_midday_minute" value="">.
|
||||
|
||||
<input type="checkbox" name="commerce_tag_value__opening_hours_1_evening" value="yes"> #}
|
||||
<hr>
|
||||
<script src="https://cdn.jsdelivr.net/npm/yohours@0.0.14/src/index.min.js"></script>
|
||||
<script src="{{ asset('js/main.js') }}"></script>
|
||||
</script>
|
||||
</div>
|
155
templates/public/home.html.twig
Normal file
155
templates/public/home.html.twig
Normal file
|
@ -0,0 +1,155 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'display.title'|trans }}{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
{{ parent() }}
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container mt-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
|
||||
|
||||
<h1>
|
||||
<i class="bi bi-shop"></i> Mon Commerce OSM
|
||||
</h1>
|
||||
<p>
|
||||
Bonjour, ce site permet de modifier les informations de votre commerce sur OpenStreetMap afin de gagner en visibilité sur des milliers de sites web à la fois en une minute, c'est gratuit et sans engagement. Nous sommes bénévoles dans une association à but non lucratif.
|
||||
<br>
|
||||
Nous vous enverrons un lien unique pour cela par email, et si vous en avez besoin, nous pouvons vous aider.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<label class="input-group-text" for="researchShop">Rechercher un commerce, écrivez son nom et la ville
|
||||
<i class="bi bi-search"></i> <input class="form-control" type="text" id="researchShop" placeholder="Rechercher un commerce">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="resultsList"></div>
|
||||
<div id="proposeLink"></div>
|
||||
<div id="proposeMail">
|
||||
|
||||
<input type="email" id="emailInput" class="form-control" placeholder="mon_email_de_commerce@exemple.com">
|
||||
<button type="submit" class="btn btn-primary p-4 d-block"> <i class="bi bi-envelope"></i> Envoyer</button>
|
||||
</div>
|
||||
<div id="emailForm"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Créer le formulaire email
|
||||
const emailFormHtml = `
|
||||
<form id="emailForm" class="mt-3">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="emailInput" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Envoyer</button>
|
||||
</form>
|
||||
`;
|
||||
|
||||
// Créer les divs pour les messages
|
||||
const proposeLinkHtml = `
|
||||
<div id="proposeLink" class="alert alert-success">
|
||||
Un email a déjà été enregistré pour ce commerce. Nous vous enverrons le lien de modification.
|
||||
</div>
|
||||
`;
|
||||
|
||||
const proposeMailHtml = `
|
||||
<div id="proposeMail" class="alert alert-info">
|
||||
Aucun email n'est enregistré pour ce commerce. Veuillez saisir votre email pour recevoir le lien de modification.
|
||||
${emailFormHtml}
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Ajouter les éléments au DOM
|
||||
document.querySelector('#proposeLink').innerHTML = proposeLinkHtml;
|
||||
document.querySelector('#proposeMail').innerHTML = proposeMailHtml;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.querySelector('#researchShop');
|
||||
const resultsList = document.querySelector('#resultsList');
|
||||
resultsList.classList.add('list-group', 'mt-2');
|
||||
|
||||
let timeoutId;
|
||||
searchInput.addEventListener('input', function(e) {
|
||||
clearTimeout(timeoutId);
|
||||
resultsList.innerHTML = '';
|
||||
|
||||
if (e.target.value.length < 3) return;
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
fetch(`https://demo.addok.xyz/search?q=${e.target.value}&limit=5`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
resultsList.innerHTML = '';
|
||||
const ul = document.createElement('ul');
|
||||
ul.classList.add('list-group');
|
||||
resultsList.appendChild(ul);
|
||||
|
||||
data.features.forEach(feature => {
|
||||
const li = document.createElement('li');
|
||||
li.classList.add('list-group-item', 'cursor-pointer');
|
||||
li.textContent = `${feature.properties.name}, ${feature.properties.city}`;
|
||||
|
||||
li.addEventListener('click', () => {
|
||||
resultsList.innerHTML = ''; // Cacher la liste
|
||||
const [lon, lat] = feature.geometry.coordinates;
|
||||
const query = `[out:json];
|
||||
(
|
||||
node["shop"](around:100,${lat},${lon});
|
||||
node["amenity"](around:100,${lat},${lon});
|
||||
);
|
||||
out body;`;
|
||||
|
||||
fetch('https://overpass-api.de/api/interpreter', {
|
||||
method: 'POST',
|
||||
body: query
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(osmData => {
|
||||
if (osmData.elements.length > 0) {
|
||||
const place = osmData.elements[0];
|
||||
console.log(`https://www.openstreetmap.org/${place.type}/${place.id}` , place.tags);
|
||||
|
||||
|
||||
|
||||
if (place.tags && (place.tags['contact:email'] || place.tags['email'])) {
|
||||
document.querySelector('#proposeLink').classList.remove('d-none');
|
||||
document.querySelector('#proposeMail').classList.add('d-none');
|
||||
} else {
|
||||
document.querySelector('#proposeMail').classList.remove('d-none');
|
||||
document.querySelector('#proposeLink').classList.add('d-none');
|
||||
|
||||
const emailForm = document.querySelector('#proposeMail form');
|
||||
emailForm.addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
const email = emailForm.querySelector('#emailInput').value;
|
||||
window.location.href = `/propose-email/${email}/${place.type}/${place.id}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ul.appendChild(li);
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
{% if status == "Les tags ont été mis à jour avec succès" %}
|
||||
<span class="badge bg-success p-4">{{status}}</span>
|
||||
|
||||
<p class="p-4">
|
||||
<p class="p-4 col-12 col-lg-8">
|
||||
Merci d'avoir contribué à l'amélioration de la base de données OSM, votre contribution sera visible sur de nombreux sites web.
|
||||
|
||||
<br>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue