radiantrh/Vue/Ajaxrequeteresumesinistres/index.php
2026-03-29 11:04:42 +00:00

117 lines
6.4 KiB
PHP

<?php $nbligne = 0; ?>
<div id="div_detail_requete" class="card border-0 shadow-sm animate__animated animate__fadeIn">
<div class="card-header bg-dark text-white p-4 border-0" style="border-radius: 12px 12px 0 0;">
<div class="row w-100 m-0 align-items-center"> <div class="col-md-4 border-end border-secondary text-center py-2">
<div class="text-uppercase opacity-75 mb-2" style="font-size: 9pt; letter-spacing: 1px;">
<i class="fas fa-layer-group me-2 text-primary"></i> <?= _("Volume Total") ?>
</div>
<div class="display-6 fw-bold">
<?= format_N($rpsinistres_total['nbLigne']) ?>
<small class="h5 opacity-50 fw-normal"><?= _("Lignes") ?></small>
</div>
</div>
<div class="col-md-4 border-end border-secondary text-center py-2">
<div class="text-uppercase opacity-75 mb-2" style="font-size: 9pt; letter-spacing: 1px;">
<i class="fas fa-hand-holding-usd me-2 text-warning"></i> <?= _("Cumul Sinistres") ?>
</div>
<div class="display-6 fw-bold text-warning">
<?= format_N($rpsinistres_total['sinistres_total']) ?>
</div>
</div>
<div class="col-md-4 text-center py-2">
<div class="text-uppercase opacity-75 mb-2" style="font-size: 9pt; letter-spacing: 1px;">
<i class="fas fa-chart-pie me-2 text-info"></i> <?= _("Ratio Moyen") ?>
</div>
<div class="display-6 fw-bold text-info">
<?= number_format((float)$rpsinistres_total['ratio_moyen'], 2, ',', ' ') ?> %
</div>
</div>
</div>
</div>
<div class="table-responsive">
<table id="table_resume_sinistres" class="table table-striped table-bordered table-hover tabliste compact w-100" style="font-size:0.85rem; white-space:nowrap;">
<thead class="table-light border-bottom text-uppercase small fw-bold">
<tr>
<th class="text-center"><?= _("N° Adhérent") ?></th>
<th><?= _("Adhérent Principal") ?></th>
<th class="text-center"><?= _("Date de début") ?></th>
<th class="text-center"><?= _("Période passée") ?></th>
<th class="text-center"><?= _("Sinistres") ?></th>
<th class="text-center"><?= _("Ratio (%)") ?></th>
<th class="text-center">Cat</th>
</tr>
</thead>
<tbody>
<?php foreach ($rpsinistres as $rpsinistre):
$nbligne++;
$ratio = (float)$rpsinistre['ratio'];
$ratioClass = ($ratio > 100) ? 'text-danger fw-bold' : (($ratio > 70) ? 'text-warning' : 'text-success');
?>
<tr>
<td class="text-center fw-bold text-primary"><?= $this->nettoyer($rpsinistre['numeroAdherent']) ?></td>
<td class="text-uppercase"><?= $this->nettoyer($rpsinistre['Adherent']) ?></td>
<td class="text-center text-muted"><?= dateLang($this->nettoyer($rpsinistre['dateEffetAdherent']), $_SESSION['lang']) ?></td>
<td class="text-center"><?= $this->nettoyer($rpsinistre['duree_acquise']) ?> <small><?= _("j") ?></small></td>
<td class="text-center fw-bold"><?= format_N($rpsinistre['sinistres']) ?></td>
<td class="text-center <?= $ratioClass ?>"><?= number_format($ratio, 2, ',', ' ') ?> %</td>
<td class="text-center">
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">
<?= $this->nettoyer($rpsinistre['codeProduit']) ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot class="table-light border-top border-dark">
<tr>
<td colspan="4" class="text-center fw-bold text-uppercase"><?= _("Total Général") ?></td>
<td class="text-center fw-bold text-dark fs-6"><?= format_N($rpsinistres_total['sinistres_total']) ?></td>
<td class="text-center fw-bold text-info fs-6"><?= number_format((float)$rpsinistres_total['ratio_moyen'], 2, ',', ' ') ?> %</td>
<td class="bg-light"></td>
</tr>
</tfoot>
</table>
</div>
<div class="card-footer bg-white d-flex justify-content-between align-items-center py-2">
<span class="text-muted small italic"><i class="fas fa-clock me-1"></i><?= _("Généré le") ?> <?= dateheureLang(date('d/m/Y H:i'), $_SESSION['lang']) ?></span>
<span class="badge bg-dark px-3"><?= $_SESSION['numeroPolice_C'] ?></span>
</div>
<input class="sr-only" type="text" id="nbligne_info" name="nbligne_info" value="<?= $nbligne ?>">
</div>
<script>
$(document).ready(function() {
// 1. Préparation des textes
const titreRapport = <?= json_encode(mb_strtoupper(_('RAPPORT RÉSUMÉ DES SINISTRES'), 'UTF-8')) ?>;
// 2. Préparation du bloc d'infos Subscriber/Policy/Period
const infosEntete =
"\n<?= _('Souscripteur') ?> : <?= $_SESSION['nomClient_C'] ?>\n" +
"<?= _('Numéro Police') ?> : <?= $_SESSION['numeroPolice_C'] ?>\n" +
"<?= _('Période couverte') ?> : <?= $_SESSION['dateEffetPolice'] ?> <?= _('au') ?> <?= $_SESSION['dateFinRequete'] ?>\n";
// 3. Appel de la fonction COMMUNE appliquerDataTable()
// On passe 'footer: true' dans les boutons pour que le <tfoot> soit exporté
appliquerDataTable('#table_resume_sinistres', {
pageLength: 50,
order: [[5, "desc"]], // Tri par Ratio décroissant
buttons: [
{ extend: 'excel', title: titreRapport, messageTop: infosEntete, footer: true },
{ extend: 'pdf', title: titreRapport, messageTop: infosEntete, orientation: 'landscape', footer: true },
{ extend: 'print', title: titreRapport, messageTop: infosEntete, footer: true }
]
}, titreRapport, infosEntete);
// 4. Mise à jour du compteur global (l'input dans ton formulaire de recherche)
$('#nbligne').val($('#nbligne_info').val());
});
</script>