From f60dc64b2d120899b865c02674c37e731875dede Mon Sep 17 00:00:00 2001 From: solocla Date: Mon, 2 Feb 2026 08:46:47 +0100 Subject: [PATCH] fixed importedit --- public/userarea/import_edit2.php | 142 +++++++++++++++++++------------ 1 file changed, 89 insertions(+), 53 deletions(-) diff --git a/public/userarea/import_edit2.php b/public/userarea/import_edit2.php index 7e5e5e4..86a1531 100644 --- a/public/userarea/import_edit2.php +++ b/public/userarea/import_edit2.php @@ -83,7 +83,35 @@ $fixedStmt = $pdo->prepare(" ORDER BY id "); $fixedStmt->execute([$template_id]); -$fixedFields = $fixedStmt->fetchAll(PDO::FETCH_ASSOC); +$fixedFieldsRaw = $fixedStmt->fetchAll(PDO::FETCH_ASSOC); + +// Ordine desiderato: Cliente Responsabile prima, poi gli altri, ConsegnaRichiesta prima delle 3 speciali +$desiredOrder = [ + 'ClienteResponsabile', + 'AnagraficaCertestObject', + 'AnagraficaCertestService', + 'MoltiplicatorePrezzo', + 'ConsegnaRichiesta', + // se ci sono altri campi fixed li mettiamo dopo +]; + +$fixedFields = []; +$tempMap = []; +foreach ($fixedFieldsRaw as $f) { + $tempMap[$f['fixed_field_key']] = $f; +} + +foreach ($desiredOrder as $key) { + if (isset($tempMap[$key])) { + $fixedFields[] = $tempMap[$key]; + unset($tempMap[$key]); + } +} + +// Aggiunge eventuali campi fixed non elencati sopra (alla fine) +foreach ($tempMap as $f) { + $fixedFields[] = $f; +} // helper default (DATE can use 'today' if you already use it elsewhere) function fixedDefaultValue(array $f): string @@ -709,24 +737,29 @@ function fixedDefaultValue(array $f): string $headerIndex++; echo "
Tracking Info
"; $headerIndex++; - echo "
Import Reference Code
"; - $headerIndex++; - echo "
" . ($slugMapping['filename_import'] ?? 'filename_import') . "
"; - $headerIndex++; - echo "
" . ($slugMapping['importdate'] ?? 'importdate') . "
"; - ?> - " . htmlspecialchars($label) . "
"; $headerIndex++; + + // Inseriamo le 3 colonne SOLO dopo ConsegnaRichiesta + if ($key === 'ConsegnaRichiesta' && !$insertedAfterConsegna) { + echo "
Import Reference Code
"; + $headerIndex++; + echo "
" . ($slugMapping['filename_import'] ?? 'filename_import') . "
"; + $headerIndex++; + echo "
" . ($slugMapping['importdate'] ?? 'importdate') . "
"; + $headerIndex++; + $insertedAfterConsegna = true; + } } } ?> @@ -862,70 +895,73 @@ function fixedDefaultValue(array $f): string Shipment Info -
- - -
- -
- File - -
- -
- - -
+ "; + data-col='" . htmlspecialchars($key, ENT_QUOTES) . "' + data-row='$index' + data-index='$cellIndex' + style='flex: 0 0 180px;'>"; if ($f['data_type'] === 'DATE') { echo ""; - } else { // INT → diventa select se è uno dei campi API - $isApiField = in_array($key, ['MoltiplicatorePrezzo', 'ClienteResponsabile', 'AnagraficaCertestObject', 'AnagraficaCertestService']); + } else { + $isApiField = in_array($key, ['MoltiplicatorePrezzo', 'ClienteResponsabile', 'AnagraficaCertestObject', 'AnagraficaCertestService'], true); $selectClass = $isApiField ? 'api-fixed-select' : ''; - - echo ""; + echo ""; } - echo ""; + $cellIndex++; + + // === INSERIMENTO dopo ConsegnaRichiesta === + if ($key === 'ConsegnaRichiesta') { + // Import Reference Code + echo "
"; + echo "" . htmlspecialchars($row['importreferencecode']) . ""; + echo ""; + echo "
"; + $cellIndex++; + + // filename_import + echo "
"; + echo "File"; + echo ""; + echo "
"; + $cellIndex++; + + // importdate + echo "
"; + echo "" . htmlspecialchars($row['importdate']) . ""; + echo ""; + echo "
"; + $cellIndex++; + } } } ?>