From 712042b8d804309a6a515dba0ee33faf00313420 Mon Sep 17 00:00:00 2001 From: Claudio Date: Tue, 26 Aug 2025 15:22:27 +0200 Subject: [PATCH] update layout table import edit 2 and fix address photos in env --- .env | 4 +- public/userarea/import_edit2.php | 387 +++++++++---------------------- public/userarea/photos_popup.php | 28 ++- 3 files changed, 140 insertions(+), 279 deletions(-) diff --git a/.env b/.env index b10709d..59b5947 100644 --- a/.env +++ b/.env @@ -42,4 +42,6 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" # Credenziali API VisualLims API_BASE_URL=https://93.43.5.102/limsapi API_USERNAME=WebApiUser -API_PASSWORD=webapiuser01 \ No newline at end of file +API_PASSWORD=webapiuser01 + +BASE_URL=http://localhost:8000/userarea/ \ No newline at end of file diff --git a/public/userarea/import_edit2.php b/public/userarea/import_edit2.php index e0bdfcc..753a402 100644 --- a/public/userarea/import_edit2.php +++ b/public/userarea/import_edit2.php @@ -58,71 +58,6 @@ foreach ($allMappings as $mapping) { } } -//// Inserisci le righe selezionate in datadb (solo campi generici con templateid) -//$insertedIds = []; -//foreach ($selected_rows as $rowIndex) { -// $row = $rows[$rowIndex]; -// $values = [ -// $template_id, // templateid -// $importReferenceCode, // importreferencecode -// $newFilename, // filename_import -// 'i', // status -// $user_id, // user_id -// null, // limscode -// date('Y-m-d') // importdate -// ]; -// $sql = "INSERT INTO datadb (templateid, importreferencecode, filename_import, status, user_id, limscode, importdate) VALUES (?, ?, ?, ?, ?, ?, ?)"; -// $stmt = $pdo->prepare($sql); -// $stmt->execute($values); -// -// $iddatadb = $pdo->lastInsertId(); -// $insertedIds[] = $iddatadb; -// -// // Inserisci tutti i campi (automatici e manuali) in import_data_details -// foreach ($allMappings as $mapping) { -// $fieldValue = null; -// if (!$mapping['is_manual']) { // Campi automatici dall'XLS -// $excelColumn = trim($mapping['excel_column']); -// $excelColumnIndex = array_search($excelColumn, array_map('trim', $columns)); -// if ($excelColumnIndex !== false && isset($row[$excelColumnIndex]) && $row[$excelColumnIndex] !== '') { -// $fieldValue = $row[$excelColumnIndex]; -// error_log("Found Excel column '$excelColumn' at index $excelColumnIndex, value: " . var_export($fieldValue, true)); -// } else { -// $fieldValue = $mapping['manual_default'] ?? ''; -// error_log("Excel column '$excelColumn' not found or empty, using default: " . var_export($fieldValue, true)); -// } -// switch ($mapping['data_type']) { -// case 'INT': -// $fieldValue = is_numeric($fieldValue) ? (int)$fieldValue : ($mapping['manual_default'] ?? 0); -// break; -// case 'DATE': -// $fieldValue = !empty($fieldValue) ? date('Y-m-d', strtotime($fieldValue)) : ($mapping['manual_default'] === 'today' ? date('Y-m-d') : ($mapping['manual_default'] ?? '')); -// break; -// case 'CHAR': -// $fieldValue = !empty($fieldValue) ? substr((string)$fieldValue, 0, 1) : ($mapping['manual_default'] ?? ''); -// break; -// case 'Testo': -// case 'VARCHAR': -// default: -// $fieldValue = !empty($fieldValue) ? htmlspecialchars((string)$fieldValue) : ($mapping['manual_default'] ?? ''); -// break; -// } -// } else { // Campi manuali -// $fieldValue = $mapping['manual_default'] ?? ''; -// if ($mapping['data_type'] === 'DATE' && $mapping['manual_default'] === 'today') { -// $fieldValue = date('Y-m-d'); -// } -// } -// if ($mapping['is_required'] && (is_null($fieldValue) || $fieldValue === '')) { -// error_log("Required field missing for mapping ID: " . $mapping['id'] . ", field: " . $mapping['field_label']); -// } -// error_log("Inserting into import_data_details - Mapping ID: " . $mapping['id'] . ", Field Value: " . var_export($fieldValue, true) . ", Is Manual: " . $mapping['is_manual'] . ", Excel Column: " . ($mapping['excel_column'] ?? 'N/A') . ", Manual Default: " . ($mapping['manual_default'] ?? 'N/A')); -// $stmt = $pdo->prepare("INSERT INTO import_data_details (id, mapping_id, field_value) VALUES (?, ?, ?)"); -// $stmt->execute([$iddatadb, $mapping['id'], $fieldValue]); -// error_log("Inserted into import_data_details for ID $iddatadb, Mapping ID: " . $mapping['id'] . ", Field Value: " . var_export($fieldValue, true)); -// } -//} - $insertedIds = $_POST['inserted_ids'] ?? $_SESSION['inserted_ids']; // Recupera i dati appena inseriti con i nomi degli utenti @@ -200,6 +135,32 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { /* Colore scuro per contrasto */ } + /* Stili per i badge di stato */ + .status-badge { + display: inline-block; + padding: 2px 8px; + font-size: 12px; + font-weight: 500; + border-radius: 12px; + text-align: center; + min-width: 60px; + } + + .status-i { + background-color: #ffc107; + color: #212529; + } + + .status-P { + background-color: #007bff; + color: white; + } + + .status-l { + background-color: #28a745; + color: white; + } + /* Stili esistenti rimangono invariati */ .grid-container { overflow-x: auto; @@ -233,7 +194,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { .grid-cell { flex: 1; min-width: 70px; - /* Ridotto da 100px per compatibilità con pulsanti */ padding: 12px 15px; border-right: 1px solid #dee2e6; overflow: hidden; @@ -410,23 +370,21 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); } - /* Sovrascrivi min-width per le celle dei pulsanti */ + /* Stile per l'header dei pulsanti combinati */ .grid-cell.button-cell, .grid-header.button-header { - min-width: 70px !important; - flex: 0 0 70px !important; + min-width: 210px !important; + flex: 0 0 210px !important; } - /* Stile per l'header dei pulsanti */ - .button-header { - min-height: 48px; - /* Altezza minima per uniformare */ - padding: 12px 0; - /* Centra verticalmente, no padding orizzontale */ - background-color: #e9ecef !important; - /* Grigio uniforme */ - border-right: 1px solid #dee2e6 !important; - /* Bordo destro coerente */ + .action-btn { + padding: 6px 8px; + margin-right: 5px; + border: none; + border-radius: 5px; + cursor: pointer; + width: 50px; + box-sizing: border-box; } Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?> @@ -438,8 +396,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
-
Imported (i) In Progress (P) @@ -461,9 +417,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
-
-
-
+
fetchAll(PDO::FETCH_ASSOC) as $row) { ?>
-
+
"; - } // Campi automatici (is_manual = 0) escluso main_field $autoIndex = 0; foreach ($allMappings as $mapping) { @@ -545,29 +495,25 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { } echo "
"; // AWB echo "
"; // Tracking Info + echo "
"; // importreferencecode + echo "
"; // filename_import + echo "
"; // importdate ?>
-
-
-
+
Actions
-
+
-
Import Reference Code
+
Status
$displayName
"; - $headerIndex++; - } + $headerIndex = $mainFieldMapping ? 3 : 2; foreach ($allMappings as $mapping) { if (!$mapping['is_manual'] && $mapping['main_field'] != 1) { echo "
" . htmlspecialchars($mapping['field_label']) . "
"; @@ -581,21 +527,24 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { } } echo "
AWB Number
"; - echo "
Tracking Info
"; + $headerIndex++; + echo "
Tracking Info
"; + $headerIndex++; + echo "
Import Reference Code
"; + $headerIndex++; + echo "
" . ($slugMapping['filename_import'] ?? 'filename_import') . "
"; + $headerIndex++; + echo "
" . ($slugMapping['importdate'] ?? 'importdate') . "
"; ?>
$row): ?>
-
- -
-
- -
-
- +
+ + +
fetchAll(PDO::FETCH_ASSOC) as $row) { $inputClass = $mainFieldMapping['is_manual'] ? 'manual-input' : 'auto-input'; if ($mainFieldMapping['is_required']) $inputClass .= ' required-input'; ?> -
+
+
+ + + +
"; - if ($col === 'importdate') { - echo "" . htmlspecialchars($value) . ""; - echo ""; - } elseif ($col === 'filename_import') { - echo "File"; - echo ""; - } elseif ($col === 'status') { - echo "" . htmlspecialchars($value === 'i' ? 'Imported' : ($value === 'P' ? 'Progress' : 'LIMS')) . ""; - echo ""; - } - echo "
"; - $cellIndex++; - } + $cellIndex = $mainFieldMapping ? 3 : 2; $rowDetails = array_filter($manualDetails, fn($d) => $d['datadb_id'] == $row['iddatadb']); $autoIndex = 0; foreach ($allMappings as $mapping) { @@ -717,6 +652,24 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { Shipment Info
+
+ + +
+ +
+ File + +
+ +
+ + +
@@ -742,7 +695,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { const unsavedDiv = document.getElementById("unsavedChanges"); let hasChanges = false; - // როცა მნიშვნელობა შეიცვლება inputs.forEach(el => { el.addEventListener("change", () => { hasChanges = true; @@ -750,7 +702,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { }); }); - // როცა save ღილაკს დააჭერს document.querySelectorAll(".save-btn").forEach(btn => { btn.addEventListener("click", () => { hasChanges = false; @@ -758,8 +709,36 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { }); }); - // სურვილისამებრ: გაფრთხილება გვერდიდან გასვლისას - window.addEventListener("beforeunload", function (e) { + window.addEventListener("beforeunload", function(e) { + if (hasChanges) { + e.preventDefault(); + e.returnValue = ""; + } + }); + }); + + + - - - - + \ No newline at end of file diff --git a/public/userarea/photos_popup.php b/public/userarea/photos_popup.php index 63d92c8..e11496f 100644 --- a/public/userarea/photos_popup.php +++ b/public/userarea/photos_popup.php @@ -11,6 +11,24 @@ use Endroid\QrCode\QrCode; use Endroid\QrCode\RoundBlockSizeMode; use Endroid\QrCode\Writer\PngWriter; +// Carica le variabili d'ambiente +try { + $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../../'); + $dotenv->load(); + error_log("File .env caricato correttamente da " . __DIR__ . '/../../.env'); +} catch (Exception $e) { + error_log("Errore nel caricamento del file .env: " . $e->getMessage()); + echo json_encode(['error' => 'Errore nel caricamento del file di configurazione']); + exit; +} + +// Verifica che BASE_URL sia definito +if (!isset($_ENV['BASE_URL'])) { + error_log("Errore: la variabile BASE_URL non è definita nel file .env"); + echo json_encode(['error' => 'Variabile BASE_URL non definita']); + exit; +} + $db = DBHandlerSelect::getInstance(); $pdo = $db->getConnection(); @@ -43,9 +61,9 @@ $photos = $stmt->fetchAll(PDO::FETCH_ASSOC); // Definisci il percorso base per le foto $photoBasePath = '../photostrf/'; -// Genera l'URL per il QR code -$baseUrl = "http://localhost:8000/userarea/"; // Sostituisci con il tuo dominio -$uploadUrl = $baseUrl . "upload_photos_mobile.php?iddatadb=" . $iddatadb; +// Usa la variabile d'ambiente BASE_URL +$baseUrl = rtrim($_ENV['BASE_URL'], '/'); // Rimuove eventuali slash finali +$uploadUrl = $baseUrl . "/upload_photos_mobile.php?iddatadb=" . $iddatadb; // Genera il QR code con endroid/qr-code 6.0.6 $qrCodeDir = '../photostrf/qrcodes/'; @@ -159,7 +177,6 @@ $result->saveToFile($qrCodeFile); background-color: #e9ecef; } - /* Stile per il modale dell'immagine ingrandita */ .image-modal { display: none; position: fixed; @@ -199,7 +216,6 @@ $result->saveToFile($qrCodeFile); text-decoration: none; } - /* Stili per il loader */ .loader { display: none; position: fixed; @@ -224,4 +240,4 @@ $result->saveToFile($qrCodeFile); font-size: 16px; color: white; } - + \ No newline at end of file