Liste Item Custom
objet(s) configuré(s) dans cette liste personnalisée.
Ajouter un bonus / malus
| ID | Statistique | Signe | Valeur | Unité | Aperçu | Actions |
|---|---|---|---|---|---|---|
| Aucune statistique configurée pour cet objet. | ||||||
| # |
|
|||||
prepare('SELECT cl_scobjs_id FROM tbl_scobjs WHERE cl_scobjs_id = :id'); $stmt_check->execute(['id' => $obj_id]); if (!$stmt_check->fetch()) { auth_flash_set('error', 'Objet introuvable.'); } else { $stmt_insert = $db->prepare('INSERT INTO tbl_scitemcustom (cl_scitemcustom_obj_id) VALUES (:obj_id)'); $stmt_insert->execute(['obj_id' => $obj_id]); auth_flash_set('success', 'Objet ajouté dans Item Custom.'); } } catch (PDOException $e) { if ((string) $e->getCode() === '23000') { auth_flash_set('error', 'Cet objet est déjà présent dans Item Custom.'); } else { auth_flash_set('error', 'Erreur lors de l\'ajout : ' . $e->getMessage()); } } } header('Location: scitemcustom.php'); exit; } if ($action === 'delete_custom_item') { $itemcustom_id = (int) ($_POST['itemcustom_id'] ?? 0); if ($itemcustom_id > 0) { try { $stmt_delete_children = $db->prepare('DELETE FROM tbl_scitemcustomstat WHERE cl_scitemcustomstat_itemcustom_id = :id'); $stmt_delete_children->execute(['id' => $itemcustom_id]); $stmt_delete = $db->prepare('DELETE FROM tbl_scitemcustom WHERE cl_scitemcustom_id = :id'); $stmt_delete->execute(['id' => $itemcustom_id]); auth_flash_set('success', 'Objet Item Custom supprimé.'); } catch (PDOException $e) { auth_flash_set('error', 'Erreur lors de la suppression : ' . $e->getMessage()); } } header('Location: scitemcustom.php'); exit; } if ($action === 'add_custom_stat') { $itemcustom_id = (int) ($_POST['itemcustom_id'] ?? 0); $stat_id = (int) ($_POST['stat_id'] ?? 0); $sign = scitemcustom_normalize_sign($_POST['sign'] ?? '+'); $value = scitemcustom_normalize_value($_POST['value'] ?? ''); if ($itemcustom_id <= 0 || $stat_id <= 0 || $value === null) { auth_flash_set('error', 'Données de statistique invalides.'); } else { try { $stmt_check = $db->prepare( 'SELECT c.cl_scitemcustom_id, s.cl_scstatsitem_id FROM tbl_scitemcustom c JOIN tbl_scstatsitem s ON s.cl_scstatsitem_id = :stat_id WHERE c.cl_scitemcustom_id = :itemcustom_id' ); $stmt_check->execute([ 'itemcustom_id' => $itemcustom_id, 'stat_id' => $stat_id, ]); if (!$stmt_check->fetch()) { auth_flash_set('error', 'Objet ou statistique introuvable.'); } else { $stmt_insert = $db->prepare( 'INSERT INTO tbl_scitemcustomstat ( cl_scitemcustomstat_itemcustom_id, cl_scitemcustomstat_stat_id, cl_scitemcustomstat_sign, cl_scitemcustomstat_value ) VALUES (:itemcustom_id, :stat_id, :sign, :value)' ); $stmt_insert->execute([ 'itemcustom_id' => $itemcustom_id, 'stat_id' => $stat_id, 'sign' => $sign, 'value' => $value, ]); auth_flash_set('success', 'Statistique ajoutée à l\'objet.'); } } catch (PDOException $e) { if ((string) $e->getCode() === '23000') { auth_flash_set('error', 'Cette statistique est déjà configurée pour cet objet.'); } else { auth_flash_set('error', 'Erreur lors de l\'ajout : ' . $e->getMessage()); } } } header('Location: scitemcustom.php'); exit; } if ($action === 'update_custom_stat') { $custom_stat_id = (int) ($_POST['custom_stat_id'] ?? 0); $stat_id = (int) ($_POST['stat_id'] ?? 0); $sign = scitemcustom_normalize_sign($_POST['sign'] ?? '+'); $value = scitemcustom_normalize_value($_POST['value'] ?? ''); if ($custom_stat_id <= 0 || $stat_id <= 0 || $value === null) { auth_flash_set('error', 'Données de mise à jour invalides.'); } else { try { $stmt_update = $db->prepare( 'UPDATE tbl_scitemcustomstat SET cl_scitemcustomstat_stat_id = :stat_id, cl_scitemcustomstat_sign = :sign, cl_scitemcustomstat_value = :value WHERE cl_scitemcustomstat_id = :id' ); $stmt_update->execute([ 'stat_id' => $stat_id, 'sign' => $sign, 'value' => $value, 'id' => $custom_stat_id, ]); auth_flash_set('success', 'Statistique mise à jour.'); } catch (PDOException $e) { if ((string) $e->getCode() === '23000') { auth_flash_set('error', 'Cette statistique est déjà configurée pour cet objet.'); } else { auth_flash_set('error', 'Erreur lors de la mise à jour : ' . $e->getMessage()); } } } header('Location: scitemcustom.php'); exit; } if ($action === 'delete_custom_stat') { $custom_stat_id = (int) ($_POST['custom_stat_id'] ?? 0); if ($custom_stat_id > 0) { try { $stmt_delete = $db->prepare('DELETE FROM tbl_scitemcustomstat WHERE cl_scitemcustomstat_id = :id'); $stmt_delete->execute(['id' => $custom_stat_id]); auth_flash_set('success', 'Statistique supprimée de l\'objet.'); } catch (PDOException $e) { auth_flash_set('error', 'Erreur lors de la suppression : ' . $e->getMessage()); } } header('Location: scitemcustom.php'); exit; } } $search = trim($_GET['search'] ?? ''); $search_results = []; if ($search !== '') { $stmt_search = $db->prepare( "SELECT * FROM tbl_scobjs WHERE (cl_scobjs_name LIKE :search OR cl_scobjs_type LIKE :search OR cl_scobjs_subtype LIKE :search OR cl_scobjs_uuid LIKE :search) AND cl_scobjs_id NOT IN (SELECT cl_scitemcustom_obj_id FROM tbl_scitemcustom) ORDER BY cl_scobjs_name ASC LIMIT 15" ); $stmt_search->execute(['search' => '%' . $search . '%']); $search_results = $stmt_search->fetchAll(); } $stmt_stats_catalog = $db->query('SELECT * FROM tbl_scstatsitem ORDER BY cl_scstatsitem_name ASC, cl_scstatsitem_id ASC'); $stats_catalog = $stmt_stats_catalog->fetchAll(); $stats_by_id = []; foreach ($stats_catalog as $stat_catalog_row) { $stats_by_id[(int) $stat_catalog_row['cl_scstatsitem_id']] = $stat_catalog_row; } $sql_custom_items = "SELECT c.*, o.cl_scobjs_name, o.cl_scobjs_uuid, o.cl_scobjs_type, o.cl_scobjs_subtype, o.cl_scobjs_rarity FROM tbl_scitemcustom c JOIN tbl_scobjs o ON o.cl_scobjs_id = c.cl_scitemcustom_obj_id ORDER BY o.cl_scobjs_name ASC, c.cl_scitemcustom_id ASC"; $stmt_custom_items = $db->query($sql_custom_items); $custom_items = $stmt_custom_items->fetchAll(); $stmt_custom_stats = $db->query( "SELECT cs.*, st.cl_scstatsitem_name, st.cl_scstatsitem_unit FROM tbl_scitemcustomstat cs JOIN tbl_scstatsitem st ON st.cl_scstatsitem_id = cs.cl_scitemcustomstat_stat_id ORDER BY cs.cl_scitemcustomstat_itemcustom_id ASC, st.cl_scstatsitem_name ASC, cs.cl_scitemcustomstat_id ASC" ); $custom_stats_rows = $stmt_custom_stats->fetchAll(); $custom_stats_by_item = []; foreach ($custom_stats_rows as $custom_stat_row) { $item_key = (int) $custom_stat_row['cl_scitemcustomstat_itemcustom_id']; if (!isset($custom_stats_by_item[$item_key])) { $custom_stats_by_item[$item_key] = []; } $custom_stats_by_item[$item_key][] = $custom_stat_row; } $current_session_user = $_SESSION['user'] ?? ''; ?>
objet(s) configuré(s) dans cette liste personnalisée.
| ID | Statistique | Signe | Valeur | Unité | Aperçu | Actions |
|---|---|---|---|---|---|---|
| Aucune statistique configurée pour cet objet. | ||||||
| # |
|
|||||