radiantproduction/Controleur/ControleurAjaxetatrapportspcatgpdetexport.php

62 lines
1.6 KiB
PHP

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Statistique.php';
class ControleurAjaxetatrapportspcatgpdetexport extends Controleurrequete
{
public function __construct() {
$this->rapportsp = new Statistique();
}
public function index()
{
$rapportsps = $this->rapportsp->etatrapportspcatgpdetexport();
// Excel
$headerXLS = array
(
_('Code Cat'),
_('Catégorie'),
_('Nb Adhérents'),
_('Nb Bénéficiaires'),
_('Moy Bénéficiaires'),
_('P Nette Cat'),
_('P Adhérent'),
_('P Bénéficiaires'),
_('Primes Acquises'),
_('Sinistres'),
_('S/P'),
_('P Adh Opt'),
_('P Adh Opt Cumul')
);
$dataXLS = array();
foreach ($rapportsps as $rapportsp)
{
$dataXLS[]=$rapportsp;
}
$classeur = new PHPExcel();
$classeur->getProperties()->setCreator("INTER-SANTE");
$classeur->setActiveSheetIndex(0);
$feuille=$classeur->getActiveSheet();
$feuille->setTitle(_('SP CAT DET GRP'));
$feuille->fromArray($headerXLS, NULL, 'A1', true);
$feuille->fromArray($dataXLS, NULL, 'A2', true);
//Forcer le téléchargement vers le navigateur;
$fichier = 'Temp/TMP_STAT_SP_CAT_DET_GRP'."_".uniqid().".xlsx";
$writer = new PHPExcel_Writer_Excel2007($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();
}
}