gesamtliste.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. /* THEME VARIABLEN */
  30. :root {
  31. --bg: #f8f9fa; --card: #ffffff; --text: #333; --border: #ddd;
  32. --header-bg: #2c3e50; --header-text: #ffffff; --row-border: #eee;
  33. }
  34. .dark-theme {
  35. --bg: #121212; --card: #1e1e1e; --text: #e0e0e0; --border: #333;
  36. --header-bg: #252525; --header-text: #e67e22; --row-border: #2a2a2a;
  37. }
  38. body { font-family: 'Segoe UI', sans-serif; background: var(--bg); margin: 0; padding: 20px; color: var(--text); transition: 0.3s; }
  39. .container { max-width: 1400px; margin: 0 auto; }
  40. .header-area { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
  41. .nav-group { display: flex; align-items: center; gap: 10px; }
  42. .back-link { color: #e67e22; text-decoration: none; font-weight: bold; padding: 8px 15px; border: 2px solid #e67e22; border-radius: 6px; }
  43. .theme-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 20px; cursor: pointer; font-size: 1.1rem; }
  44. .filter-bar { background: var(--card); 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; border: 1px solid var(--border); }
  45. select, input { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
  46. input { flex-grow: 1; }
  47. table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
  48. th { background: var(--header-bg); color: var(--header-text); text-align: left; padding: 15px; cursor: pointer; font-size: 0.8em; }
  49. td { padding: 12px 15px; border-bottom: 1px solid var(--row-border); }
  50. .game-thumb { width: 55px; height: 55px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
  51. .game-thumb:hover { transform: scale(1.1); border-color: #e67e22; }
  52. .lvl-badge { padding: 4px 10px; border-radius: 20px; color: white; font-size: 11px; font-weight: bold; text-transform: uppercase; }
  53. .lvl-Einsteiger { background: #27ae60; }
  54. .lvl-Fortgeschrittene { background: #2980b9; }
  55. .lvl-Profi { background: #c0392b; }
  56. .lvl-unknown, .badge-unknown { background: #f39c12; color: white; }
  57. .st-badge { padding: 5px 12px; border-radius: 15px; font-size: 11px; font-weight: bold; }
  58. .st-besitzt { background: #d4edda; color: #155724; }
  59. .dark-theme .st-besitzt { background: #1b4332; color: #74c69d; }
  60. .st-verkauft { background: #fff3cd; color: #856404; }
  61. .st-keins { background: #f8d7da; color: #721c24; }
  62. .team-pill { display: inline-flex; align-items: center; background: var(--bg); padding: 4px 10px; border-radius: 6px; font-size: 12px; margin: 2px; border: 1px solid var(--border); }
  63. .dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
  64. #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; }
  65. #modalContent { max-width: 90%; max-height: 90%; border-radius: 10px; }
  66. .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; }
  67. </style>
  68. <script>
  69. if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
  70. </script>
  71. </head>
  72. <body>
  73. <div class="container">
  74. <div class="header-area">
  75. <h1>📝 Sammlungs-Übersicht</h1>
  76. <div class="nav-group">
  77. <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
  78. <a href="index.php" class="back-link">← Zum Dashboard</a>
  79. </div>
  80. </div>
  81. <div class="filter-bar">
  82. <form method="GET"><select name="team_filter" onchange="this.form.submit()">
  83. <option value="0">-- Alle Teams --</option>
  84. <?php foreach ($spieler as $p): ?>
  85. <option value="<?= $p['id'] ?>" <?= $filterPlayerId == $p['id'] ? 'selected' : '' ?>><?= htmlspecialchars($p['name']) ?></option>
  86. <?php endforeach; ?>
  87. </select></form>
  88. <input type="text" id="searchInput" placeholder="Suchen..." onkeyup="filterTable()">
  89. </div>
  90. <table id="exitTable">
  91. <thead>
  92. <tr>
  93. <th onclick="sortTable(0)">ID</th>
  94. <th>Bild</th>
  95. <th onclick="sortTable(2)">Titel</th>
  96. <th>Level</th>
  97. <th>Bestwert</th>
  98. <th>Besitzstatus</th>
  99. </tr>
  100. </thead>
  101. <tbody>
  102. <?php foreach ($inventory as $row):
  103. $lvl = (empty($row['level']) || strtolower($row['level']) == 'unknown') ? 'unknown' : $row['level'];
  104. $typ = (empty($row['typ_name']) || strtolower($row['typ_name']) == 'unknown') ? 'Unbekannt' : $row['typ_name'];
  105. ?>
  106. <tr>
  107. <td>#<?= $row['id'] ?></td>
  108. <td>
  109. <img src="<?= htmlspecialchars($row['bild_url']) ?>"
  110. class="game-thumb"
  111. onclick="openModal('<?= htmlspecialchars($row['bild_url']) ?>')"
  112. onmouseover="showPreview(event, '<?= htmlspecialchars($row['bild_url']) ?>')"
  113. onmouseout="hidePreview()"
  114. onerror="this.src='https://via.placeholder.com/60?text=?'">
  115. </td>
  116. <td>
  117. <strong><?= htmlspecialchars($row['titel']) ?></strong><br>
  118. <?php if($typ == 'Unbekannt'): ?>
  119. <small class="lvl-badge badge-unknown" style="padding: 1px 6px; font-size: 9px;">UNBEKANNT</small>
  120. <?php else: ?>
  121. <small style="opacity: 0.7;"><?= htmlspecialchars($typ) ?></small>
  122. <?php endif; ?>
  123. </td>
  124. <td>
  125. <span class="lvl-badge lvl-<?= $lvl ?>">
  126. <?= ($lvl == 'unknown') ? 'Unbekannt' : $lvl ?>
  127. </span>
  128. </td>
  129. <td><?= $row['best_sterne'] ? "<b>{$row['best_sterne']} ★</b>" : "-" ?></td>
  130. <td>
  131. <?php if ($filterPlayerId > 0):
  132. $st = $row['einzel_status'] ?: 'nicht besitzt';
  133. $class = ($st == 'besitzt') ? 'st-besitzt' : (($st == 'verkauft') ? 'st-verkauft' : 'st-keins');
  134. echo "<span class='st-badge $class'>".strtoupper($st)."</span>";
  135. else:
  136. if ($row['besitz_info']) {
  137. foreach (explode('||', $row['besitz_info']) as $t) {
  138. $parts = explode(': ', $t);
  139. if(count($parts) < 2) continue;
  140. list($tn, $ts) = $parts;
  141. $dot = ($ts == 'besitzt') ? '#27ae60' : '#f39c12';
  142. echo "<span class='team-pill'><span class='dot' style='background:$dot'></span>$tn ($ts)</span>";
  143. }
  144. } else { echo "<small>-</small>"; }
  145. endif; ?>
  146. </td>
  147. </tr>
  148. <?php endforeach; ?>
  149. </tbody>
  150. </table>
  151. </div>
  152. <div id="imgModal" onclick="this.style.display='none'"><img id="modalContent"></div>
  153. <img id="hoverPreview" class="image-preview" src="">
  154. <script>
  155. function toggleTheme() {
  156. const isDark = document.documentElement.classList.toggle('dark-theme');
  157. localStorage.setItem('theme', isDark ? 'dark' : 'light');
  158. document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
  159. }
  160. if (localStorage.getItem('theme') === 'dark') document.getElementById('theme-icon').innerText = '☀️';
  161. const modal = document.getElementById("imgModal");
  162. const modalImg = document.getElementById("modalContent");
  163. function openModal(url) { modal.style.display = "flex"; modalImg.src = url; hidePreview(); }
  164. const preview = document.getElementById('hoverPreview');
  165. function showPreview(e, url) {
  166. if(modal.style.display === "flex") return;
  167. preview.src = url; preview.style.display = 'block'; updatePos(e);
  168. }
  169. function hidePreview() { preview.style.display = 'none'; }
  170. function updatePos(e) { preview.style.left = (e.pageX + 20) + 'px'; preview.style.top = (e.pageY - 100) + 'px'; }
  171. document.addEventListener('mousemove', (e) => { if(preview.style.display==='block') updatePos(e); });
  172. function filterTable() {
  173. let val = document.getElementById("searchInput").value.toUpperCase();
  174. let tr = document.getElementById("exitTable").getElementsByTagName("tr");
  175. for (let i = 1; i < tr.length; i++) tr[i].style.display = tr[i].innerText.toUpperCase().includes(val) ? "" : "none";
  176. }
  177. function sortTable(n) {
  178. var table = document.getElementById("exitTable"), rows, switching = true, i, x, y, should, dir = "asc", cnt = 0;
  179. while (switching) {
  180. switching = false; rows = table.rows;
  181. for (i = 1; i < (rows.length - 1); i++) {
  182. should = false; x = rows[i].getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n];
  183. let valX = x.innerText.toLowerCase(); let valY = y.innerText.toLowerCase();
  184. if (n === 0) { valX = parseInt(valX.replace('#','')); valY = parseInt(valY.replace('#','')); }
  185. if (dir == "asc") { if (valX > valY) { should = true; break; } }
  186. else { if (valX < valY) { should = true; break; } }
  187. }
  188. if (should) { rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); switching = true; cnt++; }
  189. else if (cnt == 0 && dir == "asc") { dir = "desc"; switching = true; }
  190. }
  191. }
  192. </script>
  193. </body>
  194. </html>