41 lines
1.5 KiB
PHP
41 lines
1.5 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 {
|
|
$idCliente = isset($_GET['id_cliente']) ? (int)$_GET['id_cliente'] : 0;
|
|
if ($idCliente <= 0) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'Missing or invalid id_cliente']);
|
|
exit;
|
|
}
|
|
|
|
$api = VisualLimsApiClient::getInstance();
|
|
|
|
// Build endpoint with OData $expand WITHOUT encoding '$' as %24
|
|
$endpoint = "Cliente($idCliente)?\$expand=Responsabili";
|
|
|
|
// Debug URL (real final URL)
|
|
$base_url = 'https://93.43.5.102/limsapi/api/odata/';
|
|
$full_url = $base_url . $endpoint;
|
|
file_put_contents(__DIR__ . '/last_url.txt', $full_url . PHP_EOL, FILE_APPEND);
|
|
|
|
// Call API: options must be empty because expand is already in endpoint
|
|
$data = $api->get($endpoint, []);
|
|
|
|
|
|
file_put_contents(__DIR__ . '/cliente_responsabili_response.json', json_encode($data, JSON_PRETTY_PRINT));
|
|
|
|
// Return only the list (standard shape used by the frontend)
|
|
$responsabili = $data['Responsabili'] ?? [];
|
|
echo json_encode(['value' => $responsabili]);
|
|
} catch (Exception $e) {
|
|
file_put_contents(__DIR__ . '/error_log.txt', date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
|
http_response_code(500);
|
|
echo json_encode(['error' => $e->getMessage()]);
|
|
}
|