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