gespielte_spiele.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. include 'db_config.php';
  3. // --- 1. DATEN LADEN ---
  4. // Alle Spieler für den Filter laden
  5. $allTeams = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
  6. // Filter-Logik
  7. $teamFilter = isset($_GET['team_id']) ? (int)$_GET['team_id'] : 0;
  8. $sql = "SELECT sp.*, sc.zeit, sc.hilfe, sc.sterne, s.name as team_name
  9. FROM spiele sp
  10. JOIN scores sc ON sp.id = sc.spiel_id
  11. JOIN spieler s ON sc.spieler_id = s.id";
  12. if ($teamFilter > 0) {
  13. $sql .= " WHERE s.id = $teamFilter";
  14. }
  15. $sql .= " ORDER BY sp.titel ASC";
  16. $stmt = $pdo->query($sql);
  17. $playedGames = $stmt->fetchAll();
  18. ?>
  19. <!DOCTYPE html>
  20. <html lang="de">
  21. <head>
  22. <meta charset="UTF-8">
  23. <title>Gespielte Spiele</title>
  24. <style>
  25. :root {
  26. --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
  27. }
  28. .dark-theme {
  29. --bg: #121212cf; --card: #1e1e1e; --text: #ffffff; --border: #333;
  30. }
  31. body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
  32. header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
  33. /* Filter Bereich */
  34. .filter-bar { background: var(--card); padding: 15px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 25px; display: flex; align-items: center; gap: 15px; }
  35. select { padding: 8px 15px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
  36. .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
  37. .item { background: var(--card); border-radius: 12px; text-align: center; border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0,0,0,0.1); overflow: hidden; position: relative; }
  38. .item img { width: 100%; height: 160px; object-fit: cover; background: #2a2a2a; border-bottom: 1px solid var(--border); }
  39. /* Ergebnis-Overlay / Badge */
  40. .stats { padding: 12px; }
  41. .team-badge { font-size: 0.75em; background: var(--accent); color: white; padding: 2px 8px; border-radius: 10px; margin-bottom: 5px; display: inline-block; }
  42. .game-title { font-weight: bold; display: block; margin-bottom: 8px; font-size: 1em; }
  43. .result-row { display: flex; justify-content: space-around; font-size: 0.85em; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
  44. .res-item span { display: block; opacity: 0.6; font-size: 0.8em; }
  45. .res-item b { color: var(--accent); }
  46. h1 { color: var(--accent); margin: 0; }
  47. .back { color: var(--accent); text-decoration: none; font-weight: bold; border: 1px solid var(--accent); padding: 5px 15px; border-radius: 6px; }
  48. .theme-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 20px; cursor: pointer; font-size: 1.1rem; }
  49. </style>
  50. <script>
  51. if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
  52. </script>
  53. </head>
  54. <body>
  55. <header>
  56. <a href="index.php" class="back">← Dashboard</a>
  57. <div style="display: flex; align-items: center; gap: 15px;">
  58. <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
  59. </div>
  60. </header>
  61. <h1>📂 Gelöste Abenteuer</h1>
  62. <div class="filter-bar">
  63. <span>Team-Filter:</span>
  64. <form id="filterForm">
  65. <select name="team_id" onchange="document.getElementById('filterForm').submit()">
  66. <option value="0">-- Alle Teams anzeigen --</option>
  67. <?php foreach ($allTeams as $t): ?>
  68. <option value="<?= $t['id'] ?>" <?= $teamFilter == $t['id'] ? 'selected' : '' ?>>
  69. <?= htmlspecialchars($t['name']) ?>
  70. </option>
  71. <?php endforeach; ?>
  72. </select>
  73. </form>
  74. </div>
  75. <div class="grid">
  76. <?php foreach ($playedGames as $game): ?>
  77. <div class="item">
  78. <img src="<?= htmlspecialchars($game['bild_url']) ?>" onerror="this.src='https://via.placeholder.com/220x160?text=Kein+Bild'">
  79. <div class="stats">
  80. <span class="team-badge"><?= htmlspecialchars($game['team_name']) ?></span>
  81. <span class="game-title"><?= htmlspecialchars($game['titel']) ?></span>
  82. <div class="result-row">
  83. <div class="res-item"><span>Zeit</span><b><?= $game['zeit'] ?> Min</b></div>
  84. <div class="res-item"><span>Hilfe</span><b><?= $game['hilfe'] ?></b></div>
  85. <div class="res-item"><span>Sterne</span><b>⭐ <?= $game['sterne'] ?></b></div>
  86. </div>
  87. </div>
  88. </div>
  89. <?php endforeach; ?>
  90. </div>
  91. <?php if (empty($playedGames)): ?>
  92. <p style="text-align: center; margin-top: 50px; opacity: 0.5;">Keine Spiele für dieses Team gefunden.</p>
  93. <?php endif; ?>
  94. <script>
  95. function toggleTheme() {
  96. const isDark = document.documentElement.classList.toggle('dark-theme');
  97. localStorage.setItem('theme', isDark ? 'dark' : 'light');
  98. document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
  99. }
  100. if (localStorage.getItem('theme') === 'dark') {
  101. document.getElementById('theme-icon').innerText = '☀️';
  102. }
  103. </script>
  104. </body>
  105. </html>