ajout view email proposé pour les commerçants
This commit is contained in:
parent
e71177dee1
commit
dbe2f62c45
12 changed files with 275 additions and 12 deletions
|
@ -82,8 +82,11 @@ final class AdminController extends AbstractController
|
|||
->setSiret($this->motocultrice->find_siret($placeData['tags']) ?? '')
|
||||
->setAskedHumainsSupport(false)
|
||||
->setLastContactAttemptDate(null)
|
||||
->setNote('')
|
||||
->setPlaceCount(0);
|
||||
->setNote($this->motocultrice->find_tag($placeData['tags'], 'note') ? true : false)
|
||||
->setNoteContent($this->motocultrice->find_tag($placeData['tags'], 'note') ?? '')
|
||||
->setPlaceCount(0)
|
||||
// ->setOsmData($placeData['modified'] ?? null)
|
||||
;
|
||||
|
||||
// Mettre à jour les données depuis Overpass
|
||||
$place->update_place_from_overpass_data($placeData);
|
||||
|
@ -175,15 +178,6 @@ final class AdminController extends AbstractController
|
|||
|
||||
$urls = $stats->getAllCTCUrlsMap();
|
||||
|
||||
$statsHistory = $this->entityManager->getRepository(StatsHistory::class)
|
||||
->createQueryBuilder('sh')
|
||||
->where('sh.stats = :stats')
|
||||
->setParameter('stats', $stats)
|
||||
->orderBy('sh.id', 'DESC')
|
||||
->setMaxResults(365)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
// Calculer les statistiques
|
||||
$calculatedStats = $this->motocultrice->calculateStats($commerces);
|
||||
|
||||
|
@ -209,6 +203,15 @@ final class AdminController extends AbstractController
|
|||
$this->entityManager->persist($stats);
|
||||
$this->entityManager->flush();
|
||||
|
||||
// Récupérer l'historique des stats APRÈS que l'entité soit persistée
|
||||
$statsHistory = $this->entityManager->getRepository(StatsHistory::class)
|
||||
->createQueryBuilder('sh')
|
||||
->where('sh.stats = :stats')
|
||||
->setParameter('stats', $stats)
|
||||
->orderBy('sh.id', 'DESC')
|
||||
->setMaxResults(365)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return $this->render('admin/stats.html.twig', [
|
||||
'stats' => $stats,
|
||||
|
@ -514,4 +517,23 @@ final class AdminController extends AbstractController
|
|||
|
||||
return $response;
|
||||
}
|
||||
|
||||
#[Route('/admin/make_email_for_place/{id}', name: 'app_admin_make_email_for_place')]
|
||||
public function make_email_for_place(Place $place): Response
|
||||
{
|
||||
|
||||
return $this->render('admin/view_email_for_place.html.twig', ['place' => $place]);
|
||||
}
|
||||
|
||||
#[Route('/admin/no_more_sollicitation_for_place/{id}', name: 'app_admin_no_more_sollicitation_for_place')]
|
||||
public function no_more_sollicitation_for_place(Place $place): Response
|
||||
{
|
||||
$place->setOptedOut(true);
|
||||
$this->entityManager->persist($place);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Votre lieu '.$place->getName().' ne sera plus sollicité pour mettre à jour ses informations.');
|
||||
|
||||
return $this->redirectToRoute('app_public_index');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,43 @@ class Place
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $habitants = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTime $osm_data_date = null;
|
||||
|
||||
|
||||
public function getPlaceTypeName(): ?string
|
||||
{
|
||||
if ($this->main_tag == 'amenity=restaurant') {
|
||||
return 'restaurant';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=bar') {
|
||||
return 'bar';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=cafe') {
|
||||
return 'café';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=hotel') {
|
||||
return 'hôtel';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=supermarket') {
|
||||
return 'supermarché';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=pharmacy') {
|
||||
return 'pharmacie';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=bank') {
|
||||
return 'banque';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=post_office') {
|
||||
return 'poste';
|
||||
}
|
||||
if ($this->main_tag == 'amenity=school') {
|
||||
return 'école';
|
||||
}
|
||||
|
||||
return 'lieu';
|
||||
}
|
||||
|
||||
public function getMainTag(): ?string
|
||||
{
|
||||
return $this->main_tag;
|
||||
|
@ -594,4 +631,16 @@ class Place
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOsmDataDate(): ?\DateTime
|
||||
{
|
||||
return $this->osm_data_date;
|
||||
}
|
||||
|
||||
public function setOsmDataDate(?\DateTime $osm_data_date): static
|
||||
{
|
||||
$this->osm_data_date = $osm_data_date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,15 @@ class Stats
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $avec_name = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTime $osm_data_date_min = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTime $osm_data_date_avg = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTime $osm_data_date_max = null;
|
||||
|
||||
public function getCTCurlBase(): ?string
|
||||
{
|
||||
$base = 'https://complete-tes-commerces.fr/';
|
||||
|
@ -493,6 +502,42 @@ class Stats
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOsmDataDateMin(): ?\DateTime
|
||||
{
|
||||
return $this->osm_data_date_min;
|
||||
}
|
||||
|
||||
public function setOsmDataDateMin(?\DateTime $osm_data_date_min): static
|
||||
{
|
||||
$this->osm_data_date_min = $osm_data_date_min;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOsmDataDateAvg(): ?\DateTime
|
||||
{
|
||||
return $this->osm_data_date_avg;
|
||||
}
|
||||
|
||||
public function setOsmDataDateAvg(?\DateTime $osm_data_date_avg): static
|
||||
{
|
||||
$this->osm_data_date_avg = $osm_data_date_avg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOsmDataDateMax(): ?\DateTime
|
||||
{
|
||||
return $this->osm_data_date_max;
|
||||
}
|
||||
|
||||
public function setOsmDataDateMax(?\DateTime $osm_data_date_max): static
|
||||
{
|
||||
$this->osm_data_date_max = $osm_data_date_max;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -216,6 +216,13 @@ out center tags;';
|
|||
return null;
|
||||
}
|
||||
|
||||
public function find_tag($tags, $tag) {
|
||||
if(isset($tags[$tag]) && $tags[$tag] != '') {
|
||||
return $tags[$tag];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get_city_osm_from_zip_code($zip_code) {
|
||||
// Requête Overpass pour obtenir la zone administrative de niveau 8 avec un nom
|
||||
$query = "[out:json][timeout:25];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue