gespielte_spiele.php 6.5 KB

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