production/Vue/Fichebeneficiaire/index.php
2025-12-01 16:12:12 +00:00

1085 lines
41 KiB
PHP
Executable File

<?php
// $this->titre = "INTER SANTE - Fiche Bénéficiaire";
$datejour = $this->datejour;
$estcouvert = ($_SESSION['dateEcheancePolice_C']>=$datejour);
$sorti = $this->nettoyer($beneficiaire['sorti']);
$dateSortieBeneficiaire = $this->nettoyer($beneficiaire['dateSortieBeneficiaire']);
$estsorti = false;
if($sorti=="1")
{
$estsorti = ($dateSortieBeneficiaire<=$datejour);
$estcouvert = ($estcouvert && ($dateSortieBeneficiaire>$datejour));
}
$dateEffetCouvert = $_SESSION['dateEffetCouvert'];
if (est_anglophone())
{
$produit = $beneficiaire['produitEng'];
$naturepiece = $beneficiaire['naturepieceEng'];
$lienparente = $beneficiaire['lienparenteEng'];
$motifsortie = $beneficiaire['motifsortieEng'];
$etatbeneficiaire = $beneficiaire['etatbeneficiaireEng'];
if($beneficiaire['sexe']=="M"){
$sexe = "Male";
}else{
$sexe = "Female";
}
}
else
{
$produit = $beneficiaire['produit'];
$naturepiece = $beneficiaire['naturepiece'];
$lienparente = $beneficiaire['lienparente'];
$motifsortie = $beneficiaire['motifsortie'];
$etatbeneficiaire = $beneficiaire['etatbeneficiaire'];
if($beneficiaire['sexe']=="M"){
$sexe = "Masculin";
}else{
$sexe = "Féminin";
}
}
$codeEtatBeneficiaire = $beneficiaire['codeEtatBeneficiaire'];
$produit = $beneficiaire['produit'];
$bareme = $beneficiaire['bareme'];
$idBaremePriseEnCharge = $beneficiaire['idBaremePriseEnCharge'];
$superUser = $_SESSION['superUser'];
$vip = $beneficiaire['vip'];
$cheminDossier = $_SESSION['dossierSociete'].'/qrcodes/';
$matricule = $this->nettoyer($beneficiaire['numeroBeneficiaire']);
$qrPath = $beneficiaire['qr_code_path'];
$cheminComplet = trim($cheminDossier).$qrPath;
$carteEditee = $this->nettoyer($beneficiaire['carteEditee']);
$imgData = $_SESSION['photoAssureCrypte'];
$faceActif = $_SESSION['faceActif'];
$faceRegistered = $this->nettoyer($beneficiaire['faceRegistered']);
$face_confirmee = $_SESSION['okId_face'];
?>
<script type="text/javascript">
</script>
<INPUT class="sr-only" TYPE="text" id="nomForm" name="nomForm" value="ficheBeneficiaire">
<INPUT class="sr-only" TYPE="text" id="garantieArchive_C" name="garantieArchive_C" value="<?= $_SESSION['garantieArchive_C'] ?>">
<INPUT class="sr-only" TYPE="text" id="primeArchive" name="primeArchive" value="<?= $beneficiaire['primeArchive'] ?>" >
<INPUT class="sr-only" TYPE="text" id="idPolice" name="idPolice" value="<?= $beneficiaire['idPolice'] ?>" >
<INPUT class="sr-only" TYPE="text" id="idCollege" name="idCollege" value="<?= $beneficiaire['idCollege'] ?>" >
<INPUT class="sr-only" TYPE="text" id="idAdherent" name="idAdherent" value="<?= $beneficiaire['idAdherent'] ?>" >
<INPUT class="sr-only" TYPE="text" id="idBeneficiaire" name="idBeneficiaire" value="<?= $_SESSION['idBeneficiaire_C'] ?>" >
<INPUT class="sr-only" TYPE="text" id="numeroAdherent" name="numeroAdherent" value="<?= $beneficiaire['numeroAdherent'] ?>" >
<INPUT class="sr-only" TYPE="text" id="numeroBeneficiaire" name="numeroBeneficiaire" value="<?= $beneficiaire['numeroBeneficiaire'] ?>" >
<INPUT class="sr-only" TYPE="text" id="prestationPossible" name="prestationPossible" value="<?= $prestationPossible ?>" >
<INPUT class="sr-only" TYPE="text" id="faceRegistered" name="faceRegistered" value="<?= $faceRegistered ?>">
<div id="div_patienter" ></div>
<style>
#container {
margin-top:5px;
display: flex;
justify-content: center; /* centre horizontalement */
align-items: center; /* centre verticalement */
height: 100%; /* à ajuster selon ton besoin */
}
</style>
<FORM name= "formfichebeneficiaire" id ="formfichebeneficiaire" method="POST">
<fieldset>
<div class="tab-container">
<legend ><?= ("Informations du Bénéficiaire (") . "" . $beneficiaire['numeroBeneficiaire'] . ") => " . _("Couverture") . " : " . dateLang($_SESSION['dateEntreeBeneficiaire_C'], $_SESSION['lang']).' - '.dateLang($_SESSION['dateEcheancePolice_C'], $_SESSION['lang']) . " => " . _("Taux") . " : " . taux_couverture(intval($this->nettoyer($beneficiaire['ticketModerateur'])))?> </legend>
<button class="sr-only" id="btn_pop_save_face" name="btn_pop_save_face" type="button" data-bs-toggle="modal" data-bs-target="#pop_rec_faciale" > </button>
<div id="div_urlFace">
<input class="sr-only" type="text" id="urlFace" name="urlFace" value="">
</div>
<div id="div_wait_face">
</div>
<?php if ($faceActif=='1') : ?>
<table class="table table-responsive table-condensed">
<tbody>
<?php if ($faceRegistered=="1") : ?>
<tr>
<td>
<button style='font-size:15pt; width:100%' type="button" class="btn btn-primary" onClick="javascript:ebene_init_confirm_photo_face();">
<i class="fa fa-camera" aria-hidden="true"></i> <?= _("CONFIRMER LA FACE") ?>
</button>
</td>
</tr>
<?php else: ?>
<tr>
<td >
<button style='font-size:15pt; width:100%' type="button" class="btn btn-primary" onClick="javascript:ebene_init_photo_face();">
<i class="fa fa-camera" aria-hidden="true"></i> <?= _("ENREGISTRER LA FACE") ?>
</button>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php endif; ?>
<table class="table table-responsive table-condensed" style="white-space: nowrap;">
<tbody>
<tr>
<td rowspan="14">
<div class="photo-container">
<?php if ($beneficiaire['faceRegistered']=="1" ): ?>
<img src="data:image/jpg;base64,<?=$imgData?>"
style="width: 100px; cursor:pointer;" data-bs-toggle="modal" data-bs-target="#pop_photo">
<?php endif; ?>
</div>
</div>
<div id="container">
<?php if ($carteEditee=="1" ): ?>
<i class="fa fa-check-circle text-success" title="<?= _('Carte éditée')?>"></i>
<?php else: ?>
<i class="fa fa-times-circle text-danger" title="<?= _('Carte non éditée')?>"></i>
<?php endif; ?>
</div>
</td>
</tr>
<tr>
<td colspan="9">
<?php if($vip=="1"): ?>
<INPUT class="form-control vip" TYPE="text" id="vip" name="vip" value="<?= _("ASSURE VIP") ?>">
<?php endif; ?>
</td >
</tr>
<tr>
<td width="10%" > <?= _("Collège") ?> </td>
<td colspan="4"><INPUT class="form-control gras" TYPE="text" id="produit" name="produit" value="<?= $beneficiaire['libelleCollege'] ?>" readonly style="white-space:nowrap; overflow: auto;"></td>
<td colspan="4">
<button class="form-control gras btn btn-info" TYPE="button" id="produit" name="produit" onclick="javascript:consulter_detail_bareme_college(<?=$idBaremePriseEnCharge?>);" title="<?= _("Afficher le barème de prise en charge")?>">
<?= _("Consulter Barème prise en charge") ?>
</button>
</td>
</tr>
<tr>
<td width="10%"> <?= _("No Adhérent") ?> </td>
<td><INPUT class="form-control gras" TYPE="text" value="<?= $beneficiaire['numeroAdherent'] ?>" readonly ></td>
<td width="10%" align="center"> <?= _("Nom") ?> </td>
<td width="20%" ><INPUT class="form-control majuscule gras" TYPE="text" id="nomBeneficiaire" NAME="nomBeneficiaire" value="<?= $beneficiaire['nomBeneficiaire'] ?>" readonly ></td>
<td width="10%" align="center"> <?= _("Prénoms") ?> </td>
<td colspan="3"><INPUT class="form-control majuscule gras" TYPE="text" id="prenomsBeneficiaire" NAME="prenomsBeneficiaire" value="<?= $beneficiaire['prenomsBeneficiaire'] ?>" readonly ></td>
</tr>
<tr>
<td width="10%" > <?= _("Entrée") ?> </td>
<td width="22%" ><INPUT class="form-control gras" TYPE="text" id="dateEntree" NAME="dateEntree" value="<?= dateLang($this->nettoyer($beneficiaire['dateEntree'])) ?>" readonly ></td>
<td align="center"> <?= _("Lien Parenté") ?> </td>
<td><INPUT class="form-control gras" TYPE="text" id="lienparente" name="lienparente" value="<?= $lienparente ?>" readonly ></td>
<td align="center"> <?= _("Naissance") ?> </td>
<td colspan="3"><INPUT class="form-control gras" TYPE="text" id="dateNaissance" NAME="dateNaissance" value="<?= dateLang($this->nettoyer($beneficiaire['dateNaissance'])).' => '.$beneficiaire['age'].' ans' ?>" readonly ></td>
</tr>
<tr>
<td><?= _("Genre") ?> </td>
<td><INPUT class="form-control gras" TYPE="text" id="sexe" name="sexe" value="<?= $sexe ?>" readonly ></td>
<td align="center"> <?= _("Groupe Sanguin") ?> </td>
<td><INPUT class="form-control gras" TYPE="text" id="codeGroupeSanguin" name="codeGroupeSanguin" value="<?= $beneficiaire['codeGroupeSanguin'] ?>" readonly ></td>
<td align="center"> <?= _("Nature Pièce") ?></td>
<td colspan="3"><INPUT class="form-control gras" TYPE="text" id="naturepiece" name="naturepiece" value="<?= $naturepiece ?>" readonly ></td>
</tr>
<tr>
<td><?= _("N° Pièce / CMU") ?></td>
<td><INPUT class="form-control gras" TYPE="text" id="numeroPiece" NAME="numeroPiece" value="<?= $beneficiaire['numeroPiece'].' / '.$beneficiaire['numeroCmu'] ?>" readonly ></td>
<td align="center"> <?= _("Tél Portable") ?> </td>
<td><INPUT class="form-control gras" TYPE="tel" id="telephonePortable" NAME="telephonePortable" value="<?= $beneficiaire['telephonePortable'] ?>" readonly ></td>
<td align="center"> <?= _("Etat") ?> </td>
<?php if ($dateEffetCouvert=="0") : ?>
<td align="center" style='font-size:10pt; background-color:red;color:white;'> <?= _("Non renouvelé") ?> </td>
<?php else: ?>
<?php if ($estcouvert) : ?>
<?php if ($beneficiaire['codeEtatBeneficiaire']=="V"): ?>
<?php if($prestationPossible=="1" && $carteEditee!="1"): ?>
<td >
<button style='font-size:10pt;' class="form-control gras btn btn-success" TYPE="button" onclick="javascript:imprimer_carte_assure();">
<?= _("Imprimer carte") ?>
</button>
</td>
<td align="center" colspan="2" style='font-size:10pt; background-color:#027BE3;color:white;'> <?= $etatbeneficiaire ?> </td>
<?php else : ?>
<td align="center" colspan="3" style='font-size:10pt; background-color:#027BE3;color:white;'> <?= $etatbeneficiaire ?> </td>
<?php endif; ?>
<?php else: ?>
<td align="center" colspan="3" style='font-size:10pt; background-color:red;color:white;'> <?= $etatbeneficiaire ?> </td>
<?php endif; ?>
<?php else: ?>
<?php if ($estsorti): ?>
<td align="center" colspan="3" style='font-size:10pt; background-color:red;color:white;'> <?= _("Retiré") ?> </td>
<?php else: ?>
<td align="center" colspan="3" style='font-size:10pt; background-color:red;color:white;'> <?= _("Expiré") ?> </td>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</tr>
<tr>
<td ><?= _("Tarif Actes") ?></td>
<td >
<select class="form-control gras" name="codeTarifActe" id="codeTarifActe" disabled >
<?= liste_options($tarifActe, $beneficiaire['codeTarifActe'], false) ?>
</select>
</td>
<td align="center"><?= _("Date Souscription") ?></td>
<td >
<INPUT class="form-control gras" TYPE="text" value="<?= datefr($beneficiaire['dateSouscription']); ?>" readonly >
</td>
<td align="center"><?= _("Seuil RD (%)") ?></td>
<td colspan="3">
<INPUT class="form-control gras" TYPE="text" value="<?= $beneficiaire['seuilRdBeneficiaire']; ?>" readonly >
</td>
</tr>
<tr>
<td> <?= _("Type Remboursement") ?> </td>
<td><INPUT class="form-control gras" TYPE="text" value="<?= $this->nettoyer($beneficiaire['codeTypeRemboursement']) ?>" readonly ></td>
<td align="center"> <?= _("Sortie") ?> </td>
<td><INPUT class="form-control gras" TYPE="text" id="dateSortie" NAME="dateSortie" value="<?= dateLang($this->nettoyer($beneficiaire['dateSortie'])) ?>" readonly ></td>
<td align="center"> <?= _("Motif Sortie") ?> </td>
<td colspan="3"><INPUT class="form-control gras" TYPE="text" id="motifSortie" NAME="motifSortie" value="<?= $motifsortie ?>" readonly ></td>
</tr>
<tr style='background-color:white'>
<td colspan="8" height="8"></td>
</tr>
<?php
$plafondGlobalFamille = $this->nettoyer($police['plafond']);
$consommationGlobaleFamille = $this->nettoyer($police['consommation']);
$niveauGlobalConsoFamille = ($consommationGlobaleFamille/$plafondGlobalFamille)*100;
$niveauGlobalConsoFamille = number_format($niveauGlobalConsoFamille, 2, ',', ' ');
$plafondGlobalBeneficiaire = $this->nettoyer($college['plafond']);
$consommationGlobaleBenef = $this->nettoyer($college['consommation']);
$niveauGlobalConsoBenef = ($consommationGlobaleBenef/$plafondGlobalBeneficiaire)*100;
$niveauGlobalConsoBenef = number_format($niveauGlobalConsoBenef, 2, ',', ' ');
/*
if($niveauGlobalConsoFamille>='50' && $niveauGlobalConsoFamille<'80'){
$styleFamille="background-color: yellow; font-size:10pt;";
}elseif($niveauGlobalConsoFamille>='80' && $niveauGlobalConsoFamille <'100'){
$styleFamille="background-color: orange; font-size:10pt;";
}elseif($niveauGlobalConsoFamille >='100'){
$styleFamille="background-color: red; color:white; font-size:10pt;";
}
*/
?>
<tr>
<td> <?= _("Plafond Famille") ?> </td>
<td>
<button class="form-control gras btn btn-primary" TYPE="button" onclick="javascript:limiteadherent();" title="Cliquez pour modifier le plafond famille...">
<?= format_N($this->nettoyer($police['plafond'])) ?>
</button>
</td>
<td align="center"> <?= _("Conso. Famille") ?> </td>
<td>
<button class="form-control gras btn btn-primary" TYPE="button" onclick="javascript:consosadherent();" title="Cliquez pour voir le détail des consommations de l'adhérent...">
<?= format_N($this->nettoyer($police['consommation'])) ?>
</button>
</td>
<td align="center"> <?= _("Solde Famille") ?> </td>
<td>
<INPUT style='text-align:center; color:red !important; font-weight:bold; font-size:10pt;' class="form-control" TYPE="text" value="<?= format_N($this->nettoyer($police['soldeConsommation'])) ?>" readonly >
</td>
<td width="2%"></td>
<td width="8%">
<INPUT style="font-size:10pt; text-align:center; font-weight:bold; color:red;" class="form-control" TYPE="text" value="<?= $niveauGlobalConsoFamille." %"; ?>" readonly >
</td>
</tr>
<?php if($police['soldeConsommation']<="0") :?>
<tr >
<td colspan="8">
<marquee behavior="scroll" direction="left" scrollamount="10" style="color:white; background-color:red; font-size:14pt; font-weight:bold;">
<?= _("Le plafond contractuel de l'adhérent est atteint!") ?>
</marquee>
</td>
</tr>
<?php endif; ?>
<tr>
<td> <?= _("Plafond Bénéficiaire") ?> </td>
<td>
<button class="form-control gras btn btn-primary" TYPE="button" onclick="javascript:limitebeneficiaire();" title="Cliquez pour modifier le plafond bénéficiaire...">
<?= format_N($this->nettoyer($college['plafond'])) ?>
</button>
</td>
<td align="center"> <?= _("Conso. Bénéficiaire") ?> </td>
<td>
<button class="form-control gras btn btn-primary" TYPE="button" onclick="javascript:consosbeneficiaire();" title="Cliquez pour afficher le détail des consommations du bénéficiaire...">
<?= format_N($this->nettoyer($college['consommation'])) ?>
</button>
</td>
<td align="center"> <?= _("Solde Bénéficiaire") ?> </td>
<td> <INPUT style='text-align:center; color:red; font-weight: bold; font-size:10pt;' class="form-control" TYPE="text" value="<?= format_N($this->nettoyer($college['soldeConsommation'])) ?>" readonly ></td>
<td width="2%"></td>
<td width="8%">
<INPUT style="font-size:10pt; text-align:center; font-weight:bold; color:red;" class="form-control" TYPE="text" value="<?= $niveauGlobalConsoBenef." %"; ?>" readonly >
</td>
</tr>
<?php if($college['soldeConsommation']<="0") :?>
<tr >
<td colspan="8">
<marquee behavior="scroll" direction="left" scrollamount="10" style="color:white; background-color:red; font-size:14pt; font-weight:bold;">
<?= _("Le plafond contractuel du bénéficiaire est atteint!") ?>
</marquee>
</td>
</tr>
<?php endif; ?>
<tr style='background-color:white'>
<td colspan="8" height="8"></td>
</tr>
<tr>
<td></td>
<td align="center">
<button class="form-control gras btn btn-info" TYPE="button" onclick="javascript:affiche_actes_plafonnes_beneficiaire();">
<?= _("Actes plafonnés") ?>
</button>
</td>
<td></td>
<td >
<button class="form-control gras btn btn-success" TYPE="button" onclick="javascript:affiche_historique_prestations_beneficiaire();">
<?= _("Historique prestations") ?>
</button>
</td>
<td></td>
<td align="center" colspan="3">
<button class="form-control gras btn btn-info" TYPE="button" onclick="javascript:affiche_reseau_prestatairessoins_beneficiaire();">
<?= _("Prestataires de soins") ?>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<?php if ($estsorti): ?>
<div class="alert alert-danger" style="height:30px; padding:5px; margin-bottom:5px; text-align:center;" >
<H4><?= _("Date sortie") . " : " . dateLang($dateSortieBeneficiaire) ?></H4>
</div>
<?php endif; ?>
</FORM>
<div >
<?php if ($_SESSION['codeTypeUtilisateur']=='AA'): ?>
<form enctype="multipart/form-data" action="Fichebeneficiaire/<?= $_SESSION['idBeneficiaire_C'] ?>/" method="post">
<?php if ($beneficiaire['lienPhoto']<=' '): ?>
<div class="col-12">
<INPUT style="text-align: center" class="form-control" TYPE="text" value="<?= _("Aucune photo") ?>" readonly>
</div>
<?php endif; ?>
<div class="col-12">
<fieldset>
<?php if ($_SESSION['lienPhoto_C']>" "): ?>
<INPUT style="font-size: 15px; height: 30px; background-color: gray; color: white; margin-bottom:-22px;" class="form-control" TYPE="text" value="<?= _("Changer la photo") ?>" readonly >
<?php else: ?>
<INPUT style="font-size: 15px; height: 30px; background-color: gray; color: white; margin-bottom:-22px;" class="form-control" TYPE="text" value="<?= _("Attribuer une photo") ?>" readonly >
<?php endif; ?>
<label for="fichier_a_uploader" title="<?= _("Recherchez une photo!") ?>"></label>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input style="font-size: 15px; height: 40px" class="form-control btn btn-primary" name="fichier_image_a_uploader" type="file" id="fichier_image_a_uploader" />
<br>
<input style="font-size: 15px; height: 30px" class="form-control btn btn-primary" type="submit" name="submit" value="<?= _("Mettre à jour") ?>" />
</fieldset>
<h4 style="text-align: center">
<?php if ($message>" "): ?>
<div class="col-12 alert alert-danger">
<?= $message ?>
</div>
<?php endif; ?>
</h4>
</div>
<?php if ($message=='Chargement réussi !'): ?>
<INPUT style="text-align: center; background-color: grey; color: white; margin-top:-12px;" class="form-control" TYPE="text" value="<?= _("Le Nouveau Fichier Photo") ?> : <?= $nouveau_fichier ?>" readonly>
<?php else: ?>
<INPUT style="text-align: center; background-color: grey; color: white; margin-top:-12px;" class="form-control" TYPE="text" value="<?= _("Fichier Photo Actuel") ?> : <?= $beneficiaire['lienPhoto'] ?>" readonly>
<?php endif; ?>
</form>
<?php else:
if ($beneficiaire['lienPhoto']<=' '): ?>
<INPUT style="text-align: center" class="form-control" TYPE="text" value="<?= _("Aucune photo") ?>" readonly>
<?php endif;
endif; ?>
</div>
<div id="div_patienter"></div>
<div id="div_limite_adherent" class="modal fade"></div>
<div id="div_consos_adherent" class="modal fade"></div>
<div id="div_limite_beneficiaire" class="modal fade"></div>
<div id="div_consos_beneficiaire" class="modal fade"></div>
<!-- Responsive Area Chart -->
<div class="row mt-4">
<div class="col-12 mb-4">
<div class="card shadow h-100">
<div class="card-header py-3 d-flex flex-column flex-md-row justify-content-between align-items-center">
<h6 class="m-0 font-weight-bold text-primary"><?= _("Dépenses mensuelles") ?></h6>
<div class="mt-2 mt-md-0">
<button type="button" id="exportTrendBtn" class="btn btn-sm btn-danger mr-2">
<i class="fas fa-download"></i> PDF
</button>
<small class="text-muted"><?= _("Évolution sur 12 mois") ?></small>
</div>
</div>
<div class="card-body">
<div class="chart-container" style="position: relative; height:300px; width:100%">
<canvas id="expenseTrendChart"></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- Bar Chart Section -->
<div class="row mt-4">
<div class="col-12 mb-4">
<div class="card shadow h-100">
<div class="card-header py-3 d-flex justify-content-between align-items-center">
<h6 class="m-0 font-weight-bold text-primary"><?= _("Dépenses par garantie") ?></h6>
<button type="button" id="exportBarBtn" class="btn btn-sm btn-danger">
<i class="fas fa-download"></i> PDF
</button>
</div>
<div class="card-body">
<div class="chart-container" style="position: relative; height:400px; width:100%">
<canvas id="depensesChart"></canvas>
</div>
</div>
</div>
</div>
</div>
<script>
// Configuration commune
(function() {
// Récupération de la devise depuis PHP
const userCurrency = '<?= isset($_SESSION['devise_C']) ? $_SESSION['devise_C'] : 'F CFA' ?>';
// Configuration des devises
const currencyFormats = {
'F CFA': {
symbol: 'F CFA',
format: (value) => new Intl.NumberFormat('fr-FR').format(value) + ' F CFA'
},
'€': {
symbol: '€',
format: (value) => new Intl.NumberFormat('fr-FR', {style: 'currency', currency: 'EUR'}).format(value)
},
'$': {
symbol: '$',
format: (value) => new Intl.NumberFormat('fr-FR', {style: 'currency', currency: 'USD'}).format(value)
},
'XOF': {
symbol: 'F CFA',
format: (value) => new Intl.NumberFormat('fr-FR').format(value) + ' F CFA'
}
};
// Format monétaire dynamique
const formatMoney = (value) => {
const currencyConfig = currencyFormats[userCurrency] || currencyFormats['F CFA'];
return currencyConfig.format(value);
};
// Format pourcentage
const formatPercentage = (value, total) => {
const percentage = (value * 100 / total).toFixed(1);
return percentage + '%';
};
// Détection mobile
const isMobile = window.matchMedia("(max-width: 768px)").matches;
// Génération des couleurs
const generateColors = (count) => {
const palette = [
'#4e73df', '#1cc88a', '#36b9cc', '#f6c23e',
'#e74a3b', '#858796', '#5a5c69', '#3a3b45',
'#2e59a9', '#17a673', '#2c9faf', '#dda20a'
];
return palette.slice(0, count).concat(
Array.from({length: Math.max(0, count - palette.length)}, (_, i) => {
const hue = Math.floor(360 * (i / Math.max(1, count - palette.length)));
return `hsl(${hue}, 70%, 60%)`;
})
);
};
// Fonction pour générer une légende personnalisée
function generateCustomLegend(chart, containerId) {
const legendContainer = document.getElementById(containerId);
legendContainer.innerHTML = '';
const items = chart.data.datasets[0].data.map((value, i) => {
const total = chart.data.datasets[0].data.reduce((a, b) => a + b, 0);
const percentage = formatPercentage(value, total);
return `
<div class="d-inline-block mx-2 my-1">
<span class="legend-color" style="
display: inline-block;
width: 12px;
height: 12px;
background-color: ${chart.data.datasets[0].backgroundColor[i]};
border: 1px solid #fff;
vertical-align: middle;
"></span>
<span class="legend-text small ml-1">
${chart.data.labels[i]}: ${formatMoney(value)} (${percentage})
</span>
</div>
`;
});
legendContainer.innerHTML = items.join('');
}
// Fonction pour exporter un graphique en PDF
function exportChartToPDF(chartId, fileName) {
const { jsPDF } = window.jspdf;
const canvas = document.getElementById(chartId);
html2canvas(canvas).then(canvasImage => {
const imgData = canvasImage.toDataURL('image/png');
const pdf = new jsPDF({
orientation: canvasImage.width > canvasImage.height ? 'landscape' : 'portrait'
});
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
const ratio = canvasImage.height / canvasImage.width;
let imgWidth = pageWidth - 20;
let imgHeight = imgWidth * ratio;
if (imgHeight > pageHeight - 20) {
imgHeight = pageHeight - 20;
imgWidth = imgHeight / ratio;
}
pdf.addImage(imgData, 'PNG',
(pageWidth - imgWidth) / 2,
(pageHeight - imgHeight) / 2,
imgWidth,
imgHeight
);
pdf.save(fileName + '.pdf');
});
}
// Graphique d'évolution des dépenses
const dataMois = <?= $dataConsoParMois ?>;
const trendCtx = document.getElementById('expenseTrendChart').getContext('2d');
const trendChart = new Chart(trendCtx, {
type: 'line',
data: {
labels: dataMois.mois,
datasets: [{
label: '<?= _("Montant dépensé") ?>',
data: dataMois.consos,
backgroundColor: 'rgba(78, 115, 223, 0.05)',
borderColor: 'rgba(78, 115, 223, 1)',
borderWidth: 2,
pointBackgroundColor: 'rgba(78, 115, 223, 1)',
pointRadius: isMobile ? 3 : 4,
pointHoverRadius: 6,
fill: true,
tension: 0.3
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
},
tooltip: {
mode: 'index',
intersect: false,
callbacks: {
label: function(context) {
return context.dataset.label + ': ' + formatMoney(context.parsed.y);
}
}
}
},
scales: {
x: {
grid: {
display: false
},
ticks: {
maxRotation: isMobile ? 45 : 0,
autoSkip: true,
maxTicksLimit: isMobile ? 6 : 12
}
},
y: {
beginAtZero: false,
ticks: {
callback: function(value) {
return formatMoney(value);
}
},
grid: {
color: 'rgba(0, 0, 0, 0.05)'
}
}
},
interaction: {
mode: 'nearest',
axis: 'x',
intersect: false
}
}
});
// Graphique des dépenses par garantie
const dataConso = <?= $dataConsoParGaranties ?>;
const barCtx = document.getElementById('depensesChart').getContext('2d');
const barChart = new Chart(barCtx, {
type: 'bar',
data: {
labels: dataConso.garanties,
datasets: [{
label: 'Dépenses',
data: dataConso.depenses,
backgroundColor: 'rgba(54, 162, 235, 0.7)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
annotation: {
annotations: dataConso.plafonds.map((plafond, index) => {
if (plafond === null) return null;
return {
type: 'line',
yMin: plafond,
yMax: plafond,
borderColor: 'rgba(255, 99, 132, 0.7)',
borderWidth: 2,
borderDash: [6, 6],
label: {
content: `Plafond: ${formatMoney(plafond)}`,
enabled: true,
position: 'right'
}
};
}).filter(annotation => annotation !== null)
},
legend: {
display: false
},
tooltip: {
callbacks: {
label: function(context) {
const plafond = dataConso.plafonds[context.dataIndex];
let tooltip = `Dépenses: ${formatMoney(context.parsed.y)}`;
if (plafond !== null) {
const pourcentage = Math.min(100, Math.round((context.parsed.y / plafond) * 100));
tooltip += ` (${pourcentage}% du plafond)`;
} else {
tooltip += ' (plafond illimité)';
}
return tooltip;
}
}
}
},
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: `Montant des dépenses (${userCurrency})`,
font: {
weight: 'bold'
}
},
ticks: {
callback: function(value) {
return formatMoney(value);
}
},
suggestedMax: Math.max(...dataConso.depenses) * 1.5
},
x: {
title: {
display: true,
text: 'Garanties',
font: {
weight: 'bold'
}
},
grid: {
display: false
}
}
}
}
});
// Boutons d'export PDF
document.getElementById('exportTrendBtn').addEventListener('click', () => {
exportChartToPDF('expenseTrendChart', 'evolution_depenses_mensuelles');
});
document.getElementById('exportBarBtn').addEventListener('click', () => {
exportChartToPDF('depensesChart', 'depenses_par_garantie');
});
})();
</script>
<style>
/* Styles communs pour tous les graphiques */
.chart-container {
position: relative;
width: 100%;
min-height: 300px;
}
.legend-text {
vertical-align: middle;
}
.btn-export {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
}
@media (max-width: 768px) {
.chart-container {
height: 60vh;
}
.card-header {
flex-direction: column;
align-items: flex-start !important;
}
.btn-export {
margin-top: 0.5rem;
align-self: flex-end;
}
}
</style>
<div id="div_legende_couleur" style="width:100%; margin: 5px; background-color: #f8f8ff;" class="tab-container">
<table class="table-responsive" style="width:100%; margin:auto; background-color: #f8f8ff; font-size:12pt;">
<tbody>
<tr>
<td style="font-weight:bold; text-align:right; background-color: #f8f8ff; text-decoration-line: underline;"> <?= _("Légende").":"; ?></td>
<td style="font-weight:bold; text-align:right; background-color: #f8f8ff;"> <?= _("Consommation")." >= 50%"; ?></td>
<td width="1%" style="background-color: #f8f8ff"></td>
<td width="4%" style="background-color:#726a57"></td >
<td width="2%" style="background-color: #f8f8ff"></td>
<td style="font-weight:bold; text-align:right; background-color: #f8f8ff;"><?= _("Consommation")." >= 80%"; ?></td>
<td width="1%" style="background-color: #f8f8ff"></td>
<td width="4%" style="background-color: orange"></td >
<td width="1%" style="background-color: #f8f8ff"></td>
<td style="font-weight:bold; text-align:right; background-color: #f8f8ff;" ><?= _("Consommation")." = 100% / ". _("Transaction")." = 100%"; ?></td>
<td style="background-color: #f8f8ff"></td>
<td width="4%" style="background-color: red;"></td >
</tr>
</tbody>
</table>
</div>
<div class="wrapper">
<div class="tabs">
<div class="tab">
<input type="radio" name="css-tabs" id="tab-1" checked class="tab-switch">
<label for="tab-1" class="tab-label"><?= _("BENEFICIAIRE"); ?></label>
<div class="tab-content tab-container">
<fieldset>
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:10pt; white-space:nowrap;">
<thead>
<tr>
<th rowspan="2" width="5%" style="text-align:center"> <?= _("Exercice") ?> </th>
<th rowspan="2" width="20%" style="text-align:center"> <?= _("Garantie") ?> </th>
<th rowspan="2" style="text-align:center" width="5%"> <?= _("Taux") ?> </th>
<th colspan="4" style="text-align:center"> <?= _("Consommations") ?> </th>
<th colspan="4" style="text-align:center"> <?= _("Prestations") ?> </th>
</tr>
<tr>
<th style="text-align:center" width="10%"> <?= _("Plafond") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Périodicité") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Dépenses") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Solde") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Nb Transaction") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Périodicité") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Nbre Prestation") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Solde") ?> </th>
</tr>
</thead>
<tbody>
<?php foreach ($garantieadherents as $v):
$champApplication = $this->nettoyer($v['champApplication']);
$pourcentConso = $this->nettoyer($v['pourcentConso']);
$transactionBeneficiaire = $this->nettoyer($v['transactionBeneficiaire']);
$soldeTransactionBeneficiaire = $this->nettoyer($v['soldeTransactionBeneficiaire']);
$idBeneficiaire = $this->nettoyer($v['idBeneficiaire']);
$codeGarantie = $this->nettoyer($v['codeGarantie']);
$exercieReference = $this->nettoyer($v['exercieReference']);
$plafond = format_N($this->nettoyer($v['plafond']));
$nbreTransaction = $this->nettoyer($v['nbreTransaction']);
?>
<?php if($pourcentConso>='50' && $pourcentConso<'80'): ?>
<tr style="background-color: yellow;" valign="top">
<?php elseif($pourcentConso>='80' && $pourcentConso <'100'): ?>
<tr style="background-color: orange;" valign="top">
<?php elseif($pourcentConso >='100' || $transactionBeneficiaire=="1"): ?>
<tr style="background-color: red; color:white" valign="top">
<?php else: ?>
<tr valign="top">
<?php endif; ?>
<td align='center'> <?= $this->nettoyer($v['exercieReference'])?> </td>
<td align='center'>
<?php if($pourcentConso >='95' || $transactionBeneficiaire=="1"): ?>
<a title="<?= _("Plafond ou nombre de transaction atteint pour cette garantie.") ?>" href="javascript:alert_ebene('Plafond ou nombre de transaction atteint pour cette garantie!', 'Limit or number of transactions reached for this guarantee!');">
<span style="color:blue; background-color:#eeeeee; border:1px solid #000; border-radius:3px;">
<?= $this->nettoyer($v['garantie'])?>
</span>
</a>
<?php else: ?>
<?= $this->nettoyer($v['garantie'])?>
<?php endif; ?>
</td>
<td align='center'><?= $this->nettoyer($v['tauxPlafond']).'%'; ?></td>
<td align='center' ><?= $plafond ?></td>
<td align='center'><?= $v['codePeriodicitePlafond'] ?></td>
<td align='center'><?= format_N($this->nettoyer($v['consommation'])) ?></td>
<td align='center' ><?= format_N($this->nettoyer($v['soldeGarantie'])) ?></td>
<td align='center'><?= $this->nettoyer($v['nbreTransaction']) ?></td>
<td align='center'><?= $v['codePeriodicite'] ?></td>
<td align='center'><?= $this->nettoyer($v['comptePrestation']) ?></td>
<td align='center'><?= $this->nettoyer($v['soldeTransactionBeneficiaire']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</fieldset>
</div>
</div>
<div class="tab">
<input type="radio" name="css-tabs" id="tab-2" class="tab-switch">
<label for="tab-2" class="tab-label"><?= _("FAMILLE")?></label>
<div class="tab-content tab-container">
<fieldset>
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:10pt; white-space:nowrap;">
<thead>
<tr>
<th rowspan="2" width="5%" style="text-align:center"> <?= _("Exercice") ?> </th>
<th rowspan="2" width="20%" style="text-align:center"> <?= _("Garantie") ?> </th>
<th rowspan="2" style="text-align:center" width="5%"> <?= _("Taux") ?> </th>
<th colspan="4" style="text-align:center"> <?= _("Consommations") ?> </th>
<th colspan="4" style="text-align:center"> <?= _("Prestations") ?> </th>
</tr>
<tr>
<th style="text-align:center" width="10%"> <?= _("Plafond") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Périodicité") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Dépenses") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Solde") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Nb Transaction") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Périodicité") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Nbre Prestation") ?> </th>
<th style="text-align:center" width="10%"> <?= _("Solde") ?> </th>
</tr>
</thead>
<tbody>
<?php foreach ($garantieadherents as $v):
$champApplication = $this->nettoyer($v['champApplication']);
$pourcentConsoFamille = $this->nettoyer($v['pourcentConsoFamille']);
$transactionFamille = $this->nettoyer($v['transactionFamille']);
$soldeTransactionFamille = $this->nettoyer($v['soldeTransactionFamille']);
$idAdherent = $this->nettoyer($v['idAdherent']);
$codeGarantie = $this->nettoyer($v['codeGarantie']);
$exercieReference = $this->nettoyer($v['exercieReference']);
$plafondFamille = format_N($this->nettoyer($v['plafondFamille']));
$nbreTransactionFamille = $this->nettoyer($v['nbreTransactionFamille']);
?>
<?php if($pourcentConsoFamille>='50' && $pourcentConsoFamille<'80'): ?>
<tr style="background-color: yellow;" valign="top">
<?php elseif($pourcentConsoFamille>='80' && $pourcentConsoFamille <'100'): ?>
<tr style="background-color: orange;" valign="top">
<?php elseif($pourcentConsoFamille >='100' || $transactionFamille=="1"): ?>
<tr style="background-color: red; color:white" valign="top">
<?php else: ?>
<tr valign="top">
<?php endif; ?>
<td align='center'> <?= $this->nettoyer($v['exercieReference'])?> </td>
<td align='center'>
<?php if($pourcentConsoFamille >='95' || $transactionFamille=="1"): ?>
<a title="<?= _("Plafond ou nombre de transaction atteint pour cette garantie.") ?>" href="javascript:alert_ebene('Plafond ou nombre de transaction atteint pour cette garantie!', 'Limit or number of transactions reached for this guarantee!');">
<span style="color:blue; background-color:#eeeeee; border:1px solid #000; border-radius:3px;">
<?= $this->nettoyer($v['garantie'])?>
</span>
</a>
<?php else: ?>
<?= $this->nettoyer($v['garantie'])?>
<?php endif; ?>
</td>
<td align='center'><?= $this->nettoyer($v['tauxPlafond']).'%'; ?></td>
<td align='center' ><?= $plafondFamille ?></td>
<td align='center'><?= $v['codePeriodicitePlafondFamille'] ?></td>
<td align='center'><?= format_N($this->nettoyer($v['consommationFamille'])) ?></td>
<td align='center' ><?= format_N($this->nettoyer($v['soldeGarantieFamille'])) ?></td>
<td align='center'><?= $this->nettoyer($v['nbreTransactionFamille']) ?></td>
<td align='center'><?= $v['codePeriodiciteFamille'] ?></td>
<td align='center'><?= $this->nettoyer($v['comptePrestationFamille']) ?></td>
<td align='center'><?= $this->nettoyer($v['soldeTransactionFamille']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</fieldset>
</div>
</div>
</div>
</div>
<div id="div_actes_bareme" class="modal fade">
</div>
<div id="div_prestataires_soins" class="modal fade">
</div>
<div id="div_prestataires_divers" class="modal fade">
</div>
<div id="div_historique_prestations" class="modal fade">
</div>
<?php if($faceActif=='1') : ?>
<?php include 'faceebene/ebenetraitementimage.php'; ?>
<?php endif; ?>