|
@@ -56,7 +56,7 @@ if ($show_login):
|
|
|
exit;
|
|
exit;
|
|
|
endif;
|
|
endif;
|
|
|
|
|
|
|
|
-// --- 3. HAUPT-LOGIK (NUR ERREICHBAR WENN EINGELOGGT) ---
|
|
|
|
|
|
|
+// --- 3. HAUPT-LOGIK ---
|
|
|
require_once 'db_config.php';
|
|
require_once 'db_config.php';
|
|
|
$msg = "";
|
|
$msg = "";
|
|
|
|
|
|
|
@@ -77,13 +77,19 @@ function downloadGameImage($ean, $url) {
|
|
|
// SPIEL HINZUFÜGEN
|
|
// SPIEL HINZUFÜGEN
|
|
|
if (isset($_POST['add_new_game'])) {
|
|
if (isset($_POST['add_new_game'])) {
|
|
|
$ean = $_POST['new_ean'];
|
|
$ean = $_POST['new_ean'];
|
|
|
- $bild_url = "https://via.placeholder.com/60";
|
|
|
|
|
|
|
+ $bild_url = "https://via.placeholder.com/60?text=Kein+Bild";
|
|
|
if (!empty($_POST['new_bild_quelle'])) {
|
|
if (!empty($_POST['new_bild_quelle'])) {
|
|
|
$downloaded = downloadGameImage($ean, $_POST['new_bild_quelle']);
|
|
$downloaded = downloadGameImage($ean, $_POST['new_bild_quelle']);
|
|
|
if ($downloaded) $bild_url = $downloaded;
|
|
if ($downloaded) $bild_url = $downloaded;
|
|
|
}
|
|
}
|
|
|
$stmt = $pdo->prepare("INSERT INTO spiele (titel, typ_id, ean, level, bild_url) VALUES (?, ?, ?, ?, ?)");
|
|
$stmt = $pdo->prepare("INSERT INTO spiele (titel, typ_id, ean, level, bild_url) VALUES (?, ?, ?, ?, ?)");
|
|
|
- $stmt->execute([$_POST['new_titel'], (int)$_POST['new_typ_id'], $ean, $_POST['new_level'], $bild_url]);
|
|
|
|
|
|
|
+ $stmt->execute([
|
|
|
|
|
+ $_POST['new_titel'],
|
|
|
|
|
+ ($_POST['new_typ_id'] == '0' ? null : (int)$_POST['new_typ_id']),
|
|
|
|
|
+ $ean,
|
|
|
|
|
+ $_POST['new_level'],
|
|
|
|
|
+ $bild_url
|
|
|
|
|
+ ]);
|
|
|
$msg = "Spiel erfolgreich angelegt!";
|
|
$msg = "Spiel erfolgreich angelegt!";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -96,7 +102,13 @@ if (isset($_POST['update_game'])) {
|
|
|
if ($new_path) $pdo->prepare("UPDATE spiele SET bild_url = ? WHERE id = ?")->execute([$new_path, $spiel_id]);
|
|
if ($new_path) $pdo->prepare("UPDATE spiele SET bild_url = ? WHERE id = ?")->execute([$new_path, $spiel_id]);
|
|
|
}
|
|
}
|
|
|
$stmt = $pdo->prepare("UPDATE spiele SET titel = ?, typ_id = ?, ean = ?, level = ? WHERE id = ?");
|
|
$stmt = $pdo->prepare("UPDATE spiele SET titel = ?, typ_id = ?, ean = ?, level = ? WHERE id = ?");
|
|
|
- $stmt->execute([$_POST['titel'], (int)$_POST['typ_id'], $ean, $_POST['level'], $spiel_id]);
|
|
|
|
|
|
|
+ $stmt->execute([
|
|
|
|
|
+ $_POST['titel'],
|
|
|
|
|
+ ($_POST['typ_id'] == '0' ? null : (int)$_POST['typ_id']),
|
|
|
|
|
+ $ean,
|
|
|
|
|
+ $_POST['level'],
|
|
|
|
|
+ $spiel_id
|
|
|
|
|
+ ]);
|
|
|
$msg = "Änderungen gespeichert!";
|
|
$msg = "Änderungen gespeichert!";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -127,23 +139,16 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
|
|
|
.container { max-width: 1200px; margin: 0 auto; }
|
|
.container { max-width: 1200px; margin: 0 auto; }
|
|
|
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
|
.alert { background: #27ae60; color: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; text-align: center; font-weight: bold; }
|
|
.alert { background: #27ae60; color: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; text-align: center; font-weight: bold; }
|
|
|
-
|
|
|
|
|
.tabs { display: flex; gap: 5px; }
|
|
.tabs { display: flex; gap: 5px; }
|
|
|
- .tab-button { padding: 12px 25px; cursor: pointer; background: #ddd; border: none; border-radius: 8px 8px 0 0; font-weight: bold; transition: 0.3s; }
|
|
|
|
|
|
|
+ .tab-button { padding: 12px 25px; cursor: pointer; background: #ddd; border: none; border-radius: 8px 8px 0 0; font-weight: bold; }
|
|
|
.tab-button.active { background: #fff; border-top: 4px solid #e67e22; color: #e67e22; }
|
|
.tab-button.active { background: #fff; border-top: 4px solid #e67e22; color: #e67e22; }
|
|
|
-
|
|
|
|
|
.tab-content { background: #fff; padding: 25px; border-radius: 0 8px 8px 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); display: none; }
|
|
.tab-content { background: #fff; padding: 25px; border-radius: 0 8px 8px 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); display: none; }
|
|
|
.tab-content.active { display: block; }
|
|
.tab-content.active { display: block; }
|
|
|
-
|
|
|
|
|
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
|
|
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
|
|
|
th, td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
|
|
th, td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
|
|
|
input, select { padding: 8px; border: 1px solid #ddd; border-radius: 5px; width: 100%; box-sizing: border-box; }
|
|
input, select { padding: 8px; border: 1px solid #ddd; border-radius: 5px; width: 100%; box-sizing: border-box; }
|
|
|
-
|
|
|
|
|
.btn { padding: 8px 15px; border: none; border-radius: 5px; color: white; cursor: pointer; font-weight: bold; text-decoration: none; display: inline-block; }
|
|
.btn { padding: 8px 15px; border: none; border-radius: 5px; color: white; cursor: pointer; font-weight: bold; text-decoration: none; display: inline-block; }
|
|
|
- .btn-add { background: #27ae60; }
|
|
|
|
|
- .btn-save { background: #2980b9; }
|
|
|
|
|
- .btn-del { background: #e74c3c; }
|
|
|
|
|
- .logout { background: #c0392b; font-size: 0.8em; }
|
|
|
|
|
|
|
+ .btn-add { background: #27ae60; } .btn-save { background: #2980b9; } .btn-del { background: #e74c3c; } .logout { background: #c0392b; font-size: 0.8em; }
|
|
|
</style>
|
|
</style>
|
|
|
</head>
|
|
</head>
|
|
|
<body>
|
|
<body>
|
|
@@ -172,10 +177,12 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
|
|
|
<div style="display:grid; grid-template-columns: 2fr 1fr 1fr 1fr 2fr; gap:10px;">
|
|
<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_titel" placeholder="Spieltitel" required>
|
|
|
<select name="new_typ_id">
|
|
<select name="new_typ_id">
|
|
|
|
|
+ <option value="0">-- Typ: Unknown --</option>
|
|
|
<?php foreach($typen as $t): ?><option value="<?= $t['id'] ?>"><?= htmlspecialchars($t['bezeichnung']) ?></option><?php endforeach; ?>
|
|
<?php foreach($typen as $t): ?><option value="<?= $t['id'] ?>"><?= htmlspecialchars($t['bezeichnung']) ?></option><?php endforeach; ?>
|
|
|
</select>
|
|
</select>
|
|
|
<input type="text" name="new_ean" placeholder="EAN" required>
|
|
<input type="text" name="new_ean" placeholder="EAN" required>
|
|
|
<select name="new_level">
|
|
<select name="new_level">
|
|
|
|
|
+ <option value="Unknown" selected>-- Level: Unknown --</option>
|
|
|
<option value="Einsteiger">Einsteiger</option>
|
|
<option value="Einsteiger">Einsteiger</option>
|
|
|
<option value="Fortgeschrittene">Fortgeschrittene</option>
|
|
<option value="Fortgeschrittene">Fortgeschrittene</option>
|
|
|
<option value="Profi">Profi</option>
|
|
<option value="Profi">Profi</option>
|
|
@@ -193,10 +200,11 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
|
|
|
<tr>
|
|
<tr>
|
|
|
<form method="POST">
|
|
<form method="POST">
|
|
|
<input type="hidden" name="spiel_id" value="<?= $sp['id'] ?>">
|
|
<input type="hidden" name="spiel_id" value="<?= $sp['id'] ?>">
|
|
|
- <td width="60"><img src="<?= $sp['bild_url'] ?>" width="50" style="border-radius:4px;"></td>
|
|
|
|
|
|
|
+ <td width="60"><img src="<?= $sp['bild_url'] ?>" width="50" style="border-radius:4px;" onerror="this.src='https://via.placeholder.com/50?text=?'"></td>
|
|
|
<td>
|
|
<td>
|
|
|
<input type="text" name="titel" value="<?= htmlspecialchars($sp['titel']) ?>" style="margin-bottom:5px;">
|
|
<input type="text" name="titel" value="<?= htmlspecialchars($sp['titel']) ?>" style="margin-bottom:5px;">
|
|
|
<select name="typ_id">
|
|
<select name="typ_id">
|
|
|
|
|
+ <option value="0" <?= $sp['typ_id'] == null ? 'selected' : '' ?>>-- Unknown --</option>
|
|
|
<?php foreach($typen as $t): ?>
|
|
<?php foreach($typen as $t): ?>
|
|
|
<option value="<?= $t['id'] ?>" <?= $sp['typ_id']==$t['id']?'selected':'' ?>><?= htmlspecialchars($t['bezeichnung']) ?></option>
|
|
<option value="<?= $t['id'] ?>" <?= $sp['typ_id']==$t['id']?'selected':'' ?>><?= htmlspecialchars($t['bezeichnung']) ?></option>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
@@ -205,14 +213,15 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
|
|
|
<td><input type="text" name="ean" value="<?= htmlspecialchars($sp['ean']) ?>"></td>
|
|
<td><input type="text" name="ean" value="<?= htmlspecialchars($sp['ean']) ?>"></td>
|
|
|
<td>
|
|
<td>
|
|
|
<select name="level">
|
|
<select name="level">
|
|
|
|
|
+ <option value="Unknown" <?= ($sp['level'] == 'Unknown' || empty($sp['level'])) ? 'selected' : '' ?>>Unknown</option>
|
|
|
<option value="Einsteiger" <?= $sp['level']=='Einsteiger'?'selected':'' ?>>Einsteiger</option>
|
|
<option value="Einsteiger" <?= $sp['level']=='Einsteiger'?'selected':'' ?>>Einsteiger</option>
|
|
|
<option value="Fortgeschrittene" <?= $sp['level']=='Fortgeschrittene'?'selected':'' ?>>Fortgeschrittene</option>
|
|
<option value="Fortgeschrittene" <?= $sp['level']=='Fortgeschrittene'?'selected':'' ?>>Fortgeschrittene</option>
|
|
|
<option value="Profi" <?= $sp['level']=='Profi'?'selected':'' ?>>Profi</option>
|
|
<option value="Profi" <?= $sp['level']=='Profi'?'selected':'' ?>>Profi</option>
|
|
|
</select>
|
|
</select>
|
|
|
</td>
|
|
</td>
|
|
|
<td style="white-space:nowrap;">
|
|
<td style="white-space:nowrap;">
|
|
|
- <button type="submit" name="update_game" class="btn btn-save" title="Speichern">💾</button>
|
|
|
|
|
- <button type="submit" name="delete_game" class="btn btn-del" onclick="return confirm('Wirklich löschen?')" title="Löschen">🗑</button>
|
|
|
|
|
|
|
+ <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>
|
|
</td>
|
|
|
</form>
|
|
</form>
|
|
|
</tr>
|
|
</tr>
|
|
@@ -229,36 +238,20 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
|
|
|
</form>
|
|
</form>
|
|
|
<table>
|
|
<table>
|
|
|
<?php foreach ($spieler as $s): ?>
|
|
<?php foreach ($spieler as $s): ?>
|
|
|
- <tr>
|
|
|
|
|
- <td><?= htmlspecialchars($s['name']) ?></td>
|
|
|
|
|
- <td width="50">
|
|
|
|
|
- <form method="POST">
|
|
|
|
|
- <input type="hidden" name="player_id" value="<?= $s['id'] ?>">
|
|
|
|
|
- <button type="submit" name="delete_player" class="btn btn-del">🗑</button>
|
|
|
|
|
- </form>
|
|
|
|
|
- </td>
|
|
|
|
|
- </tr>
|
|
|
|
|
|
|
+ <tr><td><?= htmlspecialchars($s['name']) ?></td><td><form method="POST"><input type="hidden" name="player_id" value="<?= $s['id'] ?>"><button type="submit" name="delete_player" class="btn btn-del">🗑</button></form></td></tr>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
|
</table>
|
|
</table>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div id="tab-typen" class="tab-content">
|
|
<div id="tab-typen" class="tab-content">
|
|
|
- <h3>🏷 Spiel-Typen (z.B. EXIT, Adventure Games)</h3>
|
|
|
|
|
|
|
+ <h3>🏷 Spiel-Typen</h3>
|
|
|
<form method="POST" style="display:flex; gap:10px; margin-bottom:20px;">
|
|
<form method="POST" style="display:flex; gap:10px; margin-bottom:20px;">
|
|
|
<input type="text" name="type_name" placeholder="Typ-Bezeichnung" required>
|
|
<input type="text" name="type_name" placeholder="Typ-Bezeichnung" required>
|
|
|
<button type="submit" name="add_type" class="btn btn-add">Anlegen</button>
|
|
<button type="submit" name="add_type" class="btn btn-add">Anlegen</button>
|
|
|
</form>
|
|
</form>
|
|
|
<table>
|
|
<table>
|
|
|
<?php foreach ($typen as $t): ?>
|
|
<?php foreach ($typen as $t): ?>
|
|
|
- <tr>
|
|
|
|
|
- <td><?= htmlspecialchars($t['bezeichnung']) ?></td>
|
|
|
|
|
- <td width="50">
|
|
|
|
|
- <form method="POST">
|
|
|
|
|
- <input type="hidden" name="type_id" value="<?= $t['id'] ?>">
|
|
|
|
|
- <button type="submit" name="delete_type" class="btn btn-del">🗑</button>
|
|
|
|
|
- </form>
|
|
|
|
|
- </td>
|
|
|
|
|
- </tr>
|
|
|
|
|
|
|
+ <tr><td><?= htmlspecialchars($t['bezeichnung']) ?></td><td><form method="POST"><input type="hidden" name="type_id" value="<?= $t['id'] ?>"><button type="submit" name="delete_type" class="btn btn-del">🗑</button></form></td></tr>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
|
</table>
|
|
</table>
|
|
|
</div>
|
|
</div>
|
|
@@ -274,12 +267,7 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
|
|
|
document.getElementById(tabName).style.display = "block";
|
|
document.getElementById(tabName).style.display = "block";
|
|
|
evt.currentTarget.className += " active";
|
|
evt.currentTarget.className += " active";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- setTimeout(function() {
|
|
|
|
|
- var msg = document.getElementById('msg-box');
|
|
|
|
|
- if(msg) msg.style.display = 'none';
|
|
|
|
|
- }, 3000);
|
|
|
|
|
|
|
+ setTimeout(function() { var msg = document.getElementById('msg-box'); if(msg) msg.style.display = 'none'; }, 3000);
|
|
|
</script>
|
|
</script>
|
|
|
-
|
|
|
|
|
</body>
|
|
</body>
|
|
|
</html>
|
|
</html>
|