df
This commit is contained in:
parent
c98391c74e
commit
c9ed923a0f
|
|
@ -92266,4 +92266,77 @@ function changerAnneeFiltre(valeur) {
|
|||
// Appel de votre fonction moteur
|
||||
// Astuce : vérifiez que dans votre contrôleur PHP, vous récupérez bien $_POST['annee']
|
||||
afficheDonneesTableChoisie('Ajaxtblisterjoursferiers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise une DataTable standard pour les tables de référence
|
||||
* @param {string} selector - L'ID ou la classe de la table (ex: '#tableLister')
|
||||
* @param {string} exportTitle - Le nom du fichier lors de l'export
|
||||
* @param {boolean|array} defaultOrder - Exemple: [1, 'desc'] ou false pour garder l'ordre serveur
|
||||
*/
|
||||
function initDataTableReference(selector, exportTitle = 'Export_Donnees', defaultOrder = false) {
|
||||
const codeLangue = $("#codeLangue").val();
|
||||
|
||||
// Objet de traduction interne
|
||||
const langConfig = (codeLangue === "en_US") ? {
|
||||
search: "Search:",
|
||||
lengthMenu: "Show _MENU_ entries",
|
||||
info: "Showing _START_ to _END_ of _TOTAL_ entries",
|
||||
infoEmpty: "Showing 0 to 0 of 0 entries",
|
||||
infoFiltered: "(filtered from _MAX_ total entries)",
|
||||
zeroRecords: "No matching records found",
|
||||
paginate: { next: "Next", previous: "Previous" }
|
||||
} : {
|
||||
search: "Recherche :",
|
||||
lengthMenu: "Afficher _MENU_ lignes",
|
||||
info: "Affichage de _START_ à _END_ sur _TOTAL_ lignes",
|
||||
infoEmpty: "Affichage de 0 à 0 sur 0 ligne",
|
||||
infoFiltered: "(filtré de _MAX_ lignes au total)",
|
||||
zeroRecords: "Aucune donnée trouvée",
|
||||
paginate: { next: "Suivant", previous: "Précédent" }
|
||||
};
|
||||
|
||||
if ($.fn.DataTable.isDataTable(selector)) {
|
||||
$(selector).DataTable().destroy();
|
||||
}
|
||||
|
||||
// Gestion du tri par défaut (false = pas de tri forcé)
|
||||
const orderConfig = (defaultOrder === false) ? [] : defaultOrder;
|
||||
|
||||
const table = $(selector).DataTable({
|
||||
dom: 'frtip',
|
||||
responsive: true,
|
||||
pageLength: 10,
|
||||
order: orderConfig, // <-- Application de la configuration de tri
|
||||
language: langConfig,
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
text: '<i class="fas fa-file-excel me-1"></i> Excel',
|
||||
className: 'btn btn-sm btn-success-light border-success fw-bold text-success rounded-pill shadow-xs',
|
||||
title: exportTitle,
|
||||
exportOptions: { columns: ':not(:last-child)' }
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
text: '<i class="fas fa-file-pdf me-1"></i> PDF',
|
||||
className: 'btn btn-sm btn-danger-light border-danger fw-bold text-danger rounded-pill shadow-xs',
|
||||
title: exportTitle,
|
||||
exportOptions: { columns: ':not(:last-child)' },
|
||||
customize: function (doc) {
|
||||
doc.styles.tableHeader.fillColor = '#212e53';
|
||||
doc.styles.tableHeader.color = 'white';
|
||||
doc.content[1].table.widths = Array(doc.content[1].table.body[0].length + 1).join('*').split('');
|
||||
}
|
||||
}
|
||||
],
|
||||
drawCallback: function() {
|
||||
const info = this.api().page.info();
|
||||
const label = (codeLangue === "en_US") ? " Lines" : " Lignes";
|
||||
$("#badge-total").text(info.recordsTotal + label);
|
||||
}
|
||||
});
|
||||
|
||||
table.buttons().container().appendTo('#table-buttons');
|
||||
return table;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user