prepare("SELECT cl_scobjs_id FROM tbl_scobjs WHERE cl_scobjs_uuid = :uuid");
$stmt_insert = $db->prepare("INSERT INTO tbl_scobjs (cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity, cl_scobjs_about) VALUES (:name, :type, :subtype, :uuid, '', '')");
$stmt_update = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_name = :name, cl_scobjs_type = :type, cl_scobjs_subtype = :subtype WHERE cl_scobjs_uuid = :uuid");
foreach ($items as $item) {
$uuid = $item['reference'] ?? ($item['stdItem']['UUID'] ?? '');
if (!$uuid) continue;
$name = $item['Name'] ?? ($item['stdItem']['Name'] ?? '');
$classification = $item['classification'] ?? ''; $parts = explode('.', $classification); $type = $parts[1] ?? ($item['type'] ?? '');
$subtype = $parts[2] ?? ($item['subType'] ?? '');
$stmt_check->execute(['uuid' => $uuid]);
if ($stmt_check->fetch()) {
$stmt_update->execute([
'name' => $name,
'type' => $type,
'subtype' => $subtype,
'uuid' => $uuid
]);
$count_updated++;
} else {
$stmt_insert->execute([
'name' => $name,
'type' => $type,
'subtype' => $subtype,
'uuid' => $uuid
]);
$count_new++;
}
}
auth_flash_set('success', "Importation terminée : $count_new nouveaux, $count_updated mis à jour.");
}
}
header('Location: scitems.php');
exit;
}
if ($action === 'update_item') {
$id = (int)$_POST['id'];
$rarity = trim($_POST['rarity'] ?? '');
$about = trim($_POST['about'] ?? '');
$stmt = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_rarity = :rarity, cl_scobjs_about = :about WHERE cl_scobjs_id = :id");
$stmt->execute(['rarity' => $rarity, 'about' => $about, 'id' => $id]);
auth_flash_set('success', "Objet mis à jour avec succès.");
header('Location: scitems.php?page=' . $page . '&search=' . urlencode($search));
exit;
}
}
// Fetch items
$sql_count = "SELECT COUNT(*) FROM tbl_scobjs WHERE $where";
$stmt_count = $db->prepare($sql_count);
$stmt_count->execute($params);
$total_items = (int)$stmt_count->fetchColumn();
$total_pages = ceil($total_items / $limit);
$sql_items = "SELECT * FROM tbl_scobjs WHERE $where ORDER BY cl_scobjs_name ASC LIMIT $limit OFFSET $offset";
$stmt_items = $db->prepare($sql_items);
$stmt_items->execute($params);
$items_list = $stmt_items->fetchAll();
$current_session_user = $_SESSION['user'] ?? '';
$edit_id = isset($_GET['edit']) ? (int)$_GET['edit'] : 0;
$edit_item = null;
if ($edit_id > 0) {
$stmt_edit = $db->prepare("SELECT * FROM tbl_scobjs WHERE cl_scobjs_id = :id");
$stmt_edit->execute(['id' => $edit_id]);
$edit_item = $stmt_edit->fetch();
}
?>
Gestion des Objets | R.E.A.C.T. Admin
Base de Données d'Objets
entrées
| Aperçu |
Nom / UUID / Type |
About |
Actions |
| Aucun objet trouvé. |
|
|
|
|
Editer
|
1): ?>