added proceed on the top

This commit is contained in:
2026-03-04 10:13:33 +01:00
parent c9122774b1
commit 2ee9f2ecb1
2 changed files with 51 additions and 41 deletions
File diff suppressed because one or more lines are too long
+50 -40
View File
@@ -313,54 +313,64 @@ error_log("Loaded template: " . print_r($template, true));
function showTable(data) { function showTable(data) {
console.log('Mostro tabella con dati:', data); console.log('Mostro tabella con dati:', data);
let html = ` let html = `
<form id="selectRowsForm" action="import_insert.php" method="POST"> <form id="selectRowsForm" action="import_insert.php" method="POST">
<input type="hidden" name="template_id" value="${data.template_id}"> <input type="hidden" name="template_id" value="${data.template_id}">
<input type="hidden" name="columns" value="${encodeURIComponent(JSON.stringify(data.columns))}"> <input type="hidden" name="columns" value="${encodeURIComponent(JSON.stringify(data.columns))}">
<input type="hidden" name="rows" value="${encodeURIComponent(JSON.stringify(data.rows))}"> <input type="hidden" name="rows" value="${encodeURIComponent(JSON.stringify(data.rows))}">
<input type="hidden" name="excelrows" value="${encodeURIComponent(JSON.stringify(data.excel_data.map(r => r.excelrow)))}"> <input type="hidden" name="excelrows" value="${encodeURIComponent(JSON.stringify(data.excel_data.map(r => r.excelrow)))}">
<input type="hidden" name="filename" value="${data.filename}">
<input type="hidden" name="filename" value="${data.filename}"> <!-- TOP BUTTON -->
<div class="d-flex justify-content-end mb-3">
<button type="submit" class="btn btn-primary" id="proceedButtonTop" disabled>Prosegui</button>
</div>
<div class="table-container"> <div class="table-container">
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
<th><input type="checkbox" id="selectAll"> Seleziona</th> <th><input type="checkbox" id="selectAll"> Seleziona</th>
${data.columns.map(col => `<th>${col || 'Colonna senza nome'}<div class="resize-handle"></div></th>`).join('')} ${data.columns.map(col => `<th>${col || 'Colonna senza nome'}<div class="resize-handle"></div></th>`).join('')}
</tr> </tr>
<tr class="column-filters"> <tr class="column-filters">
<th></th> <th></th>
${data.columns.map((col, i) => ` ${data.columns.map((col, i) => `
<th> <th>
<input type="text" <input type="text"
class="form-control form-control-sm column-filter" class="form-control form-control-sm column-filter"
data-col-index="${i}" data-col-index="${i}"
placeholder="Filter..."> placeholder="Filter...">
</th> </th>
`).join('')} `).join('')}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
${data.excel_data.map((row, index) => ` ${data.excel_data.map((row, index) => `
<tr> <tr>
<td><input type="checkbox" class="row-checkbox" name="selected_rows[]" value="${index}" data-excelrow="${row.excelrow}"></td> <td><input type="checkbox" class="row-checkbox" name="selected_rows[]" value="${index}" data-excelrow="${row.excelrow}"></td>
${row.data.map(cell => `<td>${cell}</td>`).join('')} ${row.data.map(cell => `<td>${cell}</td>`).join('')}
</tr> </tr>
`).join('')} `).join('')}
</tbody> </tbody>
</table> </table>
</div> </div>
<button type="submit" class="btn btn-primary mt-3" id="proceedButton" disabled>Prosegui</button>
</form> <!-- BOTTOM BUTTON -->
`; <button type="submit" class="btn btn-primary mt-3" id="proceedButtonBottom" disabled>Prosegui</button>
</form>
`;
tableContainer.innerHTML = html; tableContainer.innerHTML = html;
const proceedButton = document.getElementById('proceedButton'); const proceedButtonTop = document.getElementById('proceedButtonTop');
const proceedButtonBottom = document.getElementById('proceedButtonBottom');
const selectAllCheckbox = document.getElementById('selectAll'); const selectAllCheckbox = document.getElementById('selectAll');
const checkboxes = document.querySelectorAll('.row-checkbox'); const checkboxes = document.querySelectorAll('.row-checkbox');
function updateProceedButton() { function updateProceedButton() {
proceedButton.disabled = !Array.from(checkboxes).some(cb => cb.checked); const enabled = Array.from(checkboxes).some(cb => cb.checked);
if (proceedButtonTop) proceedButtonTop.disabled = !enabled;
if (proceedButtonBottom) proceedButtonBottom.disabled = !enabled;
} }
selectAllCheckbox.addEventListener('change', function() { selectAllCheckbox.addEventListener('change', function() {