57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?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 {
|
|
$idMatrice = isset($_GET['id_matrice']) ? (int)$_GET['id_matrice'] : 0;
|
|
|
|
if ($idMatrice <= 0) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'Missing or invalid id_matrice']);
|
|
exit;
|
|
}
|
|
|
|
$api = VisualLimsApiClient::getInstance();
|
|
|
|
/**
|
|
* OData hypothesis:
|
|
* - Expand enabled matrices
|
|
* - Return only selectable analyses
|
|
* - Include generic analyses OR analyses enabled for the given matrix
|
|
*
|
|
* This endpoint must be verified against the real VisualLims API metadata.
|
|
*/
|
|
$filter = rawurlencode("SelezionabileSuWeb eq true and (IsGenerico eq true or MatriciAbilitate/any(m:m/IdMatrice eq $idMatrice))");
|
|
$expand = rawurlencode("MatriciAbilitate");
|
|
$endpoint = "Analisi?\$top=10";
|
|
|
|
// Debug URL
|
|
$base_url = 'https://93.43.5.102/limsapi/api/odata/';
|
|
$full_url = $base_url . $endpoint;
|
|
file_put_contents(__DIR__ . '/last_url_analisi.txt', $full_url . PHP_EOL, FILE_APPEND);
|
|
|
|
$data = $api->get($endpoint, []);
|
|
|
|
file_put_contents(
|
|
__DIR__ . '/analisi_by_matrice_response.json',
|
|
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
|
|
);
|
|
|
|
$analisi = $data['value'] ?? [];
|
|
|
|
echo json_encode(['value' => $analisi], JSON_UNESCAPED_UNICODE);
|
|
} catch (Exception $e) {
|
|
file_put_contents(
|
|
__DIR__ . '/error_log_analisi.txt',
|
|
date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL,
|
|
FILE_APPEND
|
|
);
|
|
|
|
http_response_code(500);
|
|
echo json_encode(['error' => $e->getMessage()]);
|
|
}
|