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

162 lines
6.2 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Statistique.php';
//require 'Fpdf/diag.php';
class ControleurAjaxstatsmaladiefichetechniquequatorzepdf 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");
if($idPolice== ''){
$idPolice = null;
}
$depenses = $this->requete->getParametreFormulaire("depenses","numerique");
//highlight_string("<?php\n\$datas =\n" . var_export($depenses, true) . ";\n>");
$_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 = null;
$p_id_clients = null;
$p_factures = $this->detailsp->etathopitalisationsparaffections($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 14')),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->AliasNbPages();
//$pdf->SetTextColor(81,163,226);
$pdf->SetFillColor(182,216,242); // bleu
$pdf->Cell(0,8,convertirc(_("ETAT DES HOSPITALISATIONS PAR AFFECTIONS")),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);
}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;
$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(54,$hl,convertirc(_('Code Affection')),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(26,$hl,convertirc(_("Quantité")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(30,$hl,convertirc(_("Montant Facture")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(30,$hl,convertirc(_("Apres Décompte")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(30,$hl,convertirc(_("Coût Moyen")),1,0,'C',true);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(20,$hl,convertirc(_("Taux (%)")),1,1,'C',true);
$pdf->SetFont('Arial','',10);
$total_Quantite =
$total_montantFacture =
$total_apresDecompte =
$total_Coutmoyen =
$total_Taux = 0;
foreach ($p_factures as $dep)
{
$pdf->Cell(54,$hl,convertirc($dep['CodeAffection']),1,0,'C',false);
$pdf->Cell(26,$hl,convertirc(format_N($dep['Quantite'])),1,0,'C',false);
$pdf->Cell(30,$hl,convertirc(format_N($dep['montantFacture'])),1,0,'R',false);
$pdf->Cell(30,$hl,convertirc(format_N($dep['apresDecompte'])),1,0,'R',false);
$pdf->Cell(30,$hl,convertirc(format_N($dep['Coutmoyen'])),1,0,'R',false);
$pdf->Cell(20,$hl,convertirc($dep['Taux']),1,1,'C',false);
$total_Quantite = $total_Quantite +$dep['Quantite'];
$total_montantFacture = $total_montantFacture +$dep['montantFacture'];
$total_apresDecompte = $total_apresDecompte +$dep['apresDecompte'];
$total_Taux = $total_Taux +$dep['Taux'];
}
$total_Coutmoyen = $total_apresDecompte/$total_Quantite ;
$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(182,216,242);
$pdf->Cell(54,$hl,convertirc("TOTAL GENERAL"),"1",0,'C',true);
$pdf->Cell(26,$hl,format_N($total_Quantite),1,0,'C',true);
$pdf->Cell(30,$hl,format_N($total_montantFacture),1,0,'C',true);
$pdf->Cell(30,$hl,format_N($total_apresDecompte),1,0,'C',true);
$pdf->Cell(30,$hl,format_N($total_Coutmoyen),1,0,'C',true);
$pdf->Cell(20,$hl,format_N($total_Taux),1,1,'C',true);
$fichier="Temp/TMP_CUMUL_SP_FICHE14"."_".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;
}
}