up tableau thèmes
This commit is contained in:
parent
c5bf83a4f8
commit
6cfb2f0958
5 changed files with 95 additions and 35 deletions
|
@ -160,6 +160,10 @@ final class AdminController extends AbstractController
|
|||
// Associer les stats à chaque commerce
|
||||
foreach ($commerces as $commerce) {
|
||||
$commerce->setStats($stats);
|
||||
// Injection de l'emoji pour le template
|
||||
$mainTag = $commerce->getMainTag();
|
||||
$emoji = self::getTagEmoji($mainTag);
|
||||
$commerce->tagEmoji = $emoji;
|
||||
$this->entityManager->persist($commerce);
|
||||
}
|
||||
|
||||
|
@ -471,6 +475,7 @@ final class AdminController extends AbstractController
|
|||
'followup_icons' => \App\Service\FollowUpService::getFollowUpIcons(),
|
||||
'progression7Days' => $progression7Days,
|
||||
'all_types' => \App\Service\FollowUpService::getFollowUpThemes(),
|
||||
'getTagEmoji' => [self::class, 'getTagEmoji'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -1014,6 +1019,10 @@ final class AdminController extends AbstractController
|
|||
// Associer les stats à chaque commerce
|
||||
foreach ($commerces as $commerce) {
|
||||
$commerce->setStats($stats);
|
||||
// Injection de l'emoji pour le template
|
||||
$mainTag = $commerce->getMainTag();
|
||||
$emoji = self::getTagEmoji($mainTag);
|
||||
$commerce->tagEmoji = $emoji;
|
||||
$this->entityManager->persist($commerce);
|
||||
}
|
||||
|
||||
|
@ -1857,4 +1866,60 @@ final class AdminController extends AbstractController
|
|||
'stats' => $stats
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/export_csv', name: 'app_admin_export_csv_all')]
|
||||
public function export_csv_all(): Response
|
||||
{
|
||||
$statsList = $this->entityManager->getRepository(\App\Entity\Stats::class)->findAll();
|
||||
$handle = fopen('php://temp', 'r+');
|
||||
// En-tête CSV
|
||||
fputcsv($handle, [
|
||||
'zone', 'name', 'lat', 'lon', 'population', 'budgetAnnuel', 'completionPercent', 'placesCount', 'avecHoraires', 'avecAdresse', 'avecSite', 'avecAccessibilite', 'avecNote', 'siren', 'codeEpci', 'codesPostaux'
|
||||
]);
|
||||
foreach ($statsList as $stat) {
|
||||
fputcsv($handle, [
|
||||
$stat->getZone(),
|
||||
$stat->getName(),
|
||||
$stat->getLat(),
|
||||
$stat->getLon(),
|
||||
$stat->getPopulation(),
|
||||
$stat->getBudgetAnnuel(),
|
||||
$stat->getCompletionPercent(),
|
||||
$stat->getPlacesCount(),
|
||||
$stat->getAvecHoraires(),
|
||||
$stat->getAvecAdresse(),
|
||||
$stat->getAvecSite(),
|
||||
$stat->getAvecAccessibilite(),
|
||||
$stat->getAvecNote(),
|
||||
$stat->getSiren(),
|
||||
$stat->getCodeEpci(),
|
||||
$stat->getCodesPostaux(),
|
||||
]);
|
||||
}
|
||||
rewind($handle);
|
||||
$csv = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
$response = new Response($csv);
|
||||
$response->headers->set('Content-Type', 'text/csv');
|
||||
$response->headers->set('Content-Disposition', 'attachment; filename="osm-commerces-villes-export_' . date('Y-m-d_H-i-s') . '.csv"');
|
||||
return $response;
|
||||
}
|
||||
|
||||
public static function getTagEmoji(string $mainTag): string
|
||||
{
|
||||
return match ($mainTag) {
|
||||
'amenity=restaurant', 'amenity=bar', 'amenity=cafe' => '🍽️',
|
||||
'amenity=townhall', 'amenity=community_centre' => '🏛️',
|
||||
'amenity=bank', 'amenity=atm' => '🏦',
|
||||
'amenity=pharmacy', 'amenity=hospital', 'amenity=clinic' => '🏥',
|
||||
'amenity=school', 'amenity=kindergarten', 'amenity=university' => '🎓',
|
||||
'amenity=library', 'amenity=museum', 'amenity=artwork' => '📚',
|
||||
'shop=car_repair', 'shop=car_parts', 'shop=car_wash' => '🚗',
|
||||
'amenity=post_office' => '📮',
|
||||
'shop=convenience' => '🏪',
|
||||
'shop=supermarket' => '🛒',
|
||||
'shop=clothes' => '👕',
|
||||
default => '🏷️',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
22
src/Twig/TagEmojiExtension.php
Normal file
22
src/Twig/TagEmojiExtension.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Twig;
|
||||
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
use App\Controller\AdminController;
|
||||
|
||||
class TagEmojiExtension extends AbstractExtension
|
||||
{
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('tag_emoji', [self::class, 'getTagEmoji']),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getTagEmoji(?string $mainTag): string
|
||||
{
|
||||
return AdminController::getTagEmoji($mainTag);
|
||||
}
|
||||
}
|
|
@ -302,7 +302,7 @@
|
|||
${Object.entries(f.properties.tags).map(([k,v]) => `<span><b>${k}</b>: ${v}</span>`).join('<br>')}
|
||||
</span>
|
||||
<a href='${f.properties.osm_url}' target='_blank'>Voir sur OSM</a><br>
|
||||
${f.properties.uuid && f.properties.zip_code && f.properties.name ? `<a href='/edit/${f.properties.zip_code}/${encodeURIComponent(f.properties.name)}/${f.properties.uuid}' target='_blank'>📝 Modifier ce lieu</a>` : ''}
|
||||
${f.properties.uuid ? `<a href='/edit/${f.properties.zip_code}/${encodeURIComponent(f.properties.name)}/${f.properties.uuid}' target='_blank'>📝 Modifier ce lieu</a>` : ''}
|
||||
</div>
|
||||
`)
|
||||
)
|
||||
|
|
|
@ -221,10 +221,12 @@
|
|||
<table class="table table-theme">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Catégorie</th>
|
||||
<th>Thème</th>
|
||||
<th>Nombre</th>
|
||||
<th>Complétion</th>
|
||||
<th>Actions</th>
|
||||
<th>Complétion</th>
|
||||
<th>Évolution</th>
|
||||
<th>Graphique</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -73,38 +73,9 @@
|
|||
</div>
|
||||
</td>
|
||||
<td class="{{ commerce.mainTag ? 'filled' : '' }}">
|
||||
|
||||
{% if commerce.mainTag == 'amenity=restaurant' or commerce.mainTag == 'amenity=bar' or commerce.mainTag == 'amenity=cafe' %}
|
||||
<i class="bi bi-fork-knife"></i>
|
||||
|
||||
{% elseif commerce.mainTag == 'amenity=townhall' or commerce.mainTag == 'amenity=community_centre' %}
|
||||
<i class="bi bi-building"></i>
|
||||
{% elseif commerce.mainTag == 'amenity=bank' or commerce.mainTag == 'amenity=atm' %}
|
||||
<i class="bi bi-bank"></i>
|
||||
{% elseif commerce.mainTag == 'amenity=pharmacy' or commerce.mainTag == 'amenity=hospital' or commerce.mainTag == 'amenity=clinic' %}
|
||||
<i class="bi bi-hospital"></i>
|
||||
{% elseif commerce.mainTag == 'amenity=school' or commerce.mainTag == 'amenity=kindergarten' or commerce.mainTag == 'amenity=university' %}
|
||||
<i class="bi bi-school"></i>
|
||||
{% elseif commerce.mainTag == 'amenity=library' or commerce.mainTag == 'amenity=museum' or commerce.mainTag == 'amenity=artwork' %}
|
||||
<i class="bi bi-book"></i>
|
||||
{% elseif commerce.mainTag == 'shop=car_repair' or commerce.mainTag == 'shop=car_parts' or commerce.mainTag == 'shop=car_wash' %}
|
||||
<i class="bi bi-car-front"></i>
|
||||
|
||||
{% elseif commerce.mainTag == 'amenity=post_office' %}
|
||||
<i class="bi bi-envelope"></i>
|
||||
{% elseif commerce.mainTag == 'shop=convenience' %}
|
||||
<i class="bi bi-shop"></i>
|
||||
{% elseif commerce.mainTag == 'shop=supermarket' %}
|
||||
<i class="bi bi-shop"></i>
|
||||
{% elseif commerce.mainTag == 'shop=clothes' %}
|
||||
<i class="bi bi-shop"></i>
|
||||
{% else %}
|
||||
<i class="bi bi-tag"></i>
|
||||
{% endif %}
|
||||
|
||||
<a href="https://wiki.openstreetmap.org/wiki/FR:Tag:{{ commerce.mainTag }}">
|
||||
{{ commerce.mainTag }}
|
||||
</a>
|
||||
<span title="{{ commerce.mainTag }}">
|
||||
{{ tag_emoji(commerce.mainTag) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="{{ commerce.hasAddress() ? 'filled' : '' }}">{{ commerce.address }} </td>
|
||||
<td class="{{ commerce.hasAddress() ? 'filled' : '' }}">{{ commerce.housenumber }}</td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue