From 123bd8d4d191ef9b4b79166edec00bc20a3d4db2 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 19 Jun 2025 11:07:54 +0200 Subject: [PATCH] plusieurs courbes de progression --- src/Controller/AdminController.php | 15 +++++++++++- templates/admin/stats_history.html.twig | 31 ++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 64a132b..0f44d1c 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -386,11 +386,24 @@ final class AdminController extends AbstractController $statsHistory->setDate(new \DateTime()) ->setStats($stats); + // Compter les Places avec email et SIRET + $placesWithEmail = 0; + $placesWithSiret = 0; + foreach ($stats->getPlaces() as $place) { + if ($place->getEmail() && $place->getEmail() !== '') { + $placesWithEmail++; + } + if ($place->getSiret() && $place->getSiret() !== '') { + $placesWithSiret++; + } + } + $statsHistory->setPlacesCount($stats->getPlaces()->count()) ->setOpeningHoursCount($stats->getAvecHoraires()) ->setAddressCount($stats->getAvecAdresse()) ->setWebsiteCount($stats->getAvecSite()) - ->setSiretCount($stats->getAvecSiret()) + ->setSiretCount($placesWithSiret) + ->setEmailsCount($placesWithEmail) // ->setAccessibiliteCount($stats->getAvecAccessibilite()) // ->setNoteCount($stats->getAvecNote()) ->setCompletionPercent($stats->getCompletionPercent()) diff --git a/templates/admin/stats_history.html.twig b/templates/admin/stats_history.html.twig index 39786d7..2ffecdb 100644 --- a/templates/admin/stats_history.html.twig +++ b/templates/admin/stats_history.html.twig @@ -13,19 +13,19 @@ document.addEventListener('DOMContentLoaded', function() { // Préparer les données pour chaque aspect const labels = [ - {% for stat in statsHistory %} + {% for stat in statsHistory|reverse %} '{{ stat.date|date('d/m/Y') }}'{% if not loop.last %},{% endif %} {% endfor %} ]; const completionData = [ - {% for stat in statsHistory %} + {% for stat in statsHistory|reverse %} {{ stat.completionPercent }}{% if not loop.last %},{% endif %} {% endfor %} ]; const openingHoursData = [ - {% for stat in statsHistory %} + {% for stat in statsHistory|reverse %} {% if stat.placesCount > 0 %} {{ ((stat.openingHoursCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {% else %} @@ -35,7 +35,7 @@ document.addEventListener('DOMContentLoaded', function() { ]; const addressData = [ - {% for stat in statsHistory %} + {% for stat in statsHistory|reverse %} {% if stat.placesCount > 0 %} {{ ((stat.addressCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {% else %} @@ -45,7 +45,7 @@ document.addEventListener('DOMContentLoaded', function() { ]; const websiteData = [ - {% for stat in statsHistory %} + {% for stat in statsHistory|reverse %} {% if stat.placesCount > 0 %} {{ ((stat.websiteCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {% else %} @@ -55,7 +55,7 @@ document.addEventListener('DOMContentLoaded', function() { ]; const siretData = [ - {% for stat in statsHistory %} + {% for stat in statsHistory|reverse %} {% if stat.placesCount > 0 %} {{ ((stat.siretCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {% else %} @@ -64,6 +64,16 @@ document.addEventListener('DOMContentLoaded', function() { {% endfor %} ]; + const emailData = [ + {% for stat in statsHistory|reverse %} + {% if stat.placesCount > 0 %} + {{ ((stat.emailsCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} + {% else %} + 0{% if not loop.last %},{% endif %} + {% endif %} + {% endfor %} + ]; + new Chart(ctx, { type: 'line', data: { @@ -113,6 +123,15 @@ document.addEventListener('DOMContentLoaded', function() { tension: 0.3, fill: false, borderWidth: 2 + }, + { + label: 'Emails (%)', + data: emailData, + borderColor: 'rgb(199, 199, 199)', + backgroundColor: 'rgba(199, 199, 199, 0.1)', + tension: 0.3, + fill: false, + borderWidth: 2 } ] },