gespielte_spiele.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. include 'db_config.php';
  3. // --- 1. DATEN LADEN ---
  4. $allTeams = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
  5. // Filter-Logik
  6. $teamFilter = isset($_GET['team_id']) ? (int)$_GET['team_id'] : 0;
  7. $sql = "SELECT sp.*, sc.zeit, sc.hilfe, sc.sterne, s.name as team_name
  8. FROM spiele sp
  9. JOIN scores sc ON sp.id = sc.spiel_id
  10. JOIN spieler s ON sc.spieler_id = s.id";
  11. if ($teamFilter > 0) {
  12. $sql .= " WHERE s.id = $teamFilter";
  13. }
  14. $sql .= " ORDER BY sp.titel ASC";
  15. $stmt = $pdo->query($sql);
  16. $playedGames = $stmt->fetchAll();
  17. ?>
  18. <!DOCTYPE html>
  19. <html lang="de">
  20. <head>
  21. <meta charset="UTF-8">
  22. <title>EXIT - Gelöste Abenteuer</title>
  23. <style>
  24. :root {
  25. --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
  26. }
  27. .dark-theme {
  28. --bg: #121212cf; --card: #1e1e1e; --text: #ffffff; --border: #333;
  29. }
  30. body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
  31. .container { max-width: 1200px; margin: 0 auto; }
  32. /* HEADER ANALOG ZU ADMIN/INDEX */
  33. header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 2px solid var(--accent); padding-bottom: 10px; }
  34. h1 { color: var(--accent); margin: 0; font-size: 1.8rem; }
  35. .btn-nav { background: var(--accent); color: white; text-decoration: none; padding: 10px 15px; border-radius: 8px; font-weight: bold; font-size: 0.9em; display: inline-block; border: none; cursor: pointer; }
  36. .theme-toggle { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0; line-height: 1; }
  37. /* FILTER BAR */
  38. .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; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
  39. select { padding: 8px 15px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; width: auto; }
  40. /* GRID & CARDS */
  41. .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
  42. .item { background: var(--card); border-radius: 12px; text-align: center; border: 1px solid var(--border); box-shadow: 0 4px 15px rgba(0,0,0,0.1); overflow: hidden; }
  43. .item img { width: 100%; height: 180px; object-fit: cover; background: #2a2a2a; border-bottom: 1px solid var(--border); }
  44. .stats { padding: 15px; }
  45. .team-badge { font-size: 0.7em; background: var(--accent); color: white; padding: 2px 10px; border-radius: 10px; margin-bottom: 8px; display: inline-block; text-transform: uppercase; letter-spacing: 0.5px; }
  46. .game-title { font-weight: bold; display: block; margin-bottom: 10px; font-size: 1.1em; min-height: 2.2em; display: flex; align-items: center; justify-content: center; }
  47. .result-row { display: flex; justify-content: space-around; font-size: 0.85em; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 5px; }
  48. .res-item span { display: block; opacity: 0.6; font-size: 0.75em; margin-bottom: 2px; }
  49. .res-item b { color: var(--accent); font-size: 1em; }
  50. @media (max-width: 600px) {
  51. header { flex-direction: column; gap: 15px; text-align: center; }
  52. .filter-bar { flex-direction: column; align-items: stretch; }
  53. }
  54. </style>
  55. <script>
  56. if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
  57. </script>
  58. </head>
  59. <body>
  60. <div class="container">
  61. <header>
  62. <h1>📂 Gelöste Abenteuer</h1>
  63. <div style="display: flex; align-items: center; gap: 15px;">
  64. <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
  65. <a href="index.php" class="btn-nav">Dashboard</a>
  66. </div>
  67. </header>
  68. <div class="filter-bar">
  69. <strong>Filter nach Team:</strong>
  70. <form id="filterForm" method="GET">
  71. <select name="team_id" onchange="this.form.submit()">
  72. <option value="0">-- Alle Teams --</option>
  73. <?php foreach ($allTeams as $t): ?>
  74. <option value="<?= $t['id'] ?>" <?= $teamFilter == $t['id'] ? 'selected' : '' ?>>
  75. <?= htmlspecialchars($t['name']) ?>
  76. </option>
  77. <?php endforeach; ?>
  78. </select>
  79. </form>
  80. </div>
  81. <div class="grid">
  82. <?php foreach ($playedGames as $game): ?>
  83. <div class="item">
  84. <img src="<?= htmlspecialchars($game['bild_url']) ?>" onerror="this.src='https://via.placeholder.com/240x180?text=EXIT+Spiel'">
  85. <div class="stats">
  86. <span class="team-badge"><?= htmlspecialchars($game['team_name']) ?></span>
  87. <span class="game-title"><?= htmlspecialchars($game['titel']) ?></span>
  88. <div class="result-row">
  89. <div class="res-item"><span>Zeit</span><b><?= $game['zeit'] ?> Min.</b></div>
  90. <div class="res-item"><span>Hilfe</span><b><?= $game['hilfe'] ?></b></div>
  91. <div class="res-item"><span>Sterne</span><b>⭐ <?= $game['sterne'] ?></b></div>
  92. </div>
  93. </div>
  94. </div>
  95. <?php endforeach; ?>
  96. </div>
  97. <?php if (empty($playedGames)): ?>
  98. <p style="text-align: center; margin-top: 50px; opacity: 0.5;">Hier wurden noch keine Abenteuer gelöst.</p>
  99. <?php endif; ?>
  100. </div>
  101. <script>
  102. const themeIcon = document.getElementById('theme-icon');
  103. function toggleTheme() {
  104. const isDark = document.documentElement.classList.toggle('dark-theme');
  105. localStorage.setItem('theme', isDark ? 'dark' : 'light');
  106. themeIcon.innerText = isDark ? '☀️' : '🌙';
  107. }
  108. if (localStorage.getItem('theme') === 'dark') {
  109. themeIcon.innerText = '☀️';
  110. }
  111. </script>
  112. </body>
  113. </html>