This commit is contained in:
KONE SOREL 2026-01-06 13:37:34 +00:00
parent 3b8c485be6
commit 78b5560b29

View File

@ -1,63 +1,173 @@
<div id="div_detail_sp">
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:7pt;">
<thead>
<tr>
<th rowspan="2" colspan="2" style='text-align:center'> <?= _("Adhérent") ?> </th>
<?php
$this->titre = "INTER-SANTE - Synthèse Consommations";
// Initialisation des totaux pour le footer
$totStat = $totTtc = $totAll = 0;
$natures = ['OUT', 'INP', 'OPT', 'MON', 'DEN', 'FUN'];
$totPlafonds = array_fill_keys($natures, 0);
$totConsos = array_fill_keys($natures, 0);
?>
<th colspan="2" style='text-align:center'> <?= _("Primes") ?> </th>
<style>
/* --- STYLES ÉCRAN --- */
.nowrap { white-space: nowrap !important; }
.table-responsive-custom {
overflow: auto;
max-height: 70vh;
border: 1px solid #dee2e6;
background: white;
}
<th colspan="6" style='text-align:center'> <?= _("Plafonds") ?> </th>
/* Colonne Nom figée à gauche */
.sticky-col {
position: sticky;
left: 0;
z-index: 5;
background-color: #f8f9fa !important;
border-right: 2px solid #dee2e6 !important;
}
<th colspan="7" style='text-align:center'> <?= _("Consommations") ?> </th>
</tr>
/* En-tête figé en haut */
.sticky-header {
position: sticky;
top: 0;
z-index: 10;
}
<tr>
<th style='text-align:center'> Stat </th>
<th style='text-align:center'> <?= _("TTC") ?> </th>
<th style='text-align:center'> OUT </th>
<th style='text-align:center'> INP </th>
<th style='text-align:center'> OPT </th>
<th style='text-align:center'> MON </th>
<th style='text-align:center'> DEN </th>
<th style='text-align:center'> FUN </th>
<th style='text-align:center'> OUT </th>
<th style='text-align:center'> INP </th>
<th style='text-align:center'> OPT </th>
<th style='text-align:center'> MON </th>
<th style='text-align:center'> DEN </th>
<th style='text-align:center'> FUN </th>
<th style='text-align:center'> ALL </th>
</tr>
</thead>
<tbody>
<?php foreach ($conommations as $conommation): ?>
<tr valign="top">
<td><?= $this->nettoyer($conommation['nomAdherent']) ?></td>
<td align='center'><?= $this->nettoyer($conommation['numeroAdherent']) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['primeStat'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['primeTtc'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['plafond_OUT'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['plafond_INP'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['plafond_OPT'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['plafond_MON'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['plafond_DEN'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['plafond_FUN'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_OUT'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_INP'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_OPT'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_MON'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_DEN'])) ?></td>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_FUN'])) ?></td>
/* --- STYLES IMPRESSION PDF --- */
@media print {
@page { size: A4 landscape; margin: 10mm; }
body * { visibility: hidden; }
#section-to-print, #section-to-print * { visibility: visible; }
#section-to-print {
position: absolute;
left: 0; top: 0; width: 100%;
}
.no-print { display: none !important; }
.table-responsive-custom { overflow: visible !important; max-height: none !important; }
.sticky-col { position: static !important; background-color: white !important; }
table { font-size: 7pt !important; width: 100% !important; }
.nowrap { white-space: nowrap !important; }
body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
</style>
<td align='center'><?= format_N($this->nettoyer($conommation['consommation_ALL'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="container-fluid py-3" id="main-container">
<div class="card shadow-sm border-0 mb-3 no-print">
<div class="card-body bg-light py-2">
<div class="row align-items-center">
<div class="col-md-4">
<h5 class="mb-0 text-primary fw-bold"><?= _("Police") ?> : <?= $this->nettoyer($_SESSION['numeroPolice_C']) ?></h5>
</div>
<div class="col-md-8 text-end small">
<span class="me-3"><b>Effet:</b> <?= dateLang($sppoliceentete['dateEffet']) ?></span>
<span class="me-3"><b>Échéance:</b> <?= dateLang($sppoliceentete['dateEcheance']) ?></span>
<span class="badge bg-info text-dark">Ratio: <?= $sppoliceentete['ratio_acquise'] ?>%</span>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between mb-3 no-print">
<div>
<button class="btn btn-primary fw-bold shadow-sm" onclick="requetes_synthese_consommation_police();">
<i class="fas fa-sync-alt me-1"></i> <?= _("Actualiser") ?>
</button>
</div>
<div>
<button class="btn btn-outline-success fw-bold me-2 shadow-sm" onclick="requetes_synthese_consommation_police_export();">
<i class="fas fa-file-excel me-1"></i> <?= _("Excel") ?>
</button>
<button class="btn btn-danger fw-bold shadow-sm" onclick="window.print();">
<i class="fas fa-file-pdf me-1"></i> <?= _("Imprimer PDF") ?>
</button>
</div>
</div>
<div id="section-to-print">
<div class="d-none d-print-block mb-3 border-bottom pb-2">
<h3 class="text-uppercase"><?= _("Synthèse des Consommations Adhérents") ?></h3>
<p>Police: <b><?= $_SESSION['numeroPolice_C'] ?></b> | Date: <?= date('d/m/Y H:i') ?></p>
</div>
<div id="div_detail_sp" class="table-responsive-custom shadow-sm rounded">
<table class="table table-sm table-hover align-middle mb-0" style="font-size: 0.75rem;">
<thead class="text-white sticky-header">
<tr class="bg-dark text-center">
<th colspan="2" class="py-2 sticky-col bg-dark"><?= _("Bénéficiaire") ?></th>
<th colspan="2" class="bg-primary bg-opacity-75"><?= _("Primes") ?></th>
<th colspan="6" class="bg-info bg-opacity-50 text-dark"><?= _("Plafonds") ?></th>
<th colspan="7" class="bg-danger bg-opacity-75"><?= _("Consommations") ?></th>
</tr>
<tr class="bg-light text-dark small text-center border-bottom">
<th class="sticky-col bg-light"><?= _("Nom & Prénoms") ?></th>
<th class="border-end"> Adh</th>
<th>Stat</th>
<th class="border-end">TTC</th>
<?php foreach ($natures as $n): ?><th><?= $n ?></th><?php endforeach; ?>
<?php foreach ($natures as $n): ?><th class="border-start border-white"><?= $n ?></th><?php endforeach; ?>
<th class="bg-dark text-white fw-bold">TOTAL</th>
</tr>
</thead>
<tbody>
<?php foreach ($conommations as $conso):
// Cumul des totaux
$totStat += (float)$conso['primeStat'];
$totTtc += (float)$conso['primeTtc'];
$totAll += (float)$conso['consommation_ALL'];
?>
<tr class="text-center">
<td class="text-start ps-2 sticky-col fw-bold text-uppercase"><?= $this->nettoyer($conso['nomAdherent']) ?></td>
<td class="border-end text-muted small"><?= $this->nettoyer($conso['numeroAdherent']) ?></td>
<td class="nowrap"><?= format_N($conso['primeStat']) ?></td>
<td class="nowrap border-end fw-semibold"><?= format_N($conso['primeTtc']) ?></td>
<?php foreach ($natures as $n):
$totPlafonds[$n] += (float)$conso['plafond_'.$n];
?>
<td class="nowrap text-muted"><?= format_N($conso['plafond_'.$n]) ?></td>
<?php endforeach; ?>
<?php foreach ($natures as $n):
$totConsos[$n] += (float)$conso['consommation_'.$n];
?>
<td class="nowrap bg-danger bg-opacity-10 text-danger fw-medium border-start border-white">
<?= format_N($conso['consommation_'.$n]) ?>
</td>
<?php endforeach; ?>
<td class="nowrap bg-dark text-white fw-bold"><?= format_N($conso['consommation_ALL']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot class="bg-warning bg-opacity-10 fw-bold border-top border-dark text-center shadow-lg sticky-bottom">
<tr>
<td colspan="2" class="text-end pe-3 bg-dark text-white"><?= _("TOTAL GÉNÉRAL") ?> :</td>
<td class="nowrap bg-primary bg-opacity-25"><?= format_N($totStat) ?></td>
<td class="nowrap bg-primary bg-opacity-25 border-end border-dark"><?= format_N($totTtc) ?></td>
<?php foreach ($natures as $n): ?><td class="nowrap bg-info bg-opacity-25"><?= format_N($totPlafonds[$n]) ?></td><?php endforeach; ?>
<?php foreach ($natures as $n): ?><td class="nowrap bg-danger bg-opacity-25 text-danger border-start border-white"><?= format_N($totConsos[$n]) ?></td><?php endforeach; ?>
<td class="nowrap bg-dark text-warning fw-bolder fs-6 border-start border-white"><?= format_N($totAll) ?></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<script>
// Script pour s'assurer que le scroll est fluide et les colonnes figées bien alignées
document.addEventListener('DOMContentLoaded', function() {
const tableCont = document.querySelector('.table-responsive-custom');
if(tableCont) {
tableCont.addEventListener('scroll', function() {
// Optionnel : ajouter une ombre sur la colonne figée lors du scroll
});
}
});
</script>