Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a944a73f7 | |||
| 71595cc8de |
@@ -120,76 +120,4 @@ class VisualLimsApiClient
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post($endpoint, $payload)
|
|
||||||
{
|
|
||||||
$token = $this->getToken();
|
|
||||||
$url = "{$this->baseUrl}/api/odata/{$endpoint}";
|
|
||||||
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
||||||
"Authorization: Bearer {$token}",
|
|
||||||
"Content-Type: application/json",
|
|
||||||
"Accept: application/json"
|
|
||||||
]);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
$curl_error = curl_error($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
if ($response === false) {
|
|
||||||
throw new Exception("Errore nella richiesta POST: {$curl_error}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($http_code < 200 || $http_code >= 300) {
|
|
||||||
throw new Exception("POST fallito: HTTP {$http_code}, Risposta: " . substr($response, 0, 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_decode($response, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function patch($endpoint, $payload)
|
|
||||||
{
|
|
||||||
$token = $this->getToken();
|
|
||||||
$url = "{$this->baseUrl}/api/odata/{$endpoint}";
|
|
||||||
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
||||||
"Authorization: Bearer {$token}",
|
|
||||||
"Content-Type: application/json",
|
|
||||||
"Accept: application/json"
|
|
||||||
]);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
$curl_error = curl_error($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
if ($response === false) {
|
|
||||||
throw new Exception("Errore nella richiesta PATCH: {$curl_error}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($http_code < 200 || $http_code >= 300) {
|
|
||||||
throw new Exception("PATCH fallito: HTTP {$http_code}, Risposta: " . substr($response, 0, 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_decode($response, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBaseUrl()
|
|
||||||
{
|
|
||||||
return $this->baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,6 @@ Content-Length: 51
|
|||||||
< strict-transport-security: max-age=2592000
|
< strict-transport-security: max-age=2592000
|
||||||
< x-powered-by: ASP.NET
|
< x-powered-by: ASP.NET
|
||||||
< x-content-type-options: nosniff
|
< x-content-type-options: nosniff
|
||||||
< date: Sat, 06 Sep 2025 10:24:00 GMT
|
< date: Mon, 08 Sep 2025 06:40:14 GMT
|
||||||
<
|
<
|
||||||
* Connection #0 to host 93.43.5.102 left intact
|
* Connection #0 to host 93.43.5.102 left intact
|
||||||
|
|||||||
@@ -10,16 +10,16 @@
|
|||||||
* issuer: C=US; O=Corporation Service Company; CN=Corporation Service Company RSA OV SSL CA
|
* issuer: C=US; O=Corporation Service Company; CN=Corporation Service Company RSA OV SSL CA
|
||||||
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
|
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
|
||||||
* using HTTP/2
|
* using HTTP/2
|
||||||
* [HTTP/2] [1] OPENED stream for https://93.43.5.102/limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues
|
* [HTTP/2] [1] OPENED stream for https://93.43.5.102/limsapi/api/odata/CommessaWeb(529435)
|
||||||
* [HTTP/2] [1] [:method: GET]
|
* [HTTP/2] [1] [:method: GET]
|
||||||
* [HTTP/2] [1] [:scheme: https]
|
* [HTTP/2] [1] [:scheme: https]
|
||||||
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
||||||
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
* [HTTP/2] [1] [:path: /limsapi/api/odata/CommessaWeb(529435)]
|
||||||
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NzE2MTQ0MCwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.UgVN5wzjtR8MRU2xLDFWRHIAYLJTmxF3x7kWeVU11YU]
|
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NzMyMDgxNCwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.enjh2WJVy0NQ8zEDX5S09glaAOamuzcG33TM_fTgTMo]
|
||||||
* [HTTP/2] [1] [accept: application/json]
|
* [HTTP/2] [1] [accept: application/json]
|
||||||
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
> GET /limsapi/api/odata/CommessaWeb(529435) HTTP/2
|
||||||
Host: 93.43.5.102
|
Host: 93.43.5.102
|
||||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NzE2MTQ0MCwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.UgVN5wzjtR8MRU2xLDFWRHIAYLJTmxF3x7kWeVU11YU
|
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NzMyMDgxNCwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.enjh2WJVy0NQ8zEDX5S09glaAOamuzcG33TM_fTgTMo
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
|
|
||||||
< HTTP/2 200
|
< HTTP/2 200
|
||||||
@@ -30,6 +30,6 @@ Accept: application/json
|
|||||||
< odata-version: 4.0
|
< odata-version: 4.0
|
||||||
< x-powered-by: ASP.NET
|
< x-powered-by: ASP.NET
|
||||||
< x-content-type-options: nosniff
|
< x-content-type-options: nosniff
|
||||||
< date: Sat, 06 Sep 2025 10:24:02 GMT
|
< date: Mon, 08 Sep 2025 06:40:14 GMT
|
||||||
<
|
<
|
||||||
* Connection #0 to host 93.43.5.102 left intact
|
* Connection #0 to host 93.43.5.102 left intact
|
||||||
|
|||||||
@@ -11,3 +11,4 @@
|
|||||||
2025-08-26 16:48:44 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
2025-08-26 16:48:44 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||||
2025-08-26 16:49:24 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
2025-08-26 16:49:24 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||||
2025-08-26 16:50:23 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
2025-08-26 16:50:23 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||||
|
2025-09-08 08:39:17 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||||
|
|||||||
@@ -1,172 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once "class/VisualLimsApiClient.class.php";
|
|
||||||
include('include/headscript.php');
|
|
||||||
|
|
||||||
$dbHandler = DBHandlerSelect::getInstance();
|
|
||||||
$pdo = $dbHandler->getConnection();
|
|
||||||
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
|
|
||||||
try {
|
|
||||||
$iddatadb = $_POST['iddatadb'] ?? null;
|
|
||||||
if (!$iddatadb) {
|
|
||||||
throw new Exception("Missing iddatadb");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 🔹 STEP 1+2: Fetch Cliente ID + Schema ID
|
|
||||||
$stmt = $pdo->prepare("
|
|
||||||
SELECT et.idclient AS clienteId, et.idschema AS schemaId
|
|
||||||
FROM datadb as d
|
|
||||||
INNER JOIN excel_templates as et ON d.templateid = et.id
|
|
||||||
WHERE d.iddatadb = :iddatadb
|
|
||||||
LIMIT 1
|
|
||||||
");
|
|
||||||
$stmt->execute(['iddatadb' => $iddatadb]);
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
throw new Exception("No Cliente/Schema found for iddatadb {$iddatadb}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$clienteId = (int) $result['clienteId'];
|
|
||||||
$schemaId = (int) $result['schemaId'];
|
|
||||||
|
|
||||||
// 🔹 STEP 3: Fetch Parts (including idmatrice)
|
|
||||||
$stmt = $pdo->prepare("
|
|
||||||
SELECT part_number, part_description, material, color, mix, idmatrice
|
|
||||||
FROM identification_parts
|
|
||||||
WHERE iddatadb = :iddatadb
|
|
||||||
");
|
|
||||||
$stmt->execute(['iddatadb' => $iddatadb]);
|
|
||||||
$parts = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
// 🔹 STEP 4: Fetch Field Values with Labels
|
|
||||||
$stmt = $pdo->prepare("
|
|
||||||
SELECT
|
|
||||||
idd.field_value,
|
|
||||||
m.field_label,
|
|
||||||
m.schema_id,
|
|
||||||
m.field_id
|
|
||||||
FROM
|
|
||||||
import_data_details as idd
|
|
||||||
JOIN template_mapping m ON idd.mapping_id = m.id
|
|
||||||
WHERE idd.id = :iddatadb
|
|
||||||
");
|
|
||||||
$stmt->execute(['iddatadb' => $iddatadb]);
|
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
$fieldValues = [];
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
$fieldValues[] = [
|
|
||||||
"IdCommesseCustomFields" => (int) $row['field_id'],
|
|
||||||
"Valore" => $row['field_value']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 🔹 Initialize API client
|
|
||||||
$api = VisualLimsApiClient::getInstance();
|
|
||||||
|
|
||||||
// 🔹 STEP 5: Create CommessaWeb (NOT WebOrder)
|
|
||||||
$commessaWebPayload = [
|
|
||||||
"Cliente" => $clienteId,
|
|
||||||
"SchemaCustomField" => $schemaId,
|
|
||||||
"Richiedente" => "Test Web Import",
|
|
||||||
"Descrizione" => "TEST CommessaWeb",
|
|
||||||
];
|
|
||||||
$commessaWeb = $api->post("CommessaWeb", $commessaWebPayload);
|
|
||||||
|
|
||||||
$commessaId = $commessaWeb["IdCommessa"];
|
|
||||||
// Estraiamo il numero della commessa usando CodiceCommessa
|
|
||||||
$commessaWebCode = substr($commessaWeb["CodiceCommessa"] ?? "TEST CommessaWeb", 0, 30); // Limite a 30 caratteri
|
|
||||||
|
|
||||||
// 🔹 STEP 6: Create Campioni (Samples) for each part
|
|
||||||
$campioni = [];
|
|
||||||
foreach ($parts as $index => $part) {
|
|
||||||
$matriceId = (int) ($part["idmatrice"] ?? 0);
|
|
||||||
|
|
||||||
if ($matriceId <= 0) {
|
|
||||||
throw new Exception("Invalid or missing idmatrice for part: " . ($part["part_number"] ?? "Unknown"));
|
|
||||||
}
|
|
||||||
|
|
||||||
$campionePayload = [
|
|
||||||
"Commessa" => $commessaId,
|
|
||||||
"Matrice" => $matriceId,
|
|
||||||
"SottoMatrice" => null,
|
|
||||||
"SchemaCustomField" => $schemaId,
|
|
||||||
"NoteWeb" => $part["part_description"] ?? ""
|
|
||||||
];
|
|
||||||
|
|
||||||
$campione = $api->post("Campione", $campionePayload);
|
|
||||||
|
|
||||||
$campione["PartNumber"] = $part["part_number"] ?? "";
|
|
||||||
$campione["Material"] = $part["material"] ?? "";
|
|
||||||
$campione["Color"] = $part["color"] ?? "";
|
|
||||||
$campione["Mix"] = $part["mix"] ?? "";
|
|
||||||
|
|
||||||
$campioni[] = $campione;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 🔹 STEP 7: Update Custom Fields for CommessaWeb
|
|
||||||
if (!empty($fieldValues)) {
|
|
||||||
$commessaWithFields = $api->get("CommessaWeb(" . $commessaId . ")?\$expand=CommesseCustomFields");
|
|
||||||
$commessaCustomFields = [];
|
|
||||||
foreach ($commessaWithFields["CommesseCustomFields"] as $customField) {
|
|
||||||
foreach ($fieldValues as $fieldValue) {
|
|
||||||
if ($customField["IdCommesseCustomFields"] == $fieldValue["IdCommesseCustomFields"]) {
|
|
||||||
$commessaCustomFields[] = [
|
|
||||||
"IdCommesseCustomFields" => $customField["IdCommesseCustomFields"],
|
|
||||||
"Valore" => $fieldValue["Valore"]
|
|
||||||
];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($commessaCustomFields)) {
|
|
||||||
$updatePayload = ["CommesseCustomFields" => $commessaCustomFields];
|
|
||||||
$api->patch("CommessaWeb({$commessaId})", $updatePayload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 🔹 STEP 8: Update datadb with idcommessaweb, commessaweb, and status
|
|
||||||
$stmt = $pdo->prepare("
|
|
||||||
UPDATE datadb
|
|
||||||
SET idcommessaweb = :idcommessaweb, commessaweb = :commessaweb, status = 'l'
|
|
||||||
WHERE iddatadb = :iddatadb
|
|
||||||
");
|
|
||||||
$stmt->execute([
|
|
||||||
'idcommessaweb' => $commessaId,
|
|
||||||
'commessaweb' => $commessaWebCode,
|
|
||||||
'iddatadb' => $iddatadb
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 🔹 STEP 9: Send CommessaWeb to laboratory
|
|
||||||
$sendResult = $api->post("CommessaWeb({$commessaId})/InviaCommessa", []);
|
|
||||||
|
|
||||||
// 🔹 STEP 10: Prepare final response
|
|
||||||
$finalCommessa = [
|
|
||||||
"Cliente" => $clienteId,
|
|
||||||
"SchemaCustomField" => $schemaId,
|
|
||||||
"Richiedente" => $commessaWeb["Richiedente"] ?? "Web Import",
|
|
||||||
"Descrizione" => $commessaWeb["Descrizione"] ?? "",
|
|
||||||
"CommesseCustomFields" => $fieldValues,
|
|
||||||
"Campioni" => $campioni,
|
|
||||||
"Inviata" => 1
|
|
||||||
];
|
|
||||||
|
|
||||||
echo json_encode([
|
|
||||||
"success" => true,
|
|
||||||
"commessaWeb" => $finalCommessa,
|
|
||||||
"commessaWebApiResponse" => $commessaWeb, // Incluso per debug
|
|
||||||
"totalCampioni" => count($campioni),
|
|
||||||
"totalCustomFields" => count($fieldValues),
|
|
||||||
"message" => "Export successful"
|
|
||||||
]);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
error_log("LIMS Export Error: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
|
|
||||||
|
|
||||||
echo json_encode([
|
|
||||||
"success" => false,
|
|
||||||
"message" => "Export failed: " . $e->getMessage()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
|
||||||
|
require_once dirname(__FILE__) . '/class/VisualLimsApiClient.class.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$api = VisualLimsApiClient::getInstance();
|
||||||
|
|
||||||
|
// ID della CommessaWeb specifica (cambialo di volta in volta)
|
||||||
|
$id = 529435; // TODO: Cambia questo valore con l'ID desiderato
|
||||||
|
|
||||||
|
// Endpoint per recuperare la CommessaWeb specifica con espansione dello schema custom
|
||||||
|
$endpoint = "CommessaWeb({$id})";
|
||||||
|
|
||||||
|
// Opzioni per l'espansione: includi OrderCustomFields per ottenere i campi custom dello schema assegnato all'ordine
|
||||||
|
$options = ['$expand' => 'OrderCustomFields'];
|
||||||
|
|
||||||
|
// Debug: salva URL usato
|
||||||
|
$base_url = 'https://93.43.5.102/limsapi/api/odata/';
|
||||||
|
$query = http_build_query($options);
|
||||||
|
$full_url = $base_url . $endpoint . ($query ? '?' . $query : '');
|
||||||
|
file_put_contents(__DIR__ . '/last_url.txt', $full_url . PHP_EOL, FILE_APPEND);
|
||||||
|
|
||||||
|
// Chiamata API
|
||||||
|
$data = $api->get($endpoint, $options);
|
||||||
|
|
||||||
|
// Salva il JSON in locale
|
||||||
|
file_put_contents(__DIR__ . '/commessaweb_schema_response.json', json_encode($data, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
echo json_encode($data);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
file_put_contents(__DIR__ . '/error_log.txt', date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -559,11 +559,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
<?php foreach ($importedData as $index => $row): ?>
|
<?php foreach ($importedData as $index => $row): ?>
|
||||||
<div class="grid-row" data-id="<?= $row['iddatadb'] ?>">
|
<div class="grid-row" data-id="<?= $row['iddatadb'] ?>">
|
||||||
<div class="grid-cell button-cell" style="flex: 0 0 210px; position: relative;">
|
<div class="grid-cell button-cell" style="flex: 0 0 210px; position: relative;">
|
||||||
<!-- commented only for admin roles -->
|
<button type="button" class="export-lims-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Export to LIMS" style="background: #eb0b0bff; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-upload"></i></button>
|
||||||
<?php if ((Auth::user()->hasRole('Admin'))) : ?>
|
|
||||||
<button type="button" class="export-lims-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Export to LIMS" style="background: #eb0b0bff; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-upload"></i></button>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<button type="button" class="save-btn action-btn" data-row="<?= $index ?>" title="Save" style="background: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-save"></i></button>
|
<button type="button" class="save-btn action-btn" data-row="<?= $index ?>" title="Save" style="background: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-save"></i></button>
|
||||||
<button type="button" class="photos-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Photos" style="background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-camera"></i></button>
|
<button type="button" class="photos-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Photos" style="background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-camera"></i></button>
|
||||||
<button type="button" class="parts-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Parts" style="background: #ffc107; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-puzzle-piece"></i></button>
|
<button type="button" class="parts-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Parts" style="background: #ffc107; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-puzzle-piece"></i></button>
|
||||||
@@ -713,33 +709,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
<script src="parts.js"></script>
|
<script src="parts.js"></script>
|
||||||
<script src="tracking.js"></script>
|
<script src="tracking.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).on("click", ".export-lims-btn", function() {
|
|
||||||
let rowId = $(this).data("row");
|
|
||||||
let idDataDb = $(this).data("iddatadb");
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: "export_to_lims.php",
|
|
||||||
method: "POST",
|
|
||||||
data: {
|
|
||||||
iddatadb: idDataDb
|
|
||||||
},
|
|
||||||
dataType: "json",
|
|
||||||
beforeSend: function() {
|
|
||||||
alert("Export started in background for row " + rowId);
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
if (response.success) {
|
|
||||||
alert(response.message);
|
|
||||||
} else {
|
|
||||||
alert("❌ Error: " + response.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
alert("❌ AJAX error: " + error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
console.log("Page loaded, initializing event listeners");
|
console.log("Page loaded, initializing event listeners");
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!-- Modal -->
|
<!-- Modal modificato con pulsante per riconoscimento vocale -->
|
||||||
<div class="modal fade" id="partsModal" tabindex="-1" aria-labelledby="partsModalLabel" aria-hidden="true">
|
<div class="modal fade" id="partsModal" tabindex="-1" aria-labelledby="partsModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-xl" style="max-width: 80% !important; width: 80% !important;">
|
<div class="modal-dialog modal-xl" style="max-width: 80% !important; width: 80% !important;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<input type="checkbox" id="showMixParts" name="showMixParts" style="margin-right: 5px;">
|
<input type="checkbox" id="showMixParts" name="showMixParts" style="margin-right: 5px;">
|
||||||
<label for="showMixParts" style="font-size: 0.9rem; margin-right: 10px;">Mix</label>
|
<label for="showMixParts" style="font-size: 0.9rem; margin-right: 10px;">Mix</label>
|
||||||
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm ms-2" id="toggleVoiceBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;"><i class="fas fa-microphone"></i> Voce</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul id="partsList" class="list-group"></ul>
|
<ul id="partsList" class="list-group"></ul>
|
||||||
|
|||||||
@@ -20,6 +20,115 @@ $(document).ready(function () {
|
|||||||
// selection
|
// selection
|
||||||
let selectedPartNumber = null;
|
let selectedPartNumber = null;
|
||||||
|
|
||||||
|
// ===================
|
||||||
|
// VOICE RECOGNITION SETUP
|
||||||
|
// ===================
|
||||||
|
const SpeechRecognition =
|
||||||
|
window.SpeechRecognition || window.webkitSpeechRecognition;
|
||||||
|
let recognition = null;
|
||||||
|
let isVoiceActive = false;
|
||||||
|
const magicWord = "salva"; // Parola magica scelta: "prossima" (fa andare alla riga successiva)
|
||||||
|
|
||||||
|
if (SpeechRecognition) {
|
||||||
|
recognition = new SpeechRecognition();
|
||||||
|
recognition.lang = "it-IT"; // Lingua italiana
|
||||||
|
recognition.continuous = true; // Ascolto continuo
|
||||||
|
recognition.interimResults = false; // Solo risultati finali per semplicità
|
||||||
|
|
||||||
|
recognition.onresult = function (event) {
|
||||||
|
const transcript = event.results[
|
||||||
|
event.results.length - 1
|
||||||
|
][0].transcript
|
||||||
|
.trim()
|
||||||
|
.toLowerCase();
|
||||||
|
console.log("Transcript vocale:", transcript);
|
||||||
|
|
||||||
|
const $currentRow = $("#partsTableBody tr:last"); // Ultima riga corrente
|
||||||
|
const $descriptionInput = $currentRow.find(".part-description");
|
||||||
|
|
||||||
|
if (transcript.includes(magicWord)) {
|
||||||
|
// Rimuovi la parola magica e aggiungi il resto alla descrizione corrente
|
||||||
|
const cleanedTranscript = transcript
|
||||||
|
.replace(magicWord, "")
|
||||||
|
.trim();
|
||||||
|
if (cleanedTranscript) {
|
||||||
|
$descriptionInput.val(
|
||||||
|
(
|
||||||
|
$descriptionInput.val() +
|
||||||
|
" " +
|
||||||
|
cleanedTranscript
|
||||||
|
).trim(),
|
||||||
|
);
|
||||||
|
$descriptionInput.trigger("blur"); // Salva se necessario
|
||||||
|
}
|
||||||
|
// Aggiungi nuova riga (simile a click su +)
|
||||||
|
const maxPartNumber = Math.max(
|
||||||
|
...$("#partsTableBody tr")
|
||||||
|
.map(function () {
|
||||||
|
return (
|
||||||
|
parseInt($(this).find(".part-number").val()) ||
|
||||||
|
0
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
);
|
||||||
|
addNewRow(maxPartNumber + 1);
|
||||||
|
// Focus sulla nuova descrizione
|
||||||
|
const $newRow = $("#partsTableBody tr:last");
|
||||||
|
$newRow.find(".part-description").focus();
|
||||||
|
} else {
|
||||||
|
// Aggiungi il transcript alla descrizione corrente
|
||||||
|
$descriptionInput.val(
|
||||||
|
($descriptionInput.val() + " " + transcript).trim(),
|
||||||
|
);
|
||||||
|
$descriptionInput.trigger("blur"); // Salva se necessario
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recognition.onerror = function (event) {
|
||||||
|
console.error("Errore riconoscimento vocale:", event.error);
|
||||||
|
if (event.error === "no-speech" || event.error === "aborted") {
|
||||||
|
// Riavvia se necessario
|
||||||
|
if (isVoiceActive) recognition.start();
|
||||||
|
} else {
|
||||||
|
alert("Errore nel riconoscimento vocale: " + event.error);
|
||||||
|
toggleVoiceRecognition();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recognition.onend = function () {
|
||||||
|
if (isVoiceActive) {
|
||||||
|
recognition.start(); // Riavvia per ascolto continuo
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
console.warn("Riconoscimento vocale non supportato dal browser.");
|
||||||
|
$("#toggleVoiceBtn").hide(); // Nascondi pulsante se non supportato
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleVoiceRecognition() {
|
||||||
|
if (!recognition) return;
|
||||||
|
|
||||||
|
isVoiceActive = !isVoiceActive;
|
||||||
|
const $btn = $("#toggleVoiceBtn");
|
||||||
|
if (isVoiceActive) {
|
||||||
|
$btn.addClass("btn-danger").html(
|
||||||
|
'<i class="fas fa-microphone-slash"></i> Stop Voce',
|
||||||
|
);
|
||||||
|
recognition.start();
|
||||||
|
// Focus iniziale sull'ultima descrizione
|
||||||
|
const $currentRow = $("#partsTableBody tr:last");
|
||||||
|
$currentRow.find(".part-description").focus();
|
||||||
|
} else {
|
||||||
|
$btn.removeClass("btn-danger")
|
||||||
|
.addClass("btn-secondary")
|
||||||
|
.html('<i class="fas fa-microphone"></i> Voce');
|
||||||
|
recognition.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#toggleVoiceBtn").on("click", toggleVoiceRecognition);
|
||||||
|
|
||||||
// ===================
|
// ===================
|
||||||
// POPUP HANDLING
|
// POPUP HANDLING
|
||||||
// ===================
|
// ===================
|
||||||
|
|||||||
Reference in New Issue
Block a user