update export to lims

This commit is contained in:
Claudio 2025-10-11 20:19:43 +02:00
parent eef9ae8d36
commit 29e4b41874

View File

@ -33,11 +33,12 @@ try {
throw new Exception("Missing iddatadb"); throw new Exception("Missing iddatadb");
} }
// 🔹 STEP 1+2: Fetch Cliente ID + Schema ID // 🔹 STEP 1+2: Fetch Cliente ID from datadb and Schema ID from excel_templates
$stmt = $pdo->prepare(" $stmt = $pdo->prepare("
SELECT idclient AS clienteId, idschema AS schemaId SELECT d.idclient AS clienteId, et.idschema AS schemaId
FROM datadb FROM datadb as d
WHERE iddatadb = :iddatadb INNER JOIN excel_templates as et ON d.templateid = et.id
WHERE d.iddatadb = :iddatadb
LIMIT 1 LIMIT 1
"); ");
$stmt->execute(['iddatadb' => $iddatadb]); $stmt->execute(['iddatadb' => $iddatadb]);
@ -50,11 +51,11 @@ try {
$clienteId = (int) $result['clienteId']; $clienteId = (int) $result['clienteId'];
$schemaId = (int) $result['schemaId']; $schemaId = (int) $result['schemaId'];
// 🔹 STEP 3: Fetch Parts (including idmatrice and note) // 🔹 STEP 3: Fetch Parts (including idmatrice)
$stmt = $pdo->prepare(" $stmt = $pdo->prepare("
SELECT part_number, part_description, material, color, mix, idmatrice, note SELECT part_number, part_description, material, color, mix, idmatrice
FROM identification_parts FROM identification_parts
WHERE iddatadb = :iddatadb WHERE iddatadb = :iddatadb
"); ");
$stmt->execute(['iddatadb' => $iddatadb]); $stmt->execute(['iddatadb' => $iddatadb]);
$parts = $stmt->fetchAll(PDO::FETCH_ASSOC); $parts = $stmt->fetchAll(PDO::FETCH_ASSOC);
@ -134,7 +135,7 @@ try {
"Matrice" => $matriceId, "Matrice" => $matriceId,
"SottoMatrice" => null, "SottoMatrice" => null,
"SchemaCustomField" => $schemaId, "SchemaCustomField" => $schemaId,
"NoteWeb" => $part["note"] ?? "" // Modificato da part_description a note "NoteWeb" => $part["part_description"] ?? ""
]; ];
// Costruisci curl-like per questo campione // Costruisci curl-like per questo campione