From a36dd0277185ca4b9c82dbbb803589b24bee1591 Mon Sep 17 00:00:00 2001 From: kapsona777 Date: Mon, 22 Sep 2025 20:24:53 +0400 Subject: [PATCH] Lims api working version without comment --- public/userarea/export_to_lims.php | 20 ++------------------ public/userarea/import_edit2.php | 2 +- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/public/userarea/export_to_lims.php b/public/userarea/export_to_lims.php index 3331fae..7b01e66 100644 --- a/public/userarea/export_to_lims.php +++ b/public/userarea/export_to_lims.php @@ -13,8 +13,6 @@ try { throw new Exception("Missing iddatadb"); } - echo "✅ START Export for iddatadb={$iddatadb}\n"; - // 🔹 STEP 1+2: Fetch Cliente ID + Schema ID $stmt = $pdo->prepare(" SELECT et.idclient AS clienteId, et.idschema AS schemaId @@ -33,8 +31,6 @@ try { $clienteId = (int) $result['clienteId']; $schemaId = (int) $result['schemaId']; - echo "✅ Cliente={$clienteId}, Schema={$schemaId}\n"; - // 🔹 STEP 3: Fetch Parts (including idmatrice) $stmt = $pdo->prepare(" SELECT part_number, part_description, material, color, mix, idmatrice @@ -44,8 +40,6 @@ try { $stmt->execute(['iddatadb' => $iddatadb]); $parts = $stmt->fetchAll(PDO::FETCH_ASSOC); - echo "✅ Parts found: " . count($parts) . "\n"; - // 🔹 STEP 4: Fetch Field Values with Labels $stmt = $pdo->prepare(" SELECT @@ -61,8 +55,6 @@ try { $stmt->execute(['iddatadb' => $iddatadb]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - echo "✅ Field rows found: " . count($rows) . "\n"; - $fieldValues = []; foreach ($rows as $row) { $fieldValues[] = [ @@ -81,12 +73,9 @@ try { "Richiedente" => "Test Web Import", "Descrizione" => "TEST CommessaWeb", ]; - - echo "➡️ Creating CommessaWeb...\n"; $commessaWeb = $api->post("CommessaWeb", $commessaWebPayload); $commessaId = $commessaWeb["IdCommessa"]; - echo "✅ CommessaWeb created: ID={$commessaId}\n"; // 🔹 STEP 6: Create Campioni (Samples) for each part $campioni = []; @@ -105,7 +94,6 @@ try { "NoteWeb" => $part["part_description"] ?? "" ]; - echo "➡️ Creating Campione {$index} with Matrice={$matriceId}\n"; $campione = $api->post("Campione", $campionePayload); $campione["PartNumber"] = $part["part_number"] ?? ""; @@ -114,12 +102,10 @@ try { $campione["Mix"] = $part["mix"] ?? ""; $campioni[] = $campione; - echo "✅ Campione {$index} created: ID=" . ($campione["IdCampione"] ?? "N/A") . "\n"; } // 🔹 STEP 7: Update Custom Fields for CommessaWeb if (!empty($fieldValues)) { - echo "➡️ Updating CommessaWeb Custom Fields...\n"; $commessaWithFields = $api->get("CommessaWeb(" . $commessaId . ")?\$expand=CommesseCustomFields"); $commessaCustomFields = []; foreach ($commessaWithFields["CommesseCustomFields"] as $customField) { @@ -137,14 +123,11 @@ try { if (!empty($commessaCustomFields)) { $updatePayload = ["CommesseCustomFields" => $commessaCustomFields]; $api->patch("CommessaWeb({$commessaId})", $updatePayload); - echo "✅ CommessaWeb Custom Fields updated\n"; } } // 🔹 STEP 9: Send CommessaWeb to laboratory - echo "➡️ Sending CommessaWeb...\n"; $sendResult = $api->post("CommessaWeb({$commessaId})/InviaCommessa", []); - echo "✅ CommessaWeb sent to Lab\n"; // 🔹 STEP 10: Prepare final response $finalCommessa = [ @@ -161,7 +144,8 @@ try { "success" => true, "commessaWeb" => $finalCommessa, "totalCampioni" => count($campioni), - "totalCustomFields" => count($fieldValues) + "totalCustomFields" => count($fieldValues), + "message" => "Export successful" ]); } catch (Exception $e) { diff --git a/public/userarea/import_edit2.php b/public/userarea/import_edit2.php index 8f85f47..a6bc337 100644 --- a/public/userarea/import_edit2.php +++ b/public/userarea/import_edit2.php @@ -724,7 +724,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { }, success: function (response) { if (response.success) { - alert("✅ CommessaWeb created. ID: " + response.webOrder.IdCommessa); + alert(response.message); } else { alert("❌ Error: " + response.message); }