diff --git a/Js/fonctions.js b/Js/fonctions.js index 219e504b..a8005121 100755 --- a/Js/fonctions.js +++ b/Js/fonctions.js @@ -34647,25 +34647,25 @@ function requetes_synthese_consommation_police_export() }); } -function modifier_type_bon(idTypebon) -{ - donnees = 'idTypebon='+idTypebon; +function modifier_type_bon(idTypebon) { + let donnees = 'idTypebon=' + idTypebon; - $.ajax({ - url: $("#racineWeb").val()+"Ajaxparambons/", - type : 'post', - data: donnees, - error: function(errorData) { - }, - success: function(data) - { - donnees_retour = data; - }, - complete: function() - { - $('#div_maj_type_bon').html(donnees_retour); - } - }); + $.ajax({ + url: $("#racineWeb").val() + "Ajaxparambons/", + type: 'post', + data: donnees, + error: function(errorData) { + console.error("Erreur lors du chargement des paramètres du bon."); + }, + success: function(data) { + // 1. Injecter le contenu dans le conteneur de la modale + $('#div_maj_type_bon').html(data); + + // 2. Initialiser et afficher la modale Bootstrap + var myModal = new bootstrap.Modal(document.getElementById('div_maj_type_bon')); + myModal.show(); + } + }); } function enregistrer_modif_type_bon() @@ -92072,4 +92072,63 @@ function enregistrer_modif_parametres_med() } }); +} + +function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Données') { + if ($(selector).length === 0) return; + + // Détection automatique : la barre de recherche personnalisée existe-t-elle ? + var hasGlobalSearch = $('#globalSearch').length > 0; + + if ($.fn.DataTable.isDataTable(selector)) { + $(selector).DataTable().destroy(); + } + + // Configuration du DOM : + // Si hasGlobalSearch est vrai, on retire 'f' (recherche native) + var domStructure = hasGlobalSearch + ? '<"d-flex align-items-center justify-content-start p-3 border-bottom"B>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>' + : '<"d-flex align-items-center justify-content-between p-3 border-bottom"Bf>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>'; + + var table = $(selector).DataTable({ + "dom": domStructure, + "buttons": [ + { + extend: 'excelHtml5', + text: 'Excel', + className: 'btn btn-success btn-sm fw-bold border-0 shadow-sm px-3' + }, + { + extend: 'pdfHtml5', + text: 'PDF', + className: 'btn btn-danger btn-sm fw-bold border-0 shadow-sm px-3 ms-2', + title: pageTitle, + orientation: 'landscape', + pageSize: 'A4' + } + ], + "language": { + "url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json", + "search": "Rechercher : ", + "searchPlaceholder": "Filtrer..." + }, + "pageLength": 10, + "autoWidth": false, + "drawCallback": function() { + // Style uniquement si la recherche native est affichée + if (!hasGlobalSearch) { + $('.dataTables_filter input').addClass('form-control form-control-sm d-inline-block ms-2 rounded-pill border-2 shadow-none').css('width', '200px'); + } + $('.dataTables_paginate .paginate_button').addClass('btn btn-xs mx-1'); + } + }); + + // LIAISON AUTOMATIQUE : Si globalSearch existe, on branche l'événement tout de suite + if (hasGlobalSearch) { + $('#globalSearch').off('keyup').on('keyup', function() { + table.search(this.value).draw(); + }); + } + + return table; } \ No newline at end of file diff --git a/Vue/Ajaxparambons/index.php b/Vue/Ajaxparambons/index.php index c17f82e9..0e7ece6c 100755 --- a/Vue/Ajaxparambons/index.php +++ b/Vue/Ajaxparambons/index.php @@ -1,44 +1,67 @@ -