gesamtliste.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. require_once 'config.php';
  3. require_once 'db_config.php';
  4. $filterPlayerId = isset($_GET['team_filter']) ? (int)$_GET['team_filter'] : 0;
  5. $sql = "SELECT sp.*, t.bezeichnung as typ_name, MAX(sc.sterne) as best_sterne,
  6. (SELECT status FROM besitzstatus WHERE spiel_id = sp.id AND spieler_id = :fid) as einzel_status,
  7. (SELECT GROUP_CONCAT(CONCAT(p.name, ': ', b.status) SEPARATOR '||')
  8. FROM besitzstatus b JOIN spieler p ON b.spieler_id = p.id
  9. WHERE b.spiel_id = sp.id AND b.status != 'nicht besitzt') as besitz_info
  10. FROM spiele sp
  11. LEFT JOIN game_typen t ON sp.typ_id = t.id
  12. LEFT JOIN scores sc ON sp.id = sc.spiel_id " .
  13. ($filterPlayerId > 0 ? " AND sc.spieler_id = :pid " : "") . "
  14. GROUP BY sp.id ORDER BY sp.id DESC";
  15. $stmt = $pdo->prepare($sql);
  16. $params = ['fid' => $filterPlayerId];
  17. if ($filterPlayerId > 0) { $params['pid'] = $filterPlayerId; }
  18. $stmt->execute($params);
  19. $inventory = $stmt->fetchAll();
  20. $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
  21. ?>
  22. <!DOCTYPE html>
  23. <html lang="de">
  24. <head>
  25. <meta charset="UTF-8">
  26. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  27. <title>EXIT - Gesamtliste</title>
  28. <style>
  29. body { font-family: 'Segoe UI', sans-serif; background: #f8f9fa; margin: 0; padding: 20px; color: #333; }
  30. .container { max-width: 1400px; margin: 0 auto; }
  31. .header-area { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
  32. .back-link { color: #e67e22; text-decoration: none; font-weight: bold; padding: 8px 15px; border: 2px solid #e67e22; border-radius: 6px; }
  33. .filter-bar { background: white; padding: 15px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); display: flex; gap: 15px; margin-bottom: 20px; align-items: center; }
  34. select, input { padding: 12px; border: 1px solid #ddd; border-radius: 8px; }
  35. input { flex-grow: 1; }
  36. table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
  37. th { background: #2c3e50; color: white; text-align: left; padding: 15px; cursor: pointer; font-size: 0.8em; }
  38. td { padding: 12px 15px; border-bottom: 1px solid #eee; }
  39. .game-thumb { width: 55px; height: 55px; object-fit: cover; border-radius: 8px; border: 1px solid #ddd; cursor: pointer; transition: 0.2s; }
  40. .game-thumb:hover { transform: scale(1.1); border-color: #e67e22; }
  41. /* Badges & Unbekannt-Status */
  42. .lvl-badge { padding: 4px 10px; border-radius: 20px; color: white; font-size: 11px; font-weight: bold; text-transform: uppercase; }
  43. .lvl-Einsteiger { background: #27ae60; }
  44. .lvl-Fortgeschrittene { background: #2980b9; }
  45. .lvl-Profi { background: #c0392b; }
  46. .lvl-unknown, .badge-unknown { background: #f39c12; color: white; } /* Gelb/Orange für Unbekannt */
  47. .st-badge { padding: 5px 12px; border-radius: 15px; font-size: 11px; font-weight: bold; }
  48. .st-besitzt { background: #d4edda; color: #155724; }
  49. .st-verkauft { background: #fff3cd; color: #856404; }
  50. .st-keins { background: #f8d7da; color: #721c24; }
  51. .team-pill { display: inline-flex; align-items: center; background: #f1f2f6; padding: 4px 10px; border-radius: 6px; font-size: 12px; margin: 2px; border: 1px solid #dfe4ea; }
  52. .dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
  53. /* Modal & Preview */
  54. .image-preview { position: absolute; display: none; width: 220px; border: 4px solid white; border-radius: 12px; z-index: 999; box-shadow: 0 15px 35px rgba(0,0,0,0.4); pointer-events: none; }
  55. #imgModal { display: none; position: fixed; z-index: 10000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); align-items: center; justify-content: center; cursor: zoom-out; }
  56. #modalContent { max-width: 90%; max-height: 90%; border-radius: 10px; }
  57. </style>
  58. </head>
  59. <body>
  60. <div class="container">
  61. <div class="header-area">
  62. <h1>📝 Sammlungs-Übersicht</h1>
  63. <a href="index.php" class="back-link">← Zum Dashboard</a>
  64. </div>
  65. <div class="filter-bar">
  66. <form method="GET"><select name="team_filter" onchange="this.form.submit()">
  67. <option value="0">-- Alle Teams --</option>
  68. <?php foreach ($spieler as $p): ?>
  69. <option value="<?= $p['id'] ?>" <?= $filterPlayerId == $p['id'] ? 'selected' : '' ?>><?= htmlspecialchars($p['name']) ?></option>
  70. <?php endforeach; ?>
  71. </select></form>
  72. <input type="text" id="searchInput" placeholder="Suchen..." onkeyup="filterTable()">
  73. </div>
  74. <table id="exitTable">
  75. <thead>
  76. <tr>
  77. <th onclick="sortTable(0)">ID</th>
  78. <th>Bild</th>
  79. <th onclick="sortTable(2)">Titel</th>
  80. <th>Level</th>
  81. <th>Bestwert</th>
  82. <th>Besitzstatus</th>
  83. </tr>
  84. </thead>
  85. <tbody>
  86. <?php foreach ($inventory as $row):
  87. // Logik für unbekannte Werte
  88. $lvl = (empty($row['level']) || strtolower($row['level']) == 'unknown') ? 'unknown' : $row['level'];
  89. $typ = (empty($row['typ_name']) || strtolower($row['typ_name']) == 'unknown') ? 'Unbekannt' : $row['typ_name'];
  90. ?>
  91. <tr>
  92. <td>#<?= $row['id'] ?></td>
  93. <td>
  94. <img src="<?= htmlspecialchars($row['bild_url']) ?>"
  95. class="game-thumb"
  96. onclick="openModal('<?= htmlspecialchars($row['bild_url']) ?>')"
  97. onmouseover="showPreview(event, '<?= htmlspecialchars($row['bild_url']) ?>')"
  98. onmouseout="hidePreview()"
  99. onerror="this.src='https://via.placeholder.com/60?text=?'">
  100. </td>
  101. <td>
  102. <strong><?= htmlspecialchars($row['titel']) ?></strong><br>
  103. <?php if($typ == 'Unbekannt'): ?>
  104. <small class="lvl-badge badge-unknown" style="padding: 1px 6px; font-size: 9px;">UNBEKANNT</small>
  105. <?php else: ?>
  106. <small style="color:#777;"><?= htmlspecialchars($typ) ?></small>
  107. <?php endif; ?>
  108. </td>
  109. <td>
  110. <span class="lvl-badge lvl-<?= $lvl ?>">
  111. <?= ($lvl == 'unknown') ? 'Unbekannt' : $lvl ?>
  112. </span>
  113. </td>
  114. <td><?= $row['best_sterne'] ? "<b>{$row['best_sterne']} ★</b>" : "-" ?></td>
  115. <td>
  116. <?php if ($filterPlayerId > 0):
  117. $st = $row['einzel_status'] ?: 'nicht besitzt';
  118. $class = ($st == 'besitzt') ? 'st-besitzt' : (($st == 'verkauft') ? 'st-verkauft' : 'st-keins');
  119. echo "<span class='st-badge $class'>".strtoupper($st)."</span>";
  120. else:
  121. if ($row['besitz_info']) {
  122. foreach (explode('||', $row['besitz_info']) as $t) {
  123. list($tn, $ts) = explode(': ', $t);
  124. $dot = ($ts == 'besitzt') ? '#27ae60' : '#f39c12';
  125. echo "<span class='team-pill'><span class='dot' style='background:$dot'></span>$tn ($ts)</span>";
  126. }
  127. } else { echo "<small>-</small>"; }
  128. endif; ?>
  129. </td>
  130. </tr>
  131. <?php endforeach; ?>
  132. </tbody>
  133. </table>
  134. </div>
  135. <div id="imgModal" onclick="this.style.display='none'"><img id="modalContent"></div>
  136. <img id="hoverPreview" class="image-preview" src="">
  137. <script>
  138. // Modal-Logik
  139. const modal = document.getElementById("imgModal");
  140. const modalImg = document.getElementById("modalContent");
  141. function openModal(url) { modal.style.display = "flex"; modalImg.src = url; hidePreview(); }
  142. // Hover-Logik
  143. const preview = document.getElementById('hoverPreview');
  144. function showPreview(e, url) {
  145. if(modal.style.display === "flex") return;
  146. preview.src = url; preview.style.display = 'block'; updatePos(e);
  147. }
  148. function hidePreview() { preview.style.display = 'none'; }
  149. function updatePos(e) { preview.style.left = (e.pageX + 20) + 'px'; preview.style.top = (e.pageY - 100) + 'px'; }
  150. document.addEventListener('mousemove', (e) => { if(preview.style.display==='block') updatePos(e); });
  151. // Filter & Sortierung
  152. function filterTable() {
  153. let val = document.getElementById("searchInput").value.toUpperCase();
  154. let tr = document.getElementById("exitTable").getElementsByTagName("tr");
  155. for (let i = 1; i < tr.length; i++) tr[i].style.display = tr[i].innerText.toUpperCase().includes(val) ? "" : "none";
  156. }
  157. function sortTable(n) {
  158. var table = document.getElementById("exitTable"), rows, switching = true, i, x, y, should, dir = "asc", cnt = 0;
  159. while (switching) {
  160. switching = false; rows = table.rows;
  161. for (i = 1; i < (rows.length - 1); i++) {
  162. should = false; x = rows[i].getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n];
  163. let valX = x.innerText.toLowerCase(); let valY = y.innerText.toLowerCase();
  164. if (n === 0) { valX = parseInt(valX.replace('#','')); valY = parseInt(valY.replace('#','')); }
  165. if (dir == "asc") { if (valX > valY) { should = true; break; } }
  166. else { if (valX < valY) { should = true; break; } }
  167. }
  168. if (should) { rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); switching = true; cnt++; }
  169. else if (cnt == 0 && dir == "asc") { dir = "desc"; switching = true; }
  170. }
  171. }
  172. </script>
  173. </body>
  174. </html>