|
|
@@ -1,12 +1,9 @@
|
|
|
<?php
|
|
|
require_once 'db_config.php';
|
|
|
-$msg = "";
|
|
|
|
|
|
-// Status-Update Logik
|
|
|
+$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 = $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!";
|
|
|
}
|
|
|
@@ -18,98 +15,77 @@ $spiele = $pdo->query("SELECT s.*, t.bezeichnung as typ_name FROM spiele s LEFT
|
|
|
<html lang="de">
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
- <title>EXIT - Bestandsverwaltung</title>
|
|
|
+ <title>EXIT - Bestand</title>
|
|
|
<style>
|
|
|
- /* THEME VARIABLEN */
|
|
|
- :root {
|
|
|
- --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
|
|
|
- --table-head: #f8f9fa;
|
|
|
- }
|
|
|
- .dark-theme {
|
|
|
- --bg: #121212; --card: #1e1e1e; --text: #e0e0e0; --border: #333;
|
|
|
- --table-head: #2a2a2a;
|
|
|
- }
|
|
|
-
|
|
|
+ :root { --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22; }
|
|
|
+ .dark-theme { --bg: #121212; --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; }
|
|
|
|
|
|
- header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
|
- h1 { color: var(--accent); margin: 0; }
|
|
|
-
|
|
|
- .alert { background: #27ae60; color: white; padding: 10px; border-radius: 5px; margin-bottom: 20px; text-align: center; transition: opacity 0.5s; }
|
|
|
-
|
|
|
- table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
|
|
|
+ /* 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; }
|
|
|
- th { background: var(--table-head); color: var(--accent); 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 var(--border); }
|
|
|
|
|
|
- select { background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 8px; border-radius: 4px; width: 100%; cursor: pointer; transition: 0.3s; }
|
|
|
- select.besitzt { border-left: 4px solid #27ae60; }
|
|
|
- select.verkauft { border-left: 4px solid #f39c12; }
|
|
|
- select.nicht { border-left: 4px solid #7f8c8d; }
|
|
|
-
|
|
|
- .back-link { color: var(--accent); text-decoration: none; font-weight: bold; border: 1px solid var(--accent); padding: 5px 15px; border-radius: 6px; }
|
|
|
- .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; }
|
|
|
+ /* 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>
|
|
|
- <script>
|
|
|
- if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
|
|
|
- </script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="container">
|
|
|
- <header>
|
|
|
- <a href="index.php" class="back-link">← Dashboard</a>
|
|
|
- <div style="display: flex; align-items: center; gap: 15px;">
|
|
|
- <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
|
|
|
+ <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>
|
|
|
|
|
|
- <h1>📦 Bestandsverwaltung</h1>
|
|
|
- <p style="margin-bottom: 20px; opacity: 0.7;">Wer besitzt welches Spiel?</p>
|
|
|
-
|
|
|
- <?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; ?>
|
|
|
+ <?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'] ?: 'https://via.placeholder.com/40') ?>">
|
|
|
- <div>
|
|
|
- <strong><?= htmlspecialchars($sp['titel']) ?></strong><br>
|
|
|
- <small style="opacity: 0.6;"><?= htmlspecialchars($sp['typ_name']) ?></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </td>
|
|
|
+ <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']]);
|
|
|
- $current = $st_stmt->fetchColumn() ?: 'nicht besitzt';
|
|
|
- $class = ($current == 'besitzt') ? 'besitzt' : (($current == 'verkauft') ? 'verkauft' : 'nicht');
|
|
|
+ $curr = $st_stmt->fetchColumn() ?: 'nicht besitzt';
|
|
|
?>
|
|
|
- <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>
|
|
|
+ <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; ?>
|
|
|
@@ -123,15 +99,10 @@ $spiele = $pdo->query("SELECT s.*, t.bezeichnung as typ_name FROM spiele s LEFT
|
|
|
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 = '☀️';
|
|
|
}
|
|
|
-
|
|
|
- setTimeout(function() {
|
|
|
- var msg = document.getElementById('msg-box');
|
|
|
- if(msg) msg.style.opacity = '0';
|
|
|
- }, 2000);
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|