| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- require_once 'db_config.php';
- $filterPlayerId = isset($_GET['team_filter']) ? (int)$_GET['team_filter'] : 0;
- // SQL-Abfrage: :fid wird für den Einzel-Status genutzt, :pid für den globalen Filter
- $sql = "SELECT sp.*, t.bezeichnung as typ_name, MAX(sc.sterne) as best_sterne,
- (SELECT status FROM besitzstatus WHERE spiel_id = sp.id AND spieler_id = :fid) as einzel_status,
- (SELECT GROUP_CONCAT(CONCAT(p.name, ': ', b.status) SEPARATOR '||')
- FROM besitzstatus b JOIN spieler p ON b.spieler_id = p.id
- WHERE b.spiel_id = sp.id AND b.status != 'nicht besitzt') as besitz_info
- FROM spiele sp
- LEFT JOIN game_typen t ON sp.typ_id = t.id
- LEFT JOIN scores sc ON sp.id = sc.spiel_id " .
- ($filterPlayerId > 0 ? " AND sc.spieler_id = :pid " : "") . "
- GROUP BY sp.id ORDER BY sp.id DESC";
- $stmt = $pdo->prepare($sql);
- // Parameter-Array vorbereiten
- $params = ['fid' => $filterPlayerId]; // :fid wird immer benötigt für die Subquery
- if ($filterPlayerId > 0) {
- $params['pid'] = $filterPlayerId; // :pid nur hinzufügen, wenn der Filter aktiv ist
- }
- $stmt->execute($params);
- $inventory = $stmt->fetchAll();
- $spieler = $pdo->query("SELECT * FROM spieler ORDER BY id ASC")->fetchAll();
- ?>
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <title>EXIT Gesamtliste</title>
- <style>
- body { font-family: 'Segoe UI', sans-serif; background: #f8f9fa; padding: 20px; }
- .container { max-width: 1400px; margin: 0 auto; }
- table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
- th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eee; }
- th { background: #e67e22; color: white; cursor: pointer; font-size: 0.8em; text-transform: uppercase; }
- .game-thumb { width: 50px; height: 50px; object-fit: cover; border-radius: 8px; }
- .lvl-badge { padding: 4px 8px; border-radius: 4px; color: white; font-size: 0.7em; font-weight: bold; }
- .lvl-Einsteiger { background: #27ae60; } .lvl-Fortgeschrittene { background: #2980b9; } .lvl-Profi { background: #c0392b; }
- .st-badge { padding: 4px 8px; border-radius: 12px; font-size: 0.7em; font-weight: bold; display: inline-block; }
- .st-besitzt { background: #d4edda; color: #155724; }
- .st-verkauft { background: #fff3cd; color: #856404; }
- .st-keins { background: #f8d7da; color: #721c24; }
- .team-pill { display: inline-block; background: #eee; padding: 2px 6px; border-radius: 4px; font-size: 0.8em; margin: 2px; border: 1px solid #ddd; }
- </style>
- </head>
- <body>
- <div class="container">
- <div style="display:flex; justify-content: space-between; align-items:center; margin-bottom:20px;">
- <h1>📝 Sammlungs-Übersicht</h1>
- <a href="index.php" style="color:#e67e22; font-weight:bold; text-decoration:none;">← Dashboard</a>
- </div>
- <div style="background:white; padding:15px; border-radius:10px; margin-bottom:20px; display:flex; gap:15px;">
- <form method="GET">
- <select name="team_filter" onchange="this.form.submit()" style="padding:10px; border-radius:5px;">
- <option value="0">-- Alle Teams --</option>
- <?php foreach ($spieler as $p): ?>
- <option value="<?= $p['id'] ?>" <?= $filterPlayerId == $p['id'] ? 'selected' : '' ?>><?= htmlspecialchars($p['name']) ?></option>
- <?php endforeach; ?>
- </select>
- </form>
- <input type="text" id="searchInput" placeholder="Suchen..." onkeyup="filterTable()" style="flex-grow:1; padding:10px; border:1px solid #ddd; border-radius:5px;">
- </div>
- <table id="exitTable">
- <thead>
- <tr>
- <th onclick="sortTable(0)">ID</th>
- <th>Bild</th>
- <th onclick="sortTable(2)">Titel</th>
- <th>Level</th>
- <th>Bestwert</th>
- <th>Besitzstatus</th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($inventory as $row): ?>
- <tr>
- <td>#<?= $row['id'] ?></td>
- <td><img src="<?= $row['bild_url'] ?>" class="game-thumb" onerror="this.src='https://via.placeholder.com/50?text=?'"></td>
- <td><strong><?= htmlspecialchars($row['titel']) ?></strong><br><small style="color:#666;"><?= htmlspecialchars($row['typ_name'] ?? 'Unbekannt') ?></small></td>
- <td><span class="lvl-badge lvl-<?= $row['level'] ?>"><?= $row['level'] ?></span></td>
- <td><?= $row['best_sterne'] ? "<b style='color:#e67e22'>{$row['best_sterne']} ★</b>" : "-" ?></td>
- <td>
- <?php if ($filterPlayerId > 0):
- $st = $row['einzel_status'] ?: 'nicht besitzt';
- $class = ($st == 'besitzt') ? 'st-besitzt' : (($st == 'verkauft') ? 'st-verkauft' : 'st-keins');
- ?>
- <span class="st-badge <?= $class ?>"><?= strtoupper($st) ?></span>
- <?php else: ?>
- <?php
- if ($row['besitz_info']) {
- $teams = explode('||', $row['besitz_info']);
- foreach ($teams as $t) {
- $parts = explode(': ', $t);
- if(count($parts) < 2) continue;
- $tname = $parts[0]; $tstat = $parts[1];
- $color = ($tstat == 'besitzt') ? '#27ae60' : '#f39c12';
- echo "<span class='team-pill'><b style='color:$color'>●</b> " . htmlspecialchars($tname) . " (" . htmlspecialchars($tstat) . ")</span>";
- }
- } else { echo "<small style='color:#ccc'>Kein Team besitzt es</small>"; }
- ?>
- <?php endif; ?>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <script>
- function filterTable() {
- let input = document.getElementById("searchInput"),
- filter = input.value.toUpperCase(),
- tr = document.getElementById("exitTable").getElementsByTagName("tr");
- for (let i = 1; i < tr.length; i++) {
- tr[i].style.display = tr[i].innerText.toUpperCase().includes(filter) ? "" : "none";
- }
- }
- function sortTable(n) {
- var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
- table = document.getElementById("exitTable");
- switching = true; dir = "asc";
- while (switching) {
- switching = false; rows = table.rows;
- for (i = 1; i < (rows.length - 1); i++) {
- shouldSwitch = false;
- x = rows[i].getElementsByTagName("TD")[n];
- y = rows[i + 1].getElementsByTagName("TD")[n];
- var valX = x.innerText.toLowerCase().replace('#', '');
- var valY = y.innerText.toLowerCase().replace('#', '');
- if (n === 0) { valX = parseInt(valX); valY = parseInt(valY); }
- if (dir == "asc") { if (valX > valY) { shouldSwitch = true; break; }
- } else { if (valX < valY) { shouldSwitch = true; break; } }
- }
- if (shouldSwitch) {
- rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
- switching = true; switchcount ++;
- } else {
- if (switchcount == 0 && dir == "asc") { dir = "desc"; switching = true; }
- }
- }
- }
- </script>
- </body>
- </html>
|