54 lines
2.0 KiB
PHP
Executable File
54 lines
2.0 KiB
PHP
Executable File
<?php
|
|
require_once 'Framework/Controleur.php';
|
|
require_once 'Modele/Synthese.php';
|
|
|
|
class ControleurAjaxgraphiquesinistres extends Controleur {
|
|
private $synthese;
|
|
|
|
public function __construct() {
|
|
$this->synthese = new Synthese();
|
|
}
|
|
|
|
public function index() {
|
|
// Répartition sinistres
|
|
$claims = $this->synthese->getClaims();
|
|
$tabclaims = [
|
|
'claimsLabels' => array_column($claims, 'claimsLabels'),
|
|
'claimsValues' => array_column($claims, 'claimsValues')
|
|
];
|
|
|
|
// Evolution 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')
|
|
];
|
|
|
|
// --- Mode API JSON brut ---
|
|
if (isset($_GET['api']) && $_GET['api'] == '1') {
|
|
header('Content-Type: application/json');
|
|
echo json_encode([
|
|
'claims' => $tabclaims,
|
|
'claimsMonth' => $tabclaimsMonth,
|
|
'lossRatio' => $tabLossRatio
|
|
], JSON_NUMERIC_CHECK);
|
|
exit;
|
|
}
|
|
|
|
// --- Mode Vue Ajax HTML ---
|
|
$this->genererVueAjax([
|
|
'dataTabClaims' => json_encode($tabclaims, JSON_NUMERIC_CHECK),
|
|
'dataTabClaimsMonth' => json_encode($tabclaimsMonth, JSON_NUMERIC_CHECK),
|
|
'dataLossRatio' => json_encode($tabLossRatio, JSON_NUMERIC_CHECK)
|
|
]);
|
|
}
|
|
} |