prestation/Controleur/ControleurAjaxpaiementprestationcumulgraph.php
2025-12-05 10:42:46 +00:00

112 lines
3.0 KiB
PHP
Executable File

<?php
require_once 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
require_once 'Framework/Controleurrgraph.php'; // OK
require_once 'Modele/Statistique.php';
class ControleurAjaxpaiementprestationcumulgraph extends Controleurrgraph
{
private $etat;
public function __construct() {
$this->etat = new Statistique();
}
public function index()
{
/*
$debutPeriode = $this->requete->getParametreDate("debutPeriode");
$finPeriode = $this->requete->getParametreDate("finPeriode");
$donnees = $this->etat->etatpaiementprestationcumulexport($debutPeriode, $finPeriode) ;
// Excel
$headerXLS = array
(
_('Exercice'),
_('Mois'),
_('Nb Décomptes'),
_('Paiements')
);
$dataXLS = array();
foreach ($donnees as $donnee)
{
$dataXLS[]=$donnee;
}
$classeur = new Spreadsheet();
$classeur->getProperties()->setCreator("INTER-SANTE");
$classeur->setActiveSheetIndex(0);
$feuille=$classeur->getActiveSheet();
$feuille->setTitle(_('PAIEMENTS PRESTATIONS CUMUL'));
$feuille->fromArray($headerXLS, NULL, 'A1', true);
$feuille->fromArray($dataXLS, NULL, 'A2', true);
//Forcer le téléchargement vers le navigateur;
$fichier = 'Temp/TMP_PAIEMENTS_PRESTATIONS_CUMUL'."_".uniqid().".xlsx";
$writer = new Xlsx($classeur);
$writer->save($fichier);
$t_html =' <div id ="div_export_a" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
*/
$datay=array(62,105,85,50);
// Create the graph. These two calls are always required
$graph = new Graph(350,220,'auto');
$graph->SetScale("textlin");
//$theme_class="DefaultTheme";
//$graph->SetTheme(new $theme_class());
// set major and minor tick positions manually
$graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135));
$graph->SetBox(false);
//$graph->ygrid->SetColor('gray');
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A','B','C','D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
// Create the bar plots
$b1plot = new BarPlot($datay);
// ...and add it to the graPH
$graph->Add($b1plot);
$b1plot->SetColor("white");
$b1plot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION);
$b1plot->SetWidth(45);
$graph->title->Set("Bar Gradient(Left reflection)");
// Display the graph
// var_dump($graph);
// $graph->Stroke();
$fichier = 'Temp/TMP_PAIEMENTS_PRESTATIONS_CUMUL'."_".uniqid().".png";
$graph->Stroke($fichier);
$t_html =' <div id ="div_export_a" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
}
}