update template and edit import

This commit is contained in:
2025-07-08 12:25:47 +02:00
parent b092abf8c7
commit c533973420
69 changed files with 1655 additions and 20 deletions
@@ -180,8 +180,8 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
type: 'array'
});
let sheet = workbook.Sheets[workbook.SheetNames[0]];
let rowIndex = parseInt(document.getElementById('headerRow').textContent) || 1;
let startColumn = parseInt(document.getElementById('startColumn').textContent.charCodeAt(0) - 64) || 1;
let rowIndex = parseInt(document.getElementById('headerRow').textContent) || 1; // Usa header_row dal template
let startColumn = parseInt(document.getElementById('startColumn').textContent) || 1; // Usa start_column come numero
let sheetData = XLSX.utils.sheet_to_json(sheet, {
header: 1,
@@ -189,16 +189,19 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
raw: false,
range: 0
});
console.log("Dati della riga " + rowIndex + ":", sheetData[rowIndex - 1]); // Debug: stampa la riga delle intestazioni
if (!sheetData[rowIndex - 1]) {
document.getElementById('schemaFieldsBody').querySelectorAll('select.xls-columns').forEach(select => {
select.innerHTML = '<option value="">No headers found</option>';
select.innerHTML = '<option value="">Nessuna intestazione trovata</option>';
});
return;
}
let headers = sheetData[rowIndex - 1].slice(startColumn - 1).filter(header => header !== undefined && header.trim() !== "");
// Estrai le intestazioni a partire dalla colonna specificata, includendo le vuote
let headers = sheetData[rowIndex - 1].slice(startColumn - 1).map(header => header === undefined ? "" : header);
console.log("Intestazioni estratte:", headers); // Debug: stampa le intestazioni estratte
availableXlsColumns = [...headers];
usedColumnsFromDB = []; // Resetta le colonne usate dal DB dopo un nuovo caricamento
usedColumnsFromDB = []; // Resetta le colonne usate dopo un nuovo caricamento
saveXlsHeaders(headers);
updateXlsDropdowns();
};