prestation/Controleur/ControleurAjaximprimerfacturedefinitiveopt.php
2025-12-01 18:54:33 +00:00

333 lines
16 KiB
PHP

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Facture.php';
require_once $_SESSION['p_dossierSociete'].'/Html2pdf/lib/html2pdf.php';
class ControleurAjaximprimerfacturedefinitiveopt extends Controleurrequete
{
private $facture;
public function __construct()
{
$this->facture = new Facture();
}
public function index()
{
$idFacture = $this->requete->getParametre("idFacture");
$entete = $this->facture->consulterfacturefacture($idFacture);
$prestations = $this->facture->consulterfactureprestationactes($idFacture);
$optiques = $this->facture->consulterfactureoptique($idFacture);
$detfeuilleMaladies = $this->facture->getdetfeuilleMaladie($idFacture); ////////////
$feuilleMaladie =0;
foreach($detfeuilleMaladies as $detfeuilleMaladie){
}
$feuilleMaladie = $detfeuilleMaladie['numeroFeuilleMaladie'];
if($_SESSION['p_codeProfil_C'] != "OPT"){
$_SESSION['p_codeProfil_C'] = "OPT";
}
//$motifsententes = $this->facture->getmotifententeprealable($feuilleMaladie);
//highlight_string("<?php\n\$data =\n" . var_export($_SESSION['p_codeProfil_C'], true) . ";\n>");
//highlight_string("<?php\n\$data =\n" . var_export($prestations, true) . ";\n>");
//highlight_string("<?php\n\$data =\n" . var_export($detfeuilleMaladies, true) . ";\n>");
foreach ($prestations as $prestation){
if($idFacture == $prestation['idFacture']){
$depassement = $prestation['depassement'];
}
}
$factures = $optiques;
//highlight_string("<?php\n\$data =\n" . var_export($depassement, true) . ";\n>");
$datas =array();
ob_start();
?>
<style type="text/css">
table {
width: 100%;
color: #000;
border-collapse: collapse;
font-size: 16px;
}
h2 { margin: 0; padding: 0px; }
p { margin: 5px; }
.no-border td {
border: none;
padding: 6px 8px;
font-size: 16px;
}
.border th {
border: 1px solid #000;
color: black;
background: #dcdcdc;
padding: 5px 5px;
font-weight: bold;
font-size: 12px;
text-align: center; }
.border td {
border: 1px solid #000;
font-size: 12px;
padding: 4px 2px;
text-align: center;
}
.space { padding-top: 250px; }
.45p { width: 45%; }.20p { width: 20%; }.30p { width: 30%; }
.10p { width: 10%; } .15p { width: 15%; }.40p { width: 40%; }
.5p { width: 5%; } .12p { width: 12%; }.17p { width: 17%; }.11p { width: 11%; }
.25p { width: 25%; } .50p { width: 50%; }.42p { width: 42%; }
.60p { width: 60%; } .75p { width: 75%; }
.100p { width: 100%;}.22p { width: 22%; }.28p { width: 28%; }
.90p { width: 90%;}.46p { width: 46%; }.80p { width: 80%; }
.header
{
width:100%;
font-size: 9px;
}
</style>
<page backtop="20mm" backleft="5mm" backright="5mm" backbottom="10mm" footer="page;">
<page_header>
<table class="header">
<tr>
<td class="25p" style="text-align: left;font-weight: bold;">
</td>
<td class="50p" style="text-align: center;">
<img src="<?php echo($_SESSION['p_dossierLogo']); ?>" style="width:77px;height:60px;"/>
</td>
<td class="25p" style="text-align: right;">
<?= _("Edition du") ?> : <?php echo heureCouranteLang($_SESSION['p_lang']); ?>
</td>
</tr>
</table>
</page_header>
<page_footer>
</page_footer>
<table>
<tr >
<td class="10p" style="text-align: left; border-right: 1px solid #000; ">
</td>
<td class="80p" style=" border: 1px solid #000; color: black; padding: 5px 15px; font-weight: bold; font-size: 24px; text-align: center;">
<?= _("Prise en charge") ?> : <?php echo $entete['idFacture'] ;?><br>
<?php echo strtoupper( $_SESSION['p_prestataire_C']) ;?>
</td>
<td class="10p" style="text-align: right;">
</td>
</tr>
</table>
<p style=" margin-top: 30px; font-weight: bold; font-size: 14px; text-align: left;">
</p>
<table class="no-border">
<tr>
<td class="20p" style="">
<?= _("Souspcripteur") ?>
</td>
<td class="60p" style="color: black; text-align: left;">
: <?php echo $entete['souscripteur'] ;?>
</td>
</tr>
<tr>
<td class="20p" style="">
<?= _("Adhérent") ?>
</td>
<td class="60p" style="color: black; text-align: left;">
: <?php echo ($entete['numeroAdherent']." / ".$entete['adherent']); ?>
</td>
</tr>
<tr>
<td class="20p" style="font-weight: bold;">
<?= _("Patient") ?>
</td>
<td class="60p" style="color: black; font-weight: bold; text-align: left;">
: <u> <?php echo ($entete['numeroBeneficiaire']." / ".$entete['beneficiaire']);?></u>
</td>
</tr>
</table>
<table class="no-border">
<tr>
<td class="25p" >
<?= _("Genre") ?>
</td>
<td class="20p" style="color: black; font-weight: bold; ext-align: left;">
: <?php echo ( $detfeuilleMaladie['Sexe']) ;?>
</td>
<td class="15p" style=" text-align: center;">
<?= _("Né(e) le") ?> :
</td>
<td class="20p" style="font-weight: bold; text-align: left;">
<?php echo ( dateLang($detfeuilleMaladie['dateNaissance'])); ?>
</td>
</tr>
<tr>
<td class="25p">
<?= _("Numéro de Bon") ?>
</td>
<td class="20p" style="color: black; font-weight: bold; text-align: left;">
: <?php echo ( $detfeuilleMaladie['numeroBonOptique']) ;?>
</td>
<td class="30p" style="font-weight: bold;">
</td>
<td class="20p" style="font-weight: bold; text-align: left;">
/ <?php echo ( $detfeuilleMaladie['numeroFeuilleMaladie']); ?>
</td>
</tr>
<tr>
<td colspan=4 style="font-weight: bold;">
<?= _("Taux de couverture") ?> : <?php echo (taux_couverture($entete['tm'])); ?>
</td>
</tr>
</table>
<table style="margin-top: 15px;" class="border">
<thead>
<tr>
<th rowspan=2 class="10p">Date</th>
<th rowspan=2 class="42p"><?= _("Acte") ?></th>
<th rowspan=2 class="5p"><?= _("Qté") ?></th>
<th rowspan=2 class="11p"><?= _("Coût de l'acte") ?></th>
<th rowspan=2 class="12p"><?= _("Plafond") ?></th>
<th colspan=2 ><?= _("Part assuré") ?></th>
</tr>
<tr>
<th class="10p"><?= _("TM") ?></th>
<th class="10p"># <?= _("Dépas") ?></th>
</tr>
</thead>
<tbody>
<?php
$montantApayer = "0";
$fraisReel = "0";
$aPayerTotal = "0";
foreach ($factures as $v){
if ($v['depassement'] > "0")
{
$aPayer = $v['montantTm'] + $v['depassement'];
}else{
$aPayer = $v['montantTm'];
}
?>
<tr>
<td class="10p"><?php echo(dateLang($v['dateSysteme'],$_SESSION['p_lang']));?></td>
<td style="text-align: left;" class="42p"><?php echo($v['libelleActe']);?></td>
<td class="5p"><?php echo($v['quantite']);?></td>
<td class="12p" style="text-align: right;"><?php echo(format_N($v['fraisReel']));?></td>
<td class="10p" style="text-align: right;"><?php echo(format_N($v['montantApayer']));?></td>
<td class="11p" style="text-align: right;"><?php echo(format_N($v['montantTm']));?></td>
<td class="10p" style="text-align: right;"><?php echo(format_N($v['depassement']));?></td>
</tr>
<?php
$fraisReel += ($v['fraisReel']);
$montantApayer += ($v['montantApayer']);
$aPayerTotal += ($v['montantTm'] + $v['depassement']);
}
?>
<tr style=" font-weight: bold; font-size: 10px; border: 2px solid #000; ">
<td colspan=4 style="text-align: center;">Total</td>
<td style="text-align: right;"><?php echo(format_N($montantApayer)); ?></td>
<td colspan=2 ><?php echo(format_N($aPayerTotal)); ?></td>
</tr>
</tbody>
</table>
<table style="margin-top: 15px;" class="border">
<thead>
<tr>
<th colspan=4 ><?= _("Instructions Particulières") ?></th>
</tr>
<tr>
<th class="30p"><?= _("Acte") ?></th>
<th class="42p"><?= _("Instructions") ?></th>
<th class="15p"><?= _("Réponse") ?></th>
<th class="15p"><?= _("Plafond") ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($factures as $v)
{
$codeActe = $v['codeActe'];
$motifsententes = $this->facture->getmotifententeprealablenew($feuilleMaladie,$codeActe);
?>
<tr>
<td class="30p"><?php echo($motifsententes['libelleOptique']); ?></td>
<td class="42p"><?php echo($motifsententes['motifReel']); ?></td>
<td class="12p"><?php echo($motifsententes['reponsentEnteprealable']); ?></td>
<td class="15p"><?php echo(format_N($montantApayer)); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<table class="no-border" style="font-size: 14px; margin-top: 10px;" >
<tr>
<td class="22p"style="">
<?= _("Part Assurance") ?> :
</td>
<td class="28p"style="color: black; font-weight: bold; text-align: left;">
<u><?php echo(format_N($fraisReel-$aPayerTotal)); ?></u>
</td>
<td class="20p" style="">
<?= _("Part Assuré") ?> :
</td>
<td class="30p" style="color: black; font-weight: bold; text-align: left;">
<u> <?php echo(format_N($aPayerTotal+$depassement)); ?></u>
</td>
</tr>
</table>
<p style=" margin-top: 10px;font-size: 18px; font-weight: bold; text-align: center;" ><?= _("Montant de la prise en charge") ?> :</p>
<table class="border">
<tr>
<td style="padding: 10px 15px; font-size: 18px; font-style: italic;" class="100p"><?php echo(convetirEnLettre($fraisReel-$aPayerTotal, $_SESSION['p_lang'])." ".$_SESSION['p_devise_C']);?></td>
</tr>
</table>
</page>
<?php
$content = ob_get_clean();
try {
// $pdf->setTestIsImage(false);
$pdf = new HTML2PDF("p", "A4", "fr");
$pdf->pdf->SetAuthor('INTER-SANTE');
$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);
}
}
}
?>