diff --git a/stats.php b/stats.php new file mode 100755 index 0000000..468cd67 --- /dev/null +++ b/stats.php @@ -0,0 +1,224 @@ += ? AND mt.attended = 1 AND mt.wore_color = 0 + GROUP BY u.username + ORDER BY penalty_count DESC +"; +$stmt = mysqli_prepare($conn, $sql_penalties); +// Überprüfen, ob das Statement erfolgreich vorbereitet wurde +if ($stmt === false) { + die("Fehler bei der SQL-Abfrage: " . mysqli_error($conn)); +} +mysqli_stmt_bind_param($stmt, "s", $last_reset_date); +mysqli_stmt_execute($stmt); +$result = mysqli_stmt_get_result($stmt); + +while ($row = mysqli_fetch_assoc($result)) { + $penalties_data[] = $row; + $total_penalties += $row['penalty_count']; + $total_due += $row['penalty_count'] * $penalty_amount; +} +mysqli_stmt_close($stmt); + +// --- 2. Gesamt-Statistiken --- + +// Statistik 1: Häufigkeit der gewählten Farben +$color_stats = []; +$sql_colors = " + SELECT + c.name, + c.hex_code, + COUNT(m.id) AS meeting_count + FROM meetings m + JOIN colors c ON m.color_id = c.id + GROUP BY c.name, c.hex_code + ORDER BY meeting_count DESC +"; +$result = mysqli_query($conn, $sql_colors); +while ($row = mysqli_fetch_assoc($result)) { + $color_stats[] = $row; +} + +// Statistik 2: Teilnahmequote pro Benutzer +$participation_stats = []; +$sql_participation = " + SELECT + u.username, + COUNT(mt.user_id) AS total_attendance + FROM meeting_teilnehmer mt + JOIN users u ON mt.user_id = u.id + WHERE mt.attended = 1 + GROUP BY u.username + ORDER BY total_attendance DESC +"; +$result = mysqli_query($conn, $sql_participation); +while ($row = mysqli_fetch_assoc($result)) { + $participation_stats[] = $row; +} + +// Header einbinden +require_once 'inc/header.php'; +?> + +
+

Statistiken & Auswertung

+ +
+
+

Aktuelle Strafen (seit )

+
+
+

+ Gesamtzahl der Strafen:
+ Fälliger Gesamtbetrag: +

+ + + + +
+ + + + + + + + + + + + + + + + + +
BenutzerAnzahl StrafenFälliger Betrag
+
+ +
+
+ + --- + +
+
+

Gesamt-Statistiken (Alle Zeiten)

+
+
+
Häufigkeit der gewählten Farben
+ + +
Teilnahme-Ranking
+ +
+
+
+ + + + + + \ No newline at end of file