276 lines
12 KiB
PHP
Executable File
276 lines
12 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 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");
|
|
|
|
// Vérification 1: Données de base nécessaires
|
|
if (empty($debutStat) || empty($finStat) || empty($codeGcAssureur)) {
|
|
echo '<div class="alert alert-warning">' . _("Paramètres de filtrage incomplets") . '</div>';
|
|
return;
|
|
}
|
|
|
|
// Vérification 2: Dates valides
|
|
if ($debutStat > $finStat) {
|
|
echo '<div class="alert alert-warning">' . _("La date de début doit être antérieure à la date de fin") . '</div>';
|
|
return;
|
|
}
|
|
|
|
$_SESSION['debutStat'] = $debutStat;
|
|
$_SESSION['finStat'] = $finStat;
|
|
|
|
if ($idPolice == ""){
|
|
$p_id_police = null;
|
|
} else {
|
|
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
|
|
// Vérification 3: Données d'entête disponibles
|
|
if (empty($entete)) {
|
|
echo '<div class="alert alert-warning">' . _("Aucune donnée disponible pour cette police") . '</div>';
|
|
return;
|
|
}
|
|
$p_id_police = $entete['idPolice'];
|
|
}
|
|
|
|
$p_datedebut = $_SESSION['debutStat'];
|
|
$p_datefin = $_SESSION['finStat'];
|
|
$p_garant = $codeGcAssureur;
|
|
$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);
|
|
|
|
// Vérification 4: Données principales disponibles (exigence 1)
|
|
if (empty($p_factures)) {
|
|
echo '<div class="alert alert-warning">' . _("Aucune donnée disponible pour les critères de filtrage") . '</div>';
|
|
return;
|
|
}
|
|
|
|
$datas = array();
|
|
ob_start();
|
|
?>
|
|
|
|
<style type="text/css">
|
|
table {
|
|
width: 100%;
|
|
color: black;
|
|
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: 15%; }
|
|
.25p { width: 25%; } .50p { width: 50%; }
|
|
.60p { width: 60%; } .75p { width: 75%; }
|
|
.100p { width: 100%;}.30p { width: 30%; }
|
|
.90p { width: 90%;} .40p { width: 40%; }
|
|
.header
|
|
{
|
|
width:100%;
|
|
font-size: 9px;
|
|
}
|
|
.footer {
|
|
width: 100%;
|
|
text-align: center;
|
|
font-size: 10pt;
|
|
margin-top: 10px;
|
|
color: #646464;
|
|
}
|
|
</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 N°2")?>
|
|
</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")." :".heureCouranteLang($_SESSION['lang']); ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</page_header>
|
|
<page_footer>
|
|
<div class="footer">
|
|
<?= _("Page") ?> [[page_cu]]/[[page_nb]]
|
|
</div>
|
|
</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 CONTRAT") ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<p style=" margin-top: 15px; padding: 5px; font-weight: bold; font-size: 16px; text-align: center;">
|
|
<br>
|
|
<?= _("PERIODE COMPTABLE CONSIDEREE") ?> <?php echo dateLang($debutStat, $_SESSION['lang']).' '._('AU').' '.dateLang($finStat, $_SESSION['lang']); ?>
|
|
</p>
|
|
<p style=" margin-top: 15px; font-weight: bold; font-size: 14px; text-align: left;">
|
|
<i>
|
|
<?php if($p_id_police != null):?>
|
|
<u><?= _("GARANT") ?></u> : <?php echo($entete['garant'])?> <br><br>
|
|
<u><?= _("SOUSCRIPTEUR") ?></u> : <?php echo($entete['souscripteur'])?> <br><br>
|
|
<u><?= _("POLICE") ?></u> : <?php echo($entete['libellePolice'])?> <br><br>
|
|
<U><?= _("COURTIER") ?></U> : <?php echo($entete['courtier'])?> <br><br>
|
|
<?php else:?>
|
|
<u><?= _("GARANT") ?></u> : <?php echo($p_garant)?> <br><br>
|
|
<?php endif?>
|
|
</i>
|
|
</p>
|
|
<table style="margin-top: 30px;" class="border">
|
|
<thead>
|
|
<tr>
|
|
<th class="20p"><?= _("Garant") ?></th>
|
|
<th class="10p"><?= _("No Police") ?></th>
|
|
<th class="40p"><?= _("Police") ?></th>
|
|
<th class="10p"><?= _("#Mt Recl.") ?></th>
|
|
<th class="10p"><?= _("# Mt Remb.") ?></th>
|
|
<th class="10p"><?= _("Taux")." (%)" ?> </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<tr>
|
|
<?php
|
|
$total_montantFacture = 0;
|
|
$total_apresDecompte = 0;
|
|
$total_taux = 0;
|
|
|
|
if($p_id_police != null){
|
|
foreach ($p_factures as $p_facture){
|
|
$total_montantFacture = $total_montantFacture + $p_facture['montantFacture'];
|
|
$total_apresDecompte = $total_apresDecompte + $p_facture['apresDecompte'];
|
|
$total_taux = $total_taux + $p_facture['Taux'];
|
|
}
|
|
?>
|
|
|
|
<td class="20p"><?php echo($p_factures[0]['Garant']); ?></td>
|
|
<td class="10p"><?php echo($p_factures[0]['NumeroPolice']);?></td>
|
|
<td class="40p" style="text-align: left;">
|
|
<?php echo($p_factures[0]['libellePolice']); ?>
|
|
</td>
|
|
<td class="10p"><?php echo(format_N($total_montantFacture)); ?></td>
|
|
<td class="10p"><?php echo(format_N($total_apresDecompte)); ?></td>
|
|
<td class="10p"><?php echo($total_taux); ?> %</td>
|
|
|
|
<?php
|
|
} else {
|
|
foreach ($p_factures as $facture){
|
|
$total_montantFacture = $total_montantFacture + $facture['montantFacture'];
|
|
$total_apresDecompte = $total_apresDecompte + $facture['apresDecompte'];
|
|
$total_taux = $total_taux + $facture['Taux'];
|
|
?>
|
|
</tr>
|
|
<tr>
|
|
<td class="20p"><?php echo($facture['Garant']); ?></td>
|
|
<td class="10p"><?php echo($facture['NumeroPolice']);?></td>
|
|
<td class="40p" style="text-align: left;"> <?php echo($facture['libellePolice']); ?> </td>
|
|
<td class="10p"><?php echo(format_N($facture['montantFacture'])); ?></td>
|
|
<td class="10p"><?php echo(format_N($facture['apresDecompte'])); ?></td>
|
|
<td class="10p"><?php echo($facture['Taux']); ?> %</td>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</tr>
|
|
|
|
<tr style="color: black; background: #B6D8F2; font-weight: bold; ">
|
|
<td colspan=3 ><?= _("TOTAL GENERAL")." :" ?> </td>
|
|
<td ><?php echo(format_N($total_montantFacture)); ?></td>
|
|
<td ><?php echo(format_N($total_apresDecompte)); ?></td>
|
|
<td ><?php echo($total_taux); ?>%</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p style=" margin-top: 50px; font-weight: bold; font-size: 10px; text-align: left;">
|
|
<?= _("# Mt Recl. = Montant reclamé") ?> <br><br><br>
|
|
<?= _("# Mt Remb. = Montant rembousé") ?>
|
|
</p>
|
|
</page>
|
|
|
|
<?php
|
|
|
|
$content = ob_get_clean();
|
|
|
|
// Vérification 5: Contenu HTML généré avant création PDF
|
|
if (empty($content) || trim($content) == '') {
|
|
echo '<div class="alert alert-warning">' . _("Erreur lors de la génération du contenu PDF") . '</div>';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$pdf = new HTML2PDF("p", "A4", "fr");
|
|
$pdf->pdf->SetAuthor('Ebène Solutions Informatiques');
|
|
$pdf->pdf->SetSubject('Etat récapitulatif des dépenses par famille d\'actes médicaux');
|
|
$pdf->pdf->SetKeywords('HTML2PDF, ETATSTATS, PHP');
|
|
|
|
// Vérification 6: Avant d'ajouter une page (exigence 2)
|
|
if (method_exists($pdf, 'AddPage')) {
|
|
$pdf->AddPage();
|
|
}
|
|
|
|
$pdf->writeHTML($content);
|
|
|
|
// Vérification 7: Nombre de pages avant de continuer (exigence 3)
|
|
$pageCount = $pdf->pdf->getNumPages();
|
|
if ($pageCount == 0) {
|
|
echo '<div class="alert alert-warning">' . _("Le document PDF ne contient aucune page") . '</div>';
|
|
return;
|
|
}
|
|
|
|
$fichier = "Temp/TMP_CUMUL_SP_FICHE2"."_".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 FICHE 02").'</a>';
|
|
$t_html .= '</div> ';
|
|
echo $t_html;
|
|
|
|
} catch (HTML2PDF_exception $e) {
|
|
echo '<div class="alert alert-danger>' . _("Erreur lors de la génération du PDF: ") . $e->getMessage() . '</div>';
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
?>
|