diff --git a/admin.php b/admin.php
index 03f9c45..e7ea284 100644
--- a/admin.php
+++ b/admin.php
@@ -41,6 +41,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
$slug = $_POST['slug'];
$icon = $_POST['icon'];
$description = $_POST['description'];
+ $modifier_ids = isset($_POST['modifiers']) ? $_POST['modifiers'] : [];
if ($id > 0) {
$stmt = $db->prepare("UPDATE celestial_object_types SET name = ?, slug = ?, icon = ?, description = ? WHERE id = ?");
@@ -48,7 +49,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
} else {
$stmt = $db->prepare("INSERT INTO celestial_object_types (name, slug, icon, description) VALUES (?, ?, ?, ?)");
$stmt->execute([$name, $slug, $icon, $description]);
+ $id = $db->lastInsertId();
}
+
+ // Sync modifiers
+ $db->prepare("DELETE FROM celestial_object_type_modifiers WHERE celestial_object_type_id = ?")->execute([$id]);
+ if (!empty($modifier_ids)) {
+ $ins = $db->prepare("INSERT INTO celestial_object_type_modifiers (celestial_object_type_id, modifier_id) VALUES (?, ?)");
+ foreach ($modifier_ids as $mid) {
+ $ins->execute([$id, (int)$mid]);
+ }
+ }
+
header("Location: admin.php?tab=objects&success=1");
exit;
}
@@ -87,7 +99,7 @@ if (isset($_GET['delete_status'])) {
}
// Handle Settlement Type CRUD
-if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_settlement') {
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_settlement_type') {
$id = (int)$_POST['id'];
$name = $_POST['name'];
$slug = $_POST['slug'];
@@ -100,14 +112,39 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
$stmt = $db->prepare("INSERT INTO settlement_types (name, slug, description) VALUES (?, ?, ?)");
$stmt->execute([$name, $slug, $description]);
}
- header("Location: admin.php?tab=settlements&success=1");
+ header("Location: admin.php?tab=settlement_types&success=1");
exit;
}
-if (isset($_GET['delete_settlement'])) {
- $id = (int)$_GET['delete_settlement'];
+if (isset($_GET['delete_settlement_type'])) {
+ $id = (int)$_GET['delete_settlement_type'];
$db->prepare("DELETE FROM settlement_types WHERE id = ?")->execute([$id]);
- header("Location: admin.php?tab=settlements&success=1");
+ header("Location: admin.php?tab=settlement_types&success=1");
+ exit;
+}
+
+// Handle Modifiers CRUD
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_modifier') {
+ $id = (int)$_POST['id'];
+ $name = $_POST['name'];
+ $type = $_POST['type'];
+ $description = $_POST['description'];
+
+ if ($id > 0) {
+ $stmt = $db->prepare("UPDATE modifiers SET name = ?, type = ?, description = ? WHERE id = ?");
+ $stmt->execute([$name, $type, $description, $id]);
+ } else {
+ $stmt = $db->prepare("INSERT INTO modifiers (name, type, description) VALUES (?, ?, ?)");
+ $stmt->execute([$name, $type, $description]);
+ }
+ header("Location: admin.php?tab=modifiers&success=1");
+ exit;
+}
+
+if (isset($_GET['delete_modifier'])) {
+ $id = (int)$_GET['delete_modifier'];
+ $db->prepare("DELETE FROM modifiers WHERE id = ?")->execute([$id]);
+ header("Location: admin.php?tab=modifiers&success=1");
exit;
}
@@ -115,16 +152,26 @@ if (isset($_GET['delete_settlement'])) {
$users_list = [];
$objects_list = [];
$statuses_list = [];
-$settlements_list = [];
+$settlement_types_list = [];
+$modifiers_list = [];
if ($tab === 'users') {
$users_list = $db->query("SELECT id, username, email, role FROM users ORDER BY username ASC")->fetchAll();
} elseif ($tab === 'objects') {
$objects_list = $db->query("SELECT * FROM celestial_object_types ORDER BY name ASC")->fetchAll();
+ // For each object, get its modifiers
+ foreach ($objects_list as &$obj) {
+ $stmt = $db->prepare("SELECT modifier_id FROM celestial_object_type_modifiers WHERE celestial_object_type_id = ?");
+ $stmt->execute([$obj['id']]);
+ $obj['modifier_ids'] = $stmt->fetchAll(PDO::FETCH_COLUMN);
+ }
+ $modifiers_list = $db->query("SELECT * FROM modifiers ORDER BY type, name ASC")->fetchAll();
} elseif ($tab === 'statuses') {
$statuses_list = $db->query("SELECT * FROM celestial_object_statuses ORDER BY name ASC")->fetchAll();
-} elseif ($tab === 'settlements') {
- $settlements_list = $db->query("SELECT * FROM settlement_types ORDER BY name ASC")->fetchAll();
+} elseif ($tab === 'settlement_types') {
+ $settlement_types_list = $db->query("SELECT * FROM settlement_types ORDER BY name ASC")->fetchAll();
+} elseif ($tab === 'modifiers') {
+ $modifiers_list = $db->query("SELECT * FROM modifiers ORDER BY type, name ASC")->fetchAll();
}
?>
@@ -142,7 +189,7 @@ if ($tab === 'users') {
.nav-links a:hover { color: #fff; }
.container { padding: 40px; max-width: 1200px; margin: 0 auto; }
- .tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 2px solid #2d3545; }
+ .tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 2px solid #2d3545; flex-wrap: wrap; }
.tab-link { padding: 10px 20px; text-decoration: none; color: #8c92a3; background: #0a0f1d; border: 1px solid #2d3545; border-bottom: none; font-weight: bold; font-size: 14px; }
.tab-link.active { background: #1a202c; color: #88c0d0; border-bottom: 2px solid #88c0d0; }
@@ -162,6 +209,10 @@ if ($tab === 'users') {
.btn-ok { background: #88c0d0; color: #000; }
.success-msg { background: #a3be8c; color: #000; padding: 10px; margin-bottom: 20px; border-radius: 4px; font-weight: bold; }
+
+ .modifier-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: bold; margin-right: 5px; margin-bottom: 5px; }
+ .tag-bonus { background: #a3be8c; color: #000; }
+ .tag-malus { background: #bf616a; color: #fff; }
@@ -186,8 +237,9 @@ if ($tab === 'users') {
@@ -244,7 +296,24 @@ if ($tab === 'users') {
-
- | Icône | Nom | Slug | Actions |
+ | Icône | Nom | Slug | Bonus/Malus | Actions |
|
|
|
+
+ prepare("SELECT m.name, m.type FROM modifiers m JOIN celestial_object_type_modifiers cotm ON m.id = cotm.modifier_id WHERE cotm.celestial_object_type_id = ?");
+ $stmt->execute([$o['id']]);
+ $m_list = $stmt->fetchAll();
+ foreach ($m_list as $ml): ?>
+
+
+
+
+ |
Suppr
@@ -270,6 +350,56 @@ if ($tab === 'users') {
|
+
+ Gestion des Bonus & Malus
+
+
+
+ | Type | Nom | Description | Actions |
+
+
+
+ |
+
+
+
+ |
+ |
+ |
+
+
+ Suppr
+ |
+
+
+
+
+
Statuts / États