| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- require_once 'db_config.php';
- $msg = "";
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_status'])) {
- $stmt = $pdo->prepare("INSERT INTO besitzstatus (spieler_id, spiel_id, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)");
- $stmt->execute([(int)$_POST['spieler_id'], (int)$_POST['spiel_id'], $_POST['status']]);
- $msg = "Status aktualisiert!";
- }
- $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
- $spiele = $pdo->query("SELECT s.*, t.bezeichnung as typ_name FROM spiele s LEFT JOIN game_typen t ON s.typ_id = t.id ORDER BY s.titel ASC")->fetchAll();
- ?>
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <title>EXIT - Bestand</title>
- <style>
- :root { --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22; }
- .dark-theme { --bg: #121212cf; --card: #1e1e1e; --text: #e0e0e0; --border: #333; }
- body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
- .container { max-width: 1200px; margin: auto; }
-
- /* DASHBOARD BUTTON DESIGN AUS ADMIN.PHP */
- .btn-nav {
- background: var(--accent);
- color: white;
- padding: 10px 15px;
- border-radius: 6px;
- text-decoration: none;
- font-weight: bold;
- display: inline-block;
- font-size: 0.9em;
- transition: 0.2s;
- border: none;
- cursor: pointer;
- }
- .btn-nav:hover { opacity: 0.8; transform: translateY(-1px); }
- table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); }
- th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; }
-
- /* Status Einfärbung Logik */
- select { padding: 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
- select[data-status="besitzt"] { background: #d4edda !important; color: #155724 !important; }
- select[data-status="nicht besitzt"] { background: #f8d7da !important; color: #721c24 !important; }
- select[data-status="verkauft"] { background: #fff3e0 !important; color: #e67e22 !important; }
- </style>
- </head>
- <body>
- <div class="container">
- <header style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
- <h1>📦 Bestand / Besitz</h1>
- <div style="display: flex; gap: 15px; align-items: center;">
- <button onclick="toggleTheme()" id="theme-icon" style="background:none; border:none; cursor:pointer; font-size:1.2rem;">🌙</button>
- <a href="index.php" class="btn-nav">Dashboard</a>
- </div>
- </header>
- <table>
- <thead>
- <tr>
- <th>Spiel</th>
- <?php foreach ($spieler as $s): ?><th><?= htmlspecialchars($s['name']) ?></th><?php endforeach; ?>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($spiele as $sp): ?>
- <tr>
- <td><strong><?= htmlspecialchars($sp['titel']) ?></strong></td>
- <?php foreach ($spieler as $s):
- $st_stmt = $pdo->prepare("SELECT status FROM besitzstatus WHERE spieler_id = ? AND spiel_id = ?");
- $st_stmt->execute([$s['id'], $sp['id']]);
- $curr = $st_stmt->fetchColumn() ?: 'nicht besitzt';
- ?>
- <td>
- <form method="POST">
- <input type="hidden" name="update_status" value="1">
- <input type="hidden" name="spieler_id" value="<?= $s['id'] ?>">
- <input type="hidden" name="spiel_id" value="<?= $sp['id'] ?>">
- <select name="status" onchange="this.form.submit()" data-status="<?= $curr ?>">
- <option value="besitzt" <?= $curr=='besitzt'?'selected':'' ?>>Besitzt</option>
- <option value="nicht besitzt" <?= $curr=='nicht besitzt'?'selected':'' ?>>Nicht</option>
- <option value="verkauft" <?= $curr=='verkauft'?'selected':'' ?>>Verkauft</option>
- </select>
- </form>
- </td>
- <?php endforeach; ?>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <script>
- function toggleTheme() {
- const isDark = document.documentElement.classList.toggle('dark-theme');
- localStorage.setItem('theme', isDark ? 'dark' : 'light');
- document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
- }
- if (localStorage.getItem('theme') === 'dark') {
- document.documentElement.classList.add('dark-theme');
- document.getElementById('theme-icon').innerText = '☀️';
- }
- </script>
- </body>
- </html>
|