frt
This commit is contained in:
parent
b22846229c
commit
4b1529360e
104
Js/fonctions.js
104
Js/fonctions.js
|
|
@ -41,6 +41,7 @@ function connexion_cookie()
|
|||
$(function() {
|
||||
// Initialisation des composants au chargement de la page
|
||||
appliquerDataTable('.tabliste');
|
||||
dataTableMini();
|
||||
|
||||
//const vueOuverte = $("#vue").val();
|
||||
let nomForm = $("#nomForm").val();
|
||||
|
|
@ -1448,53 +1449,69 @@ function enregistrer_avenant()
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise un DataTable de manière générique avec support Ajax et Bootstrap
|
||||
* @param {string} selector - L'ID ou la classe du tableau (ex: '#monTableau')
|
||||
* @param {Object} customOptions - Options spécifiques pour surcharger la config par défaut
|
||||
*/
|
||||
function genericInitDataTable(selector, customOptions = {}) {
|
||||
// 1. Sécurité : Vérifier si l'élément existe
|
||||
if ($(selector).length === 0) return;
|
||||
function dataTableMini() {
|
||||
const $table = $('.tabmini');
|
||||
const codeLangue = $("#codeLangue").val() || "fr_FR";
|
||||
|
||||
// 2. Si une instance existe déjà, on la détruit proprement
|
||||
if ($.fn.DataTable.isDataTable(selector)) {
|
||||
$(selector).DataTable().destroy();
|
||||
$(selector).empty(); // Optionnel : vide le DOM si nécessaire
|
||||
// Détruire l'instance existante si elle existe
|
||||
if ($.fn.DataTable.isDataTable($table)) {
|
||||
$table.DataTable().clear().destroy();
|
||||
}
|
||||
|
||||
// 3. Configuration par défaut (Standard pour votre portail RH)
|
||||
const defaultOptions = {
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json"
|
||||
},
|
||||
"pageLength": 10,
|
||||
"responsive": true,
|
||||
"dom": '<"d-flex justify-content-between align-items-center mb-3"fB>rt<"d-flex justify-content-between align-items-center mt-3"ip>',
|
||||
"buttons": [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
className: 'btn btn-sm btn-outline-success rounded-pill px-3',
|
||||
text: '<i class="far fa-file-excel me-1"></i> Excel'
|
||||
// Définition des traductions
|
||||
const langOptions = {
|
||||
en_US: {
|
||||
lengthMenu: "Display _MENU_ records per page",
|
||||
zeroRecords: "Nothing found - sorry",
|
||||
info: "Showing page _PAGE_ of _PAGES_",
|
||||
infoEmpty: "No records available",
|
||||
search: "Search:",
|
||||
paginate: {
|
||||
next: "►",
|
||||
previous: "◄",
|
||||
first: "|◄",
|
||||
last: "►|"
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
className: 'btn btn-sm btn-outline-danger rounded-pill px-3',
|
||||
text: '<i class="far fa-file-pdf me-1"></i> PDF'
|
||||
}
|
||||
],
|
||||
"drawCallback": function() {
|
||||
// Style Bootstrap pour le champ de recherche
|
||||
$('.dataTables_filter input').addClass('form-control form-control-sm shadow-none rounded-pill');
|
||||
$('.dataTables_paginate .paginate_button').addClass('btn btn-xs');
|
||||
infoFiltered: "(filtered from _MAX_ total records)"
|
||||
},
|
||||
fr_FR: {
|
||||
lengthMenu: "Affiche _MENU_ par page",
|
||||
zeroRecords: "Désolé - Aucune donnée trouvée",
|
||||
info: "_PAGE_ sur _PAGES_ pages",
|
||||
infoEmpty: "Pas d'enregistrement",
|
||||
search: "Recherche:",
|
||||
paginate: {
|
||||
next: "►",
|
||||
previous: "◄",
|
||||
first: "|◄",
|
||||
last: "►|"
|
||||
},
|
||||
infoFiltered: "(filtré de _MAX_ total enregistrements)"
|
||||
}
|
||||
};
|
||||
|
||||
// 4. Fusion des options par défaut avec les options personnalisées
|
||||
const finalOptions = $.extend(true, {}, defaultOptions, customOptions);
|
||||
try {
|
||||
$table.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
lengthMenu: [10], // tu peux mettre [10, 25, 50] pour plus de flexibilité
|
||||
scrollX: true,
|
||||
scrollY: "20vh",
|
||||
pagingType: "full_numbers",
|
||||
autoWidth: false,
|
||||
searching: false, // équivalent moderne de bFilter:false
|
||||
lengthChange: false, // équivalent moderne de bLengthChange:false
|
||||
orderMulti: true,
|
||||
language: langOptions[codeLangue] || langOptions.fr_FR
|
||||
});
|
||||
|
||||
// 5. Initialisation
|
||||
return $(selector).DataTable(finalOptions);
|
||||
// Ajuster les colonnes après init
|
||||
$table.DataTable().columns.adjust().draw();
|
||||
|
||||
} catch (err) {
|
||||
console.error("Erreur DataTable:", err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1529,14 +1546,7 @@ function pop_afficher_selection_retrait() {
|
|||
div_selection_assure.html(data);
|
||||
|
||||
// 3. INITIALISATION DU DATATABLE GÉNÉRIQUE
|
||||
// On cible l'ID du tableau qui est généré dans votre vue Ajax
|
||||
genericInitDataTable('#table_retrait_assures', {
|
||||
"order": [[1, "asc"]], // Trie par nom
|
||||
"pageLength": 10,
|
||||
"columnDefs": [
|
||||
{ "orderable": false, "targets": [-1] } // Désactive le tri sur la dernière colonne (Action)
|
||||
]
|
||||
});
|
||||
dataTableMini();
|
||||
},
|
||||
complete: function() {
|
||||
// 4. Gestion propre du Modal
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="table-responsive py-2">
|
||||
<table id="table_retrait_assures" class="table table-hover align-middle border shadow-sm" style="width:100%; font-size: 8.5pt;">
|
||||
<table class="table table-hover align-middle border shadow-sm tabmini compact" style="width:100%; font-size: 8.5pt;">
|
||||
<thead class="table-dark">
|
||||
<tr class="text-center text-nowrap">
|
||||
<th><?= _("Cat") ?></th>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="table_retrait_assures" class="table table-striped table-hover align-middle border" style="width:100%; font-size:8pt;">
|
||||
<table id="table_retrait_assures" class="table table-striped table-hover align-middle border tabmini compact" style="width:100%; font-size:8pt;">
|
||||
<thead class="table-dark text-nowrap">
|
||||
<tr>
|
||||
<th class="text-center small"><?= _("Cat") ?></th>
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ $photoAssureCrypte = $_SESSION['photoAssureCrypte'];
|
|||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<!-- Application Scripts -->
|
||||
<script src="/Js/fonctions.js?ver=2026.01.19.12"></script>
|
||||
<script src="/Js/fonctions.js?ver=2026.01.19.13"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
raffraichier_gabarit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user