getConnection();
$templateFilter = isset($_GET['template_id']) ? (int) $_GET['template_id'] : 0;
$search = trim($_GET['q'] ?? '');
$templates = $pdo->query("SELECT id, name FROM excel_templates ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
$conds = [];
$params = [];
if ($templateFilter > 0) {
$conds[] = 'b.template_id = ?';
$params[] = $templateFilter;
}
if ($search !== '') {
$conds[] = '(b.source_value LIKE ? OR b.lims_value LIKE ? OR m.field_label LIKE ? OR f.fixed_field_key LIKE ?)';
$like = '%' . $search . '%';
array_push($params, $like, $like, $like, $like);
}
$where = $conds ? ('WHERE ' . implode(' AND ', $conds)) : '';
$stmt = $pdo->prepare(
"SELECT b.id, b.template_id, b.binding_kind, b.mapping_id, b.field_id, b.source_value,
b.lims_value_id, b.lims_value, b.updated_at,
t.name AS template_name,
COALESCE(m.field_label, f.fixed_field_key) AS field_label,
COALESCE(m.excel_column, f.excel_column) AS excel_column,
f.fixed_field_key
FROM lims_value_binding b
LEFT JOIN excel_templates t ON t.id = b.template_id
LEFT JOIN template_mapping m ON m.id = b.mapping_id AND b.binding_kind = 'custom'
LEFT JOIN template_fixed_mapping f ON f.id = b.mapping_id AND b.binding_kind = 'fixed'
$where
ORDER BY t.name ASC, field_label ASC, b.source_value ASC"
);
$stmt->execute($params);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$groups = [];
foreach ($rows as $r) {
$kind = $r['binding_kind'] ?? 'custom';
$gkey = $kind . ':' . (int) $r['mapping_id'];
if (!isset($groups[$gkey])) {
$groups[$gkey] = [
'kind' => $kind,
'label' => $kind === 'fixed'
? binding_fixed_label((string) $r['fixed_field_key'])
: ($r['field_label'] ?: ('Mapping ' . $gkey)),
'excel_column' => $r['excel_column'] ?: '',
'template_name' => $r['template_name'] ?: ('Template ' . $r['template_id']),
'template_id' => (int) $r['template_id'],
'rows' => [],
];
}
$groups[$gkey]['rows'][] = $r;
}
?>
Gestione binding - = htmlspecialchars($titlewebsite ?? '', ENT_QUOTES, 'UTF-8'); ?>
Nessun binding salvato per i filtri selezionati.
|
Valore importato |
Valore LIMS |
Aggiornato |
Azioni |
$g): ?>
|
= htmlspecialchars($g['label']) ?>
campo fisso
· = htmlspecialchars($g['template_name']) ?>
· colonna «= htmlspecialchars($g['excel_column']) ?>»
· = count($g['rows']) ?> valore/i
|
| › |
= htmlspecialchars($r['source_value']) ?> |
|
= htmlspecialchars((string) $r['updated_at']) ?> |
|