gesamtliste.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. --accent: #e67e22;
  34. }
  35. .dark-theme {
  36. --bg: #121212cf; --card: #1e1e1e; --text: #e0e0e0; --border: #333;
  37. --header-bg: #252525; --header-text: #e67e22; --row-border: #2a2a2a;
  38. }
  39. body { font-family: 'Segoe UI', sans-serif; background: var(--bg); margin: 0; padding: 20px; color: var(--text); transition: 0.3s; }
  40. .container { max-width: 1400px; margin: 0 auto; }
  41. .header-area { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
  42. .nav-group { display: flex; align-items: center; gap: 10px; }
  43. .back-link {
  44. background: var(--accent);
  45. color: white !important;
  46. text-decoration: none;
  47. font-weight: bold;
  48. padding: 10px 18px;
  49. border-radius: 6px;
  50. border: none;
  51. display: inline-block;
  52. transition: 0.2s;
  53. }
  54. .back-link:hover { opacity: 0.8; transform: translateY(-1px); }
  55. .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; }
  56. .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); }
  57. select, input { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
  58. input { flex-grow: 1; }
  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.8em; }
  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: #e67e22; }
  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, .badge-unknown { background: #f39c12; color: white; }
  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. </style>
  80. <script>
  81. if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
  82. </script>
  83. </head>
  84. <body>
  85. <div class="container">
  86. <div class="header-area">
  87. <h1>📝 Sammlungs-Übersicht</h1>
  88. <div class="nav-group">
  89. <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
  90. <a href="index.php" class="back-link">Dashboard</a>
  91. </div>
  92. </div>
  93. <div class="filter-bar">
  94. <form method="GET"><select name="team_filter" onchange="this.form.submit()">
  95. <option value="0">-- Alle Teams --</option>
  96. <?php foreach ($spieler as $p): ?>
  97. <option value="<?= $p['id'] ?>" <?= $filterPlayerId == $p['id'] ? 'selected' : '' ?>><?= htmlspecialchars($p['name']) ?></option>
  98. <?php endforeach; ?>
  99. </select></form>
  100. <input type="text" id="searchInput" placeholder="Suchen..." onkeyup="filterTable()">
  101. </div>
  102. <table id="exitTable">
  103. <thead>
  104. <tr>
  105. <th onclick="sortTable(0)">ID ↕</th>
  106. <th>Bild</th>
  107. <th onclick="sortTable(2)">Titel ↕</th>
  108. <th onclick="sortTable(3)">Level ↕</th>
  109. <th onclick="sortTable(4)">Bestwert ↕</th>
  110. <th>Besitzstatus</th>
  111. </tr>
  112. </thead>
  113. <tbody>
  114. <?php foreach ($inventory as $row):
  115. $lvl = (empty($row['level']) || strtolower($row['level']) == 'unknown') ? 'unknown' : $row['level'];
  116. $typ = (empty($row['typ_name']) || strtolower($row['typ_name']) == 'unknown') ? 'Unbekannt' : $row['typ_name'];
  117. ?>
  118. <tr>
  119. <td>#<?= $row['id'] ?></td>
  120. <td>
  121. <img src="<?= htmlspecialchars($row['bild_url']) ?>"
  122. class="game-thumb"
  123. onclick="openModal('<?= htmlspecialchars($row['bild_url']) ?>')"
  124. onmouseover="showPreview(event, '<?= htmlspecialchars($row['bild_url']) ?>')"
  125. onmouseout="hidePreview()"
  126. onerror="this.src='https://via.placeholder.com/60?text=?'">
  127. </td>
  128. <td>
  129. <strong><?= htmlspecialchars($row['titel']) ?></strong><br>
  130. <?php if($typ == 'Unbekannt'): ?>
  131. <small class="lvl-badge badge-unknown" style="padding: 1px 6px; font-size: 9px;">UNBEKANNT</small>
  132. <?php else: ?>
  133. <small style="opacity: 0.7;"><?= htmlspecialchars($typ) ?></small>
  134. <?php endif; ?>
  135. </td>
  136. <td>
  137. <span class="lvl-badge lvl-<?= $lvl ?>">
  138. <?= ($lvl == 'unknown') ? 'Unbekannt' : $lvl ?>
  139. </span>
  140. </td>
  141. <td><?= $row['best_sterne'] ? "<b>{$row['best_sterne']} ★</b>" : "-" ?></td>
  142. <td>
  143. <?php if ($filterPlayerId > 0):
  144. $st = $row['einzel_status'] ?: 'nicht besitzt';
  145. $class = ($st == 'besitzt') ? 'st-besitzt' : (($st == 'verkauft') ? 'st-verkauft' : 'st-keins');
  146. echo "<span class='st-badge $class'>".strtoupper($st)."</span>";
  147. else:
  148. if ($row['besitz_info']) {
  149. foreach (explode('||', $row['besitz_info']) as $t) {
  150. $parts = explode(': ', $t);
  151. if(count($parts) < 2) continue;
  152. list($tn, $ts) = $parts;
  153. $dot = ($ts == 'besitzt') ? '#27ae60' : '#f39c12';
  154. echo "<span class='team-pill'><span class='dot' style='background:$dot'></span>$tn ($ts)</span>";
  155. }
  156. } else { echo "<small>-</small>"; }
  157. endif; ?>
  158. </td>
  159. </tr>
  160. <?php endforeach; ?>
  161. </tbody>
  162. </table>
  163. </div>
  164. <div id="imgModal" onclick="this.style.display='none'"><img id="modalContent"></div>
  165. <img id="hoverPreview" class="image-preview" src="">
  166. <script>
  167. function toggleTheme() {
  168. const isDark = document.documentElement.classList.toggle('dark-theme');
  169. localStorage.setItem('theme', isDark ? 'dark' : 'light');
  170. document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
  171. }
  172. if (localStorage.getItem('theme') === 'dark') document.getElementById('theme-icon').innerText = '☀️';
  173. const modal = document.getElementById("imgModal");
  174. const modalImg = document.getElementById("modalContent");
  175. function openModal(url) { modal.style.display = "flex"; modalImg.src = url; hidePreview(); }
  176. const preview = document.getElementById('hoverPreview');
  177. function showPreview(e, url) {
  178. if(modal.style.display === "flex") return;
  179. preview.src = url; preview.style.display = 'block'; updatePos(e);
  180. }
  181. function hidePreview() { preview.style.display = 'none'; }
  182. function updatePos(e) { preview.style.left = (e.pageX + 20) + 'px'; preview.style.top = (e.pageY - 100) + 'px'; }
  183. document.addEventListener('mousemove', (e) => { if(preview.style.display==='block') updatePos(e); });
  184. function filterTable() {
  185. let val = document.getElementById("searchInput").value.toUpperCase();
  186. let tr = document.getElementById("exitTable").getElementsByTagName("tr");
  187. for (let i = 1; i < tr.length; i++) tr[i].style.display = tr[i].innerText.toUpperCase().includes(val) ? "" : "none";
  188. }
  189. function sortTable(n) {
  190. var table = document.getElementById("exitTable");
  191. var rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
  192. switching = true;
  193. dir = "asc";
  194. while (switching) {
  195. switching = false;
  196. rows = table.rows;
  197. for (i = 1; i < (rows.length - 1); i++) {
  198. shouldSwitch = false;
  199. x = rows[i].getElementsByTagName("TD")[n];
  200. y = rows[i + 1].getElementsByTagName("TD")[n];
  201. let valX = x.innerText.toLowerCase().trim();
  202. let valY = y.innerText.toLowerCase().trim();
  203. // Spezielle Logik für ID (Zahlen)
  204. if (n === 0) {
  205. valX = parseInt(valX.replace('#', '')) || 0;
  206. valY = parseInt(valY.replace('#', '')) || 0;
  207. }
  208. if (dir == "asc") {
  209. if (valX > valY) { shouldSwitch = true; break; }
  210. } else if (dir == "desc") {
  211. if (valX < valY) { shouldSwitch = true; break; }
  212. }
  213. }
  214. if (shouldSwitch) {
  215. rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
  216. switching = true;
  217. switchcount ++;
  218. } else {
  219. if (switchcount == 0 && dir == "asc") {
  220. dir = "desc";
  221. switching = true;
  222. }
  223. }
  224. }
  225. }
  226. </script>
  227. </body>
  228. </html>