getConnection(); $stmt = $pdo->prepare(" SELECT name, header_row, start_column, target_table, source_type, xls_sheet_index, sample_xlsx, idclient, clientname, idschema, schemaname, schemajson, xls_headers, api_sample_json, json_nodes FROM excel_templates WHERE id = ? "); $stmt->execute([$id]); $template = $stmt->fetch(PDO::FETCH_ASSOC); if (!$template) { die("Template not found"); } $sourceType = strtoupper($template['source_type'] ?? 'XLS'); if (!in_array($sourceType, ['XLS', 'API', 'PDF'], true)) { $sourceType = 'XLS'; } $xlsSheetIndex = isset($template['xls_sheet_index']) && $template['xls_sheet_index'] !== null ? (int)$template['xls_sheet_index'] : 0; if ($xlsSheetIndex < 0) { $xlsSheetIndex = 0; } $clientName = $template['clientname'] ?: ''; $schemaName = $template['schemaname'] ?: ''; $schemajson = $template['schemajson'] ? json_decode($template['schemajson'], true) : []; $isSchemajsonEmpty = empty(trim($template['schemajson'] ?? '')); // Recupera i campi dalla tabella template_mapping $stmt = $pdo->prepare(" SELECT id, field_id, field_order, excel_column, json_node, is_manual, manual_default, auto_value, data_type, is_required, default_value, has_list, length, decimals, min_value, max_value, default_curr_date, tablename, field_label, main_field, is_visible_import, is_visible_parts, is_addnote FROM template_mapping WHERE template_id = ? ORDER BY field_order ASC, id ASC "); $stmt->execute([$id]); $mappings = $stmt->fetchAll(PDO::FETCH_ASSOC); // Recupera i fixed fields dalla tabella template_fixed_mapping $stmt = $pdo->prepare(" SELECT id, fixed_field_key, is_manual, data_type, is_required, default_value, is_visible_import, default_source, excel_column FROM template_fixed_mapping WHERE template_id = ? ORDER BY id ASC "); $stmt->execute([$id]); $fixedMappings = $stmt->fetchAll(PDO::FETCH_ASSOC); $hasFixedMappings = !empty($fixedMappings); // Recupera le colonne XLS già associate nel database $usedColumnsFromDB = array_filter(array_column($mappings, 'excel_column')); // Recupera i nodi JSON già associati nel database $usedJsonNodesFromDB = array_filter(array_column($mappings, 'json_node')); // Decodifica l'header XLS salvato, se presente $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], true) : []; if (!is_array($xlsHeaders)) { $xlsHeaders = []; } // Decodifica nodi JSON API salvati, se presenti $jsonNodes = $template['json_nodes'] ? json_decode($template['json_nodes'], true) : []; if (!is_array($jsonNodes)) { $jsonNodes = []; } $apiSampleJson = $template['api_sample_json'] ?? ''; ?> Configure Template <?= htmlspecialchars($template['name'], ENT_QUOTES, 'UTF-8'); ?>
Configure Template:

Client: | Schema: | Source: | Sheet Number: | Header Row: | Start Column:

✅ Current file: No file uploaded yet.
✅ JSON nodes already loaded: No JSON nodes loaded yet.
PDF source type is not implemented yet.
Schema Fields Configuration
Main Import Parts Note Title Order Type Default Value
> > > > Required () ()
Values from the file are linked to the LIMS list via Value Bindings
Fixed Fields Defaults
Defaults are saved automatically when changed
Visible on Import Required Field Type Source Default Value
> > 'Buyer']; $fixedKey = $fm['fixed_field_key']; echo htmlspecialchars($fixedFieldLabels[$fixedKey] ?? $fixedKey); ?>