getConnection(); $stmt = $pdo->prepare(" SELECT name, header_row, start_column, target_table, source_type, 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'; } $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, 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 FROM template_mapping WHERE template_id = ? "); $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 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: | 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 Title Type Default Value
> > > Required () ()
Fixed Fields Defaults
Defaults are saved automatically when changed
Visible on Import Required Field Type Default Value
> >