gespielte_spiele.php_bak 6.4 KB

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