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

230 lines
9.2 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Statistique.php';
require_once 'Modele/Collegepolice.php';
//require 'Fpdf/diag.php';
class ControleurAjaxstatsmaladiefichetechniqueneufpdf extends Controleur
{
private $detailsp;
public function __construct() {
$this->detailsp = new Statistique();
$this->college = new Collegepolice();
}
public function index()
{
$idPolice = $this->requete->getParametreFormulaire("idPolice");
$idCollege = $this->requete->getParametreFormulaire("idCollege");
if( $idCollege ==""){
$idCollege = null;
}
$debutStat = $this->requete->getParametreDate("debutStat");
$finStat = $this->requete->getParametreDate("finStat");
$codeGcAssureur = $this->requete->getParametreFormulaire("codeGcAssureur");
if($idPolice== ''){
$idPolice = null;
}
$depenses = $this->requete->getParametreFormulaire("depenses","numerique");
$_SESSION['debutStat'] = $debutStat;
$_SESSION['finStat'] = $finStat;
$_SESSION['depenses'] = $depenses;
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
$p_datedebut = $_SESSION['debutStat'];
$p_datefin =$_SESSION['finStat'];
$p_garant = $codeGcAssureur;
$p_id = $idPolice;
$p_id_college = $idCollege;
$p_id_clients = null;
$infocollege = $this->college->getCollegepoliceId($idCollege);
$_SESSION['collegeStat'] =$infocollege['libelleCollege'];
//$garanties = $this->detailsp->etatrecapdepensesparfamilledactesmedicaux($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin);
$garanties = $this->detailsp->etatdepensesfamilledactesmedicaux($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin);
//
$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['lienLogo'],94,3,15);
$pdf->SetFont('Arial','B',7);
$pdf->Cell(0,5,convertirc(_('FICHE TECHNIQUE No 9')),0,1,'L',false);
$pdf->SetY(10);
$pdf->SetFont('Arial','',7);
$pdf->Cell(0,5,convertirc(_('Edition du').': '.heureCouranteLang($_SESSION['lang'])),0,1,'R',false);
$pdf->Ln(2);
$pdf->SetFont('Arial','B',13);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(0,8,convertirc(_("ETAT DETAILLE DES DEPENSES PAR FAMILLE D'ACTES")),1,0,'C',true);
$pdf->Ln(10);
$pdf->SetFont('Arial', 'B', 11);
$pdf->SetTextColor(0);
$pdf->Ln(8);
$pdf->Cell(0, 6, convertirc(_('PERIODE COMPTABLE CONSIDEREE').': '.dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang'])), 0, 1, 'C', false);
if ($p_id!=null){
$pdf->Ln(10);
$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 No').': '), 0, 0, 'L', false);
$pdf->SetFont('Arial', 'BI', 11);
$pdf->Cell(0, 8, convertirc($entete['numeroPolice'].' / '.$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);
if($idCollege!=null){
$pdf->SetFont('Arial', 'BUI', 11);
$pdf->Cell(35, 8, convertirc(_('COLLEGE').': '), 0, 0, 'L', false);
$pdf->SetFont('Arial', 'BI', 11);
$pdf->Cell(0, 8, convertirc($_SESSION['collegeStat']), 0, 1, 'L', false);
}
}else{
$pdf->Ln(10);
$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($p_garant), 0, 1, 'L', false);
}
$pdf->Ln(8);
$hl=7;
$TypeP_old= "";
$total_montantFacture=
$total_apresDecompte=
$total_Coutmoyen=
$total_Taux= 0;
$total_montantFactureg=
$total_apresDecompteg=
$total_Coutmoyeng=
$total_Tauxg= 0;
$total_montantFactureold=
$total_apresDecompteold=
$total_Coutmoyenold=
$total_Tauxold= 0;
foreach ($garanties as $garantie) {
$total_montantFacture=
$total_apresDecompte=
$Coutmoyentotal=
$total_Coutmoyen=
$total_Taux= 0;
$p_garantie = $garantie['codeGarantie'];
$p_garant = $codeGcAssureur;
$p_id = $idPolice;
$p_id_college = $idCollege;
$p_id_clients = null;
$p_debutStat = $_SESSION['debutStat'];
$p_finStat =$_SESSION['finStat'];
$recaps = $this->detailsp->getdepenseActerp($p_garant, $p_id_clients, $p_id, $p_id_college,$p_garantie,$p_debutStat,$p_finStat);
$hl=7;
$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(241,242,255);
$pdf->Cell(191,$hl,convertirc($garantie['libelle']),0,1,'L',true);
$hl=7;
$pdf->SetFont('Arial','B',9);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(18,$hl,convertirc(_('Code Acte')),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(90,$hl,convertirc(_("Acte")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(18,$hl,convertirc(_("Quantité")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(25,$hl,convertirc(_("# Mt Remb.")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(25,$hl,convertirc(_("Coût moyen")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(15,$hl,convertirc(_("Taux (%)")),1,1,'C',true);
$pdf->SetFont('Arial','',8);
foreach ($recaps as $key => $recap)
{
$pdf->Cell(18,$hl,convertirc($recap['codeActe']),1,0,'L',false);
$pdf->Cell(90,$hl,convertirc(substr($recap['acte'],0,50)),1,0,'L',false);
$pdf->Cell(18,$hl,convertirc(format_N($recap['Quantite'])),1,0,'C',false);
$pdf->Cell(25,$hl,convertirc(format_N($recap['MontantRembourse'])),1,0,'R',false);
$pdf->Cell(25,$hl,convertirc(format_N($recap['Coutmoyen'])),1,0,'R',false);
$pdf->Cell(15,$hl,convertirc($recap['Taux']),1,1,'C',false);
$total_montantFacture = $total_montantFacture + $recap['Quantite'];
$total_apresDecompte = $total_apresDecompte + $recap['MontantRembourse'];
$total_Taux = $total_Taux + $recap['Taux'];
}
$Coutmoyentotal = $total_montantFacture > 0 ? $total_apresDecompte / $total_montantFacture : 0 ;
$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(108,$hl,convertirc("Sous total"),"1",0,'C',true);
$pdf->Cell(18,$hl,format_N($total_montantFacture),1,0,'C',true);
$pdf->Cell(25,$hl,format_N($total_apresDecompte),1,0,'C',true);
$pdf->Cell(25,$hl,format_N($Coutmoyentotal),1,0,'C',true);
$pdf->Cell(15,$hl,format_N($total_Taux),1,1,'C',true);
$total_montantFactureg = $total_montantFactureg + $total_montantFacture;
$total_apresDecompteg = $total_apresDecompteg + $total_apresDecompte;
$total_Tauxg = $total_Tauxg + $total_Taux;
}
$total_Coutmoyen = $total_montantFactureg>0 ? $total_apresDecompteg/$total_montantFactureg : 0;
$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(108,$hl,convertirc("TOTAL GENERAL"),"1",0,'C',true);
$pdf->Cell(18,$hl,format_N($total_montantFactureg),1,0,'C',true);
$pdf->Cell(25,$hl,format_N($total_apresDecompteg),1,0,'C',true);
$pdf->Cell(25,$hl,format_N($total_Coutmoyen),1,0,'C',true);
$pdf->Cell(15,$hl,format_N($total_Taux),1,1,'C',true);
$pdf->Ln(15);
$pdf->Cell(45,$hl,convertirc(_("# Mt Remb. = Montant rembousé")),0,0,'L',false);
$fichier="Temp/TMP_CUMUL_SP_FICHE09"."_".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;
}
}