| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- include 'db_config.php';
- // --- 1. DATEN LADEN ---
- $allTeams = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
- $teamFilter = isset($_GET['team_id']) ? (int)$_GET['team_id'] : 0;
- $sql = "SELECT sp.*, sc.zeit, sc.hilfe, sc.sterne, s.name as team_name
- FROM spiele sp
- JOIN scores sc ON sp.id = sc.spiel_id
- JOIN spieler s ON sc.spieler_id = s.id";
- if ($teamFilter > 0) {
- $sql .= " WHERE s.id = $teamFilter";
- }
- $sql .= " ORDER BY sp.titel ASC, sc.zeit ASC";
- $stmt = $pdo->query($sql);
- $results = $stmt->fetchAll();
- // --- 2. GRUPPIERUNG NACH SPIEL ---
- $groupedGames = [];
- foreach ($results as $row) {
- $gameTitle = $row['titel'];
- if (!isset($groupedGames[$gameTitle])) {
- $groupedGames[$gameTitle] = [
- 'bild_url' => $row['bild_url'],
- 'teams' => []
- ];
- }
- $groupedGames[$gameTitle]['teams'][] = [
- 'name' => $row['team_name'],
- 'zeit' => (int)$row['zeit'],
- 'hilfe' => (int)$row['hilfe'],
- 'sterne' => (int)$row['sterne']
- ];
- }
- ?>
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <title>EXIT - Gelöste Abenteuer</title>
- <style>
- :root {
- --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
- --muted: #888;
- }
- .dark-theme {
- --bg: #121212cf; --card: #1e1e1e; --text: #ffffff; --border: #333; --muted: #aaa;
- }
- body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
- .container { max-width: 1200px; margin: 0 auto; }
- header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 2px solid var(--accent); padding-bottom: 10px; }
- h1 { color: var(--accent); margin: 0; font-size: 1.8rem; }
-
- .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; }
- .theme-toggle { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0; line-height: 1; }
- .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); }
- select { padding: 8px 15px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
- .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; }
- .item { background: var(--card); border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 4px 15px rgba(0,0,0,0.1); overflow: hidden; display: flex; flex-direction: column; }
- .item img { width: 100%; height: 200px; object-fit: cover; background: #2a2a2a; border-bottom: 1px solid var(--border); }
-
- .stats { padding: 15px; flex-grow: 1; }
- .game-title { font-weight: bold; display: block; margin-bottom: 15px; font-size: 1.2em; color: var(--accent); text-align: center; }
-
- .team-section-label { font-size: 0.7em; color: var(--muted); display: block; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
- .team-entry { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
- .team-entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
-
- .team-name-text { font-size: 0.95em; font-weight: bold; display: block; margin-bottom: 5px; }
-
- .result-row { display: flex; justify-content: space-between; font-size: 0.8em; }
- .res-item span { opacity: 0.6; margin-right: 4px; }
- .res-item b { color: var(--accent); }
- .res-only-solved { font-size: 0.8em; color: var(--muted); font-style: italic; }
- @media (max-width: 600px) {
- header { flex-direction: column; gap: 15px; text-align: center; }
- .filter-bar { flex-direction: column; align-items: stretch; }
- }
- </style>
- <script>
- if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
- </script>
- </head>
- <body>
- <div class="container">
- <header>
- <h1>📂 Gelöste Abenteuer</h1>
- <div style="display: flex; align-items: center; gap: 15px;">
- <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
- <a href="index.php" class="btn-nav">Dashboard</a>
- </div>
- </header>
- <div class="filter-bar">
- <strong>Filter nach Team:</strong>
- <form id="filterForm" method="GET">
- <select name="team_id" onchange="this.form.submit()">
- <option value="0">-- Alle Teams --</option>
- <?php foreach ($allTeams as $t): ?>
- <option value="<?= $t['id'] ?>" <?= $teamFilter == $t['id'] ? 'selected' : '' ?>>
- <?= htmlspecialchars($t['name']) ?>
- </option>
- <?php endforeach; ?>
- </select>
- </form>
- </div>
- <div class="grid">
- <?php foreach ($groupedGames as $title => $data): ?>
- <div class="item">
- <img src="<?= htmlspecialchars($data['bild_url']) ?>" onerror="this.src='https://via.placeholder.com/300x200?text=EXIT+Spiel'">
- <div class="stats">
- <span class="game-title"><?= htmlspecialchars($title) ?></span>
-
- <span class="team-section-label">Gelöst von</span>
-
- <?php foreach ($data['teams'] as $team): ?>
- <div class="team-entry">
- <span class="team-name-text">👥 <?= htmlspecialchars($team['name']) ?></span>
-
- <?php if ($team['zeit'] === 0 && $team['hilfe'] === 0 && $team['sterne'] === 0): ?>
- <div class="res-only-solved">✅ Erfolgreich gelöst</div>
- <?php else: ?>
- <div class="result-row">
- <div class="res-item"><span>Zeit:</span><b><?= $team['zeit'] ?> Min.</b></div>
- <div class="res-item"><span>Hilfe:</span><b><?= $team['hilfe'] ?></b></div>
- <div class="res-item"><b>⭐ <?= $team['sterne'] ?></b></div>
- </div>
- <?php endif; ?>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- <?php if (empty($groupedGames)): ?>
- <p style="text-align: center; margin-top: 50px; opacity: 0.5;">Hier wurden noch keine Abenteuer gelöst.</p>
- <?php endif; ?>
- </div>
- <script>
- const themeIcon = document.getElementById('theme-icon');
- function toggleTheme() {
- const isDark = document.documentElement.classList.toggle('dark-theme');
- localStorage.setItem('theme', isDark ? 'dark' : 'light');
- themeIcon.innerText = isDark ? '☀️' : '🌙';
- }
- if (localStorage.getItem('theme') === 'dark') {
- themeIcon.innerText = '☀️';
- }
- </script>
- </body>
- </html>
|