radiantrh/Controleur/ControleurAjaxgraphiquesinistres.php
2025-12-30 14:50:49 +00:00

59 lines
1.8 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleur.php';
require_once 'Modele/Synthese.php';
class ControleurAjaxgraphiquesinistres extends Controleur {
private $menuvue;
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')
];
$dataTabClaims = json_encode($tabclaims, JSON_NUMERIC_CHECK);
// 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')
];
$dataTabClaimsMonth = json_encode($tabclaimsMonth, JSON_NUMERIC_CHECK);
// SINISTRALITÉ
$claimsLossRatio = $this->synthese->getClaimsLossRatio();
$tabLossRatio = [
'lossRatioLabels' => array_column($claimsLossRatio, 'months'),
'lossRatioValues' => array_column($claimsLossRatio, 'ratio')
];
$dataLossRatio = json_encode($tabLossRatio, JSON_NUMERIC_CHECK);
$this->genererVueAjax(
array
(
'dataTabClaims' => $dataTabClaims,
'dataTabClaimsMonth' => $dataTabClaimsMonth,
'dataLossRatio' => $dataLossRatio
)
);
}
}