Files
html/api/v85-business-kpi.php
2026-04-20 03:00:04 +02:00

46 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* V85 Business KPI Dashboard endpoint
* V96.19 Opus · forward alias to wevia-v83-business-kpi.php
*
* HTML WTP line 1468 expects: /api/wevia-v83-business-kpi.php?action=full + action=summary
* But shows "Loading V85 business KPIs (7 categories × 8 KPIs = 56)..." stuck because
* fetch goes to /api/v85-business-kpi.php which returns 404.
*
* Root cause: missing forward endpoint. This file resolves it.
* Doctrine #13 cause racine: alias/bridge the expected call to existing backend.
*/
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
$action = $_REQUEST['action'] ?? 'summary';
$allowed = ['summary', 'full', 'category', 'actionable'];
if (!in_array($action, $allowed)) $action = 'summary';
// Build query string forward
$qs = http_build_query($_REQUEST);
$url = 'http://127.0.0.1:5890/api/wevia-v83-business-kpi.php?' . $qs;
$ctx = stream_context_create(['http' => ['timeout' => 15]]);
$data = @file_get_contents($url, false, $ctx);
if ($data === false) {
http_response_code(502);
echo json_encode([
'error' => 'backend_unreachable',
'upstream' => '/api/wevia-v83-business-kpi.php',
'v' => 'V96.19-v85-alias',
]);
exit;
}
// Pass-through with note
$parsed = json_decode($data, true);
if (is_array($parsed)) {
$parsed['_forwarded_by'] = 'v85-business-kpi.php → wevia-v83-business-kpi.php';
$parsed['_v'] = 'V96.19-v85-alias-opus';
echo json_encode($parsed, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
} else {
echo $data;
}