diff --git a/public/userarea/get_analisi_by_cliente_matrice.php b/public/userarea/get_analisi_by_cliente_matrice.php new file mode 100644 index 0000000..177729a --- /dev/null +++ b/public/userarea/get_analisi_by_cliente_matrice.php @@ -0,0 +1,68 @@ + 'Missing or invalid id_cliente']); + exit; + } + + $api = VisualLimsApiClient::getInstance(); + + if ($idMatrice > 0) { + $expandExpr = "AnalisiAbilitate(\$filter=Matrice/IdMatrice eq $idMatrice)"; + } else { + $expandExpr = "AnalisiAbilitate"; + } + + // Encode only the $expand expression because it contains spaces, slash and parentheses + $expandEncoded = rawurlencode($expandExpr); + $endpoint = "Cliente($idCliente)?\$expand={$expandEncoded}"; + + $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_cliente_matrice_response.json', + json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) + ); + + if ($debug === 1) { + echo json_encode([ + 'endpoint' => $endpoint, + 'full_url' => $full_url, + 'raw_response' => $data + ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + exit; + } + + $analisi = $data['AnalisiAbilitate'] ?? []; + + echo json_encode([ + 'value' => $analisi, + 'count' => is_array($analisi) ? count($analisi) : 0 + ], 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()]); +}