From cb6108277537cdf4ca46fcde963152034f297b5e Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 8 Apr 2026 02:12:38 +0000 Subject: [PATCH] Autosave: 20260408-021238 --- scitems.php | 287 +++++++++++++++++++++------------------------------- 1 file changed, 116 insertions(+), 171 deletions(-) diff --git a/scitems.php b/scitems.php index 977498f..54c2211 100644 --- a/scitems.php +++ b/scitems.php @@ -57,16 +57,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $count_updated = 0; $stmt_check = $db->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"); + $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, '', :about)"); + $stmt_update = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_name = :name, cl_scobjs_type = :type, cl_scobjs_subtype = :subtype, cl_scobjs_about = :about WHERE cl_scobjs_uuid = :uuid"); foreach ($items as $item) { $uuid = $item['reference'] ?? ($item['stdItem']['UUID'] ?? ''); if (!$uuid) continue; - $name = $item['stdItem']['Name'] ?? ''; + $manufacturer = $item['manufacturer'] ?? ($item['stdItem']['Manufacturer']['Code'] ?? ''); + $raw_name = $item['stdItem']['Name'] ?? ''; + $name = ($manufacturer && strpos($raw_name, $manufacturer) === false) ? "[$manufacturer] $raw_name" : $raw_name; + $type = $item['type'] ?? ''; $subtype = $item['subType'] ?? ''; + $about = $item['stdItem']['Description'] ?? ''; $stmt_check->execute(['uuid' => $uuid]); if ($stmt_check->fetch()) { @@ -74,6 +78,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'name' => $name, 'type' => $type, 'subtype' => $subtype, + 'about' => $about, 'uuid' => $uuid ]); $count_updated++; @@ -82,7 +87,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'name' => $name, 'type' => $type, 'subtype' => $subtype, - 'uuid' => $uuid + 'uuid' => $uuid, + 'about' => $about ]); $count_new++; } @@ -102,140 +108,93 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $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."); + auth_flash_set('success', 'Objet mis à jour.'); 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); +// Fetch data +$stmt_count = $db->prepare("SELECT COUNT(*) FROM tbl_scobjs WHERE $where"); $stmt_count->execute($params); -$total_items = (int)$stmt_count->fetchColumn(); +$total_items = $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(); +$stmt_list = $db->prepare("SELECT * FROM tbl_scobjs WHERE $where ORDER BY cl_scobjs_id DESC LIMIT $limit OFFSET $offset"); +$stmt_list->execute($params); +$items_list = $stmt_list->fetchAll(); -$current_session_user = $_SESSION['user'] ?? ''; -$edit_id = isset($_GET['edit']) ? (int)$_GET['edit'] : 0; $edit_item = null; -if ($edit_id > 0) { +if (isset($_GET['edit'])) { $stmt_edit = $db->prepare("SELECT * FROM tbl_scobjs WHERE cl_scobjs_id = :id"); - $stmt_edit->execute(['id' => $edit_id]); + $stmt_edit->execute(['id' => (int)$_GET['edit']]); $edit_item = $stmt_edit->fetch(); } +$current_session_user = $_SESSION['user_name'] ?? 'Admin'; + ?> - - Gestion des Objets | R.E.A.C.T. Admin - - + Admin - Base d'Objets + +