val
This commit is contained in:
parent
192ca971bc
commit
b4db6d23d2
534
Js/fonctions.js
534
Js/fonctions.js
|
|
@ -48407,462 +48407,88 @@ function supprimer_garant(){
|
|||
*/
|
||||
|
||||
// Applique la librairie DataBase sur les tableaux
|
||||
function appliquerDataTable(){
|
||||
// alert('applying datatable')
|
||||
|
||||
const oTable = $('.tabliste');
|
||||
|
||||
var codeLangue = $("#codeLangue").val();
|
||||
|
||||
|
||||
var nomForm = $('#nomForm').val();
|
||||
|
||||
var tab = $('#dataliste');
|
||||
|
||||
// Détruire l'instance existante si elle existe
|
||||
if ($.fn.DataTable.isDataTable(oTable)) {
|
||||
table.DataTable().destroy();
|
||||
table.empty(); // Optionnel : vider le contenu si nécessaire
|
||||
/**
|
||||
* Applique la configuration DataTable aux tableaux de la vue
|
||||
* Optimisée pour éviter les répétitions et corriger les erreurs d'instance
|
||||
*/
|
||||
function appliquerDataTable() {
|
||||
// Vérification de sécurité : DataTables est-il chargé ?
|
||||
if (typeof $.fn.DataTable === 'undefined') {
|
||||
console.error("DataTables n'est pas chargé. Vérifiez l'ordre des scripts.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Détruire l'instance existante si elle existe
|
||||
if ($.fn.DataTable.isDataTable(tab)) {
|
||||
table.DataTable().destroy();
|
||||
table.empty(); // Optionnel : vider le contenu si nécessaire
|
||||
|
||||
const oTable = $('.tabliste');
|
||||
const tab = $('#dataliste');
|
||||
const codeLangue = $("#codeLangue").val();
|
||||
const nomForm = $('#nomForm').val();
|
||||
|
||||
// --- 1. Gestion de la destruction des instances existantes ---
|
||||
[oTable, tab].forEach(t => {
|
||||
if ($.fn.DataTable.isDataTable(t)) {
|
||||
t.DataTable().destroy();
|
||||
// Ne pas faire .empty() ici sinon vous perdez l'entête <thead> du tableau
|
||||
}
|
||||
});
|
||||
|
||||
// --- 2. Définition des traductions (i18n) ---
|
||||
const langConfig = (codeLangue === "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: "►|" },
|
||||
infoFiltered: "(filtered from _MAX_ total records)"
|
||||
} : {
|
||||
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)"
|
||||
};
|
||||
|
||||
// --- 3. Configuration de base commune ---
|
||||
let baseOptions = {
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
lengthMenu: [50, 100, 150],
|
||||
scrollX: true,
|
||||
scrollY: "75vh",
|
||||
pagingType: "full_numbers",
|
||||
autoWidth: false,
|
||||
language: langConfig
|
||||
};
|
||||
|
||||
// --- 4. Personnalisation selon le formulaire ---
|
||||
try {
|
||||
if (oTable.length > 0) {
|
||||
let specificOptions = { ...baseOptions };
|
||||
|
||||
if (['listebareme', 'collegepolice', 'reseausoins', 'fichedevis'].includes(nomForm)) {
|
||||
specificOptions.order = [0, "desc"];
|
||||
}
|
||||
else if (['compositiontarifactes', 'sourceDonnees', 'requetepersonnalisee', 'Fichechangementcollege', 'frmficherenouvellement'].includes(nomForm)) {
|
||||
specificOptions.ordering = false;
|
||||
}
|
||||
else if (nomForm === 'frmtrancheaccessoire') {
|
||||
specificOptions.order = [[1, "desc"], [6, "asc"], [2, "asc"]];
|
||||
}
|
||||
|
||||
oTable.DataTable(specificOptions);
|
||||
}
|
||||
|
||||
// Cas spécifique pour le deuxième tableau
|
||||
if (nomForm === 'compositiontarifactes' && tab.length > 0) {
|
||||
tab.DataTable({ ...baseOptions, ordering: false });
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error("Erreur DataTable:", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(nomForm == 'listebareme' || nomForm == 'collegepolice' || nomForm == 'reseausoins'){
|
||||
try{
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"order": [0, "desc"],
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"order": [0, "desc"],
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
catch(err){
|
||||
return false;
|
||||
}
|
||||
}else if(nomForm == 'compositiontarifactes' || nomForm == 'sourceDonnees' || nomForm == 'requetepersonnalisee'){
|
||||
try{
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"ordering": false,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}else{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"ordering": false,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// oTable.columns.adjust().draw();
|
||||
}
|
||||
catch(err){
|
||||
return false;
|
||||
}
|
||||
}else if(nomForm == 'frmtrancheaccessoire'){
|
||||
try{
|
||||
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"order": [[ 1, "desc" ],[6, "asc"],[2, "asc"]],
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"order": [[ 1, "desc" ],[6, "asc"],[2, "asc"]],
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//"order": [[ 4, "asc" ],[0, "desc"]], oTable.columns.adjust().draw();
|
||||
}
|
||||
catch(err){
|
||||
return false;
|
||||
}
|
||||
}else if(nomForm == 'Fichechangementcollege' || nomForm == 'frmficherenouvellement'){
|
||||
try{
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"ordering": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}else{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"ordering": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//oTable.columns.adjust().draw();
|
||||
}
|
||||
catch(err){
|
||||
console.log('error: ',err)
|
||||
return false;
|
||||
|
||||
}
|
||||
}else if(nomForm == 'fichedevis'){
|
||||
try{
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"order": [1, "desc"],
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"order": [0, "desc"],
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch(err){
|
||||
return false;
|
||||
}
|
||||
|
||||
}else{
|
||||
try{
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
oTable.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//oTable.columns.adjust().draw();
|
||||
}
|
||||
catch(err){
|
||||
console.log('error: ',err)
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(nomForm == 'compositiontarifactes'){
|
||||
try{
|
||||
if(codeLangue=="en_US")
|
||||
{
|
||||
tab.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"ordering": false,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}else{
|
||||
tab.DataTable({
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
"ordering": false,
|
||||
"lengthMenu": [ 50, 100, 150],
|
||||
"scrollX": true,
|
||||
"scrollY": "75vh",
|
||||
"pagingType": "full_numbers",
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"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)"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//tab.columns.adjust().draw();
|
||||
}
|
||||
catch(err){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user