From 5a58decd40eea2132eb38f19658231e9750ba65b Mon Sep 17 00:00:00 2001 From: solocla Date: Thu, 19 Mar 2026 10:08:29 +0100 Subject: [PATCH] added clienti in template, export --- public/userarea/create_fixed_fields.php | 2 + public/userarea/debug_commessa_api.php | 290 ++++ public/userarea/error_log.txt | 1 + public/userarea/export_to_lims.php | 2 + public/userarea/import_edit2.php | 327 ++-- ...messa_565085_campioni_step6_1773911004.txt | 90 ++ .../commessa_565085_get_step10_1773911014.txt | 1314 +++++++++++++++++ .../commessa_565085_get_step7_1773911008.txt | 1314 +++++++++++++++++ ...messa_565085_importa_step91_1773911013.txt | 20 + ...messa_565085_photos_step5_2_1773911007.txt | 48 + .../commessa_565085_send_step9_1773911010.txt | 18 + ...ommessa_565085_update_step7_1773911009.txt | 226 +++ .../commessa_create_step5_1279_1773910998.txt | 29 + .../userarea/mapping_template_xls_scheme2.php | 48 +- public/userarea/save_edited_row.php | 3 +- 15 files changed, 3497 insertions(+), 235 deletions(-) create mode 100644 public/userarea/debug_commessa_api.php create mode 100644 public/userarea/logs/api/commessa_565085_campioni_step6_1773911004.txt create mode 100644 public/userarea/logs/api/commessa_565085_get_step10_1773911014.txt create mode 100644 public/userarea/logs/api/commessa_565085_get_step7_1773911008.txt create mode 100644 public/userarea/logs/api/commessa_565085_importa_step91_1773911013.txt create mode 100644 public/userarea/logs/api/commessa_565085_photos_step5_2_1773911007.txt create mode 100644 public/userarea/logs/api/commessa_565085_send_step9_1773911010.txt create mode 100644 public/userarea/logs/api/commessa_565085_update_step7_1773911009.txt create mode 100644 public/userarea/logs/api/commessa_create_step5_1279_1773910998.txt diff --git a/public/userarea/create_fixed_fields.php b/public/userarea/create_fixed_fields.php index 61a598a..57eae37 100644 --- a/public/userarea/create_fixed_fields.php +++ b/public/userarea/create_fixed_fields.php @@ -30,6 +30,8 @@ if ((int)$stmt->fetchColumn() > 0) { $fixedFields = [ // fixed_field_key, data_type ['ClienteResponsabile', 'INT'], + ['ClienteFornitore', 'INT'], + ['ClienteAnalisi', 'INT'], ['MoltiplicatorePrezzo', 'INT'], ['AnagraficaCertestObject', 'INT'], ['AnagraficaCertestService', 'INT'], diff --git a/public/userarea/debug_commessa_api.php b/public/userarea/debug_commessa_api.php new file mode 100644 index 0000000..7f70715 --- /dev/null +++ b/public/userarea/debug_commessa_api.php @@ -0,0 +1,290 @@ +No records found'; + return; + } + + $firstRow = reset($items); + if (!is_array($firstRow)) { + echo '
' . h(json_encode($items, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) . '
'; + return; + } + + $headers = []; + foreach ($items as $row) { + if (is_array($row)) { + $headers = array_unique(array_merge($headers, array_keys($row))); + } + } + + echo '
'; + echo ''; + echo ''; + foreach ($headers as $header) { + echo ''; + } + echo ''; + + foreach ($items as $row) { + echo ''; + foreach ($headers as $header) { + $value = $row[$header] ?? ''; + if (is_array($value) || is_object($value)) { + $value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + echo ''; + } else { + echo ''; + } + } + echo ''; + } + + echo '
' . h($header) . '
' . h($value) . '
' . h($value) . '
'; + echo '
'; +} + +try { + if ($entityId > 0) { + $api = VisualLimsApiClient::getInstance(); + + // Default expands for better debugging + if ($customExpand !== '') { + $expand = $customExpand; + } else { + if ($entityType === 'CommessaWeb') { + $expand = implode(',', [ + 'CommesseCustomFields($expand=CustomField)', + 'Campioni' + ]); + } else { + $expand = implode(',', [ + 'CommesseCustomFields($expand=CustomField)', + 'Campioni' + ]); + } + } + + $rawEndpoint = $entityType . '(' . $entityId . ')?$expand=' . $expand; + $result = $api->get($rawEndpoint); + } +} catch (Exception $e) { + $error = $e->getMessage(); +} +?> + + + + + + + Debug Commessa API + + + + + +
+
+

Commessa / CommessaWeb API Inspector

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+ + +
+
Requested Endpoint
+
+
+ + + +
+
+ API Error:
+ +
+
+ + + +
+
Main Information
+
+
+ ID + +
+
+ Code + +
+
+ Cliente + +
+
+ SchemaCustomField + +
+
+ Richiedente + +
+
+ Descrizione + +
+
+
+ +
+
Direct Properties
+
+
+ + +
+
CommesseCustomFields
+ $field['IdCommesseCustomFields'] ?? '', + 'Valore' => $field['Valore'] ?? '', + 'CustomFieldId' => $field['CustomField']['IdCustomField'] ?? '', + 'Label' => $field['CustomField']['Descrizione'] ?? ($field['CustomField']['Name'] ?? ''), + 'Tipo' => $field['CustomField']['Tipo'] ?? '', + ]; + } + renderArrayAsTable($fieldsRows); + ?> +
+ + + +
+
Campioni
+ +
+ + +
+
Raw JSON
+
+
+ 0 && !$error): ?> +
+
No data returned from API
+
+ +
+ + + + + \ No newline at end of file diff --git a/public/userarea/error_log.txt b/public/userarea/error_log.txt index 81f9982..70b7984 100644 --- a/public/userarea/error_log.txt +++ b/public/userarea/error_log.txt @@ -315,3 +315,4 @@ 2026-02-28 21:01:27 [AnagraficaCertestService] Autenticazione fallita: HTTP 400, Errore cURL: , Risposta: {"title":"Bad Request","status":400,"detail":"Cannot persist the object. It was modified or deleted (purged) by another application.","instance":"POST /api/authentication/authenticate","errorCode":"96bfc1252b"} 2026-03-01 19:11:58 [AnagraficaCertestObject] Autenticazione fallita: HTTP 400, Errore cURL: , Risposta: {"title":"Bad Request","status":400,"detail":"Cannot persist the object. It was modified or deleted (purged) by another application.","instance":"POST /api/authentication/authenticate","errorCode":"96bfc1252b"} 2026-03-18 15:51:45 [AnagraficaCertestService] Autenticazione fallita: HTTP 400, Errore cURL: , Risposta: {"title":"Bad Request","status":400,"detail":"Cannot persist the object. It was modified or deleted (purged) by another application.","instance":"POST /api/authentication/authenticate","errorCode":"96bfc1252b"} +2026-03-19 09:50:34 [AnagraficaCertestService] Autenticazione fallita: HTTP 400, Errore cURL: , Risposta: {"title":"Bad Request","status":400,"detail":"Cannot persist the object. It was modified or deleted (purged) by another application.","instance":"POST /api/authentication/authenticate","errorCode":"96bfc1252b"} diff --git a/public/userarea/export_to_lims.php b/public/userarea/export_to_lims.php index 7148733..d9e0929 100644 --- a/public/userarea/export_to_lims.php +++ b/public/userarea/export_to_lims.php @@ -101,6 +101,7 @@ try { $anagraficaObject = !empty($result['anagrafica_certest_object_id']) ? (int) $result['anagrafica_certest_object_id'] : null; $anagraficaService = !empty($result['anagrafica_certest_service_id']) ? (int) $result['anagrafica_certest_service_id'] : null; $clienteFornitore = !empty($result['cliente_fornitore_id']) ? (int) $result['cliente_fornitore_id'] : null; + $clienteAnalisi = !empty($result['clienteAnalisi']) ? (int) $result['clienteAnalisi'] : null; $consegnaRichiesta = !empty($result['consegna_richiesta']) ? $result['consegna_richiesta'] : null; // 🔹 STEP 3: Fetch Parts (including idmatrice) @@ -175,6 +176,7 @@ try { "AnagraficaCertestObject" => $anagraficaObject, "AnagraficaCertestService" => $anagraficaService, "ClienteFornitore" => $clienteFornitore, // PLACEHOLDER — to be implemented + "ClienteAnalisi" => $clienteAnalisi, // PLACEHOLDER — to be implemented // DeliveryRequest goes to Campione, not CommessaWeb ]; diff --git a/public/userarea/import_edit2.php b/public/userarea/import_edit2.php index cb6d978..0409654 100644 --- a/public/userarea/import_edit2.php +++ b/public/userarea/import_edit2.php @@ -167,6 +167,8 @@ $fixedFieldsRaw = $fixedStmt->fetchAll(PDO::FETCH_ASSOC); // Ordine desiderato: Cliente Responsabile prima, poi gli altri, ConsegnaRichiesta prima delle 3 speciali $desiredOrder = [ 'ClienteResponsabile', + 'ClienteFornitore', + 'ClienteAnalisi', 'AnagraficaCertestObject', 'AnagraficaCertestService', 'MoltiplicatorePrezzo', @@ -174,8 +176,8 @@ $desiredOrder = [ // se ci sono altri campi fixed li mettiamo dopo ]; -// ClienteFornitore is rendered as a standalone column (like idclient), skip it in fixed fields -$excludeFromFixed = ['ClienteFornitore']; +// No exclusions: fixed fields will be rendered together at the end +$excludeFromFixed = []; $fixedFields = []; $tempMap = []; @@ -199,10 +201,11 @@ foreach ($tempMap as $f) { // Maps logical fixed_field_key → real datadb column name (mirrors JS fixedAliasMap) $fixedAliasMap = [ 'ClienteResponsabile' => 'cliente_responsabile_id', + 'ClienteFornitore' => 'cliente_fornitore_id', + 'ClienteAnalisi' => 'clienteAnalisi', 'MoltiplicatorePrezzo' => 'moltiplicatore_prezzo_id', 'AnagraficaCertestObject' => 'anagrafica_certest_object_id', 'AnagraficaCertestService' => 'anagrafica_certest_service_id', - 'ClienteFornitore' => 'cliente_fornitore_id', 'ConsegnaRichiesta' => 'consegna_richiesta', ]; @@ -966,15 +969,9 @@ function fixedDefaultValue(array $f): string -
- - -
Client
-
Cliente Fornitore
-
" . htmlspecialchars($mapping['field_label']) . "
"; @@ -1245,13 +1242,9 @@ function fixedDefaultValue(array $f): string -
- -
+ $d['datadb_id'] == $row['iddatadb']); $autoIndex = 0; foreach ($allMappings as $mapping) { @@ -1376,7 +1369,7 @@ function fixedDefaultValue(array $f): string . (((int)$f['is_required'] === 1) ? "required" : "") . ">"; } else { - $isApiField = in_array($key, ['MoltiplicatorePrezzo', 'ClienteResponsabile', 'AnagraficaCertestObject', 'AnagraficaCertestService'], true); + $isApiField = in_array($key, ['MoltiplicatorePrezzo', 'ClienteResponsabile', 'ClienteFornitore', 'ClienteAnalisi', 'AnagraficaCertestObject', 'AnagraficaCertestService'], true); $selectClass = $isApiField ? 'api-fixed-select' : ''; echo "