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

223 lines
11 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Statistique.php';
require_once $_SESSION['dossierSociete'].'/Html2pdf/lib/html2pdf.php';
class ControleurAjaxstatsmaladiefichetechniquedixseptpdf 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;
}
$_SESSION['debutStat'] = $debutStat;
$_SESSION['finStat'] = $finStat;
$depenses = $this->requete->getParametreFormulaire("depenses","numerique");
$_SESSION['depenses'] = $depenses;
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
$p_datedebut = $_SESSION['debutStat'];
$p_datefin = $_SESSION['finStat'];
$p_garant = $codeGcAssureur;
$p_id = $idPolice;
$p_limite = 0;
$p_limite = $_SESSION['depenses'];
//highlight_string("<?php\n\$datas =\n" . var_export($_SESSION, true) . ";\n>");
$p_id_college = null;
$p_id_clients = null;
$p_factures = $this->detailsp->etatdepenseparpharmacie($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut,$p_datefin,$p_limite);
$datas =array();
ob_start();
?>
<style type="text/css">
table {
width: 100%;
color: #000;
border-collapse: collapse;
}
h2 { margin: 0; padding: 0px; }
p { margin: 5px; }
.no-border td {
border: none;
padding: 4px 2px;
}
.border th {
border: 1px solid #000;
color: black;
background: #B6D8F2;
padding: 5px 5px;
font-weight: bold;
font-size: 12px;
text-align: center; }
.border td {
border: 1px solid #000;
font-size: 10px;
padding: 4px 2px;
text-align: center;
}
.space { padding-top: 250px; }
.45p { width: 45%; }.20p { width: 20%; }
.10p { width: 10%; } .15p { width: 15%; }
.5p { width: 5%; } .12p { width: 12%; }
.25p { width: 25%; } .50p { width: 50%; }
.60p { width: 60%; } .75p { width: 75%; }
.100p { width: 100%;}.20p { width: 20%; }
.90p { width: 90%;}.46p { width: 46%; }
.header
{
width:100%;
font-size: 9px;
}
</style>
<page backtop="15mm" backleft="5mm" backright="5mm" backbottom="10mm" footer="page;">
<page_header>
<table class="header">
<tr>
<td class="25p" style="text-align: left;font-weight: bold;">
<?= _('FICHE TECHNIQUE No 17')?>
</td>
<td class="50p" style="text-align: center;">
<img src="<?php echo($_SESSION['lienLogo']); ?>" style="width:57px;height:47px;"/>
</td>
<td class="25p" style="text-align: right;">
<?= _('Edition du').': ' ?> <?php echo heureCouranteLang($_SESSION['lang']); ?>
</td>
</tr>
</table>
</page_header>
<page_footer>
</page_footer>
<table>
<tr >
<td class="100p" style=" border: 1px solid #000; color: black; background: #B6D8F2; padding: 5px 15px; font-weight: bold; font-size: 18px; text-align: center;">
<?= _('ETAT DES DEPENSES PAR PHARMACIE')?>
</td>
</tr>
</table>
<p style=" margin-top: 10px; padding: 5px; font-weight: bold; font-size: 16px; text-align: center;">
<br><br>
<?= _('PERIODE COMPTABLE CONSIDEREE')?> <?php echo dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang']); ?>
</p>
<p style=" margin-top: 10px; font-weight: bold; font-size: 14px; text-align: left;">
<i> <?php if($p_id !=null):?>
<u>GARANT</u> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($entete['garant'])?> <br><br>
<u>SOUSCRIPTEUR</u>&nbsp;&nbsp; : <?php echo($entete['souscripteur'])?> <br><br>
<u>POLICE</u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($entete['libellePolice'])?> <br><br>
<U>COURTIER</U> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($entete['courtier'])?> <br><br>
<?php else:?>
<u>GARANT</u> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($p_garant)?> <br><br>
<?php endif?>
</i>
</p>
<table>
<tr>
<td class="20p" style=" border-right: 1px solid #000;">
</td>
<td class="60p" style=" border: 1px solid #000; color: black; padding: 5px 15px; font-weight: bold; font-size: 12px; text-align: center;">
<?= _('DEPENSES SUPERIEURES A')?> <?php echo (format_N($p_limite)) ?> <?php echo ($_SESSION['devise_C']) ?>
</td>
</tr>
</table>
<table style="margin-top: 15px;" class="border">
<thead>
<tr>
<th class="10p"><?= _('Code')?></th>
<th class="46p"><?= _('Prestataire')?></th>
<th class="12p"><?= _('Montant Facture')?></th>
<th class="12p"><?= _('Apres Décompte')?></th>
<th class="10p"><?= _('Coût Moyen')?></th>
<th class="10p"><?= _('Taux')?></th>
</tr>
</thead>
<tbody>
<?php
$total_montantFacture=
$total_apresDecompte=
$total_Coutmoyen=
$total_Taux= 0;
foreach ($p_factures as $p_facture) {
$datas['codeP'] = $p_facture['codeP'];
$datas['Prestataire'] = $p_facture['Prestataire'];
$datas['montantFacture'] = $p_facture['montantFacture'];
$datas['apresDecompte'] = $p_facture['apresDecompte'];
$datas['Coutmoyen'] = $p_facture['Coutmoyen'];
$datas['Taux'] = $p_facture['Taux'];
// highlight_string("<?php\n\$datas =\n" . var_export($p_facture, true) . ";\n>");
$total_montantFacture= $total_montantFacture + $p_facture['montantFacture'];
$total_apresDecompte= $total_apresDecompte + $p_facture['apresDecompte'];
$total_Coutmoyen= $total_Coutmoyen + $p_facture['Coutmoyen'];
$total_Taux= $total_Taux + $p_facture['Taux'];
?>
<tr>
<td class="10p" style="text-align: left;"><?php echo($datas['codeP']);?></td>
<td class="46p" style="text-align: left;">
<?php echo($datas['Prestataire']);?>
</td>
<td class="12p" style="text-align: right; "><?php echo(format_N($datas['montantFacture']));?>
</td>
<td class="12p" style="text-align: right; "><?php echo(format_N($datas['apresDecompte']));?>
</td>
<td class="10p" style="text-align: right; "><?php echo(format_N($datas['Coutmoyen'])); ?></td>
<td class="10p" style="text-align: right;"><?php echo($datas['Taux']); ?>%</td>
</tr>
<?php
}
?>
<tr style=" font-weight: bold; font-size: 10px; border: 2px solid #000; background: #B6D8F2;">
<td colspan=2 style="text-align: left;"><?= _('TOTAL GENERAL')?></td>
<td style="text-align: right;"><?php echo(format_N($total_montantFacture));?></td>
<td style="text-align: right;"><?php echo(format_N($total_apresDecompte)); ?></td>
<td style="text-align: right;"><?php echo(format_N($total_Coutmoyen)); ?></td>
<td style="text-align: right;"><?php echo(format_N(100)); ?>%</td>
</tr>
</tbody>
</table>
</page>
<?php
$content = ob_get_clean();
try {
$pdf = new HTML2PDF("p", "A4", "fr");
$pdf->pdf->SetAuthor('Vitalissanté');
$pdf->pdf->SetSubject('Facture Definitive');
$pdf->pdf->SetKeywords('HTML2PDF, ETATSTATS, PHP');
$pdf->writeHTML($content);
$fichier="Temp/TMP_FACTURE_DEFINITIVE"."_".uniqid().".pdf";
$pdf->Output($fichier, "F");
$pdf->pdf->SetTitle($fichier);
$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;
} catch (HTML2PDF_exception $e) {
die($e);
}
}
}
?>