From fa13bc916709b1f422d86ed0c2d2e061c67535f9 Mon Sep 17 00:00:00 2001 From: Voxan Date: Wed, 21 Oct 2026 22:00:52 +0200 Subject: [PATCH] Import --- admin/statistics.php | 178 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 admin/statistics.php diff --git a/admin/statistics.php b/admin/statistics.php new file mode 100644 index 0000000..4aa3a78 --- /dev/null +++ b/admin/statistics.php @@ -0,0 +1,178 @@ +query('SELECT id, name FROM countries ORDER BY name')->fetchAll(PDO::FETCH_ASSOC); +$countryId = filter_input(INPUT_GET, 'country_id', FILTER_VALIDATE_INT) ?: null; + +$whereCountry = ''; +$params = []; +if ($countryId) { + $whereCountry = 'WHERE s.country_id = ?'; + $params[] = $countryId; +} + +$totalSites = 0; +$totalCells = 0; +try { + $stmt = $db->prepare("SELECT COUNT(*) FROM sites s $whereCountry"); + $stmt->execute($params); + $totalSites = (int)$stmt->fetchColumn(); + + $stmt = $db->prepare( + "SELECT COUNT(*) FROM cells c INNER JOIN sites s ON s.id = c.site_id $whereCountry" + ); + $stmt->execute($params); + $totalCells = (int)$stmt->fetchColumn(); +} catch (Throwable $e) { + error_log('[statistics] compteurs generaux: ' . $e->getMessage()); +} + +$byOperator = $db->prepare( + "SELECT o.brand AS operator_name, COUNT(DISTINCT s.id) AS site_count, COUNT(c.id) AS cell_count + FROM operators o + LEFT JOIN sites s ON s.operator_id = o.id " . ($countryId ? 'AND s.country_id = ?' : '') . " + LEFT JOIN cells c ON c.site_id = s.id + GROUP BY o.id, o.brand + ORDER BY cell_count DESC" +); +$byOperator->execute($countryId ? [$countryId] : []); +$byOperator = $byOperator->fetchAll(PDO::FETCH_ASSOC); + +$byTechnology = $db->prepare( + "SELECT c.tech, COUNT(*) AS total + FROM cells c + INNER JOIN sites s ON s.id = c.site_id + $whereCountry + GROUP BY c.tech + ORDER BY total DESC" +); +$byTechnology->execute($params); +$byTechnology = $byTechnology->fetchAll(PDO::FETCH_ASSOC); + +$byBand = $db->prepare( + "SELECT c.band, COUNT(*) AS total + FROM cells c + INNER JOIN sites s ON s.id = c.site_id + $whereCountry + GROUP BY c.band + ORDER BY total DESC + LIMIT 30" +); +$byBand->execute($params); +$byBand = $byBand->fetchAll(PDO::FETCH_ASSOC); + +$user = current_admin_username(); +?> + + + + + Statistiques — NetMonster Admin + + + + + +
+

Statistiques

+

Vue de consultation agregee, sans action d'ecriture possible.

+ +
+
+ +
+
+ +
+

Vue d'ensemble

+
+
Sites
+
Cellules
+
+
+ +
+

Par operateur

+ + + + + + + + + + + + +
OperateurSitesCellules
Aucune donnee.
+
+ +
+

Par technologie

+ + + + + + + + + + + +
TechnologieCellules
Aucune donnee.
+
+ +
+

Par bande (top 30)

+ + + + + + + + + + + +
BandeCellules
Aucune donnee.
+
+
+ + \ No newline at end of file