gesamtliste.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. require_once 'config.php';
  3. require_once 'db_config.php';
  4. // Filter-Werte abrufen
  5. $filterPlayerId = isset($_GET['team_filter']) ? (int)$_GET['team_filter'] : 0;
  6. $filterTypId = isset($_GET['typ_filter']) ? (int)$_GET['typ_filter'] : 0;
  7. // SQL Query: COUNT(sc.id) hinzugefügt, um "gespielt" ohne Sterne zu erkennen
  8. $sql = "SELECT sp.*, t.bezeichnung as typ_name,
  9. MAX(sc.sterne) as best_sterne,
  10. COUNT(sc.id) as anzahl_scores,
  11. (SELECT status FROM besitzstatus WHERE spiel_id = sp.id AND spieler_id = :fid) as einzel_status,
  12. (SELECT GROUP_CONCAT(CONCAT(p.name, ': ', b.status) SEPARATOR '||')
  13. FROM besitzstatus b JOIN spieler p ON b.spieler_id = p.id
  14. WHERE b.spiel_id = sp.id AND b.status != 'nicht besitzt') as besitz_info
  15. FROM spiele sp
  16. LEFT JOIN game_typen t ON sp.typ_id = t.id
  17. LEFT JOIN scores sc ON sp.id = sc.spiel_id " .
  18. ($filterPlayerId > 0 ? " AND sc.spieler_id = :pid " : "") . "
  19. WHERE 1=1 ";
  20. if ($filterTypId > 0) {
  21. $sql .= " AND sp.typ_id = :tid ";
  22. }
  23. $sql .= " GROUP BY sp.id ORDER BY sp.titel ASC";
  24. $stmt = $pdo->prepare($sql);
  25. $params = ['fid' => $filterPlayerId];
  26. if ($filterPlayerId > 0) { $params['pid'] = $filterPlayerId; }
  27. if ($filterTypId > 0) { $params['tid'] = $filterTypId; }
  28. $stmt->execute($params);
  29. $inventory = $stmt->fetchAll();
  30. // Daten für die Filter-Dropdowns
  31. $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
  32. $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetchAll();
  33. ?>
  34. <!DOCTYPE html>
  35. <html lang="de">
  36. <head>
  37. <meta charset="UTF-8">
  38. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  39. <title>EXIT - Gesamtliste</title>
  40. <style>
  41. :root {
  42. --bg: #f8f9fa; --card: #ffffff; --text: #333; --border: #ddd;
  43. --header-bg: #2c3e50; --header-text: #ffffff; --row-border: #eee;
  44. --accent: #e67e22;
  45. }
  46. .dark-theme {
  47. --bg: #121212cf; --card: #1e1e1e; --text: #e0e0e0; --border: #333;
  48. --header-bg: #252525; --header-text: #e67e22; --row-border: #2a2a2a;
  49. }
  50. body { font-family: 'Segoe UI', sans-serif; background: var(--bg); margin: 0; padding: 20px; color: var(--text); transition: 0.3s; }
  51. .container { max-width: 1400px; margin: 0 auto; }
  52. .header-area { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
  53. .nav-group { display: flex; align-items: center; gap: 10px; }
  54. .back-link { background: var(--accent); color: white !important; text-decoration: none; font-weight: bold; padding: 10px 18px; border-radius: 6px; display: inline-block; }
  55. .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); flex-wrap: wrap; }
  56. .filter-bar form { display: flex; gap: 10px; flex-grow: 1; align-items: center; }
  57. select, input { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
  58. #searchInput { flex-grow: 1; min-width: 200px; }
  59. 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); }
  60. th { background: var(--header-bg); color: var(--header-text); text-align: left; padding: 15px; cursor: pointer; font-size: 0.85em; }
  61. td { padding: 12px 15px; border-bottom: 1px solid var(--row-border); }
  62. .game-thumb { width: 55px; height: 55px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
  63. .game-thumb:hover { transform: scale(1.1); border-color: var(--accent); }
  64. .lvl-badge { padding: 4px 10px; border-radius: 20px; color: white; font-size: 11px; font-weight: bold; text-transform: uppercase; }
  65. .lvl-Einsteiger { background: #27ae60; }
  66. .lvl-Fortgeschrittene { background: #2980b9; }
  67. .lvl-Profi { background: #c0392b; }
  68. .lvl-unknown { background: #f39c12; }
  69. .st-badge { padding: 5px 12px; border-radius: 15px; font-size: 11px; font-weight: bold; }
  70. .st-besitzt { background: #d4edda; color: #155724; }
  71. .dark-theme .st-besitzt { background: #1b4332; color: #74c69d; }
  72. .st-verkauft { background: #fff3cd; color: #856404; }
  73. .st-keins { background: #f8d7da; color: #721c24; }
  74. .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); }
  75. .dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
  76. #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; }
  77. #modalContent { max-width: 90%; max-height: 90%; border-radius: 10px; }
  78. .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; }
  79. .theme-toggle { background: none; border: none; font-size: 1.5rem; cursor: pointer; }
  80. </style>
  81. </head>
  82. <body>
  83. <div class="container">
  84. <div class="header-area">
  85. <h1>📝 Sammlungs-Übersicht</h1>
  86. <div class="nav-group">
  87. <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
  88. <a href="index.php" class="back-link">Dashboard</a>
  89. </div>
  90. </div>
  91. <div class="filter-bar">
  92. <form method="GET" id="filterForm">
  93. <select name="team_filter" onchange="this.form.submit()">
  94. <option value="0">-- Alle Teams --</option>
  95. <?php foreach ($spieler as $p): ?>
  96. <option value="<?= $p['id'] ?>" <?= $filterPlayerId == $p['id'] ? 'selected' : '' ?>><?= htmlspecialchars($p['name']) ?></option>
  97. <?php endforeach; ?>
  98. </select>
  99. <select name="typ_filter" onchange="this.form.submit()">
  100. <option value="0">-- Alle Typen --</option>
  101. <?php foreach ($typen as $t): ?>
  102. <option value="<?= $t['id'] ?>" <?= $filterTypId == $t['id'] ? 'selected' : '' ?>><?= htmlspecialchars($t['bezeichnung']) ?></option>
  103. <?php endforeach; ?>
  104. </select>
  105. </form>
  106. <input type="text" id="searchInput" placeholder="Suchen..." onkeyup="filterTable()">
  107. </div>
  108. <table id="exitTable">
  109. <thead>
  110. <tr>
  111. <th style="width: 70px;">Bild</th>
  112. <th onclick="sortTable(1)">Titel ↕</th>
  113. <th onclick="sortTable(2)">Level ↕</th>
  114. <th onclick="sortTable(3)">Bestwert ↕</th>
  115. <th>Besitzstatus</th>
  116. </tr>
  117. </thead>
  118. <tbody>
  119. <?php foreach ($inventory as $row):
  120. $lvl = (empty($row['level']) || strtolower($row['level']) == 'unknown') ? 'unknown' : $row['level'];
  121. $typ = (empty($row['typ_name']) || strtolower($row['typ_name']) == 'unknown') ? 'Unbekannt' : $row['typ_name'];
  122. ?>
  123. <tr>
  124. <td>
  125. <img src="<?= htmlspecialchars($row['bild_url']) ?>"
  126. class="game-thumb"
  127. onclick="openModal('<?= htmlspecialchars($row['bild_url']) ?>')"
  128. onmouseover="showPreview(event, '<?= htmlspecialchars($row['bild_url']) ?>')"
  129. onmouseout="hidePreview()"
  130. onerror="this.src='https://via.placeholder.com/60?text=?'">
  131. </td>
  132. <td>
  133. <strong><?= htmlspecialchars($row['titel']) ?></strong><br>
  134. <small style="opacity: 0.7;"><?= htmlspecialchars($typ) ?></small>
  135. </td>
  136. <td>
  137. <span class="lvl-badge lvl-<?= $lvl ?>">
  138. <?= ($lvl == 'unknown') ? 'Unbekannt' : $lvl ?>
  139. </span>
  140. </td>
  141. <td>
  142. <?php
  143. if ($row['best_sterne'] > 0) {
  144. echo "<b>{$row['best_sterne']} ★</b>";
  145. } elseif ($row['anzahl_scores'] > 0) {
  146. echo "<i style='opacity:0.7'>Gespielt</i>";
  147. } else {
  148. echo "-";
  149. }
  150. ?>
  151. </td>
  152. <td>
  153. <?php if ($filterPlayerId > 0):
  154. $st = $row['einzel_status'] ?: 'nicht besitzt';
  155. $class = ($st == 'besitzt') ? 'st-besitzt' : (($st == 'verkauft') ? 'st-verkauft' : 'st-keins');
  156. echo "<span class='st-badge $class'>".strtoupper($st)."</span>";
  157. else:
  158. if ($row['besitz_info']) {
  159. foreach (explode('||', $row['besitz_info']) as $t) {
  160. $parts = explode(': ', $t);
  161. if(count($parts) < 2) continue;
  162. list($tn, $ts) = $parts;
  163. $dot = ($ts == 'besitzt') ? '#27ae60' : '#f39c12';
  164. echo "<span class='team-pill'><span class='dot' style='background:$dot'></span>$tn ($ts)</span>";
  165. }
  166. } else { echo "<small>-</small>"; }
  167. endif; ?>
  168. </td>
  169. </tr>
  170. <?php endforeach; ?>
  171. </tbody>
  172. </table>
  173. </div>
  174. <div id="imgModal" onclick="this.style.display='none'"><img id="modalContent"></div>
  175. <img id="hoverPreview" class="image-preview" src="">
  176. <script>
  177. // Theme Switcher
  178. function toggleTheme() {
  179. const isDark = document.documentElement.classList.toggle('dark-theme');
  180. localStorage.setItem('theme', isDark ? 'dark' : 'light');
  181. document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
  182. }
  183. if (localStorage.getItem('theme') === 'dark') {
  184. document.documentElement.classList.add('dark-theme');
  185. document.getElementById('theme-icon').innerText = '☀️';
  186. }
  187. // Modal & Preview Logik
  188. const modal = document.getElementById("imgModal");
  189. const modalImg = document.getElementById("modalContent");
  190. function openModal(url) { modal.style.display = "flex"; modalImg.src = url; hidePreview(); }
  191. const preview = document.getElementById('hoverPreview');
  192. function showPreview(e, url) {
  193. if(modal.style.display === "flex") return;
  194. preview.src = url; preview.style.display = 'block'; updatePos(e);
  195. }
  196. function hidePreview() { preview.style.display = 'none'; }
  197. function updatePos(e) {
  198. preview.style.left = (e.pageX + 20) + 'px';
  199. preview.style.top = (e.pageY - 100) + 'px';
  200. }
  201. document.addEventListener('mousemove', (e) => { if(preview.style.display==='block') updatePos(e); });
  202. // Live-Suche
  203. function filterTable() {
  204. let val = document.getElementById("searchInput").value.toUpperCase();
  205. let tr = document.getElementById("exitTable").getElementsByTagName("tr");
  206. for (let i = 1; i < tr.length; i++) tr[i].style.display = tr[i].innerText.toUpperCase().includes(val) ? "" : "none";
  207. }
  208. // Sortierung
  209. function sortTable(n) {
  210. var table = document.getElementById("exitTable");
  211. var rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
  212. switching = true; dir = "asc";
  213. while (switching) {
  214. switching = false; rows = table.rows;
  215. for (i = 1; i < (rows.length - 1); i++) {
  216. shouldSwitch = false;
  217. x = rows[i].getElementsByTagName("TD")[n];
  218. y = rows[i + 1].getElementsByTagName("TD")[n];
  219. let valX = x.innerText.toLowerCase().trim();
  220. let valY = y.innerText.toLowerCase().trim();
  221. if (dir == "asc") { if (valX > valY) { shouldSwitch = true; break; } }
  222. else if (dir == "desc") { if (valX < valY) { shouldSwitch = true; break; } }
  223. }
  224. if (shouldSwitch) {
  225. rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
  226. switching = true; switchcount ++;
  227. } else {
  228. if (switchcount == 0 && dir == "asc") { dir = "desc"; switching = true; }
  229. }
  230. }
  231. }
  232. </script>
  233. </body>
  234. </html>