diff --git a/public/userarea/import_xls2.php b/public/userarea/import_xls2.php index dcf3202..5d98e16 100644 --- a/public/userarea/import_xls2.php +++ b/public/userarea/import_xls2.php @@ -337,8 +337,8 @@ error_log("Loaded template: " . print_r($template, true));
- - + + @@ -389,6 +389,42 @@ error_log("Loaded template: " . print_r($template, true)); `; tableContainer.innerHTML = html; + const selectRowsForm = document.getElementById('selectRowsForm'); + + selectRowsForm.addEventListener('submit', function(e) { + const checkedBoxes = Array.from(document.querySelectorAll('.row-checkbox:checked')); + + if (checkedBoxes.length === 0) { + e.preventDefault(); + alert('Seleziona almeno una riga.'); + return; + } + + const selectedRows = []; + const selectedExcelRows = []; + + checkedBoxes.forEach((cb, newIndex) => { + const originalIndex = parseInt(cb.value, 10); + + if (data.rows && data.rows[originalIndex]) { + selectedRows.push(data.rows[originalIndex]); + } + + if (data.excel_data && data.excel_data[originalIndex]) { + selectedExcelRows.push(data.excel_data[originalIndex].excelrow); + } + + // Reindex selected_rows so import_insert.php receives only the reduced rows array + cb.value = newIndex; + }); + + document.getElementById('selectedRowsData').value = + encodeURIComponent(JSON.stringify(selectedRows)); + + document.getElementById('selectedExcelRowsData').value = + encodeURIComponent(JSON.stringify(selectedExcelRows)); + }); + const topTableScrollbar = document.getElementById('topTableScrollbar'); const topTableScrollbarInner = document.getElementById('topTableScrollbarInner'); const mainTableContainer = document.getElementById('mainTableContainer'); diff --git a/public/userarea/trial.php b/public/userarea/trial.php new file mode 100644 index 0000000..3f16307 --- /dev/null +++ b/public/userarea/trial.php @@ -0,0 +1,23 @@ +get($endpoint); + + echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); +} catch (Exception $e) { + http_response_code(500); + echo json_encode([ + "success" => false, + "error" => $e->getMessage() + ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); +}