diff --git a/public/userarea/export_to_lims.php b/public/userarea/export_to_lims.php index 4ca7a8b..e7f8dfa 100644 --- a/public/userarea/export_to_lims.php +++ b/public/userarea/export_to_lims.php @@ -33,11 +33,12 @@ try { 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(" - SELECT idclient AS clienteId, idschema AS schemaId - FROM datadb - WHERE iddatadb = :iddatadb + SELECT d.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]); @@ -50,11 +51,11 @@ try { $clienteId = (int) $result['clienteId']; $schemaId = (int) $result['schemaId']; - // 🔹 STEP 3: Fetch Parts (including idmatrice and note) + // 🔹 STEP 3: Fetch Parts (including idmatrice) $stmt = $pdo->prepare(" - SELECT part_number, part_description, material, color, mix, idmatrice, note - FROM identification_parts - WHERE iddatadb = :iddatadb + 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); @@ -134,7 +135,7 @@ try { "Matrice" => $matriceId, "SottoMatrice" => null, "SchemaCustomField" => $schemaId, - "NoteWeb" => $part["note"] ?? "" // Modificato da part_description a note + "NoteWeb" => $part["part_description"] ?? "" ]; // Costruisci curl-like per questo campione