| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- require_once 'db_config.php';
- $msg = "";
- // Status-Update Logik
- 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 - Bestandsverwaltung</title>
- <style>
- body { font-family: 'Segoe UI', sans-serif; background: #121212; color: #e0e0e0; padding: 20px; }
- .container { max-width: 1200px; margin: auto; }
- h1 { color: #e67e22; }
- .alert { background: #27ae60; color: white; padding: 10px; border-radius: 5px; margin-bottom: 20px; text-align: center; }
- table { width: 100%; border-collapse: collapse; background: #1e1e1e; border-radius: 8px; overflow: hidden; }
- th, td { padding: 12px; border-bottom: 1px solid #333; text-align: left; }
- th { background: #2a2a2a; color: #e67e22; text-transform: uppercase; font-size: 0.85em; }
- .game-info { display: flex; align-items: center; gap: 15px; }
- .game-info img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid #444; }
- select { background: #2a2a2a; color: white; border: 1px solid #444; padding: 5px; border-radius: 4px; width: 100%; cursor: pointer; }
- select.besitzt { border-left: 4px solid #27ae60; }
- select.verkauft { border-left: 4px solid #f39c12; }
- select.nicht { border-left: 4px solid #7f8c8d; }
- .back-link { color: #e67e22; text-decoration: none; font-weight: bold; margin-bottom: 20px; display: inline-block; }
- </style>
- </head>
- <body>
- <div class="container">
- <a href="index.php" class="back-link">← Zurück zum Dashboard</a>
- <h1>📦 Bestandsverwaltung</h1>
-
- <?php if ($msg): ?><div class="alert" id="msg-box"><?= $msg ?></div><?php endif; ?>
- <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>
- <div class="game-info">
- <img src="<?= htmlspecialchars($sp['bild_url']) ?>">
- <div>
- <strong><?= htmlspecialchars($sp['titel']) ?></strong><br>
- <small style="color:#888"><?= htmlspecialchars($sp['typ_name']) ?></small>
- </div>
- </div>
- </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']]);
- $current = $st_stmt->fetchColumn() ?: 'nicht besitzt';
- $class = ($current == 'besitzt') ? 'besitzt' : (($current == 'verkauft') ? 'verkauft' : 'nicht');
- ?>
- <td>
- <form method="POST" style="margin:0;">
- <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" class="<?= $class ?>" onchange="this.form.submit()">
- <option value="besitzt" <?= $current == 'besitzt' ? 'selected' : '' ?>>Besitzt</option>
- <option value="nicht besitzt" <?= $current == 'nicht besitzt' ? 'selected' : '' ?>>Nicht</option>
- <option value="verkauft" <?= $current == 'verkauft' ? 'selected' : '' ?>>Verkauft</option>
- </select>
- </form>
- </td>
- <?php endforeach; ?>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <script>
- setTimeout(function() {
- var msg = document.getElementById('msg-box');
- if(msg) msg.style.opacity = '0';
- }, 2000);
- </script>
- </body>
- </html>
|