|
|
@@ -5,18 +5,12 @@ require_once 'db_config.php';
|
|
|
|
|
|
// --- 1. LOGIN / LOGOUT SCHUTZ ---
|
|
|
if (isset($_GET['logout'])) { session_destroy(); header("Location: admin.php"); exit; }
|
|
|
-
|
|
|
-$show_login = true;
|
|
|
-if (isset($_SESSION['admin_auth']) && $_SESSION['admin_auth'] === true) { $show_login = false; }
|
|
|
-
|
|
|
if (isset($_POST['login_auth'])) {
|
|
|
- if ($_POST['pw'] === ADMIN_PASSWORD) {
|
|
|
- $_SESSION['admin_auth'] = true;
|
|
|
- $show_login = false;
|
|
|
- } else { $login_error = "Falsches Passwort!"; }
|
|
|
+ if ($_POST['pw'] === ADMIN_PASSWORD) { $_SESSION['admin_auth'] = true; }
|
|
|
}
|
|
|
+$is_admin = (isset($_SESSION['admin_auth']) && $_SESSION['admin_auth'] === true);
|
|
|
|
|
|
-if ($show_login):
|
|
|
+if (!$is_admin):
|
|
|
?>
|
|
|
<!DOCTYPE html>
|
|
|
<html lang="de">
|
|
|
@@ -24,333 +18,239 @@ if ($show_login):
|
|
|
<meta charset="UTF-8">
|
|
|
<title>Admin Login</title>
|
|
|
<style>
|
|
|
- :root { --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; }
|
|
|
- .dark-theme { --bg: #121212cf; --card: #1e1e1e; --text: #e0e0e0; --border: #333; }
|
|
|
- body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
|
|
|
- .login-box { background: var(--card); padding: 40px; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; width: 300px; }
|
|
|
- input { width: 100%; padding: 12px; margin: 15px 0; border-radius: 5px; border: 1px solid var(--border); background: var(--card); color: var(--text); box-sizing: border-box; }
|
|
|
- button { background: #e67e22; color: white; border: none; padding: 12px; border-radius: 5px; cursor: pointer; width: 100%; font-weight: bold; }
|
|
|
+ body { font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: #f4f7f6; margin: 0; }
|
|
|
+ .login-box { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); text-align: center; }
|
|
|
+ input { width: 100%; padding: 10px; margin: 10px 0; box-sizing: border-box; border: 1px solid #ddd; border-radius: 4px; }
|
|
|
+ button { width: 100%; padding: 10px; background: #e67e22; color: white; border: none; cursor: pointer; border-radius: 4px; font-weight: bold; }
|
|
|
</style>
|
|
|
- <script>if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');</script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="login-box">
|
|
|
- <h2>🔐 Admin Login</h2>
|
|
|
- <?php if(isset($login_error)) echo "<div style='color:red; margin-bottom:10px;'>$login_error</div>"; ?>
|
|
|
- <form method="POST">
|
|
|
- <input type="password" name="pw" placeholder="Passwort" autofocus required>
|
|
|
- <button type="submit" name="login_auth">Einloggen</button>
|
|
|
- </form>
|
|
|
+ <h2>🔒 Admin Login</h2>
|
|
|
+ <form method="POST"><input type="password" name="pw" placeholder="Passwort" autofocus required><button type="submit" name="login_auth">Einloggen</button></form>
|
|
|
</div>
|
|
|
</body>
|
|
|
</html>
|
|
|
<?php exit; endif; ?>
|
|
|
|
|
|
<?php
|
|
|
-// --- 2. DATENBANK LOGIK ---
|
|
|
+// --- 2. VERARBEITUNG DER FORMULARE ---
|
|
|
$msg = "";
|
|
|
-$msg_type = "success";
|
|
|
|
|
|
-// Spiel hinzufügen
|
|
|
-if (isset($_POST['add_new_game'])) {
|
|
|
- $ean = trim($_POST['new_ean']);
|
|
|
- $titel = trim($_POST['new_titel']);
|
|
|
- $level = (empty($_POST['new_level']) || $_POST['new_level'] == 'Unknown') ? 'Unknown' : $_POST['new_level'];
|
|
|
- $typ_id = ($_POST['new_typ_id'] == '0') ? null : (int)$_POST['new_typ_id'];
|
|
|
- $bild_url = trim($_POST['new_bild_url']);
|
|
|
-
|
|
|
- try {
|
|
|
- $stmt = $pdo->prepare("INSERT INTO spiele (titel, typ_id, ean, level, bild_url) VALUES (?, ?, ?, ?, ?)");
|
|
|
- $stmt->execute([$titel, $typ_id, $ean, $level, $bild_url]);
|
|
|
- $msg = "✅ Spiel erfolgreich angelegt!";
|
|
|
- } catch (PDOException $e) {
|
|
|
- if ($e->getCode() == 23000) {
|
|
|
- $msg = "❌ Fehler: EAN existiert bereits!";
|
|
|
- $msg_type = "error";
|
|
|
- } else { $msg = "Fehler: " . $e->getMessage(); }
|
|
|
- }
|
|
|
+// SPIELE (Add/Update/Delete)
|
|
|
+if (isset($_POST['add_game'])) {
|
|
|
+ $stmt = $pdo->prepare("INSERT INTO spiele (game_reihe_id, titel, game_typ_id, game_level_id, ean, bild_url) VALUES (?,?,?,?,?,?)");
|
|
|
+ $stmt->execute([(int)$_POST['r_id'], $_POST['titel'], (int)$_POST['t_id'], (int)$_POST['l_id'], $_POST['ean'], $_POST['url']]);
|
|
|
+ $msg = "✅ Spiel hinzugefügt!";
|
|
|
}
|
|
|
-
|
|
|
-// Spiel updaten
|
|
|
-if (isset($_POST['update_game'])) {
|
|
|
- $stmt = $pdo->prepare("UPDATE spiele SET titel = ?, typ_id = ?, ean = ?, level = ?, bild_url = ? WHERE id = ?");
|
|
|
- $stmt->execute([$_POST['titel'], ($_POST['typ_id'] == '0' ? null : (int)$_POST['typ_id']), $_POST['ean'], $_POST['level'], $_POST['bild_url'], (int)$_POST['spiel_id']]);
|
|
|
+if (isset($_POST['upd_game'])) {
|
|
|
+ $stmt = $pdo->prepare("UPDATE spiele SET game_reihe_id=?, titel=?, game_typ_id=?, game_level_id=?, ean=?, bild_url=? WHERE id=?");
|
|
|
+ $stmt->execute([(int)$_POST['r_id'], $_POST['titel'], (int)$_POST['t_id'], (int)$_POST['l_id'], $_POST['ean'], $_POST['url'], (int)$_POST['id']]);
|
|
|
$msg = "💾 Änderungen gespeichert!";
|
|
|
}
|
|
|
|
|
|
-// Spiele-Typ hinzufügen
|
|
|
-if (isset($_POST['add_new_typ'])) {
|
|
|
- $bez = trim($_POST['new_typ_bez']);
|
|
|
- if(!empty($bez)) {
|
|
|
- $pdo->prepare("INSERT INTO game_typen (bezeichnung) VALUES (?)")->execute([$bez]);
|
|
|
- $msg = "✅ Neuer Typ '$bez' hinzugefügt!";
|
|
|
- }
|
|
|
+// SPIELER
|
|
|
+if (isset($_POST['add_spieler'])) {
|
|
|
+ $pdo->prepare("INSERT INTO spieler (name) VALUES (?)")->execute([$_POST['name']]);
|
|
|
}
|
|
|
|
|
|
-// Spiele-Typ löschen
|
|
|
-if (isset($_POST['delete_typ'])) {
|
|
|
- try {
|
|
|
- $pdo->prepare("DELETE FROM game_typen WHERE id = ?")->execute([(int)$_POST['typ_id']]);
|
|
|
- $msg = "🗑 Typ gelöscht!";
|
|
|
- } catch (Exception $e) {
|
|
|
- $msg = "❌ Fehler: Typ wird noch von Spielen verwendet!";
|
|
|
- $msg_type = "error";
|
|
|
- }
|
|
|
-}
|
|
|
+// REIHEN / TYPEN / LEVEL
|
|
|
+if (isset($_POST['add_reihe'])) { $pdo->prepare("INSERT INTO game_reihe (name) VALUES (?)")->execute([$_POST['name']]); }
|
|
|
+if (isset($_POST['add_typ'])) { $pdo->prepare("INSERT INTO game_typ (game_reihe_id, bezeichnung) VALUES (?,?)")->execute([$_POST['r_id'], $_POST['bez']]); }
|
|
|
+if (isset($_POST['add_level'])) { $pdo->prepare("INSERT INTO game_level (game_reihe_id, bezeichnung) VALUES (?,?)")->execute([$_POST['r_id'], $_POST['bez']]); }
|
|
|
|
|
|
-// Spiel löschen
|
|
|
-if (isset($_POST['delete_game'])) {
|
|
|
- $pdo->prepare("DELETE FROM spiele WHERE id = ?")->execute([(int)$_POST['spiel_id']]);
|
|
|
- $msg = "🗑 Spiel gelöscht!";
|
|
|
-}
|
|
|
-
|
|
|
-// NEU: Spieler umbenennen
|
|
|
-if (isset($_POST['rename_player'])) {
|
|
|
- $p_id = (int)$_POST['player_id'];
|
|
|
- $p_name = trim($_POST['new_name']);
|
|
|
- if (!empty($p_name)) {
|
|
|
- $pdo->prepare("UPDATE spieler SET name = ? WHERE id = ?")->execute([$p_name, $p_id]);
|
|
|
- $msg = "💾 Teamname aktualisiert!";
|
|
|
+// LÖSCHEN (Universal)
|
|
|
+if (isset($_GET['del_table']) && isset($_GET['del_id'])) {
|
|
|
+ $allowed = ['spiele', 'spieler', 'game_reihe', 'game_typ', 'game_level'];
|
|
|
+ if (in_array($_GET['del_table'], $allowed)) {
|
|
|
+ $stmt = $pdo->prepare("DELETE FROM `".$_GET['del_table']."` WHERE id = ?");
|
|
|
+ $stmt->execute([(int)$_GET['del_id']]);
|
|
|
+ header("Location: admin.php"); exit;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Spieler löschen
|
|
|
-if (isset($_POST['delete_player'])) {
|
|
|
- $pdo->prepare("DELETE FROM spieler WHERE id = ?")->execute([(int)$_POST['player_id']]);
|
|
|
- $msg = "👤 Spieler/Team gelöscht!";
|
|
|
-}
|
|
|
-
|
|
|
-$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.id DESC")->fetchAll();
|
|
|
-$typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetchAll();
|
|
|
-$spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
|
|
|
+// --- 3. DATEN LADEN ---
|
|
|
+$reihen = $pdo->query("SELECT * FROM game_reihe ORDER BY name")->fetchAll();
|
|
|
+$typen = $pdo->query("SELECT * FROM game_typ ORDER BY bezeichnung")->fetchAll();
|
|
|
+$levels = $pdo->query("SELECT * FROM game_level ORDER BY bezeichnung")->fetchAll();
|
|
|
+$spieler = $pdo->query("SELECT * FROM spieler ORDER BY name")->fetchAll();
|
|
|
+$spiele = $pdo->query("SELECT s.*, r.name as r_name FROM spiele s LEFT JOIN game_reihe r ON s.game_reihe_id = r.id ORDER BY s.id DESC")->fetchAll();
|
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
<html lang="de">
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
- <title>EXIT Admin - Stammdaten</title>
|
|
|
+ <title>Admin Dashboard</title>
|
|
|
<style>
|
|
|
- :root {
|
|
|
- --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
|
|
|
- --header-bg: #f8f9fa; --input-bg: #fff; --unknown-bg: #fff3e0;
|
|
|
- }
|
|
|
- .dark-theme {
|
|
|
- --bg: #121212cf; --card: #1e1e1e; --text: #e0e0e0; --border: #333;
|
|
|
- --header-bg: #252525; --header-text: #e67e22; --input-bg: #2a2a2a; --unknown-bg: #4d2b00;
|
|
|
- }
|
|
|
-
|
|
|
- body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
|
|
|
- .container { max-width: 1500px; margin: 0 auto; }
|
|
|
+ :root { --accent: #e67e22; --bg: #f4f7f6; --card: #fff; --text: #333; --border: #ddd; }
|
|
|
+ .dark-theme { --bg: #1a1a1a; --card: #2d2d2d; --text: #eee; --border: #444; }
|
|
|
+ body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); margin: 0; padding: 20px; transition: 0.3s; }
|
|
|
+ .container { max-width: 1400px; margin: 0 auto; }
|
|
|
|
|
|
- .tab-nav { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid var(--border); padding-bottom: 10px; flex-wrap: wrap; }
|
|
|
- .tab-btn { padding: 10px 20px; border: none; background: none; color: var(--text); cursor: pointer; font-weight: bold; border-radius: 8px; transition: 0.2s; }
|
|
|
- .tab-btn.active { background: var(--accent); color: white; }
|
|
|
- .tab-content { display: none; }
|
|
|
- .tab-content.active { display: block; }
|
|
|
-
|
|
|
- .admin-card { background: var(--card); padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); margin-bottom: 30px; border: 1px solid var(--border); }
|
|
|
- .alert { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: bold; text-align: center; border: 1px solid transparent; }
|
|
|
- .alert-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }
|
|
|
- .alert-error { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
|
|
|
-
|
|
|
- table { width: 100%; border-collapse: collapse; margin-top: 10px; background: var(--card); }
|
|
|
- th { background: var(--header-bg); padding: 12px; text-align: left; font-size: 0.85em; border-bottom: 2px solid var(--border); color: var(--text); }
|
|
|
- td { padding: 10px; border-bottom: 1px solid var(--border); }
|
|
|
-
|
|
|
- input, select { padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); color: var(--text); width: 100%; box-sizing: border-box; }
|
|
|
-
|
|
|
- .btn { padding: 10px 15px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; color: white; text-decoration: none; display: inline-block; }
|
|
|
- .btn-add { background: #27ae60; margin-top: 10px; width: 100%; }
|
|
|
- .btn-save { background: #2980b9; }
|
|
|
- .btn-del { background: #c0392b; }
|
|
|
+ /* Header & Buttons */
|
|
|
+ .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
|
+ .header-btns { display: flex; gap: 10px; align-items: center; }
|
|
|
+ .btn { padding: 8px 15px; border: none; border-radius: 6px; cursor: pointer; color: white; text-decoration: none; font-weight: bold; font-size: 0.9em; transition: 0.2s; }
|
|
|
+ .btn-s { background: #2980b9; } .btn-s:hover { background: #3498db; }
|
|
|
+ .btn-d { background: #c0392b; } .btn-d:hover { background: #e74c3c; }
|
|
|
+ .btn-a { background: #27ae60; } .btn-a:hover { background: #2ecc71; }
|
|
|
.btn-nav { background: var(--accent); }
|
|
|
+ #theme-icon { background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 5px; }
|
|
|
|
|
|
- .img-preview { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
|
|
|
- .lvl-unknown { background: var(--unknown-bg) !important; color: #e67e22 !important; }
|
|
|
+ /* Tabs */
|
|
|
+ .nav-tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 2px solid var(--border); padding-bottom: 10px; }
|
|
|
+ .t-btn { padding: 10px 20px; border: none; background: transparent; color: var(--text); cursor: pointer; font-weight: bold; border-radius: 6px; }
|
|
|
+ .t-btn.active { background: var(--accent); color: white; }
|
|
|
+ .tab { display: none; background: var(--card); padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid var(--border); }
|
|
|
+ .tab.active { display: block; }
|
|
|
|
|
|
- #scrollToTop { position: fixed; bottom: 30px; right: 30px; background: var(--accent); color: white; width: 45px; height: 45px; border-radius: 50%; border: none; cursor: pointer; display: none; }
|
|
|
+ /* Table & Forms */
|
|
|
+ table { width: 100%; border-collapse: collapse; margin-top: 15px; }
|
|
|
+ th { text-align: left; padding: 12px; border-bottom: 2px solid var(--border); background: rgba(0,0,0,0.02); }
|
|
|
+ td { padding: 10px; border-bottom: 1px solid var(--border); }
|
|
|
+ input, select { padding: 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); width: 100%; box-sizing: border-box; }
|
|
|
+ .alert { padding: 15px; background: #d4edda; color: #155724; border-radius: 8px; margin-bottom: 20px; text-align: center; font-weight: bold; }
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
|
|
|
<div class="container">
|
|
|
- <div style="display:flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
|
|
- <h1>🛠 Admin-Bereich</h1>
|
|
|
- <div style="display: flex; align-items: center; gap: 10px;">
|
|
|
- <button onclick="toggleTheme()" class="theme-toggle" style="background:none; border:none; font-size:1.5rem; cursor:pointer;" id="theme-icon">🌙</button>
|
|
|
- <a href="index.php" class="btn btn-nav">Dashboard</a>
|
|
|
- <a href="admin.php?logout=1" class="btn btn-del">Logout</a>
|
|
|
+ <div class="header">
|
|
|
+ <h1>🛠 Admin Dashboard</h1>
|
|
|
+ <div class="header-btns">
|
|
|
+ <button onclick="toggleTheme()" id="theme-icon">🌙</button>
|
|
|
+ <a href="index.php" class="btn btn-nav">Katalog</a>
|
|
|
+ <a href="admin.php?logout=1" class="btn btn-d">Logout</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <?php if ($msg): ?>
|
|
|
- <div class="alert alert-<?= $msg_type ?>" id="msg-box"><?= $msg ?></div>
|
|
|
- <?php endif; ?>
|
|
|
+ <?php if($msg): ?><div class="alert" id="msgbox"><?=$msg?></div><?php endif; ?>
|
|
|
|
|
|
- <div class="tab-nav">
|
|
|
- <button class="tab-btn active" onclick="openTab(event, 'games')">🎮 Spiele</button>
|
|
|
- <button class="tab-btn" onclick="openTab(event, 'typen')">🏷 Spieletypen</button>
|
|
|
- <button class="tab-btn" onclick="openTab(event, 'players')">👥 Spieler / Teams</button>
|
|
|
+ <div class="nav-tabs">
|
|
|
+ <button class="t-btn active" onclick="openTab(event, 't-spiele')">🎮 Spiele</button>
|
|
|
+ <button class="t-btn" onclick="openTab(event, 't-spieler')">👥 Spieler</button>
|
|
|
+ <button class="t-btn" onclick="openTab(event, 't-config')">⚙️ Stammdaten</button>
|
|
|
</div>
|
|
|
|
|
|
- <div id="games" class="tab-content active">
|
|
|
- <div class="admin-card">
|
|
|
- <h3>🆕 Neues Spiel hinzufügen</h3>
|
|
|
+ <div id="t-spiele" class="tab active">
|
|
|
+ <h3>Neues Spiel hinzufügen</h3>
|
|
|
+ <form method="POST" style="display:grid; grid-template-columns: 1fr 2fr 1fr 1fr 1fr 2fr auto; gap:10px; align-items: end;">
|
|
|
+ <div><label>Reihe</label><select name="r_id" id="r_new" onchange="filter('new')" required><option value="">Wählen...</option><?php foreach($reihen as $r): ?><option value="<?=$r['id']?>"><?=$r['name']?></option><?php endforeach; ?></select></div>
|
|
|
+ <div><label>Titel</label><input type="text" name="titel" required></div>
|
|
|
+ <div><label>Typ</label><select name="t_id" id="t_new"><option value="0" data-p="0">--</option><?php foreach($typen as $t): ?><option data-p="<?=$t['game_reihe_id']?>" value="<?=$t['id']?>"><?=$t['bezeichnung']?></option><?php endforeach; ?></select></div>
|
|
|
+ <div><label>Level</label><select name="l_id" id="l_new"><option value="0" data-p="0">--</option><?php foreach($levels as $l): ?><option data-p="<?=$l['game_reihe_id']?>" value="<?=$l['id']?>"><?=$l['bezeichnung']?></option><?php endforeach; ?></select></div>
|
|
|
+ <div><label>EAN</label><input type="text" name="ean"></div>
|
|
|
+ <div><label>Bild URL</label><input type="text" name="url"></div>
|
|
|
+ <button type="submit" name="add_game" class="btn btn-a">Hinzufügen</button>
|
|
|
+ </form>
|
|
|
+
|
|
|
+ <hr style="margin: 30px 0; border: 0; border-top: 1px solid var(--border);">
|
|
|
+
|
|
|
+ <table>
|
|
|
+ <thead><tr><th>Reihe</th><th>Titel</th><th>Typ</th><th>Level</th><th style="width:100px;">Aktion</th></tr></thead>
|
|
|
+ <?php foreach($spiele as $s): ?>
|
|
|
<form method="POST">
|
|
|
- <div style="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 2fr; gap: 10px;">
|
|
|
- <input type="text" name="new_titel" placeholder="Spieltitel" required>
|
|
|
- <input type="text" name="new_ean" placeholder="EAN" required>
|
|
|
- <select name="new_typ_id">
|
|
|
- <option value="0">-- Typ: Unbekannt --</option>
|
|
|
- <?php foreach($typen as $t): ?><option value="<?= $t['id'] ?>"><?= htmlspecialchars($t['bezeichnung']) ?></option><?php endforeach; ?>
|
|
|
- </select>
|
|
|
- <select name="new_level">
|
|
|
- <option value="Unknown">-- Level: Unbekannt --</option>
|
|
|
- <option value="Einsteiger">Einsteiger</option>
|
|
|
- <option value="Fortgeschrittene">Fortgeschrittene</option>
|
|
|
- <option value="Profi">Profi</option>
|
|
|
- </select>
|
|
|
- <input type="text" name="new_bild_url" placeholder="Bild-URL">
|
|
|
- </div>
|
|
|
- <button type="submit" name="add_new_game" class="btn btn-add">In Datenbank speichern</button>
|
|
|
+ <input type="hidden" name="id" value="<?=$s['id']?>">
|
|
|
+ <tr>
|
|
|
+ <td><select name="r_id" id="r_<?=$s['id']?>" onchange="filter(<?=$s['id']?>)"><?php foreach($reihen as $r): ?><option value="<?=$r['id']?>" <?=$s['game_reihe_id']==$r['id']?'selected':''?>><?=$r['name']?></option><?php endforeach; ?></select></td>
|
|
|
+ <td><input type="text" name="titel" value="<?=htmlspecialchars($s['titel'])?>"></td>
|
|
|
+ <td><select name="t_id" id="t_<?=$s['id']?>"><option value="0" data-p="0">--</option><?php foreach($typen as $t): ?><option data-p="<?=$t['game_reihe_id']?>" value="<?=$t['id']?>" <?=$s['game_typ_id']==$t['id']?'selected':''?>><?=$t['bezeichnung']?></option><?php endforeach; ?></select></td>
|
|
|
+ <td><select name="l_id" id="l_<?=$s['id']?>"><option value="0" data-p="0">--</option><?php foreach($levels as $l): ?><option data-p="<?=$l['game_reihe_id']?>" value="<?=$l['id']?>" <?=$s['game_level_id']==$l['id']?'selected':''?>><?=$l['bezeichnung']?></option><?php endforeach; ?></select></td>
|
|
|
+ <td>
|
|
|
+ <div style="display:flex; gap:5px;">
|
|
|
+ <button type="submit" name="upd_game" class="btn btn-s">💾</button>
|
|
|
+ <a href="?del_table=spiele&del_id=<?=$s['id']?>" class="btn btn-d" onclick="return confirm('Löschen?')">🗑</a>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
</form>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="admin-card" style="padding:0; overflow-x:auto;">
|
|
|
- <table>
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th style="width:50px;">Bild</th>
|
|
|
- <th>Titel</th>
|
|
|
- <th style="width:120px;">EAN</th>
|
|
|
- <th style="width:140px;">Typ</th>
|
|
|
- <th style="width:140px;">Level</th>
|
|
|
- <th style="width:200px;">Bild-URL</th>
|
|
|
- <th style="width:90px;">Aktion</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <?php foreach ($spiele as $sp): ?>
|
|
|
- <tr>
|
|
|
- <form method="POST">
|
|
|
- <input type="hidden" name="spiel_id" value="<?= $sp['id'] ?>">
|
|
|
- <td><img src="<?= htmlspecialchars($sp['bild_url']) ?>" class="img-preview" onerror="this.src='https://via.placeholder.com/40?text=?';"></td>
|
|
|
- <td><input type="text" name="titel" value="<?= htmlspecialchars($sp['titel']) ?>"></td>
|
|
|
- <td><input type="text" name="ean" value="<?= htmlspecialchars($sp['ean']) ?>"></td>
|
|
|
- <td>
|
|
|
- <select name="typ_id">
|
|
|
- <option value="0">Unbekannt</option>
|
|
|
- <?php foreach($typen as $t): ?>
|
|
|
- <option value="<?= $t['id'] ?>" <?= ($sp['typ_id']==$t['id'])?'selected':'' ?>><?= htmlspecialchars($t['bezeichnung']) ?></option>
|
|
|
- <?php endforeach; ?>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select name="level">
|
|
|
- <option value="Unknown" <?= ($sp['level']=='Unknown' || empty($sp['level']))?'selected':'' ?>>Unbekannt</option>
|
|
|
- <option value="Einsteiger" <?= $sp['level']=='Einsteiger'?'selected':'' ?>>Einsteiger</option>
|
|
|
- <option value="Fortgeschrittene" <?= $sp['level']=='Fortgeschrittene'?'selected':'' ?>>Fortgeschrittene</option>
|
|
|
- <option value="Profi" <?= $sp['level']=='Profi'?'selected':'' ?>>Profi</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td><input type="text" name="bild_url" value="<?= htmlspecialchars($sp['bild_url']) ?>"></td>
|
|
|
- <td>
|
|
|
- <button type="submit" name="update_game" class="btn btn-save">💾</button>
|
|
|
- <button type="submit" name="delete_game" class="btn btn-del" onclick="return confirm('Löschen?')">🗑</button>
|
|
|
- </td>
|
|
|
- </form>
|
|
|
- </tr>
|
|
|
- <?php endforeach; ?>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </table>
|
|
|
</div>
|
|
|
|
|
|
- <div id="typen" class="tab-content">
|
|
|
- <div class="admin-card">
|
|
|
- <h3>🏷 Spieletypen verwalten</h3>
|
|
|
- <form method="POST" style="display:flex; gap:10px; margin-bottom:20px;">
|
|
|
- <input type="text" name="new_typ_bez" placeholder="z.B. Adventure Games" required>
|
|
|
- <button type="submit" name="add_new_typ" class="btn btn-add" style="margin:0; width:auto;">Hinzufügen</button>
|
|
|
- </form>
|
|
|
- <table>
|
|
|
- <thead>
|
|
|
- <tr><th>ID</th><th>Bezeichnung</th><th style="width:100px;">Aktion</th></tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <?php foreach ($typen as $t): ?>
|
|
|
- <tr>
|
|
|
- <td>#<?= $t['id'] ?></td>
|
|
|
- <td><strong><?= htmlspecialchars($t['bezeichnung']) ?></strong></td>
|
|
|
- <td>
|
|
|
- <form method="POST" onsubmit="return confirm('Typ löschen?')">
|
|
|
- <input type="hidden" name="typ_id" value="<?= $t['id'] ?>">
|
|
|
- <button type="submit" name="delete_typ" class="btn btn-del">Löschen</button>
|
|
|
- </form>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- <?php endforeach; ?>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
+ <div id="t-spieler" class="tab">
|
|
|
+ <h3>Spieler Profile</h3>
|
|
|
+ <form method="POST" style="display:flex; gap:10px; margin-bottom:20px;"><input type="text" name="name" placeholder="Name" required style="max-width:300px;"> <button type="submit" name="add_spieler" class="btn btn-a">Spieler anlegen</button></form>
|
|
|
+ <table>
|
|
|
+ <?php foreach($spieler as $sl): ?>
|
|
|
+ <tr><td><?=$sl['name']?></td><td style="text-align:right;"><a href="?del_table=spieler&del_id=<?=$sl['id']?>" class="btn btn-d">Löschen</a></td></tr>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </table>
|
|
|
</div>
|
|
|
|
|
|
- <div id="players" class="tab-content">
|
|
|
- <div class="admin-card">
|
|
|
- <h3>👥 Spieler / Teams bearbeiten</h3>
|
|
|
- <table>
|
|
|
- <thead>
|
|
|
- <tr><th>ID</th><th>Name</th><th style="width:160px;">Aktion</th></tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <?php foreach ($spieler as $p): ?>
|
|
|
- <tr>
|
|
|
- <td>#<?= $p['id'] ?></td>
|
|
|
- <form method="POST">
|
|
|
- <td>
|
|
|
- <input type="hidden" name="player_id" value="<?= $p['id'] ?>">
|
|
|
- <input type="text" name="new_name" value="<?= htmlspecialchars($p['name']) ?>" required>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <button type="submit" name="rename_player" class="btn btn-save">💾</button>
|
|
|
- <button type="submit" name="delete_player" class="btn btn-del" onclick="return confirm('Diesen Spieler wirklich löschen?')">🗑</button>
|
|
|
- </td>
|
|
|
- </form>
|
|
|
- </tr>
|
|
|
- <?php endforeach; ?>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
+ <div id="t-config" class="tab">
|
|
|
+ <div style="display:grid; grid-template-columns: 1fr 1fr 1fr; gap:30px;">
|
|
|
+ <div>
|
|
|
+ <h4>Reihen</h4>
|
|
|
+ <form method="POST" style="display:flex; gap:5px; margin-bottom:15px;"><input type="text" name="name" placeholder="Neu..."><button type="submit" name="add_reihe" class="btn btn-a">+</button></form>
|
|
|
+ <div style="max-height:400px; overflow-y:auto;">
|
|
|
+ <?php foreach($reihen as $r): ?> <div style="display:flex; justify-content:space-between; padding:5px; border-bottom:1px solid var(--border);"><span><?=$r['name']?></span> <a href="?del_table=game_reihe&del_id=<?=$r['id']?>" style="color:red; text-decoration:none;">✕</a></div> <?php endforeach; ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <h4>Typen (pro Reihe)</h4>
|
|
|
+ <form method="POST">
|
|
|
+ <select name="r_id" style="margin-bottom:5px;"><?php foreach($reihen as $r): ?><option value="<?=$r['id']?>"><?=$r['name']?></option><?php endforeach; ?></select>
|
|
|
+ <div style="display:flex; gap:5px;"><input type="text" name="bez" placeholder="Neu..."><button type="submit" name="add_typ" class="btn btn-a">+</button></div>
|
|
|
+ </form>
|
|
|
+ <div style="margin-top:15px; font-size:0.85em;">
|
|
|
+ <?php foreach($typen as $t): ?> <div style="padding:3px; border-bottom:1px solid #eee;"><?=$t['bezeichnung']?> <small>(ID: <?=$t['game_reihe_id']?>)</small> <a href="?del_table=game_typ&del_id=<?=$t['id']?>" style="color:red; float:right;">✕</a></div> <?php endforeach; ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <h4>Level (pro Reihe)</h4>
|
|
|
+ <form method="POST">
|
|
|
+ <select name="r_id" style="margin-bottom:5px;"><?php foreach($reihen as $r): ?><option value="<?=$r['id']?>"><?=$r['name']?></option><?php endforeach; ?></select>
|
|
|
+ <div style="display:flex; gap:5px;"><input type="text" name="bez" placeholder="Neu..."><button type="submit" name="add_level" class="btn btn-a">+</button></div>
|
|
|
+ </form>
|
|
|
+ <div style="margin-top:15px; font-size:0.85em;">
|
|
|
+ <?php foreach($levels as $l): ?> <div style="padding:3px; border-bottom:1px solid #eee;"><?=$l['bezeichnung']?> <small>(ID: <?=$l['game_reihe_id']?>)</small> <a href="?del_table=game_level&del_id=<?=$l['id']?>" style="color:red; float:right;">✕</a></div> <?php endforeach; ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
function openTab(evt, tabName) {
|
|
|
- let i, content, btns;
|
|
|
- content = document.getElementsByClassName("tab-content");
|
|
|
- for (i = 0; i < content.length; i++) { content[i].classList.remove("active"); }
|
|
|
- btns = document.getElementsByClassName("tab-btn");
|
|
|
- for (i = 0; i < btns.length; i++) { btns[i].classList.remove("active"); }
|
|
|
+ document.querySelectorAll(".tab").forEach(t => t.classList.remove("active"));
|
|
|
+ document.querySelectorAll(".t-btn").forEach(b => b.classList.remove("active"));
|
|
|
document.getElementById(tabName).classList.add("active");
|
|
|
evt.currentTarget.classList.add("active");
|
|
|
}
|
|
|
|
|
|
- const themeIcon = document.getElementById('theme-icon');
|
|
|
function toggleTheme() {
|
|
|
const isDark = document.documentElement.classList.toggle('dark-theme');
|
|
|
localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
|
|
- themeIcon.innerText = isDark ? '☀️' : '🌙';
|
|
|
+ document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
|
|
|
}
|
|
|
- if (localStorage.getItem('theme') === 'dark') {
|
|
|
- document.documentElement.classList.add('dark-theme');
|
|
|
- themeIcon.innerText = '☀️';
|
|
|
+
|
|
|
+ function filter(id) {
|
|
|
+ let reiheSelect = document.getElementById('r_'+id);
|
|
|
+ if(!reiheSelect) return;
|
|
|
+ let val = reiheSelect.value;
|
|
|
+
|
|
|
+ ['t_'+id, 'l_'+id].forEach(sid => {
|
|
|
+ let s = document.getElementById(sid);
|
|
|
+ if(!s) return;
|
|
|
+ s.querySelectorAll('option').forEach(o => {
|
|
|
+ let p = o.getAttribute('data-p');
|
|
|
+ o.style.display = (p == "0" || p == val) ? "block" : "none";
|
|
|
+ });
|
|
|
+ if(s.options[s.selectedIndex].style.display == "none") s.value = "0";
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- const msg = document.getElementById('msg-box');
|
|
|
- if(msg) { msg.style.transition = 'opacity 0.5s'; msg.style.opacity = '0'; }
|
|
|
- }, 3000);
|
|
|
+ document.addEventListener('DOMContentLoaded', () => {
|
|
|
+ if (localStorage.getItem('theme') === 'dark') {
|
|
|
+ document.documentElement.classList.add('dark-theme');
|
|
|
+ document.getElementById('theme-icon').innerText = '☀️';
|
|
|
+ }
|
|
|
+ filter('new');
|
|
|
+ <?php foreach($spiele as $s): ?> filter(<?=$s['id']?>); <?php endforeach; ?>
|
|
|
+ setTimeout(() => { if(document.getElementById('msgbox')) document.getElementById('msgbox').style.display='none'; }, 3000);
|
|
|
+ });
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|