gdf
This commit is contained in:
parent
abffcf887d
commit
1f9045d152
297
Js/fonctions.js
297
Js/fonctions.js
|
|
@ -47466,142 +47466,105 @@ function medecinsprestataire()
|
||||||
* AUTRE TABLE DE REFERENCES
|
* AUTRE TABLE DE REFERENCES
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
// Récupère les fichiers contenu dans la table autrestablesreference
|
function chargerFichiersTable() {
|
||||||
function chargerFichiersTable(){
|
const idTable = $('#listetables').val();
|
||||||
|
const racineWeb = $("#racineWeb").val();
|
||||||
|
const codeLangue = $("#codeLangue").val();
|
||||||
var $id = $('#listetables').val();
|
|
||||||
|
|
||||||
if ($id !=''){
|
// 1. Si aucune table n'est sélectionnée, on nettoie tout
|
||||||
donnees = 'id='+$id;
|
if (!idTable || idTable === "") {
|
||||||
|
$('#div_fichiers_table, #div_entete_table, #div_lister_table, #div_maj_table').empty();
|
||||||
$.ajax({
|
return;
|
||||||
url: $("#racineWeb").val()+"Ajaxaccesfichiersautrestables/",
|
}
|
||||||
type : 'post',
|
|
||||||
data: donnees,
|
// 2. Feedback visuel global
|
||||||
error: function(errorData){
|
const loadingHtml = `
|
||||||
alert("Erreur : "+errorData);
|
<div class="text-center p-5">
|
||||||
},
|
<div class="spinner-border text-primary" role="status"></div>
|
||||||
success: function(data) {
|
<p class="mt-2 text-muted italic">${(codeLangue === "en_US") ? "Loading table data..." : "Chargement des données..."}</p>
|
||||||
//alert("Success : "+data);
|
</div>`;
|
||||||
fermeFormulaire();
|
|
||||||
$('#div_fichiers_table').html(data);
|
$('#div_lister_table').html(loadingHtml);
|
||||||
afficheDonneesTableChoisie($('#fichier_lister').val());
|
$('#div_maj_table').html(""); // On vide la zone de saisie pour le nouveau contexte
|
||||||
},
|
|
||||||
complete: function() {
|
// 3. Appel AJAX pour récupérer les fichiers/paramètres de la table
|
||||||
|
$.ajax({
|
||||||
}
|
url: racineWeb + "Ajaxaccesfichiersautrestables/",
|
||||||
});
|
type: 'post',
|
||||||
}else{
|
data: { id: idTable },
|
||||||
$('#div_fichiers_table').empty();
|
success: function(data) {
|
||||||
$('#div_entete_table').empty();
|
// Fermeture de tout formulaire d'édition ouvert
|
||||||
$('#div_lister_table').empty();
|
if (typeof fermeFormulaire === "function") fermeFormulaire();
|
||||||
|
|
||||||
}
|
// Injection des données cachées (nom du fichier lister, etc.)
|
||||||
|
$('#div_fichiers_table').html(data);
|
||||||
|
|
||||||
|
// 4. Lancement de l'affichage du formulaire et de la liste
|
||||||
|
// On récupère le nom du fichier depuis le champ caché injecté dans 'data'
|
||||||
|
const fichierLister = $('#fichier_lister').val();
|
||||||
|
|
||||||
|
// Affiche le formulaire de saisie (à gauche) et la liste (à droite)
|
||||||
|
afficheDonneesTableChoisie(fichierLister);
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
toastr.error((codeLangue === "en_US") ? "Error accessing table files" : "Erreur d'accès aux fichiers de la table");
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affiche les données de la table selectionnée dans un tableau
|
function afficheDonneesTableChoisie(fichier) {
|
||||||
function afficheDonneesTableChoisie(fichier){
|
if (!fichier || fichier === '') return;
|
||||||
|
|
||||||
var codeLangue = $("#codeLangue").val();
|
const racineWeb = $("#racineWeb").val();
|
||||||
|
const codeLangue = $("#codeLangue").val();
|
||||||
|
const $divLister = $('#div_lister_table');
|
||||||
if(fichier=="Ajaxtblisterjoursferiers"){
|
let donnees = {};
|
||||||
codePays = $('#codePays').val();
|
|
||||||
annee = $('#annee').val();
|
// 1. Gestion des cas particuliers (ex: Jours fériés)
|
||||||
|
if (fichier === "Ajaxtblisterjoursferiers") {
|
||||||
if(codePays==undefined){
|
const codePays = $('#codePays').val() || "CI";
|
||||||
codePays ="CI"
|
const annee = $('#annee').val() || new Date().getFullYear();
|
||||||
}
|
donnees = { codePays: codePays, annee: annee };
|
||||||
|
}
|
||||||
if(annee==undefined){
|
|
||||||
var ladate=new Date();
|
// 2. Affichage d'un loader pendant le chargement
|
||||||
annee =ladate.getFullYear();
|
$divLister.html(`
|
||||||
}
|
<div class="text-center p-5">
|
||||||
|
<div class="spinner-border text-primary" role="status"></div>
|
||||||
donnees = 'codePays='+codePays+'&annee='+annee;
|
<p class="mt-2 text-muted italic">${(codeLangue === "en_US") ? "Synchronizing..." : "Synchronisation..."}</p>
|
||||||
}else{
|
</div>
|
||||||
donnees = '';
|
`);
|
||||||
}
|
|
||||||
|
// 3. Appel AJAX
|
||||||
if(fichier !=''){
|
$.ajax({
|
||||||
$.ajax({
|
url: racineWeb + fichier + "/",
|
||||||
url: $("#racineWeb").val()+fichier+"/",
|
type: 'post',
|
||||||
type : 'post',
|
data: donnees,
|
||||||
data: donnees,
|
success: function(data) {
|
||||||
error: function(errorData){
|
$divLister.html(data);
|
||||||
alert("Erreur : "+errorData);
|
|
||||||
},
|
// 4. Post-traitement selon le fichier
|
||||||
success: function(data) {
|
if (fichier === "Ajaxtblisterjoursferiers") {
|
||||||
//alert("Success : "+data);
|
$('#codePays').val(donnees.codePays);
|
||||||
|
$('#annee').val(donnees.annee);
|
||||||
$('#div_lister_table').html(data);
|
}
|
||||||
//
|
|
||||||
|
// 5. Initialisation de la DataTable
|
||||||
|
if (fichier === "Ajaxtblistertableauajustementgarant") {
|
||||||
if(fichier=="Ajaxtblisterjoursferiers"){
|
// Appel de votre fonction spécifique si elle existe toujours
|
||||||
$('#codePays').val(codePays);
|
if (typeof appliquerDataTable === "function") appliquerDataTable();
|
||||||
$('#annee').val(annee);
|
} else {
|
||||||
}
|
// Utilisation de la fonction générique avec exports Excel/PDF
|
||||||
if(fichier=="Ajaxtblistertableauajustementgarant"){
|
const nomTable = $("#listetables option:selected").text();
|
||||||
appliquerDataTable();
|
initDataTableReference('#tableLister', 'Export_' + nomTable.replace(/\s+/g, '_'));
|
||||||
}else{
|
}
|
||||||
|
},
|
||||||
if(codeLangue=="en_US")
|
error: function(xhr) {
|
||||||
{
|
toastr.error((codeLangue === "en_US") ? "Data loading error" : "Erreur de chargement des données");
|
||||||
$('#tableLister').DataTable({
|
$divLister.html(`<div class="alert alert-danger m-3">${xhr.statusText}</div>`);
|
||||||
"lengthMenu": [ 20, 50, 100],
|
}
|
||||||
"language": {
|
});
|
||||||
"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": "►|"
|
|
||||||
},
|
|
||||||
"infoFiltered": "(filtered from _MAX_ total records)",
|
|
||||||
"aoColumnDefs": [
|
|
||||||
{ "bSearchable": false, "aTargets": [ 0 ] }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$('#tableLister').DataTable({
|
|
||||||
"lengthMenu": [ 20, 50, 100],
|
|
||||||
"language": {
|
|
||||||
"lengthMenu":"Affiche _MENU_ par page",
|
|
||||||
"zeroRecords": "Désolé - Aucune donnée trouvée",
|
|
||||||
"info": "_PAGE_ sur _PAGES_ pages",
|
|
||||||
"infoEmpty": "Pas d'enregistrement valable",
|
|
||||||
"search": "Recherche:",
|
|
||||||
"paginate": {
|
|
||||||
"next": "►",
|
|
||||||
"previous": "◄",
|
|
||||||
"first": "|◄",
|
|
||||||
"last": "►|"
|
|
||||||
},
|
|
||||||
"infoFiltered": "(filtré de _MAX_ total enregistrements)",
|
|
||||||
"aoColumnDefs": [
|
|
||||||
{ "bSearchable": false, "aTargets": [ 0 ] }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gère l'affichage des boutons en entête des formulaires
|
// Gère l'affichage des boutons en entête des formulaires
|
||||||
|
|
@ -91709,5 +91672,73 @@ function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Donn
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
function initDataTableReference(selector, exportTitle = 'Export_Donnees') {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
const table = $(selector).DataTable({
|
||||||
|
dom: 'frtip',
|
||||||
|
responsive: true,
|
||||||
|
pageLength: 10,
|
||||||
|
language: langConfig, // On utilise l'objet défini au-dessus
|
||||||
|
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;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,21 @@
|
||||||
<?php $superUser = $_SESSION['superUser'] ?? 0; ?>
|
<?php $superUser = $_SESSION['superUser'] ?? 0; ?>
|
||||||
|
|
||||||
<div class="card border-0 shadow-sm overflow-hidden" style="border-radius: var(--radius-md);">
|
<div class="card border-0 shadow-sm overflow-hidden" style="border-radius: var(--radius-md);">
|
||||||
<div class="card-header bg-white py-3 border-bottom-0 d-flex justify-content-between align-items-center">
|
<div class="card-header bg-white py-3 border-bottom d-flex justify-content-between align-items-center">
|
||||||
<h6 class="mb-0 fw-bold text-uppercase text-primary small">
|
<div class="d-flex align-items-center">
|
||||||
<i class="fas fa-globe-africa me-2"></i><?= _("Liste des Pays de référence") ?>
|
<h6 class="mb-0 fw-bold text-uppercase text-primary small">
|
||||||
</h6>
|
<i class="fas fa-table me-2"></i><?= _("Données de référence") ?>
|
||||||
<span class="badge bg-primary-ghost text-primary px-3 py-2 rounded-pill fw-bold" id="badge-total">
|
</h6>
|
||||||
0 <?= _("Lignes") ?>
|
<span class="badge bg-primary-ghost text-primary ms-3 px-3 py-2 rounded-pill fw-bold" id="badge-total">
|
||||||
</span>
|
0 <?= _("Lignes") ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div id="table-buttons" class="d-flex gap-2"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body p-0">
|
<div class="card-body p-0">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="tableLister" class="table table-hover align-middle mb-0 datatable-inter" style="width:100%">
|
<table id="tableLister" class="table table-hover align-middle mb-0" style="width:100%">
|
||||||
<thead class="bg-light text-muted small text-uppercase">
|
<thead class="bg-light text-muted small text-uppercase">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="ps-4 border-0"><?= _("Centre") ?></th>
|
<th class="ps-4 border-0"><?= _("Centre") ?></th>
|
||||||
|
|
@ -48,7 +51,13 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.bg-primary-ghost { background-color: rgba(33, 46, 83, 0.08) !important; }
|
.bg-primary-ghost { background-color: rgba(33, 46, 83, 0.08) !important; }
|
||||||
#tableLister thead th { padding-top: 15px; padding-bottom: 15px; }
|
#tableLister thead th { padding-top: 15px; padding-bottom: 15px; font-weight: 700; }
|
||||||
#tableLister tbody td { border-color: #f1f4f6; }
|
#tableLister tbody td { border-color: #f1f4f6; }
|
||||||
.shadow-xs { box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
|
.shadow-xs { box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
|
||||||
|
|
||||||
|
/* Style pour les boutons d'export injectés */
|
||||||
|
.dt-buttons .btn {
|
||||||
|
font-size: 0.75rem !important;
|
||||||
|
padding: 0.4rem 0.8rem !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user