From 10a0c5e9b00b0932bfdf940b073ce35ae5831833 Mon Sep 17 00:00:00 2001 From: KONE SOREL Date: Wed, 31 Dec 2025 09:12:38 +0000 Subject: [PATCH] modi --- .../ControleurAjaxgraphiquesinistres.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Controleur/ControleurAjaxgraphiquesinistres.php b/Controleur/ControleurAjaxgraphiquesinistres.php index 18b7bf7..738ee48 100755 --- a/Controleur/ControleurAjaxgraphiquesinistres.php +++ b/Controleur/ControleurAjaxgraphiquesinistres.php @@ -73,4 +73,39 @@ class ControleurAjaxgraphiquesinistres extends Controleur echo json_encode($data, JSON_NUMERIC_CHECK); 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; + } } \ No newline at end of file