diff --git a/db/migrations/20260708195704_add_addnote_to_template_mapping.php b/db/migrations/20260708195704_add_addnote_to_template_mapping.php new file mode 100644 index 0000000..fbdd37b --- /dev/null +++ b/db/migrations/20260708195704_add_addnote_to_template_mapping.php @@ -0,0 +1,20 @@ +table('template_mapping'); + $table->addColumn('is_addnote', 'boolean', [ + 'default' => 0, + 'null' => false, + 'after' => 'is_visible_parts', + 'comment' => 'Campo utilizzabile come addnote (multi-selezione)', + ]) + ->update(); + } +} diff --git a/public/userarea/error_log.txt b/public/userarea/error_log.txt index 6db6756..76bec6b 100644 --- a/public/userarea/error_log.txt +++ b/public/userarea/error_log.txt @@ -363,3 +363,14 @@ 2026-06-16 17:14:25 - Autenticazione fallita: HTTP 0, Errore cURL: Failed to connect to bvcpsitaly-elims.com port 443 after 21065 ms: Couldn't connect to server, Risposta: 2026-06-16 17:14:46 - Autenticazione fallita: HTTP 0, Errore cURL: Failed to connect to bvcpsitaly-elims.com port 443 after 21071 ms: Couldn't connect to server, Risposta: 2026-06-16 17:14:46 - Autenticazione fallita: HTTP 0, Errore cURL: Failed to connect to bvcpsitaly-elims.com port 443 after 21078 ms: Couldn't connect to server, Risposta: +2026-07-09 08:06:33 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:33 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:33 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:33 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:33 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:41 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:41 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:41 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:41 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-09 08:06:41 - Autenticazione fallita: HTTP 0, Errore cURL: Could not resolve host: bvcpsitaly-elims.com, Risposta: +2026-07-10 08:12:24 - Errore nella richiesta: SSL connection timeout diff --git a/public/userarea/export_to_lims.php b/public/userarea/export_to_lims.php index 76c8e36..76409d8 100644 --- a/public/userarea/export_to_lims.php +++ b/public/userarea/export_to_lims.php @@ -150,7 +150,7 @@ try { // ๐น STEP 1+2: Fetch Cliente ID from datadb and Schema ID from excel_templates // Also fetch fixed fields stored in datadb $stmt = $pdo->prepare(" - SELECT d.idclient AS clienteId, et.idschema AS schemaId, + SELECT d.idclient AS clienteId, et.idschema AS schemaId, et.id AS templateId, d.cliente_responsabile_id, d.moltiplicatore_prezzo_id, d.anagrafica_certest_object_id, @@ -173,6 +173,7 @@ try { $clienteId = (int) $result['clienteId']; $schemaId = (int) $result['schemaId']; + $templateId = (int) $result['templateId']; // Extract fixed fields (nullable INTs) $clienteResponsabile = !empty($result['cliente_responsabile_id']) ? (int) $result['cliente_responsabile_id'] : null; @@ -212,6 +213,7 @@ try { } } + // ๐น STEP 4a: Auto-populate export_date / export_time fields $stmt = $pdo->prepare(" UPDATE import_data_details idd @@ -235,7 +237,9 @@ try { idd.field_value, m.field_label, m.schema_id, - m.field_id + m.field_id, + m.field_order, + m.is_addnote FROM import_data_details as idd JOIN template_mapping m ON idd.mapping_id = m.id @@ -255,6 +259,27 @@ try { $valueMap[(int) $row['field_id']] = $row['field_value']; } + // ๐น Note aggiuntive: custom field flaggati is_addnote e valorizzati. + // Valori a livello di commessa โ identici su tutte le parti. + $addnoteChunks = []; + $addnoteRows = array_filter($rows, fn($r) => (int)($r['is_addnote'] ?? 0) === 1); + + usort($addnoteRows, function ($a, $b) { + $oa = (int)($a['field_order'] ?? 9999); + $ob = (int)($b['field_order'] ?? 9999); + if ($oa !== $ob) return $oa <=> $ob; + return strcmp((string)($a['field_label'] ?? ''), (string)($b['field_label'] ?? '')); + }); + + foreach ($addnoteRows as $r) { + $val = trim((string)($r['field_value'] ?? '')); + if ($val !== '') { + $addnoteChunks[] = $val; + } + } + + $addnoteText = implode(' - ', $addnoteChunks); + // Logga i fieldValues in error_log $logFieldValues = "FieldValues dal DB (iddatadb={$iddatadb}):\n" . json_encode($fieldValues, JSON_PRETTY_PRINT); error_log($logFieldValues); @@ -311,7 +336,23 @@ try { $partDescription = $part["part_description"] ?? ""; $partNote = trim((string)($part["note"] ?? "")); - $noteWebValue = $partNote !== "" ? $partDescription . " - " . $partNote : $partDescription; + + // Note aggiuntive dai custom field flaggati is_addnote + $partDescription = $part["part_description"] ?? ""; + $partNote = trim((string)($part["note"] ?? "")); + + // Componi NoteWeb: descrizione [- note] [- addnote di commessa] + $noteParts = []; + if ($partDescription !== "") { + $noteParts[] = $partDescription; + } + if ($partNote !== "") { + $noteParts[] = $partNote; + } + if ($addnoteText !== "") { + $noteParts[] = $addnoteText; + } + $noteWebValue = implode(" - ", $noteParts); $campionePayload = [ "Commessa" => $commessaId, diff --git a/public/userarea/mapping_template_xls_scheme2.php b/public/userarea/mapping_template_xls_scheme2.php index 4586cb7..11db485 100644 --- a/public/userarea/mapping_template_xls_scheme2.php +++ b/public/userarea/mapping_template_xls_scheme2.php @@ -77,7 +77,8 @@ $stmt = $pdo->prepare(" field_label, main_field, is_visible_import, - is_visible_parts + is_visible_parts, + is_addnote FROM template_mapping WHERE template_id = ? ORDER BY field_order ASC, id ASC @@ -183,7 +184,9 @@ $apiSampleJson = $template['api_sample_json'] ?? ''; #schemaFieldsTable th:nth-child(2), #schemaFieldsTable td:nth-child(2), #schemaFieldsTable th:nth-child(3), - #schemaFieldsTable td:nth-child(3) { + #schemaFieldsTable td:nth-child(3), + #schemaFieldsTable th:nth-child(4), + #schemaFieldsTable td:nth-child(4) { width: 48px; /* ๐ฅ piรน stretto */ text-align: center; @@ -195,7 +198,8 @@ $apiSampleJson = $template['api_sample_json'] ?? ''; /* Make checkbox itself not oversized */ #schemaFieldsTable td:nth-child(1) input[type="checkbox"], #schemaFieldsTable td:nth-child(2) input[type="checkbox"], - #schemaFieldsTable td:nth-child(3) input[type="checkbox"] { + #schemaFieldsTable td:nth-child(3) input[type="checkbox"], + #schemaFieldsTable td:nth-child(4) input[type="checkbox"] { transform: scale(0.95); margin: 0; } @@ -398,6 +402,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';