This commit is contained in:
KONE SOREL 2025-12-31 09:12:38 +00:00
parent baa563b466
commit 10a0c5e9b0

View File

@ -73,4 +73,39 @@ class ControleurAjaxgraphiquesinistres extends Controleur
echo json_encode($data, JSON_NUMERIC_CHECK); echo json_encode($data, JSON_NUMERIC_CHECK);
exit; exit;
} }
public function api()
{
// Répartition sinistres
$claims = $this->synthese->getClaims();
$tabclaims = [
'claimsLabels' => array_column($claims, 'claimsLabels'),
'claimsValues' => array_column($claims, 'claimsValues')
];
// Évolution des sinistres
$claimsMonth = $this->synthese->getClaimsMonth();
$claimsSingleMonth = $this->synthese->getClaimsSingleMonth();
$tabclaimsMonth = [
'months' => array_column($claimsMonth, 'months'),
'monthlyClaims' => array_column($claimsMonth, 'monthlyClaims'),
'singleClaims' => array_column($claimsSingleMonth, 'singleClaims')
];
// Sinistralité
$claimsLossRatio = $this->synthese->getClaimsLossRatio();
$tabLossRatio = [
'lossRatioLabels' => array_column($claimsLossRatio, 'months'),
'lossRatioValues' => array_column($claimsLossRatio, 'ratio')
];
// Réponse JSON
header('Content-Type: application/json; charset=utf-8');
echo json_encode([
'claims' => $tabclaims,
'claimsMonth' => $tabclaimsMonth,
'lossRatio' => $tabLossRatio
], JSON_NUMERIC_CHECK);
exit;
}
} }