102 lines
2.2 KiB
PHP
102 lines
2.2 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/Statistique.php';
|
|
|
|
class ControleurAjaxetatcumulmoisexport extends Controleurrequete
|
|
{
|
|
private $cumulprestataire;
|
|
|
|
public function __construct() {
|
|
$this->cumulprestataire = new Statistique();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$debutStat = $this->requete->getParametreDate("debutStat");
|
|
$finStat = $this->requete->getParametreDate("finStat");
|
|
|
|
$_SESSION['debutStat'] = $debutStat;
|
|
$_SESSION['finStat'] = $finStat;
|
|
|
|
$cumulprestataires = $this->cumulprestataire->etatcumulprestatairmoiseexport($debutStat, $finStat) ;
|
|
|
|
// var_dump($cumulprestataires);
|
|
// exit();
|
|
|
|
// Excel
|
|
$headerXLS = array(
|
|
_('Prestataire'),
|
|
'mt_01',
|
|
'nb_01',
|
|
'moy_01',
|
|
'mt_02',
|
|
'nb_02',
|
|
'moy_02',
|
|
'mt_03',
|
|
'nb_03',
|
|
'moy_03',
|
|
'mt_04',
|
|
'nb_04',
|
|
'moy_04',
|
|
'mt_05',
|
|
'nb_05',
|
|
'moy_05',
|
|
'mt_06',
|
|
'nb_06',
|
|
'moy_06',
|
|
'mt_07',
|
|
'nb_07',
|
|
'moy_07',
|
|
'mt_08',
|
|
'nb_08',
|
|
'moy_08',
|
|
'mt_09',
|
|
'nb_09',
|
|
'moy_09',
|
|
'mt_10',
|
|
'nb_10',
|
|
'moy_10',
|
|
'mt_11',
|
|
'nb_11',
|
|
'moy_11',
|
|
'mt_12',
|
|
'nb_12',
|
|
'moy_12',
|
|
'mt_an',
|
|
'nb_an',
|
|
'moy_an');
|
|
|
|
$dataXLS = array();
|
|
|
|
|
|
foreach ($cumulprestataires as $cumulprestataire)
|
|
{
|
|
$dataXLS[]=$cumulprestataire;
|
|
}
|
|
|
|
|
|
$classeur = new Spreadsheet();
|
|
$classeur->getProperties()->setCreator("INTER-SANTE");
|
|
$classeur->setActiveSheetIndex(0);
|
|
$feuille=$classeur->getActiveSheet();
|
|
$feuille->setTitle(_('CUMULE PAR MOIS'));
|
|
$feuille->fromArray($headerXLS, NULL, 'A1', true);
|
|
$feuille->fromArray($dataXLS, NULL, 'A2', true);
|
|
|
|
//Forcer le téléchargement vers le navigateur;
|
|
$fichier = 'Temp/TMP_STAT_CUMUL_MOIS'."_".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();
|
|
}
|
|
} |