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

86 lines
2.6 KiB
PHP
Executable File

<?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 ControleurAjaxdetailrapportspgarantieadh extends Controleur
{
private $detailsp;
public function __construct() {
$this->detailsp = new Statistique();
}
public function index()
{
$idAdherent = $this->requete->getParametreFormulaire("idAdherent");
$entete = $this->detailsp->detailrapportspadhpdfentete($idAdherent);
$detailsps = $this->detailsp->detailrapportspgarantieadh($idAdherent);
// Excel
$headerXLS = array
(
_('Matricule'),
_('Bénéficiaire'),
_('Date'),
_('Prestataire'),
_('No Fact'),
_('Garantie'),
_('Montant')
);
$dataXLS = array();
foreach ($detailsps as $detailsp)
{
$dataXLS[]=$detailsp;
}
$classeur = new Spreadsheet();
$classeur->getProperties()->setCreator("INTER-SANTE");
$classeur->setActiveSheetIndex(0);
$feuille=$classeur->getActiveSheet();
$feuille->setTitle(_('DETAIL GARANTIES FAMILLE'));
$feuille->setCellValue('A1', convertirc($entete['nomAssureur']));
$feuille->setCellValue('B1', convertirc(_("RAPPORT SINISTRE A PRIME PAR FAMILLE")));
$feuille->setCellValue('A2', convertirc(_('Garant').' : '));
$feuille->setCellValue('B2', convertirc($entete['garant']));
$feuille->setCellValue('A3', convertirc(_('Souscripteur').' : '));
$feuille->setCellValue('B3', convertirc($entete['souscripteur']));
$feuille->setCellValue('A4', convertirc(_('Police').' No: '));
$feuille->setCellValue('B4', convertirc($entete['numeroPolice']).' / '.$entete['libellePolice']);
$feuille->setCellValue('A5', convertirc(_('Adherent').' Mle: '));
$feuille->setCellValue('B5', convertirc($entete['numeroAdherent']).' / '.$entete['adherent']);
$feuille->setCellValue('A6', convertirc(_('Couverture').' : '));
$feuille->setCellValue('B6', convertirc($entete['dateEffetAdherent']." To ".$entete['dateFinAdherent']));
$feuille->fromArray($headerXLS, NULL, 'A8', true);
$feuille->fromArray($dataXLS, NULL, 'A9', true);
$fichier = 'Temp/DETAIL_GARANTIES_FAMILLE'."_".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();
}
}