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

99 lines
3.2 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/Derogation.php';
class ControleurAjaxrequetedemandederogationexport extends Controleurrequete
{
private $Derogation;
public function __construct() {
$this->derogation = new Derogation();
}
public function index()
{
// Ligne 1
$codePrestataire = $this->requete->getParametreFormulaire("codePrestataire");
$dateDemande1 = $this->requete->getParametreDate("dateDemande1");
$dateDemande2 = $this->requete->getParametreDate("dateDemande2");
$numeroAdherent = $this->requete->getParametreFormulaire("numeroAdherent");
$numeroBeneficiaire = $this->requete->getParametreFormulaire("numeroBeneficiaire");
// Ligne 2
$numeroDerogation1 = $this->requete->getParametreFormulaire("numeroDerogation1");
$numeroDerogation2 = $this->requete->getParametreFormulaire("numeroDerogation2");
// Ligne 3
$codeDerogation = $this->requete->getParametreFormulaire("codeDerogation");
$codeReponseDerogation = $this->requete->getParametreFormulaire("codeReponseDerogation");
// Ligne 4
$adherent = $this->requete->getParametreFormulaire("adherent");
$beneficiaire = $this->requete->getParametreFormulaire("beneficiaire");
// FIN Champs
$_SESSION['codePrestataire_C'] = $codePrestataire;
$_SESSION['debutRequeteFr_C'] = $this->requete->getParametreFormulaire("dateDemande1");
$_SESSION['finRequeteFr_C'] = $this->requete->getParametreFormulaire("dateDemande2");
$demandederogations = $this->derogation->requetesdemandederogationexport($codePrestataire, $dateDemande1, $dateDemande2, $numeroAdherent, $numeroBeneficiaire,
$numeroDerogation1, $numeroDerogation2, $codeDerogation, $codeReponseDerogation, $adherent, $beneficiaire) ;
// Excel
$headerXLS = array
(
_('Prestataire'),
_('Système'),
_('Numéro'),
_('Souscripteur'),
_('No Adhérent'),
_('Adhérent'),
_('No Bénéficiaire'),
_('Bénéficiaire'),
_('Type'),
_('Responsable'),
_('Date Réponse'),
_('Motif Réel'),
_('Début'),
_('Fin'),
_('T M'),
_('Réponse')
);
$dataXLS = array();
foreach ($demandederogations as $demandederogation)
{
$dataXLS[]=$demandederogation;
}
$classeur = new Spreadsheet();
$classeur->getProperties()->setCreator("INTER-SANTE");
$classeur->setActiveSheetIndex(0);
$feuille=$classeur->getActiveSheet();
$feuille->setTitle(_('DEROGATIONS'));
$feuille->fromArray($headerXLS, NULL, 'A1', true);
$feuille->fromArray($dataXLS, NULL, 'A2', true);
//Forcer le téléchargement vers le navigateur;
$fichier = 'Temp/TMP_DEROGATIONS_SANTE'."_".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();
}
}