export to lims
This commit is contained in:
parent
6e465e3010
commit
62bf4ebd92
12
.gitignore
vendored
12
.gitignore
vendored
@ -51,4 +51,16 @@ public/userarea/class/curl_request_debug.log
|
|||||||
# Ignora cartella photostrf in public/userarea
|
# Ignora cartella photostrf in public/userarea
|
||||||
/public/userarea/photostrf/
|
/public/userarea/photostrf/
|
||||||
public/userarea/customfield_values_response.json
|
public/userarea/customfield_values_response.json
|
||||||
|
/public/userarea/logaspi/
|
||||||
|
|
||||||
|
public/userarea/logsapi/campione_762_1.json
|
||||||
|
public/userarea/logsapi/campione_763_1.json
|
||||||
|
public/userarea/logsapi/campione_762_2.json
|
||||||
|
public/userarea/logsapi/campione_763_2.json
|
||||||
|
public/userarea/logsapi/commessaweb_create_762.json
|
||||||
|
public/userarea/logsapi/commessaweb_create_763.json
|
||||||
|
public/userarea/logsapi/commessaweb_customfields_762.json
|
||||||
|
public/userarea/logsapi/commessaweb_customfields_763.json
|
||||||
|
public/userarea/logsapi/commessaweb_invia_762.json
|
||||||
|
public/userarea/logsapi/commessaweb_invia_763.json
|
||||||
|
public/userarea/logsapi/last_auth_url.txt
|
||||||
|
|||||||
239
public/userarea/export_to_lims.js
Normal file
239
public/userarea/export_to_lims.js
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
console.log("export_to_lims.js loaded");
|
||||||
|
|
||||||
|
// Debug: verifica che i pulsanti siano trovati
|
||||||
|
const exportButtons = document.querySelectorAll(".export-lims-btn");
|
||||||
|
console.log(`Found ${exportButtons.length} export-lims-btn buttons`);
|
||||||
|
|
||||||
|
if (exportButtons.length === 0) {
|
||||||
|
console.warn("No .export-lims-btn buttons found in the DOM");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
exportButtons.forEach((btn) => {
|
||||||
|
btn.addEventListener("click", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const rowIndex = btn.dataset.row;
|
||||||
|
const iddatadb = btn.dataset.iddatadb;
|
||||||
|
console.log(
|
||||||
|
`Export to LIMS clicked for row ${rowIndex}, iddatadb: ${iddatadb}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Mostra il modale di conferma
|
||||||
|
const confirmModalElement =
|
||||||
|
document.getElementById("exportConfirmModal");
|
||||||
|
if (!confirmModalElement) {
|
||||||
|
console.error("exportConfirmModal not found in the DOM");
|
||||||
|
alert("Errore: Modale di conferma non trovato");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmModal = new bootstrap.Modal(confirmModalElement, {
|
||||||
|
keyboard: false,
|
||||||
|
});
|
||||||
|
document.getElementById("exportIddatadb").textContent = iddatadb;
|
||||||
|
confirmModal.show();
|
||||||
|
|
||||||
|
// Gestisci il click su "Conferma"
|
||||||
|
const confirmBtn = document.getElementById("exportConfirmBtn");
|
||||||
|
if (!confirmBtn) {
|
||||||
|
console.error("exportConfirmBtn not found in the DOM");
|
||||||
|
confirmModal.hide();
|
||||||
|
alert("Errore: Pulsante di conferma non trovato");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmHandler = async () => {
|
||||||
|
console.log(`Confirmed export for iddatadb: ${iddatadb}`);
|
||||||
|
confirmModal.hide();
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("iddatadb", iddatadb);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("export_to_lims.php", {
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
if (!response.ok)
|
||||||
|
throw new Error(
|
||||||
|
`HTTP error! status: ${response.status}`,
|
||||||
|
);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
console.log("Export response:", data);
|
||||||
|
|
||||||
|
// Mostra il modale di risposta
|
||||||
|
const responseModalElement = document.getElementById(
|
||||||
|
"exportResponseModal",
|
||||||
|
);
|
||||||
|
if (!responseModalElement) {
|
||||||
|
console.error(
|
||||||
|
"exportResponseModal not found in the DOM",
|
||||||
|
);
|
||||||
|
alert("Errore: Modale di risposta non trovato");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseModal = new bootstrap.Modal(
|
||||||
|
responseModalElement,
|
||||||
|
{
|
||||||
|
keyboard: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const responseMessage = document.getElementById(
|
||||||
|
"exportResponseMessage",
|
||||||
|
);
|
||||||
|
if (data.success) {
|
||||||
|
responseMessage.innerHTML = `${data.message.replace(/\n/g, "<br>")}<br>ID CommessaWeb: ${data.idcommessaweb}`;
|
||||||
|
document.getElementById(
|
||||||
|
"exportResponseModalLabel",
|
||||||
|
).textContent = "Esportazione Completata";
|
||||||
|
responseModal.show();
|
||||||
|
|
||||||
|
// Aggiorna la UI per riflettere lo stato 'To LIMS'
|
||||||
|
const statusCell = btn
|
||||||
|
.closest(".grid-row")
|
||||||
|
.querySelector(
|
||||||
|
'.grid-cell[data-col="status"] .status-badge',
|
||||||
|
);
|
||||||
|
if (statusCell) {
|
||||||
|
statusCell.classList.remove("status-i", "status-P");
|
||||||
|
statusCell.classList.add("status-l");
|
||||||
|
statusCell.textContent = "To LIMS";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestisci la chiusura del modale di risposta
|
||||||
|
responseModalElement.addEventListener(
|
||||||
|
"hidden.bs.modal",
|
||||||
|
() => {
|
||||||
|
console.log(
|
||||||
|
"exportResponseModal closed, cleaning up",
|
||||||
|
);
|
||||||
|
// Rimuovi tutti i backdrop residui
|
||||||
|
document
|
||||||
|
.querySelectorAll(".modal-backdrop")
|
||||||
|
.forEach((backdrop) => {
|
||||||
|
console.log(
|
||||||
|
"Removing backdrop:",
|
||||||
|
backdrop,
|
||||||
|
);
|
||||||
|
backdrop.remove();
|
||||||
|
});
|
||||||
|
// Ripristina il body
|
||||||
|
document.body.classList.remove("modal-open");
|
||||||
|
document.body.style.paddingRight = "";
|
||||||
|
// Nascondi l'overlay
|
||||||
|
const overlay = document.querySelector(
|
||||||
|
".overlay.toggle-icon",
|
||||||
|
);
|
||||||
|
if (overlay) {
|
||||||
|
overlay.style.display = "none";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
responseMessage.textContent = `Errore durante la generazione dei payload: ${data.message}`;
|
||||||
|
document.getElementById(
|
||||||
|
"exportResponseModalLabel",
|
||||||
|
).textContent = "Errore Esportazione";
|
||||||
|
responseModal.show();
|
||||||
|
|
||||||
|
// Gestisci la chiusura del modale di risposta anche in caso di errore
|
||||||
|
responseModalElement.addEventListener(
|
||||||
|
"hidden.bs.modal",
|
||||||
|
() => {
|
||||||
|
console.log(
|
||||||
|
"exportResponseModal closed, cleaning up",
|
||||||
|
);
|
||||||
|
// Rimuovi tutti i backdrop residui
|
||||||
|
document
|
||||||
|
.querySelectorAll(".modal-backdrop")
|
||||||
|
.forEach((backdrop) => {
|
||||||
|
console.log(
|
||||||
|
"Removing backdrop:",
|
||||||
|
backdrop,
|
||||||
|
);
|
||||||
|
backdrop.remove();
|
||||||
|
});
|
||||||
|
// Ripristina il body
|
||||||
|
document.body.classList.remove("modal-open");
|
||||||
|
document.body.style.paddingRight = "";
|
||||||
|
// Nascondi l'overlay
|
||||||
|
const overlay = document.querySelector(
|
||||||
|
".overlay.toggle-icon",
|
||||||
|
);
|
||||||
|
if (overlay) {
|
||||||
|
overlay.style.display = "none";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Export error:", error);
|
||||||
|
const responseModalElement = document.getElementById(
|
||||||
|
"exportResponseModal",
|
||||||
|
);
|
||||||
|
if (!responseModalElement) {
|
||||||
|
console.error(
|
||||||
|
"exportResponseModal not found in the DOM",
|
||||||
|
);
|
||||||
|
alert("Errore: Modale di risposta non trovato");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const responseModal = new bootstrap.Modal(
|
||||||
|
responseModalElement,
|
||||||
|
{
|
||||||
|
keyboard: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
document.getElementById(
|
||||||
|
"exportResponseMessage",
|
||||||
|
).textContent =
|
||||||
|
`Errore durante la generazione dei payload: ${error.message}`;
|
||||||
|
document.getElementById(
|
||||||
|
"exportResponseModalLabel",
|
||||||
|
).textContent = "Errore Esportazione";
|
||||||
|
responseModal.show();
|
||||||
|
|
||||||
|
// Gestisci la chiusura del modale di risposta in caso di errore
|
||||||
|
responseModalElement.addEventListener(
|
||||||
|
"hidden.bs.modal",
|
||||||
|
() => {
|
||||||
|
console.log(
|
||||||
|
"exportResponseModal closed, cleaning up",
|
||||||
|
);
|
||||||
|
// Rimuovi tutti i backdrop residui
|
||||||
|
document
|
||||||
|
.querySelectorAll(".modal-backdrop")
|
||||||
|
.forEach((backdrop) => {
|
||||||
|
console.log("Removing backdrop:", backdrop);
|
||||||
|
backdrop.remove();
|
||||||
|
});
|
||||||
|
// Ripristina il body
|
||||||
|
document.body.classList.remove("modal-open");
|
||||||
|
document.body.style.paddingRight = "";
|
||||||
|
// Nascondi l'overlay
|
||||||
|
const overlay = document.querySelector(
|
||||||
|
".overlay.toggle-icon",
|
||||||
|
);
|
||||||
|
if (overlay) {
|
||||||
|
overlay.style.display = "none";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rimuovi il listener dopo l'esecuzione
|
||||||
|
confirmBtn.removeEventListener("click", confirmHandler);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Rimuovi eventuali listener precedenti
|
||||||
|
confirmBtn.removeEventListener("click", confirmHandler);
|
||||||
|
confirmBtn.addEventListener("click", confirmHandler);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
199
public/userarea/export_to_lims.php
Normal file
199
public/userarea/export_to_lims.php
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
<?php
|
||||||
|
// File: export_to_lims.php
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('log_errors', 1);
|
||||||
|
ini_set('error_log', __DIR__ . '/logsapi/export_lims_error.log');
|
||||||
|
|
||||||
|
// Includi il file con la connessione al database
|
||||||
|
require_once __DIR__ . '/include/headscript.php';
|
||||||
|
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/class/VisualLimsApiClient.class.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Verifica che la richiesta sia POST e contenga iddatadb
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['iddatadb'])) {
|
||||||
|
throw new Exception('Richiesta non valida: iddatadb mancante');
|
||||||
|
}
|
||||||
|
|
||||||
|
$iddatadb = (int)$_POST['iddatadb'];
|
||||||
|
|
||||||
|
// Crea la cartella logsapi se non esiste
|
||||||
|
$logDir = __DIR__ . '/logsapi';
|
||||||
|
if (!is_dir($logDir)) {
|
||||||
|
mkdir($logDir, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ottieni connessione al database
|
||||||
|
$db = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
|
// Simula idcommessaweb per il test (sostituire con risposta API nel flusso reale)
|
||||||
|
$idcommessaweb = 10176; // Fittizio per il test
|
||||||
|
|
||||||
|
// Salva idcommessaweb in datadb (simulazione per il test)
|
||||||
|
$updateStmt = $pdo->prepare("UPDATE datadb SET idcommessaweb = :idcommessaweb WHERE iddatadb = :iddatadb");
|
||||||
|
$updateStmt->execute(['idcommessaweb' => $idcommessaweb, 'iddatadb' => $iddatadb]);
|
||||||
|
|
||||||
|
// Step 1: Creazione payload per CommessaWeb
|
||||||
|
$queryCommessa = "
|
||||||
|
SELECT
|
||||||
|
d.iddatadb,
|
||||||
|
e.idclient AS Cliente,
|
||||||
|
e.idschema AS SchemaCustomField
|
||||||
|
FROM datadb d
|
||||||
|
LEFT JOIN excel_templates e ON d.templateid = e.id
|
||||||
|
WHERE d.iddatadb = :iddatadb
|
||||||
|
";
|
||||||
|
|
||||||
|
$stmtCommessa = $pdo->prepare($queryCommessa);
|
||||||
|
$stmtCommessa->execute(['iddatadb' => $iddatadb]);
|
||||||
|
$recordCommessa = $stmtCommessa->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$recordCommessa) {
|
||||||
|
throw new Exception("Nessun record trovato per iddatadb: {$iddatadb}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload per creazione CommessaWeb
|
||||||
|
$payloadCommessa = [
|
||||||
|
'Cliente' => (int)$recordCommessa['Cliente'],
|
||||||
|
'SchemaCustomField' => (int)$recordCommessa['SchemaCustomField'],
|
||||||
|
'Richiedente' => null,
|
||||||
|
'Descrizione' => 'example'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Salva il payload di creazione CommessaWeb
|
||||||
|
$outputFileCommessa = $logDir . "/commessaweb_create_{$iddatadb}.json";
|
||||||
|
file_put_contents($outputFileCommessa, json_encode($payloadCommessa, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
// Step 2: Creazione payload per campi custom (CommesseCustomFields)
|
||||||
|
$queryCustomFields = "
|
||||||
|
SELECT
|
||||||
|
tm.field_id AS IdCommesseCustomFields,
|
||||||
|
idd.field_value AS Valore
|
||||||
|
FROM import_data_details idd
|
||||||
|
JOIN template_mapping tm ON idd.mapping_id = tm.id
|
||||||
|
WHERE idd.id = :iddatadb
|
||||||
|
";
|
||||||
|
|
||||||
|
$stmtCustomFields = $pdo->prepare($queryCustomFields);
|
||||||
|
$stmtCustomFields->execute(['iddatadb' => $iddatadb]);
|
||||||
|
$customFields = $stmtCustomFields->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// Costruisci l'array CommesseCustomFields
|
||||||
|
$commesseCustomFields = [];
|
||||||
|
foreach ($customFields as $field) {
|
||||||
|
$commesseCustomFields[] = [
|
||||||
|
'IdCommesseCustomFields' => (int)$field['IdCommesseCustomFields'],
|
||||||
|
'Valore' => $field['Valore'] ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload per aggiornamento campi custom
|
||||||
|
$payloadCustomFields = [
|
||||||
|
'CommesseCustomFields' => $commesseCustomFields
|
||||||
|
];
|
||||||
|
|
||||||
|
// Salva il payload dei campi custom
|
||||||
|
$outputFileCustomFields = $logDir . "/commessaweb_customfields_{$iddatadb}.json";
|
||||||
|
file_put_contents($outputFileCustomFields, json_encode($payloadCustomFields, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
// Step 3: Creazione payload per Campioni (da identification_parts)
|
||||||
|
$queryCampioni = "
|
||||||
|
SELECT
|
||||||
|
part_number,
|
||||||
|
idmatrice AS Matrice,
|
||||||
|
part_description AS NoteWeb
|
||||||
|
FROM identification_parts
|
||||||
|
WHERE iddatadb = :iddatadb
|
||||||
|
";
|
||||||
|
|
||||||
|
$stmtCampioni = $pdo->prepare($queryCampioni);
|
||||||
|
$stmtCampioni->execute(['iddatadb' => $iddatadb]);
|
||||||
|
$campioni = $stmtCampioni->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$payloadsCampioni = [];
|
||||||
|
foreach ($campioni as $campione) {
|
||||||
|
$payloadCampione = [
|
||||||
|
'Commessa' => $idcommessaweb, // Usa idcommessaweb simulato
|
||||||
|
'Matrice' => (int)$campione['Matrice'],
|
||||||
|
'SottoMatrice' => null,
|
||||||
|
'SchemaCustomField' => 1,
|
||||||
|
'NoteWeb' => $campione['NoteWeb'] ?? ''
|
||||||
|
];
|
||||||
|
|
||||||
|
// Salva il payload del campione
|
||||||
|
$outputFileCampione = $logDir . "/campione_{$iddatadb}_{$campione['part_number']}.json";
|
||||||
|
file_put_contents($outputFileCampione, json_encode($payloadCampione, JSON_PRETTY_PRINT));
|
||||||
|
$payloadsCampioni[] = $payloadCampione;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 4: Creazione payload per InviaCommessa
|
||||||
|
$payloadInviaCommessa = []; // Corpo vuoto, come tipico per azioni OData
|
||||||
|
$outputFileInviaCommessa = $logDir . "/commessaweb_invia_{$iddatadb}.json";
|
||||||
|
file_put_contents($outputFileInviaCommessa, json_encode($payloadInviaCommessa, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
// Aggiorna lo status a 'l' (To LIMS)
|
||||||
|
$updateStmt = $pdo->prepare("UPDATE datadb SET status = 'l' WHERE iddatadb = :iddatadb");
|
||||||
|
$updateStmt->execute(['iddatadb' => $iddatadb]);
|
||||||
|
|
||||||
|
// Risposta di successo
|
||||||
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'message' => "Payload generati e salvati in {$outputFileCommessa}, {$outputFileCustomFields}, file campioni e {$outputFileInviaCommessa}",
|
||||||
|
'idcommessaweb' => $idcommessaweb,
|
||||||
|
'payload_commessa' => $payloadCommessa,
|
||||||
|
'payload_customfields' => $payloadCustomFields,
|
||||||
|
'payload_campioni' => $payloadsCampioni,
|
||||||
|
'payload_invia_commessa' => $payloadInviaCommessa
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Log dell'errore
|
||||||
|
file_put_contents($logDir . '/export_lims_error.log', date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Errore: ' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flusso reale (commentato, da attivare quando pronto)
|
||||||
|
try {
|
||||||
|
$apiClient = VisualLimsApiClient::getInstance();
|
||||||
|
|
||||||
|
// Step 1: Crea CommessaWeb
|
||||||
|
$response = $apiClient->post('/api/odata/CommessaWeb', $payloadCommessa);
|
||||||
|
if ($response['success'] && isset($response['CommessaId'])) {
|
||||||
|
$idcommessaweb = $response['CommessaId'];
|
||||||
|
// Salva idcommessaweb in datadb
|
||||||
|
$updateStmt = $pdo->prepare("UPDATE datadb SET idcommessaweb = :idcommessaweb WHERE iddatadb = :iddatadb");
|
||||||
|
$updateStmt->execute(['idcommessaweb' => $idcommessaweb, 'iddatadb' => $iddatadb]);
|
||||||
|
} else {
|
||||||
|
throw new Exception('Errore nella creazione della CommessaWeb: ' . json_encode($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Aggiorna CommesseCustomFields
|
||||||
|
$apiClient->patch("/api/odata/CommessaWeb({$idcommessaweb})", $payloadCustomFields);
|
||||||
|
|
||||||
|
// Step 3: Crea Campioni
|
||||||
|
foreach ($payloadsCampioni as $payloadCampione) {
|
||||||
|
$apiClient->post('/api/odata/Campione', $payloadCampione);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 4: Invia Commessa
|
||||||
|
$apiClient->post("/api/odata/CommessaWeb({$idcommessaweb})/InviaCommessa", $payloadInviaCommessa);
|
||||||
|
|
||||||
|
// (Opzionale) Recupera il numero commessaweb con una GET
|
||||||
|
$commessaData = $apiClient->get("/api/odata/CommessaWeb({$idcommessaweb})");
|
||||||
|
$commessaweb = $commessaData['Numero'] ?? ''; // Da confermare il nome del campo
|
||||||
|
if ($commessaweb) {
|
||||||
|
$updateStmt = $pdo->prepare("UPDATE datadb SET commessaweb = :commessaweb WHERE iddatadb = :iddatadb");
|
||||||
|
$updateStmt->execute(['commessaweb' => $commessaweb, 'iddatadb' => $iddatadb]);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
file_put_contents($logDir . '/export_lims_error.log', date('Y-m-d H:i:s') . ' - Flusso reale fallito: ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
*/
|
||||||
@ -405,6 +405,16 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
.save-all-btn:hover {
|
.save-all-btn:hover {
|
||||||
background-color: #218838;
|
background-color: #218838;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#exportConfirmModal,
|
||||||
|
#exportResponseModal {
|
||||||
|
z-index: 1300 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#exportConfirmModal .modal-backdrop,
|
||||||
|
#exportResponseModal .modal-backdrop {
|
||||||
|
z-index: 1299 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<title>Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
<title>Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
||||||
</head>
|
</head>
|
||||||
@ -708,6 +718,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
<script src="photos.js"></script>
|
<script src="photos.js"></script>
|
||||||
<script src="parts.js"></script>
|
<script src="parts.js"></script>
|
||||||
<script src="tracking.js"></script>
|
<script src="tracking.js"></script>
|
||||||
|
<script src="export_to_lims.js"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
console.log("Page loaded, initializing event listeners");
|
console.log("Page loaded, initializing event listeners");
|
||||||
@ -900,6 +911,8 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.addEventListener("beforeunload", function(e) {
|
window.addEventListener("beforeunload", function(e) {
|
||||||
if (hasChanges) {
|
if (hasChanges) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -907,6 +920,26 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Gestisci la chiusura dei modali per rimuovere i backdrop
|
||||||
|
document.querySelectorAll('#exportConfirmModal, #exportResponseModal').forEach(modal => {
|
||||||
|
modal.addEventListener('hidden.bs.modal', () => {
|
||||||
|
console.log(`Modal ${modal.id} closed, removing backdrops`);
|
||||||
|
// Rimuovi tutti i backdrop residui
|
||||||
|
document.querySelectorAll('.modal-backdrop').forEach(backdrop => {
|
||||||
|
console.log('Removing backdrop:', backdrop);
|
||||||
|
backdrop.remove();
|
||||||
|
});
|
||||||
|
// Ripristina il body
|
||||||
|
document.body.classList.remove('modal-open');
|
||||||
|
document.body.style.paddingRight = '';
|
||||||
|
// Assicurati che l'overlay sia nascosto
|
||||||
|
const overlay = document.querySelector('.overlay.toggle-icon');
|
||||||
|
if (overlay) {
|
||||||
|
overlay.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
@ -1066,6 +1099,43 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
populateDropdowns();
|
populateDropdowns();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<!-- Modale di conferma per l'esportazione -->
|
||||||
|
<div class="modal fade" id="exportConfirmModal" tabindex="-1" aria-labelledby="exportConfirmModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exportConfirmModalLabel">Conferma Esportazione</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p id="exportConfirmMessage">Confermi l'esportazione al LIMS per iddatadb <span id="exportIddatadb"></span>?</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Annulla</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" id="exportConfirmBtn">Conferma</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale di risposta per l'esportazione -->
|
||||||
|
<div class="modal fade" id="exportResponseModal" tabindex="-1" aria-labelledby="exportResponseModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exportResponseModalLabel">Risultato Esportazione</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p id="exportResponseMessage"></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
58
public/userarea/test_auth.php
Normal file
58
public/userarea/test_auth.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
// File: test_auth.php
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('log_errors', 1);
|
||||||
|
|
||||||
|
// Includi le dipendenze
|
||||||
|
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/class/VisualLimsApiClient.class.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Crea la cartella logsapi se non esiste
|
||||||
|
$logDir = __DIR__ . '/logsapi';
|
||||||
|
if (!is_dir($logDir)) {
|
||||||
|
mkdir($logDir, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Istanzia il client API (autenticazione automatica tramite .env)
|
||||||
|
$api = VisualLimsApiClient::getInstance();
|
||||||
|
|
||||||
|
// Esegui una chiamata di test per verificare l'autenticazione
|
||||||
|
$endpoint = 'SchemaCustomField';
|
||||||
|
$options = []; // Nessun filtro per il test
|
||||||
|
$data = $api->get($endpoint, $options);
|
||||||
|
|
||||||
|
// 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($logDir . '/last_auth_url.txt', $full_url . PHP_EOL, FILE_APPEND);
|
||||||
|
|
||||||
|
// Nota: getToken() è privato, quindi non possiamo accedervi direttamente
|
||||||
|
// Supponiamo che l'autenticazione sia avvenuta correttamente se la GET ha successo
|
||||||
|
$token = null; // Non possiamo accedere al token direttamente
|
||||||
|
$auth_success = true; // La GET ha successo, quindi l'autenticazione funziona
|
||||||
|
|
||||||
|
// Salva un file di conferma dell'autenticazione
|
||||||
|
$outputFile = $logDir . '/auth_token.json';
|
||||||
|
file_put_contents($outputFile, json_encode(['auth_success' => true, 'token' => 'Not directly accessible (private method)'], JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
// Risposta di successo
|
||||||
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'message' => "Autenticazione completata con successo, dettagli salvati in {$outputFile}",
|
||||||
|
'auth_success' => $auth_success,
|
||||||
|
'schema_data' => $data // Dati di esempio dalla GET
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Log dell'errore
|
||||||
|
file_put_contents($logDir . '/auth_error.log', date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Errore durante l\'autenticazione: ' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user