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

288 lines
10 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Prestationactes.php';
require_once 'Modele/Facture.php';
class ControleurAjaximprimerfacturepartielleselection extends Controleurrequete
{
private $prestationacte;
public function __construct()
{
$this->prestationacte = new Prestationactes();
$this->facture = new Facture();
}
public function index()
{
$idEnteteFacture = $this->requete->getParametre("idEnteteFacture");
$feuilleMaladie = $_SESSION['p_numeroFeuilleMaladie_C'];
//var_dump($idEnteteFacture)
if($idEnteteFacture=="0"){
$idEnteteFacture = $this->prestationacte->getEnteteFacturepartielleId();
}
$enteteFactures = $this->prestationacte->getEnteteFacturepartielle($idEnteteFacture);
$factures = $this->prestationacte->getActesFacturepartielle($idEnteteFacture);
$motifsententes = $this->facture->getmotifententeprealable($feuilleMaladie, $idEnteteFacture);
if ($enteteFactures['depassementTotal'] > "0")
{
$aPayer = $enteteFactures['montantTmTotal'] + $enteteFactures['depassementTotal'];
}else{
$aPayer = $enteteFactures['montantTmTotal'];
}
$pdf = new FPDF_Protection();
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = '';
$ownerPassword = null;
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
$pdf->AliasNbPages();
$pdf->AddPage();
$ht=8;
$hl=5;
$nbre = count($factures);
$nbreEntentes = count($motifsententes);
if($nbre=="1"){
$hh=50;
$codeTypePrestation = $this->prestationacte->getcodeTypePrestationFacturepartielle($idEnteteFacture);
}elseif($nbre>="2" && $nbre<="5"){
$hh=20;
$codeTypePrestation = "";
}else{
$hh=6;
$codeTypePrestation = "";
}
$pdf->SetMargins(10, 10, 10) ;
$pdf->Image($_SESSION['p_lienLogo'],94,3,18);
$pdf->Ln(2);
$pdf->SetFont('Arial','', 7);
$pdf->Cell(0,$ht,convertirc(' Edité le '.heureCouranteLang($_SESSION['p_lang'])),0,1,'R',false);
$pdf->Ln(10);
// Décalage à droite
$pdf->Cell(30);
$pdf->SetFont('Arial','B', 18);
$pdf->Cell(140,$ht,convertirc("RECU No : ".$enteteFactures['numeroFacture']),'TLBR',1,'C',false);
$pdf->Ln(10);
$pdf->SetFont('Arial','', 12);
/* $pdf->SetFont('Arial','', 12);
$pdf->Cell(30,$ht,convertirc(_('Souscripteur')),0,0,'L',false);
$pdf->Cell(45,$ht,convertirc(" : ".$_SESSION['p_nomClient_C']),0,1,'L',false);*/
$pdf->SetFont('Arial','', 12);
$pdf->Cell(55,$ht,convertirc(_('Garant / Souscripteur')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(55,$ht,convertirc(": ".$_SESSION['p_nomClient_C']),0,1,'L',false);
$pdf->SetFont('Arial','', 12);
$pdf->Cell(55,$ht,convertirc(_('Adhérent')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(55,$ht,convertirc(": ".$_SESSION['p_numeroAdherent_C']." / ".$_SESSION['p_adherent_C']),0,1,'L',false);
$pdf->SetFont('Arial','', 12);
$pdf->Cell(55,$ht,convertirc(_('Patient')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(55,$ht,convertirc(": ".$_SESSION['p_numeroBeneficiaire_C']." / ".$_SESSION['p_beneficiaire_C']),0,1,'L',false);
$pdf->SetFont('Arial','', 12);
$pdf->Cell(55,$ht,convertirc(_('Genre')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(25,$ht,convertirc(": ".$_SESSION['p_sexe_C']),0,0,'L',false);
$pdf->SetFont('Arial','', 12);
$pdf->Cell(30,$ht,convertirc(_('Né(e) le')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(15,$ht,convertirc(": ".dateLang($_SESSION['p_dateNaissance_C'])),0,1,'L',false);
$pdf->SetFont('Arial','', 12);
$pdf->Cell(55,$ht,convertirc(_('Numéro de Bon')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(25,$ht,convertirc(": ".$_SESSION['p_numeroBonConsultation_C']),0,0,'L',false);
/*
$pdf->SetFont('Arial','', 12);
$pdf->Cell(30,$ht,convertirc(_('Prise en charge')),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(55,$ht,convertirc(": ".taux_couverture($_SESSION['p_tm_C'])),0,1,'L',false);
*/
$pdf->Ln(2);
///////////////////////////////////////////////////////
$pdf->SetFont('Arial','B', 10);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$ht,convertirc(_("Date")),'TLR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$ht,convertirc(_('Garantie')),'LTR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(65,$ht,convertirc(_("Acte / PEC")),'LTR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$ht,convertirc(_("Plafond")),'LTR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(10,$ht,convertirc(_("Nbre")),'LTR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$ht,convertirc(_("Montant")),'LTR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(35,$ht,convertirc(_("Net à Payer")),1,1,'C',true);
$pdf->Cell(20,$hl,convertirc(""),'LBR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$hl,convertirc(""),'LBR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(65,$hl,convertirc(""),'LBR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$hl,convertirc(""),'LBR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(10,$hl,convertirc(""),'LBR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(20,$hl,convertirc(""),'LBR',0,'C',true);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(18,$hl,convertirc(_("TM")),1,0,'C',true);
$pdf->Cell(17,$hl,convertirc(_("Dépas")),1,1,'C',true);
/////////////////////////////////////////////////////////////////
// highlight_string("<?php\n\$datas =\n" . var_export($factures , true) . ";\n>");
foreach ($factures as $v){
if (isset($_SESSION['p_lang']) && $_SESSION['p_lang']=="en_US")
{
$libelleActe = $v['libelleActeEng'].' ('.$v['pec'].'%)';
}else{
$libelleActe = $v['libelleActe'].' ('.$v['pec'].'%)';
}
if($v['codeTypePrestation']=="CSM"){
$libelleActe = $v['libelleConsommable'];
$codeGarantie= "AUX";
}
if ($v['plafondActe'] > "0" && $v['plafondActe'] !="9999999999"){
$plafondActe = $v['plafondActe'];
}else{
$plafondActe = "0";
}
$pdf->SetFont('Arial','', 8);
$pdf->Cell(20,$hh,convertirc(dateLang($v['datePrestation'],$_SESSION['p_lang'])),'LBR',0,'C',false);
$pdf->Cell(20,$hh,convertirc($v['codeGarantie']),'LBR',0,'C',false);
$pdf->SetFont('Arial','', 7);
$pdf->Cell(65,$hh,convertirc(substr($libelleActe,0,45)),'LBR',0,'L',false);
$pdf->Cell(20,$hh,convertirc(format_N($plafondActe)),'LBR',0,'C',false);
$pdf->Cell(10,$hh,convertirc($v['quantiteReel']),'BR',0,'C',false);
$pdf->Cell(20,$hh,convertirc(format_N($v['fraisReel'])),'LBR',0,'C',false);
$pdf->Cell(18,$hh,convertirc(format_N($v['montantTm'])),1,0,'C',false);
$pdf->Cell(17,$hh,convertirc(format_N($v['depassement'])),1,1,'C',false);
}
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(135,10,convertirc(_("Total")),1,0,'C',false);
$pdf->Cell(20,10,convertirc(format_N($enteteFactures['fraisReelTotal'])),1,0,'C',false);
$pdf->Cell(35,10,convertirc(format_N($aPayer)),1,1,'C',false);
if($nbreEntentes > "1" && $codeTypePrestation!="CONS"){
$ht= 6;
$pdf->Ln(5);
$pdf->SetFillColor(223, 232, 247);
$pdf->Cell(190,$ht,convertirc(_("Instructions particulières")),1,1,'C',true);
$pdf->Cell(70,$ht,convertirc(_("Acte")),1,0,'C',true);
$pdf->Cell(60,$ht,convertirc(_("Instructions Assureur")),1,0,'C',true);
$pdf->Cell(60,$ht,convertirc(_("Réponse Assureur")),1,1,'C',true);
$pdf->SetFont('Arial','', 7);
foreach($motifsententes as $motifsentente){
$pdf->Cell(70,$ht,convertirc(substr($motifsentente['libelleActe'],0,40)),1,0,'L',false);
$pdf->Cell(60,$ht,convertirc(_($motifsentente['motifReel'])),1,0,'C',false);
$pdf->Cell(60,$ht,convertirc(substr($motifsentente['reponsentEnteprealable'],0,60)),1,1,'C',false);
}
}
$pdf->Ln(5);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(42,6,convertirc(_('Part Assuré').' : '),0,0,'L',false);
$pdf->SetFont('Arial','BU', 12);
$pdf->Cell(25,6,convertirc(format_N($aPayer)." ".$_SESSION['p_devise_C']),0,1,'L',false);
$pdf->Ln(2);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(42,6,convertirc(_('Net à Rembourser').' : '),0,0,'L',false);
$pdf->SetFont('Arial','BU', 12);
$pdf->Cell(25,6,convertirc(format_N($enteteFactures['fraisReelTotal']-$aPayer)." ".$_SESSION['p_devise_C']),0,1,'L',false);
$pdf->Ln(5);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(0,6,convertirc(_('Montant de la prise en charge').' : '),0,1,'C',false);
$pdf->Ln(3);
$pdf->SetFont('Arial','I',12);
$pdf->Cell(0,15, convetirEnLettre(($enteteFactures['fraisReelTotal']-$aPayer), $_SESSION['p_lang'])." ".$_SESSION['p_devise_C'],'TLBR',1,'C',false);
$ica ='';
$ica ='CE0353';
if($ica!=$_SESSION['p_codePrestataire_C']){
$pdf->Ln(20);
$pdf->SetFont('','BU');
$pdf->Cell(0,6,convertirc($_SESSION['p_prestataire_C']),0,0,'R',false);
} else{
$pdf->Ln(30);
$pdf->SetFont('', 'BU', 10);
$pdf->Cell(42, 6, convertirc(_('Médecin conseil')), 0, 0, 'L', false);
$pdf->Cell(100, 6, convertirc(_('Signature et Telephone')), 0, 0, 'C', false);
$pdf->Cell(60, 6, convertirc('Signature et cachet'), 0, 0, 'C', false);
$pdf->Ln(7);
$pdf->Cell(40, 6, convertirc(''), 0, 0, 'L', false);
$pdf->Cell(100, 6, convertirc(_('Du Patient')), 0, 0, 'C', false);
$pdf->Ln(2);
$pdf->Cell(0,6,convertirc($_SESSION['p_prestataire_C']),0,0,'R',false);
}
//highlight_string("<?php\n\$datas =\n" . var_export($_SESSION , true) . ";\n>");
$fichier="Temp/TMP_facture_partielle_selection"."_".uniqid().".pdf";
$pdf->Output($fichier,"F");
$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();
}
}