Import initial du projet Production
This commit is contained in:
69
Controleur/ControleurAjaxetatrapportspperiodeexport.php
Normal file
69
Controleur/ControleurAjaxetatrapportspperiodeexport.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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 ControleurAjaxetatrapportspperiodeexport extends Controleurrequete
|
||||
{
|
||||
public function __construct() {
|
||||
$this->rapportsp = new Statistique();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$debutStat = $this->requete->getParametreDate("debutStat");
|
||||
$finStat = $this->requete->getParametreDate("finStat");
|
||||
|
||||
$_SESSION['debutStat'] = $debutStat;
|
||||
$_SESSION['finStat'] = $finStat;
|
||||
|
||||
$rapportsps = $this->rapportsp->etatrapportspperiodeexport($debutStat, $finStat) ;
|
||||
|
||||
// Excel
|
||||
$headerXLS = array
|
||||
(
|
||||
_('Souscripteur'),
|
||||
_('No Police'),
|
||||
_('Date Effet'),
|
||||
_('Date Fin'),
|
||||
_('Jrs'),
|
||||
_('Primes Annuelles'),
|
||||
_('Primes Acquises'),
|
||||
_('Sinistres'),
|
||||
_('S/P'),
|
||||
_('S/P Annuel')
|
||||
);
|
||||
|
||||
$dataXLS = array();
|
||||
|
||||
|
||||
foreach ($rapportsps as $rapportsp)
|
||||
{
|
||||
$dataXLS[]=$rapportsp;
|
||||
}
|
||||
|
||||
|
||||
$classeur = new Spreadsheet();
|
||||
$classeur->getProperties()->setCreator("INTER-SANTE");
|
||||
$classeur->setActiveSheetIndex(0);
|
||||
$feuille=$classeur->getActiveSheet();
|
||||
$feuille->setTitle(_('RAPPORT SINISTRES A PRIMES'));
|
||||
$feuille->fromArray($headerXLS, NULL, 'A1', true);
|
||||
$feuille->fromArray($dataXLS, NULL, 'A2', true);
|
||||
|
||||
//Forcer le téléchargement vers le navigateur;
|
||||
$fichier = 'Temp/TMP_STAT_RAPPRT_SIN_PRIME'."_".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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user