This commit is contained in:
KONE SOREL 2026-03-28 17:05:20 +00:00
parent 82c921d249
commit d94d1ad727
3 changed files with 43 additions and 20 deletions

View File

@ -22,7 +22,15 @@ class ControleurListeavenant extends Controleur {
$police = $this->police->getPoliceId($idPolice);
$avenants = $this->avenant->getAvenant($idPolice);
$dj = date("Y-m-d");
$this->genererVue(array('police' => $police, 'avenants' => $avenants));
$sppoliceentete = $this->sppolice->getRapportSpPoliceEntete($idPolice, $dj);
$this->genererVue(array(
'police' => $police,
'avenants' => $avenants,
'sppoliceentete' => $sppoliceentete
));
}
}

View File

@ -366,7 +366,7 @@ function changer_langue_connexion() {
* @param {string|jQuery} selector - Sélecteur du tableau (ex: '.tabliste' ou '#myTable')
* @param {object} options - Options personnalisées (langue, boutons, ordre, etc.)
*/
function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Rapport") {
function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Rapport", message = "") {
const codeLangue = $("#codeLangue").val() || 'fr_FR';
const translations = {
@ -389,19 +389,29 @@ function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Ra
$(selector).each(function() {
const $table = $(this);
// Colonnes marquées comme 'data-hidden'
const hiddenTargets = [];
$table.find('thead th').each((idx, th) => {
if ($(th).data('hidden')) hiddenTargets.push(idx);
});
// Configuration des boutons avec le titre dynamique
// Configuration des boutons avec Titre ET Message de haut de page
const exportButtons = [
{ extend: 'copy', title: titreDoc },
{ extend: 'csv', title: titreDoc },
{ extend: 'excel', title: titreDoc },
{ extend: 'pdf', title: titreDoc },
{ extend: 'print', title: titreDoc }
{
extend: 'excel',
title: titreDoc,
messageTop: message // Ajoute les infos en haut de l'Excel
},
{
extend: 'pdf',
title: titreDoc,
messageTop: message, // Ajoute les infos en haut du PDF
orientation: 'landscape'
},
{
extend: 'print',
title: titreDoc,
messageTop: message // Ajoute les infos sur l'impression
}
];
const instance = $table.DataTable($.extend(true, {
@ -411,10 +421,9 @@ function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Ra
language: translations[codeLangue] || translations.fr_FR,
columnDefs: [{ targets: hiddenTargets, visible: false }],
dom: 'Bfrtip',
buttons: exportButtons // Utilisation des boutons configurés
buttons: exportButtons
}, options));
// Ajustement après rendu
$table.on('init.dt', function () {
if (instance && instance.responsive) {
instance.columns.adjust();

View File

@ -1,7 +1,5 @@
<?php
$titre = est_anglophone()
? 'History of Endorsements'
: 'Historique des Avenants';
$titre = 'Historique des Avenants';
?>
<div id="div_avenant" class="card shadow-sm border-0 mb-4 animate__animated animate__fadeIn">
@ -91,11 +89,19 @@
</div>
</div>
</div>
<script>
// Exécution au chargement complet du DOM
document.addEventListener("DOMContentLoaded", function() {
// Initialisation des composants au chargement de la page
appliquerDataTable('.tabliste', {}, "<?= mb_strtoupper($titre, 'UTF-8'); ?>");
});
<script>
document.addEventListener("DOMContentLoaded", function() {
// Préparation du titre
const titre = "<?= mb_strtoupper($titre, 'UTF-8'); ?>";
// Préparation du bloc d'informations (Le \n sert pour le retour à la ligne dans Excel/PDF)
const infosComplementaires =
"<?= _('Souscripteur').' : '.$_SESSION['nomClient_C'] ?>\n" +
"<?= _('Numéro Police').' : '.$_SESSION['numeroPolice_C'] ?>\n" +
"<?= _('Période couverte').' : '.dateLang($sppoliceentete['dateEffet'], $_SESSION['lang']) ?> <?= _('au') ?> <?= dateLang($sppoliceentete['dateEcheance'], $_SESSION['lang']) ?>";
// Appel de la fonction
appliquerDataTable('.tabliste', {}, titre, infosComplementaires);
});
</script>