82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
require_once 'vendor/autoload.php';
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
require_once 'Framework/Controleurrequete.php'; // OK
|
|
require_once 'Modele/Police.php';
|
|
|
|
class ControleurAjaxsyntheseconsopolice extends Controleurrequete
|
|
{
|
|
private $police;
|
|
|
|
public function __construct() {
|
|
$this->police = new Police();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$conommations = $this->police->getsyntheseconsopolice() ;
|
|
|
|
$this->genererVueAjax(array('conommations' => $conommations));
|
|
}
|
|
|
|
public function exportxls()
|
|
{
|
|
|
|
$conommations = $this->police->getsyntheseconsopolice() ;
|
|
|
|
// Excel
|
|
$headerXLS = array
|
|
(
|
|
"dateReference",
|
|
"idAderent",
|
|
_('No Adhérent'),
|
|
_('Adhérent'),
|
|
"primeStat",
|
|
"primeTtc",
|
|
"plafond_OUT",
|
|
"consommation_OUT",
|
|
"plafond_INP",
|
|
"consommation_INP",
|
|
"plafond_OPT",
|
|
"consommation_OPT",
|
|
"plafond_MON",
|
|
"consommation_MON",
|
|
"plafond_DEN",
|
|
"consommation_DEN",
|
|
"plafond_FUN",
|
|
"consommation_FUN",
|
|
"consommation_ALL"
|
|
);
|
|
|
|
$dataXLS = array();
|
|
|
|
|
|
foreach ($conommations as $conommation)
|
|
{
|
|
$dataXLS[]=$conommation;
|
|
}
|
|
|
|
$classeur = new Spreadsheet();
|
|
$classeur->getProperties()->setCreator("INTER-SANTE");
|
|
$classeur->setActiveSheetIndex(0);
|
|
$feuille=$classeur->getActiveSheet();
|
|
$feuille->setTitle(_('SYNTHESE CONSOMMATIONS'));
|
|
$feuille->fromArray($headerXLS, NULL, 'A1', true);
|
|
$feuille->fromArray($dataXLS, NULL, 'A2', true);
|
|
|
|
//Forcer le téléchargement vers le navigateur;
|
|
$fichier = 'Temp/TMP_SYNTHESE_CONS'."_".uniqid().".xlsx";
|
|
|
|
$writer = new Xlsx($classeur);
|
|
$writer->save($fichier);
|
|
|
|
$t_html =' <div id ="div_detail_exp" class="alert alert-info"> ';
|
|
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
|
|
$t_html .=' </div ';
|
|
echo $t_html;
|
|
|
|
exit();
|
|
}
|
|
|
|
} |