production/Controleur/ControleurAjaxstatsmaladiefichetechniquedeuxpdfnew.php
2025-12-02 11:29:44 +00:00

175 lines
6.9 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Statistique.php';
class ControleurAjaxstatsmaladiefichetechniquedeuxpdf extends Controleur
{
private $detailsp;
public function __construct() {
$this->detailsp = new Statistique();
}
public function index()
{
$idPolice = $this->requete->getParametreFormulaire("idPolice");
$debutStat = $this->requete->getParametreDate("debutStat");
$finStat = $this->requete->getParametreDate("finStat");
$codeGcAssureur = $this->requete->getParametreFormulaire("codeGcAssureur");
$depenses = $this->requete->getParametreFormulaire("depenses","numerique");
$primeSinistre = $this->detailsp->getprimesinistre($idPolice,$debutStat,$finStat);
$depensesFamille = $this->detailsp->getdepensesfamilles($idPolice,$debutStat,$finStat,$depenses);
// highlight_string("<?php\n\$datas =\n" . var_export($depensesFamille, true) . ";\n>");
$_SESSION['debutStat'] = $debutStat;
$_SESSION['finStat'] = $finStat;
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
$p_datedebut = $_SESSION['debutStat'];
$p_datefin =$_SESSION['finStat'];
$p_garant = $codeGcAssureur;
$p_id_police = $entete ['idPolice'] ;
$p_id_college = null;
$p_id_clients = null;
$p_factures = $this->detailsp->getdepenseparcontratrp($p_garant, $p_id_clients, $p_id_police, $p_id_college, $p_datedebut, $p_datefin);
$total_montantFacture = 0;
$total_apresDecompte = 0;
$total_taux = 0;
$pdf = new FPDF_Protection();
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = '';
$ownerPassword = null;
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetMargins(10, 10, 10) ;
$pdf->Image($_SESSION['dossierSociete'].'/Tarifs/Img/logo_vitalis.png',94,3,15);
$pdf->SetFont('Arial','B',7);
$pdf->Cell(0,5,'FICHE TECHNIQUE No 2',0,1,'L',false);
$pdf->SetY(10);
$pdf->SetFont('Arial','',7);
$pdf->Cell(0,5,'Edition du : '.heureCouranteLang($_SESSION['lang']),0,1,'R',false);
$pdf->Ln(2);
$pdf->SetFont('Arial','B',13);
// $pdf->AliasNbPages();
//$pdf->SetTextColor(81,163,226);
$pdf->SetFillColor(143,206,143); // bleu
$pdf->Cell(0,8,convertirc(_("RECAPITULATIF DES DEPENSES PAR STATUT DE BENEFICIAIRES")),1,0,'C',true);
$pdf->Ln(10);
$pdf->SetFont('Arial', 'B', 11);
$pdf->SetTextColor(0);
$pdf->Ln(8);
$pdf->Cell(0, 5, convertirc(_('PERIODE COMPTABLE CONSIDEREE').' : '.dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang'])), 0, 1, 'C', false);
$pdf->Ln(8);
$pdf->SetFont('Arial', 'BUI', 11);
$pdf->Cell(35, 8, convertirc(_('GARANT')), 0, 0, 'L', false);
$pdf->SetFont('Arial', 'BI', 11);
$pdf->Cell(0, 8, convertirc(_(' : '.$entete['garant'])), 0, 1, 'L', false);
$pdf->SetFont('Arial', 'BUI', 11);
$pdf->Cell(35, 8, convertirc(_('SOUSCRIPTEUR')), 0, 0, 'L', false);
$pdf->SetFont('Arial', 'BI', 11);
$pdf->Cell(0, 8, convertirc(_(' : '.$entete['souscripteur'])), 0, 1, 'L', false);
$pdf->SetFont('Arial', 'BUI', 11);
$pdf->Cell(35, 8, convertirc(_('POLICE')), 0, 0, 'L', false);
$pdf->SetFont('Arial', 'BI', 11);
$pdf->Cell(0, 8, convertirc(_($entete['libellePolice'])), 0, 1, 'L', false);
$pdf->SetFont('Arial', 'BUI', 11);
$pdf->Cell(35, 8, convertirc(_('COURTIER')), 0, 0, 'L', false);
$pdf->SetFont('Arial', 'BI', 11);
$pdf->Cell(0, 8, convertirc(_(' : '.$entete['courtier'])), 0, 1, 'L', false);
$pdf->Ln(5);
$hl=7;
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(40,$hl,convertirc(_('Garant')),1,0,'C',true);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(20,$hl,convertirc(_("No Police")),1,0,'C',true);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(74,$hl,convertirc(_("Police")),1,0,'C',true);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(20,$hl,convertirc(_("#Mt A Remb.")),1,0,'C',true);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(20,$hl,convertirc(_("# Mt Remb.")),1,0,'C',true);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(16,$hl,convertirc(_("Taux (%)")),1,1,'C',true);
$pdf->SetFont('Arial','',8);
if($p_id_police!=null){
foreach ($p_factures as $p_facture){
$p_factures['Garant']=$p_facture['Garant'];
$p_factures['NumeroPolice']=$p_facture['NumeroPolice'];
$p_factures['libellePolice']=$p_facture['libellePolice'];
$p_factures['montantFacture']=$p_facture['montantFacture'];
$p_factures['apresDecompte']=$p_facture['apresDecompte'];
$p_factures['Taux']=$p_facture['Taux'];
$total_montantFacture = $total_montantFacture + $p_facture['montantFacture'];
$total_apresDecompte = $total_apresDecompte + $p_facture['apresDecompte'];
$total_taux = $total_taux + $p_facture['Taux'];
}
$pdf->Cell(40,$hl,convertirc($p_factures['Garant']),1,0,'L',false);
$pdf->Cell(20,$hl,convertirc($p_factures['NumeroPolice']),1,0,'C',false);
$pdf->Cell(74,$hl,convertirc($p_factures['libellePolice']),1,0,'L',false);
$pdf->Cell(20,$hl,convertirc(format_N($total_montantFacture)),1,0,'C',false);
$pdf->Cell(20,$hl,convertirc(format_N($total_apresDecompte)),1,0,'C',false);
$pdf->Cell(16,$hl,convertirc( $total_taux ),1,1,'C',false);
}else{
foreach ($p_factures as $facture){
$pdf->Cell(40,$hl,convertirc($facture['Garant']),1,0,'L',false);
$pdf->Cell(20,$hl,convertirc($facture['NumeroPolice']),1,0,'C',false);
$pdf->Cell(74,$hl,convertirc($facture['libellePolice']),1,0,'L',false);
$pdf->Cell(20,$hl,convertirc(format_N($facture['montantFacture'])),1,0,'C',false);
$pdf->Cell(20,$hl,convertirc(format_N($facture['apresDecompte'])),1,0,'C',false);
$pdf->Cell(16,$hl,convertirc( $facture['Taux'] ),1,1,'C',false);
}
}
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(143,206,143);
$pdf->Cell(134,$hl,convertirc("TOTAL GENERAL"),"1",0,'C',true);
$pdf->Cell(20,$hl,format_N($total_montantFacture),1,0,'C',true);
$pdf->Cell(20,$hl,format_N($total_apresDecompte),1,0,'C',true);
$pdf->Cell(16,$hl,format_N($total_taux),1,0,'C',true);
$pdf->Ln(5);
$pdf->Ln(8);
$pdf->Cell(45,$hl,convertirc(_("# Mt A Remb. = Montant à rembouser")),0,0,'L',false);
$pdf->Ln(5);
$pdf->Cell(45,$hl,convertirc(_("# Mt Remb. = Montant rembousé")),0,0,'L',false);
$fichier="Temp/TMP_CUMUL_SP_FICHE2"."_".uniqid().".pdf";
$pdf->Output($fichier,"F");
$t_html =' <div id ="div_export_b" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
}
}