V1.3.5
This commit is contained in:
parent
2936084d77
commit
40f86c7597
485
scitemcustom.php
485
scitemcustom.php
@ -71,6 +71,17 @@ function scitemcustom_current_owner_auth_id(PDO $db): int
|
|||||||
return (int) $stmt_owner->fetchColumn();
|
return (int) $stmt_owner->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scitemcustom_redirect(?int $itemcustom_id = null): void
|
||||||
|
{
|
||||||
|
$location = 'scitemcustom.php';
|
||||||
|
if ($itemcustom_id !== null && $itemcustom_id > 0) {
|
||||||
|
$location .= '#itemcustom-' . $itemcustom_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Location: ' . $location);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$flash = auth_flash_get();
|
$flash = auth_flash_get();
|
||||||
$flash_type = $flash['type'] ?? '';
|
$flash_type = $flash['type'] ?? '';
|
||||||
$flash_message = $flash['message'] ?? '';
|
$flash_message = $flash['message'] ?? '';
|
||||||
@ -91,14 +102,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$submitted_csrf = $_POST['csrf_token'] ?? '';
|
$submitted_csrf = $_POST['csrf_token'] ?? '';
|
||||||
if (!auth_validate_csrf($submitted_csrf)) {
|
if (!auth_validate_csrf($submitted_csrf)) {
|
||||||
auth_flash_set('error', 'Jeton CSRF invalide.');
|
auth_flash_set('error', 'Jeton CSRF invalide.');
|
||||||
header('Location: scitemcustom.php');
|
scitemcustom_redirect();
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = $_POST['action'] ?? '';
|
$action = $_POST['action'] ?? '';
|
||||||
|
|
||||||
if ($action === 'add_custom_item') {
|
if ($action === 'add_custom_item') {
|
||||||
$obj_id = (int) ($_POST['obj_id'] ?? 0);
|
$obj_id = (int) ($_POST['obj_id'] ?? 0);
|
||||||
|
$redirect_itemcustom_id = null;
|
||||||
if ($obj_id <= 0) {
|
if ($obj_id <= 0) {
|
||||||
auth_flash_set('error', 'Objet invalide.');
|
auth_flash_set('error', 'Objet invalide.');
|
||||||
} else {
|
} else {
|
||||||
@ -116,6 +127,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
'owner_auth_id' => $current_owner_auth_id,
|
'owner_auth_id' => $current_owner_auth_id,
|
||||||
'obj_id' => $obj_id,
|
'obj_id' => $obj_id,
|
||||||
]);
|
]);
|
||||||
|
$redirect_itemcustom_id = (int) $db->lastInsertId();
|
||||||
auth_flash_set('success', 'Objet ajouté dans Item Custom.');
|
auth_flash_set('success', 'Objet ajouté dans Item Custom.');
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
@ -127,8 +139,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: scitemcustom.php');
|
scitemcustom_redirect($redirect_itemcustom_id);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'delete_custom_item') {
|
if ($action === 'delete_custom_item') {
|
||||||
@ -155,8 +166,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: scitemcustom.php');
|
scitemcustom_redirect();
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'add_custom_stat') {
|
if ($action === 'add_custom_stat') {
|
||||||
@ -210,12 +220,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: scitemcustom.php');
|
scitemcustom_redirect($itemcustom_id);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'update_custom_stat') {
|
if ($action === 'update_custom_stat') {
|
||||||
$custom_stat_id = (int) ($_POST['custom_stat_id'] ?? 0);
|
$custom_stat_id = (int) ($_POST['custom_stat_id'] ?? 0);
|
||||||
|
$itemcustom_id = (int) ($_POST['itemcustom_id'] ?? 0);
|
||||||
$stat_id = (int) ($_POST['stat_id'] ?? 0);
|
$stat_id = (int) ($_POST['stat_id'] ?? 0);
|
||||||
$sign = scitemcustom_normalize_sign($_POST['sign'] ?? '+');
|
$sign = scitemcustom_normalize_sign($_POST['sign'] ?? '+');
|
||||||
$value = scitemcustom_normalize_value($_POST['value'] ?? '');
|
$value = scitemcustom_normalize_value($_POST['value'] ?? '');
|
||||||
@ -256,12 +266,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: scitemcustom.php');
|
scitemcustom_redirect($itemcustom_id);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'delete_custom_stat') {
|
if ($action === 'delete_custom_stat') {
|
||||||
$custom_stat_id = (int) ($_POST['custom_stat_id'] ?? 0);
|
$custom_stat_id = (int) ($_POST['custom_stat_id'] ?? 0);
|
||||||
|
$itemcustom_id = (int) ($_POST['itemcustom_id'] ?? 0);
|
||||||
if ($custom_stat_id > 0) {
|
if ($custom_stat_id > 0) {
|
||||||
try {
|
try {
|
||||||
$stmt_delete = $db->prepare(
|
$stmt_delete = $db->prepare(
|
||||||
@ -286,8 +296,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: scitemcustom.php');
|
scitemcustom_redirect($itemcustom_id);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,6 +681,92 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-summary {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-summary-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 0.75rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-stats-count {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.55rem;
|
||||||
|
padding: 0.6rem 0.9rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid rgba(162, 155, 120, 0.25);
|
||||||
|
background: rgba(162, 155, 120, 0.08);
|
||||||
|
color: #fff;
|
||||||
|
font-family: 'Electrolize', sans-serif;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-btn:hover {
|
||||||
|
background: rgba(162, 155, 120, 0.14);
|
||||||
|
border-color: rgba(162, 155, 120, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-btn:focus-visible {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 0 3px rgba(162, 155, 120, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-label {
|
||||||
|
color: var(--primary);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
line-height: 1;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-btn[aria-expanded="true"] .item-toggle-icon {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-card {
|
||||||
|
scroll-margin-top: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-card.is-open {
|
||||||
|
border-color: rgba(162, 155, 120, 0.35);
|
||||||
|
box-shadow: 0 0 0 1px rgba(162, 155, 120, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-body {
|
||||||
|
display: grid;
|
||||||
|
gap: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-body[hidden] {
|
||||||
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-form {
|
.inline-form {
|
||||||
@ -816,6 +911,20 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
.actions-row {
|
.actions-row {
|
||||||
justify-content: stretch;
|
justify-content: stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-item-summary {
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-item-summary-actions {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-toggle-btn {
|
||||||
|
flex: 1;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -931,6 +1040,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
<?php foreach ($custom_items as $item): ?>
|
<?php foreach ($custom_items as $item): ?>
|
||||||
<?php $item_id = (int) $item['cl_scitemcustom_id']; ?>
|
<?php $item_id = (int) $item['cl_scitemcustom_id']; ?>
|
||||||
<?php $item_stats = $custom_stats_by_item[$item_id] ?? []; ?>
|
<?php $item_stats = $custom_stats_by_item[$item_id] ?? []; ?>
|
||||||
|
<?php $item_stats_count = count($item_stats); ?>
|
||||||
<?php $item_search_text = trim(implode(' ', array_filter([
|
<?php $item_search_text = trim(implode(' ', array_filter([
|
||||||
(string) ($item['cl_scobjs_name'] ?? ''),
|
(string) ($item['cl_scobjs_name'] ?? ''),
|
||||||
(string) ($item['cl_scobjs_type'] ?? ''),
|
(string) ($item['cl_scobjs_type'] ?? ''),
|
||||||
@ -938,136 +1048,156 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
(string) ($item['cl_scobjs_uuid'] ?? ''),
|
(string) ($item['cl_scobjs_uuid'] ?? ''),
|
||||||
]))); ?>
|
]))); ?>
|
||||||
<section class="custom-item-card" id="itemcustom-<?php echo $item_id; ?>" data-item-search="<?php echo htmlspecialchars($item_search_text, ENT_QUOTES, 'UTF-8'); ?>">
|
<section class="custom-item-card" id="itemcustom-<?php echo $item_id; ?>" data-item-search="<?php echo htmlspecialchars($item_search_text, ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
<div class="custom-item-header">
|
<div class="custom-item-summary">
|
||||||
<div class="item-meta">
|
<div class="custom-item-header">
|
||||||
<img src="https://cstone.space/uifimages/<?php echo htmlspecialchars($item['cl_scobjs_uuid'], ENT_QUOTES, 'UTF-8'); ?>.png" class="item-preview" alt="">
|
<div class="item-meta">
|
||||||
<div>
|
<img src="https://cstone.space/uifimages/<?php echo htmlspecialchars($item['cl_scobjs_uuid'], ENT_QUOTES, 'UTF-8'); ?>.png" class="item-preview" alt="">
|
||||||
<strong class="item-name"><?php echo htmlspecialchars($item['cl_scobjs_name'], ENT_QUOTES, 'UTF-8'); ?></strong>
|
<div>
|
||||||
<div class="item-submeta">
|
<strong class="item-name"><?php echo htmlspecialchars($item['cl_scobjs_name'], ENT_QUOTES, 'UTF-8'); ?></strong>
|
||||||
<?php echo htmlspecialchars($item['cl_scobjs_type'], ENT_QUOTES, 'UTF-8'); ?>
|
<div class="item-submeta">
|
||||||
<?php if (!empty($item['cl_scobjs_subtype'])): ?> / <?php echo htmlspecialchars($item['cl_scobjs_subtype'], ENT_QUOTES, 'UTF-8'); ?><?php endif; ?><br>
|
<?php echo htmlspecialchars($item['cl_scobjs_type'], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
UUID: <?php echo htmlspecialchars($item['cl_scobjs_uuid'], ENT_QUOTES, 'UTF-8'); ?>
|
<?php if (!empty($item['cl_scobjs_subtype'])): ?> / <?php echo htmlspecialchars($item['cl_scobjs_subtype'], ENT_QUOTES, 'UTF-8'); ?><?php endif; ?><br>
|
||||||
|
UUID: <?php echo htmlspecialchars($item['cl_scobjs_uuid'], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="badge custom-item-stats-count"><?php echo $item_stats_count; ?> stat<?php echo $item_stats_count > 1 ? 's' : ''; ?></span>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" onsubmit="return confirm('Supprimer cet objet Item Custom et toutes ses stats ?');">
|
<div class="custom-item-summary-actions">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
<button
|
||||||
<input type="hidden" name="action" value="delete_custom_item">
|
type="button"
|
||||||
<input type="hidden" name="itemcustom_id" value="<?php echo $item_id; ?>">
|
class="item-toggle-btn"
|
||||||
<button type="submit" class="btn-modern danger">Supprimer l'objet</button>
|
aria-expanded="false"
|
||||||
</form>
|
aria-controls="itemcustom-panel-<?php echo $item_id; ?>"
|
||||||
</div>
|
data-toggle-label-open="Replier"
|
||||||
|
data-toggle-label-closed="Déplier"
|
||||||
<div>
|
>
|
||||||
<h3>Ajouter un bonus / malus</h3>
|
<span class="item-toggle-label">Déplier</span>
|
||||||
<?php if (empty($stats_catalog)): ?>
|
<span class="item-toggle-icon" aria-hidden="true">▾</span>
|
||||||
<div class="form-help">Aucune statistique disponible. Crée d'abord des entrées dans l'onglet <strong>Stats Item</strong>.</div>
|
</button>
|
||||||
<?php else: ?>
|
<form method="post" onsubmit="return confirm('Supprimer cet objet Item Custom et toutes ses stats ?');">
|
||||||
<form method="post" class="inline-form">
|
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
<input type="hidden" name="action" value="add_custom_stat">
|
<input type="hidden" name="action" value="delete_custom_item">
|
||||||
<input type="hidden" name="itemcustom_id" value="<?php echo $item_id; ?>">
|
<input type="hidden" name="itemcustom_id" value="<?php echo $item_id; ?>">
|
||||||
|
<button type="submit" class="btn-modern danger">Supprimer l'objet</button>
|
||||||
<div class="form-group" style="margin-bottom:0;">
|
|
||||||
<label>Statistique</label>
|
|
||||||
<select name="stat_id" class="form-control" required>
|
|
||||||
<?php foreach ($stats_catalog as $stat_option): ?>
|
|
||||||
<option value="<?php echo (int) $stat_option['cl_scstatsitem_id']; ?>">
|
|
||||||
<?php echo htmlspecialchars($stat_option['cl_scstatsitem_name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo htmlspecialchars($stat_option['cl_scstatsitem_unit'], ENT_QUOTES, 'UTF-8'); ?>)
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group" style="margin-bottom:0;">
|
|
||||||
<label>Signe</label>
|
|
||||||
<select name="sign" class="form-control">
|
|
||||||
<?php foreach ($allowed_signs as $sign_option): ?>
|
|
||||||
<option value="<?php echo htmlspecialchars($sign_option, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $sign_option === '+' ? 'selected' : ''; ?>>
|
|
||||||
<?php echo htmlspecialchars($sign_labels[$sign_option], ENT_QUOTES, 'UTF-8'); ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group" style="margin-bottom:0;">
|
|
||||||
<label>Valeur</label>
|
|
||||||
<input type="number" name="value" class="form-control" min="0" step="0.01" value="0" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn-modern">Ajouter la stat</button>
|
|
||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="overflow-x:auto;">
|
<div class="custom-item-body" id="itemcustom-panel-<?php echo $item_id; ?>" hidden>
|
||||||
<table class="modern-table">
|
<div>
|
||||||
<thead>
|
<h3>Ajouter un bonus / malus</h3>
|
||||||
<tr>
|
<?php if (empty($stats_catalog)): ?>
|
||||||
<th>Statistique</th>
|
<div class="form-help">Aucune statistique disponible. Crée d'abord des entrées dans l'onglet <strong>Stats Item</strong>.</div>
|
||||||
<th style="width:110px;">Signe</th>
|
<?php else: ?>
|
||||||
<th style="width:140px;">Valeur</th>
|
<form method="post" class="inline-form">
|
||||||
<th style="width:120px;">Unité</th>
|
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
<th style="width:130px;">Aperçu</th>
|
<input type="hidden" name="action" value="add_custom_stat">
|
||||||
<th style="text-align:right; width:220px;">Actions</th>
|
<input type="hidden" name="itemcustom_id" value="<?php echo $item_id; ?>">
|
||||||
</tr>
|
|
||||||
</thead>
|
<div class="form-group" style="margin-bottom:0;">
|
||||||
<tbody>
|
<label>Statistique</label>
|
||||||
<?php if (empty($item_stats)): ?>
|
<select name="stat_id" class="form-control" required>
|
||||||
|
<?php foreach ($stats_catalog as $stat_option): ?>
|
||||||
|
<option value="<?php echo (int) $stat_option['cl_scstatsitem_id']; ?>">
|
||||||
|
<?php echo htmlspecialchars($stat_option['cl_scstatsitem_name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo htmlspecialchars($stat_option['cl_scstatsitem_unit'], ENT_QUOTES, 'UTF-8'); ?>)
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group" style="margin-bottom:0;">
|
||||||
|
<label>Signe</label>
|
||||||
|
<select name="sign" class="form-control">
|
||||||
|
<?php foreach ($allowed_signs as $sign_option): ?>
|
||||||
|
<option value="<?php echo htmlspecialchars($sign_option, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $sign_option === '+' ? 'selected' : ''; ?>>
|
||||||
|
<?php echo htmlspecialchars($sign_labels[$sign_option], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group" style="margin-bottom:0;">
|
||||||
|
<label>Valeur</label>
|
||||||
|
<input type="number" name="value" class="form-control" min="0" step="0.01" value="0" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn-modern">Ajouter la stat</button>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="overflow-x:auto;">
|
||||||
|
<table class="modern-table">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="empty-state">Aucune statistique configurée pour cet objet.</td>
|
<th>Statistique</th>
|
||||||
|
<th style="width:110px;">Signe</th>
|
||||||
|
<th style="width:140px;">Valeur</th>
|
||||||
|
<th style="width:120px;">Unité</th>
|
||||||
|
<th style="width:130px;">Aperçu</th>
|
||||||
|
<th style="text-align:right; width:220px;">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php else: ?>
|
</thead>
|
||||||
<?php foreach ($item_stats as $item_stat): ?>
|
<tbody>
|
||||||
|
<?php if (empty($item_stats)): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td colspan="6" class="empty-state">Aucune statistique configurée pour cet objet.</td>
|
||||||
<form method="post">
|
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
|
||||||
<input type="hidden" name="action" value="update_custom_stat">
|
|
||||||
<input type="hidden" name="custom_stat_id" value="<?php echo (int) $item_stat['cl_scitemcustomstat_id']; ?>">
|
|
||||||
<select name="stat_id" class="form-control" required>
|
|
||||||
<?php foreach ($stats_catalog as $stat_option): ?>
|
|
||||||
<option value="<?php echo (int) $stat_option['cl_scstatsitem_id']; ?>" <?php echo (int) $stat_option['cl_scstatsitem_id'] === (int) $item_stat['cl_scitemcustomstat_stat_id'] ? 'selected' : ''; ?>>
|
|
||||||
<?php echo htmlspecialchars($stat_option['cl_scstatsitem_name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo htmlspecialchars($stat_option['cl_scstatsitem_unit'], ENT_QUOTES, 'UTF-8'); ?>)
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select name="sign" class="form-control">
|
|
||||||
<?php foreach ($allowed_signs as $sign_option): ?>
|
|
||||||
<option value="<?php echo htmlspecialchars($sign_option, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $sign_option === $item_stat['cl_scitemcustomstat_sign'] ? 'selected' : ''; ?>>
|
|
||||||
<?php echo htmlspecialchars($sign_labels[$sign_option], ENT_QUOTES, 'UTF-8'); ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="number" name="value" class="form-control" min="0" step="0.01" value="<?php echo htmlspecialchars(scitemcustom_display_value($item_stat['cl_scitemcustomstat_value']), ENT_QUOTES, 'UTF-8'); ?>" required>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="badge"><?php echo htmlspecialchars($item_stat['cl_scstatsitem_unit'], ENT_QUOTES, 'UTF-8'); ?></span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="preview-pill"><?php echo htmlspecialchars(scitemcustom_preview($item_stat['cl_scitemcustomstat_sign'], $item_stat['cl_scitemcustomstat_value'], $item_stat['cl_scstatsitem_unit']), ENT_QUOTES, 'UTF-8'); ?></span>
|
|
||||||
</td>
|
|
||||||
<td style="text-align:right;">
|
|
||||||
<div class="actions-row">
|
|
||||||
<button type="submit" class="btn-modern btn-mini">Save</button>
|
|
||||||
</form>
|
|
||||||
<form method="post" onsubmit="return confirm('Supprimer cette statistique ?');">
|
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
|
||||||
<input type="hidden" name="action" value="delete_custom_stat">
|
|
||||||
<input type="hidden" name="custom_stat_id" value="<?php echo (int) $item_stat['cl_scitemcustomstat_id']; ?>">
|
|
||||||
<button type="submit" class="btn-modern btn-mini danger">X</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php else: ?>
|
||||||
<?php endif; ?>
|
<?php foreach ($item_stats as $item_stat): ?>
|
||||||
</tbody>
|
<tr>
|
||||||
</table>
|
<td>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
|
<input type="hidden" name="action" value="update_custom_stat">
|
||||||
|
<input type="hidden" name="itemcustom_id" value="<?php echo $item_id; ?>">
|
||||||
|
<input type="hidden" name="custom_stat_id" value="<?php echo (int) $item_stat['cl_scitemcustomstat_id']; ?>">
|
||||||
|
<select name="stat_id" class="form-control" required>
|
||||||
|
<?php foreach ($stats_catalog as $stat_option): ?>
|
||||||
|
<option value="<?php echo (int) $stat_option['cl_scstatsitem_id']; ?>" <?php echo (int) $stat_option['cl_scstatsitem_id'] === (int) $item_stat['cl_scitemcustomstat_stat_id'] ? 'selected' : ''; ?>>
|
||||||
|
<?php echo htmlspecialchars($stat_option['cl_scstatsitem_name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo htmlspecialchars($stat_option['cl_scstatsitem_unit'], ENT_QUOTES, 'UTF-8'); ?>)
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name="sign" class="form-control">
|
||||||
|
<?php foreach ($allowed_signs as $sign_option): ?>
|
||||||
|
<option value="<?php echo htmlspecialchars($sign_option, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $sign_option === $item_stat['cl_scitemcustomstat_sign'] ? 'selected' : ''; ?>>
|
||||||
|
<?php echo htmlspecialchars($sign_labels[$sign_option], ENT_QUOTES, 'UTF-8'); ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" name="value" class="form-control" min="0" step="0.01" value="<?php echo htmlspecialchars(scitemcustom_display_value($item_stat['cl_scitemcustomstat_value']), ENT_QUOTES, 'UTF-8'); ?>" required>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="badge"><?php echo htmlspecialchars($item_stat['cl_scstatsitem_unit'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="preview-pill"><?php echo htmlspecialchars(scitemcustom_preview($item_stat['cl_scitemcustomstat_sign'], $item_stat['cl_scitemcustomstat_value'], $item_stat['cl_scstatsitem_unit']), ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
|
</td>
|
||||||
|
<td style="text-align:right;">
|
||||||
|
<div class="actions-row">
|
||||||
|
<button type="submit" class="btn-modern btn-mini">Save</button>
|
||||||
|
</form>
|
||||||
|
<form method="post" onsubmit="return confirm('Supprimer cette statistique ?');">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token, ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
|
<input type="hidden" name="action" value="delete_custom_stat">
|
||||||
|
<input type="hidden" name="itemcustom_id" value="<?php echo $item_id; ?>">
|
||||||
|
<input type="hidden" name="custom_stat_id" value="<?php echo (int) $item_stat['cl_scitemcustomstat_id']; ?>">
|
||||||
|
<button type="submit" class="btn-modern btn-mini danger">X</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@ -1085,7 +1215,7 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
var emptyState = document.getElementById('item-custom-no-results');
|
var emptyState = document.getElementById('item-custom-no-results');
|
||||||
var itemCards = Array.prototype.slice.call(document.querySelectorAll('#item-custom-list .custom-item-card'));
|
var itemCards = Array.prototype.slice.call(document.querySelectorAll('#item-custom-list .custom-item-card'));
|
||||||
|
|
||||||
if (!filterInput || !resetButton || !visibleCount || !emptyState || itemCards.length === 0) {
|
if (itemCards.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1098,6 +1228,99 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCardState(card, isOpen) {
|
||||||
|
var body = card.querySelector('.custom-item-body');
|
||||||
|
var toggleButton = card.querySelector('.item-toggle-btn');
|
||||||
|
var toggleLabel = toggleButton ? toggleButton.querySelector('.item-toggle-label') : null;
|
||||||
|
if (!body || !toggleButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
card.classList.toggle('is-open', isOpen);
|
||||||
|
body.hidden = !isOpen;
|
||||||
|
toggleButton.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
||||||
|
|
||||||
|
if (toggleLabel) {
|
||||||
|
toggleLabel.textContent = isOpen
|
||||||
|
? (toggleButton.getAttribute('data-toggle-label-open') || 'Replier')
|
||||||
|
: (toggleButton.getAttribute('data-toggle-label-closed') || 'Déplier');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeAllCards() {
|
||||||
|
itemCards.forEach(function (card) {
|
||||||
|
setCardState(card, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentUrlWithoutHash() {
|
||||||
|
return window.location.pathname + window.location.search;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCard(card, options) {
|
||||||
|
var settings = options || {};
|
||||||
|
itemCards.forEach(function (otherCard) {
|
||||||
|
setCardState(otherCard, otherCard === card);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (settings.syncHash !== false) {
|
||||||
|
window.history.replaceState(null, '', '#' + card.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.scrollIntoView) {
|
||||||
|
card.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCard(card, options) {
|
||||||
|
var settings = options || {};
|
||||||
|
setCardState(card, false);
|
||||||
|
|
||||||
|
if (settings.syncHash !== false && window.location.hash === '#' + card.id) {
|
||||||
|
window.history.replaceState(null, '', getCurrentUrlWithoutHash());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncFromHash() {
|
||||||
|
var hash = window.location.hash || '';
|
||||||
|
if (hash.indexOf('#itemcustom-') !== 0) {
|
||||||
|
closeAllCards();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var targetCard = document.querySelector(hash + '.custom-item-card');
|
||||||
|
if (!targetCard) {
|
||||||
|
closeAllCards();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
openCard(targetCard, { syncHash: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
itemCards.forEach(function (card) {
|
||||||
|
var toggleButton = card.querySelector('.item-toggle-btn');
|
||||||
|
if (!toggleButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCardState(card, false);
|
||||||
|
toggleButton.addEventListener('click', function () {
|
||||||
|
var isOpen = toggleButton.getAttribute('aria-expanded') === 'true';
|
||||||
|
if (isOpen) {
|
||||||
|
closeCard(card);
|
||||||
|
} else {
|
||||||
|
openCard(card, { scrollIntoView: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
syncFromHash();
|
||||||
|
window.addEventListener('hashchange', syncFromHash);
|
||||||
|
|
||||||
|
if (!filterInput || !resetButton || !visibleCount || !emptyState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function applyFilter() {
|
function applyFilter() {
|
||||||
var query = normalizeValue(filterInput.value);
|
var query = normalizeValue(filterInput.value);
|
||||||
var matches = 0;
|
var matches = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user