json bindings filter && order

This commit is contained in:
2026-06-16 10:20:03 +03:00
parent 9eb257d237
commit 25c3990753
5 changed files with 57 additions and 26 deletions
+51 -20
View File
@@ -52,7 +52,7 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
font-size: 12px;
}
</style>
<title>Gestione Binding JSON -> LIMS - <?= htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?></title>
<title>Gestione Binding JSON &rarr; LIMS - <?= htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?></title>
</head>
<body>
@@ -65,18 +65,22 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
<div class="card radius-10">
<div class="card-header">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2">
<h6 class="mb-0">Gestione Binding JSON -> LIMS</h6>
<form method="GET" class="d-flex align-items-center gap-2">
<label class="small text-muted mb-0">Template</label>
<select name="template_id" class="form-select form-select-sm" onchange="this.form.submit()">
<option value="0">Tutti</option>
<?php foreach ($templates as $t): ?>
<option value="<?= (int) $t['id'] ?>" <?= $templateFilter === (int) $t['id'] ? 'selected' : '' ?>>
<?= htmlspecialchars($t['name']) ?>
</option>
<?php endforeach; ?>
</select>
</form>
<h6 class="mb-0">Gestione Binding JSON &rarr; LIMS</h6>
<div class="d-flex align-items-center gap-2 flex-wrap">
<input type="text" id="bindingSearch" class="form-control form-control-sm" style="width:220px;"
placeholder="Cerca (campo, valore...)">
<form method="GET" class="d-flex align-items-center gap-2 mb-0">
<label class="small text-muted mb-0">Template</label>
<select name="template_id" class="form-select form-select-sm" onchange="this.form.submit()">
<option value="0">Tutti</option>
<?php foreach ($templates as $t): ?>
<option value="<?= (int) $t['id'] ?>" <?= $templateFilter === (int) $t['id'] ? 'selected' : '' ?>>
<?= htmlspecialchars($t['name']) ?>
</option>
<?php endforeach; ?>
</select>
</form>
</div>
</div>
</div>
@@ -85,23 +89,23 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
<div class="alert alert-secondary small">
Le modifiche ai binding si applicano alle <strong>importazioni future</strong>.
I record gia' importati non vengono ricalcolati.
I record gi&agrave; importati non vengono ricalcolati.
</div>
<div class="table-responsive">
<table class="table table-striped table-bordered align-middle">
<table class="table table-striped table-bordered align-middle" id="bindingsTable">
<thead>
<tr>
<th>Template</th>
<th>Campo (template_mapping)</th>
<th>Valore JSON</th>
<th>Valore LIMS</th>
<th class="sortable" data-col="0" style="cursor:pointer;">Template <span class="sort-caret"></span></th>
<th class="sortable" data-col="1" style="cursor:pointer;">Campo (template_mapping) <span class="sort-caret"></span></th>
<th class="sortable" data-col="2" style="cursor:pointer;">Valore JSON <span class="sort-caret"></span></th>
<th class="sortable" data-col="3" style="cursor:pointer;">Valore LIMS <span class="sort-caret"></span></th>
<th style="width:170px;">Azioni</th>
</tr>
</thead>
<tbody>
<?php if (empty($bindings)): ?>
<tr>
<tr class="no-data-row">
<td colspan="5" class="text-center text-muted">Nessun binding presente.</td>
</tr>
<?php else: ?>
@@ -155,6 +159,33 @@ $bindings = $stmt->fetchAll(PDO::FETCH_ASSOC);
$(function() {
const $globalError = $('#globalError');
// Filtro testuale generale su tutte le colonne.
const $rows = () => $('#bindingsTable tbody tr').not('.no-data-row');
$('#bindingSearch').on('input', function() {
const q = $(this).val().toLowerCase().trim();
$rows().each(function() {
const text = $(this).text().toLowerCase();
$(this).toggle(q === '' || text.indexOf(q) !== -1);
});
});
// Ordinamento per colonna (click sull'intestazione).
$('#bindingsTable thead .sortable').on('click', function() {
const col = +$(this).data('col');
const asc = !($(this).data('asc'));
$('#bindingsTable thead .sortable').data('asc', null).find('.sort-caret').html('');
$(this).data('asc', asc).find('.sort-caret').html(asc ? ' &#9650;' : ' &#9660;');
const $tbody = $('#bindingsTable tbody');
const rows = $tbody.find('tr').not('.no-data-row').get();
rows.sort((a, b) => {
const x = $(a).find('td').eq(col).text().trim().toLowerCase();
const y = $(b).find('td').eq(col).text().trim().toLowerCase();
return asc ? x.localeCompare(y) : y.localeCompare(x);
});
rows.forEach(r => $tbody.append(r));
});
$('.binding-select').each(function() {
const fieldId = $(this).data('field-id');
const initialVal = $(this).val();
+1 -1
View File
@@ -174,7 +174,7 @@ error_log("Loaded JSON import template: " . print_r($template, true));
<div class="mb-3 text">
<a href="imported.php?id=<?= $id ?>" class="btn btn-warning me-2">Imported (i)</a>
<a href="tolims.php?id=<?= $id ?>" class="btn btn-success me-2">To LIMS (l)</a>
<a href="bindings_manage.php?template_id=<?= $id ?>" class="btn btn-outline-secondary">Binding JSON -> LIMS</a>
<a href="bindings_manage.php?template_id=<?= $id ?>" class="btn btn-outline-secondary">Binding JSON &rarr; LIMS</a>
</div>
<div class="card radius-10">
+1 -1
View File
@@ -1311,7 +1311,7 @@ $gridMeta = [
<div class="mb-3 text d-flex align-items-center gap-2">
<a href="imported.php?id=<?= $template_id ?>" class="btn btn-warning me-2">Imported (i)</a>
<a href="tolims.php?id=<?= $template_id ?>" class="btn btn-success">To LIMS (l)</a>
<a href="bindings_manage.php?template_id=<?= $template_id ?>" class="btn btn-outline-secondary">Binding JSON -> LIMS</a>
<a href="bindings_manage.php?template_id=<?= $template_id ?>" class="btn btn-outline-secondary">Binding JSON &rarr; LIMS</a>
<?php if ($importref === ''): ?>
<span class="ms-3">
<label class="form-check-label" style="font-size: 13px; cursor: pointer;">
+1 -1
View File
@@ -51,7 +51,7 @@
<ul>
<li> <a href="quotations.php"><i class='bx bx-radio-circle'></i><?php echo $quotationstitle; ?></a>
</li>
<li> <a href="bindings_manage.php"><i class='bx bx-radio-circle'></i>Binding JSON -> LIMS</a>
<li> <a href="bindings_manage.php"><i class='bx bx-radio-circle'></i>Binding JSON &rarr; LIMS</a>
</li>
+3 -3
View File
@@ -80,7 +80,7 @@ $templateName = $stmt->fetchColumn() ?: ('Template ' . $templateId);
height: 36px;
}
</style>
<title>Binding JSON -> LIMS - <?= htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?></title>
<title>Binding JSON &rarr; LIMS - <?= htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?></title>
</head>
<body>
@@ -94,8 +94,8 @@ $templateName = $stmt->fetchColumn() ?: ('Template ' . $templateId);
<div class="card-header">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2">
<div>
<h6 class="mb-0">Binding JSON -> LIMS</h6>
<small><?= htmlspecialchars($templateName) ?> - Template ID: <?= $templateId ?></small>
<h6 class="mb-0">Binding JSON &rarr; LIMS</h6>
<small><?= htmlspecialchars($templateName) ?> &middot; Template ID: <?= $templateId ?></small>
</div>
<a href="bindings_manage.php?template_id=<?= $templateId ?>" class="btn btn-sm btn-outline-secondary">
<i class="fas fa-cog"></i> Gestione binding