radiantrh/Controleur/ControleurAjaxrequetefactureexport.php

138 lines
4.5 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php';
require_once 'Modele/Facture.php';
class ControleurAjaxrequetefactureexport extends Controleurrequete
{
private $facture;
public function __construct() {
$this->facture = new Facture();
}
public function index()
{
// Ligne 1
$codePrestataire = $this->requete->getParametreFormulaire("codePrestataire");
$dateFacture1 = $this->requete->getParametreDate("dateFacture1");
$dateFacture2 = $this->requete->getParametreDate("dateFacture2");
$numeroAdherent = $this->requete->getParametreFormulaire("numeroAdherent");
$numeroBeneficiaire = $this->requete->getParametreFormulaire("numeroBeneficiaire");
// Ligne 2
$numeroBonConsultation1 = $this->requete->getParametreFormulaire("numeroBonConsultation1");
$numeroBonConsultation2 = $this->requete->getParametreFormulaire("numeroBonConsultation2");
$numeroBonOrdonnance1 = $this->requete->getParametreFormulaire("numeroBonOrdonnance1");
$numeroBonOrdonnance2 = $this->requete->getParametreFormulaire("numeroBonOrdonnance2");
$numeroBonHospitalisation1 = $this->requete->getParametreFormulaire("numeroBonHospitalisation1");
$numeroBonHospitalisation2 = $this->requete->getParametreFormulaire("numeroBonHospitalisation2");
$numeroBonOptique1 = $this->requete->getParametreFormulaire("numeroBonOptique1");
$numeroBonOptique2 = $this->requete->getParametreFormulaire("numeroBonOptique2");
// Ligne 3
$codeTypePrestataire = $this->requete->getParametreFormulaire("codeTypePrestataire");
$numeroDecompte1 = $this->requete->getParametreFormulaire("numeroDecompte1");
$numeroDecompte2 = $this->requete->getParametreFormulaire("numeroDecompte2");
$hospitalisation = $this->requete->getParametreFormulaire("hospitalisation");
$numeroChambre = $this->requete->getParametreFormulaire("numeroChambre");
$chirurgie = $this->requete->getParametreFormulaire("chirurgie");
// Ligne 4
$adherent = $this->requete->getParametreFormulaire("adherent");
$beneficiaire = $this->requete->getParametreFormulaire("beneficiaire");
// FIN Champs
$_SESSION['codePrestataire_C'] = $codePrestataire;
$_SESSION['debutRequeteFr_C'] = $this->requete->getParametreFormulaire("dateFacture1");
$_SESSION['finRequeteFr_C'] = $this->requete->getParametreFormulaire("dateFacture2");
$factures = $this->facture->requetesfactureexport($codePrestataire, $dateFacture1, $dateFacture2, $numeroAdherent, $numeroBeneficiaire,
$numeroBonConsultation1, $numeroBonConsultation2, $numeroBonOrdonnance1, $numeroBonOrdonnance2, $numeroBonHospitalisation1, $numeroBonHospitalisation2, $numeroBonOptique1, $numeroBonOptique2,
$codeTypePrestataire, $numeroDecompte1, $numeroDecompte2, $hospitalisation, $numeroChambre, $chirurgie, $adherent, $beneficiaire) ;
// Excel
/*
$headerXLS = array(
'prestataire',
'dateSysteme',
'NoAdherent',
'adherent',
'NoBeneficiaire',
'beneficiaire',
'NoFeuille',
'dateFacture',
'NoBonCons',
'NoBonOrd',
'NoBonHosp',
'NoBonOpt',
'fraisReel',
'TM',
'Arembourser',
'Exclu',
'Retenu',
'MtForce',
'Redresse',
'Apayer',
'Paye',
'Rembourse',
'hospitalisation',
'Hospit',
'chirurgie',
'NoDecompte',
'valide',
'regle',
'login');
*/
$headerXLS = array(
'prestataire',
'NoAdherent',
'adherent',
'NoBeneficiaire',
'beneficiaire',
'dateFacture',
'NoBon',
'fraisReel',
'TM',
'Arembourser',
'Depass',
'Retenu');
$dataXLS = array();
foreach ($factures as $facture)
{
$dataXLS[]=$facture;
}
$classeur = new PHPExcel();
$classeur->getProperties()->setCreator("INTER-SANTE");
$classeur->setActiveSheetIndex(0);
$feuille=$classeur->getActiveSheet();
$feuille->setTitle('FACTURES MEDICARE');
$feuille->fromArray($headerXLS, NULL, 'A1', true);
$feuille->fromArray($dataXLS, NULL, 'A2', true);
//Forcer le téléchargement vers le navigateur;
$fichier = 'Temp/FACTURES_MEDICARE'."_".uniqid().".xlsx";
$writer = new PHPExcel_Writer_Excel2007($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 FACTURES MEDICARE AU FORMAT EXCEL / DONWLOAD RESULTS </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
}
}