diff --git a/Js/fonctions.js b/Js/fonctions.js index a31d574..6449166 100755 --- a/Js/fonctions.js +++ b/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: ' 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: ' 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 diff --git a/Vue/Ajaxdetailretrait/index.php b/Vue/Ajaxdetailretrait/index.php index 6c401aa..fa3da5d 100644 --- a/Vue/Ajaxdetailretrait/index.php +++ b/Vue/Ajaxdetailretrait/index.php @@ -70,7 +70,7 @@
- +
diff --git a/Vue/Ajaxselectionretrait/index.php b/Vue/Ajaxselectionretrait/index.php index 201ed11..c643ff0 100644 --- a/Vue/Ajaxselectionretrait/index.php +++ b/Vue/Ajaxselectionretrait/index.php @@ -3,7 +3,7 @@ ?>
-
+
diff --git a/Vue/gabarit.php b/Vue/gabarit.php index 1659c0b..1f8db59 100755 --- a/Vue/gabarit.php +++ b/Vue/gabarit.php @@ -654,7 +654,7 @@ $photoAssureCrypte = $_SESSION['photoAssureCrypte']; - +