diff --git a/Js/fonctions.js b/Js/fonctions.js index edd6a546..38b188a6 100755 --- a/Js/fonctions.js +++ b/Js/fonctions.js @@ -47482,443 +47482,341 @@ function medecinsprestataire() * AUTRE TABLE DE REFERENCES *******************************************************************/ -// Récupère les fichiers contenu dans la table autrestablesreference -function chargerFichiersTable(){ - - - var $id = $('#listetables').val(); +/****************************************************************** + * AUTRE TABLE DE REFERENCES +*******************************************************************/ +function chargerFichiersTable() { + const $select = $('#listetables'); + const idTable = $select.val(); + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); - if ($id !=''){ - donnees = 'id='+$id; - - $.ajax({ - url: $("#racineWeb").val()+"Ajaxaccesfichiersautrestables/", - type : 'post', - data: donnees, - error: function(errorData){ - alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - fermeFormulaire(); - $('#div_fichiers_table').html(data); - afficheDonneesTableChoisie($('#fichier_lister').val()); - }, - complete: function() { - - } - }); - }else{ - $('#div_fichiers_table').empty(); - $('#div_entete_table').empty(); - $('#div_lister_table').empty(); - - } + if (!idTable || idTable === "") { + $('#div_fichiers_table, #div_entete_table, #div_lister_table, #div_maj_table').empty(); + return; + } + + // --- FIX ANTI-ACCUMULATION --- + // On récupère le texte propre AVANT l'AJAX + const selectedText = $select.find('option:selected').text().trim(); + + const loadingHtml = `
`; + $('#div_lister_table').html(loadingHtml); + $('#div_maj_table').html(""); + + $.ajax({ + url: racineWeb + "Ajaxaccesfichiersautrestables/", + type: 'post', + data: { id: idTable }, + success: function(data) { + fermeFormulaire(); + $('#div_fichiers_table').html(data); + afficheDonneesTableChoisie($('#fichier_lister').val()); + + // --- CORRECTION NEUTRAL PRO --- + // 1. On rafraîchit le picker pour l'état interne + $select.selectpicker('refresh'); + + // 2. On FORCE le texte du bouton à redevenir unique + // On cible précisément la div interne de rendu de Bootstrap-Select + $('.bootstrap-select .filter-option-inner-inner').each(function() { + $(this).text(selectedText); + }); + }, + error: function(xhr) { + toastr.error((codeLangue === "en_US") ? "Error..." : "Erreur..."); + } + }); } // Affiche les données de la table selectionnée dans un tableau -function afficheDonneesTableChoisie(fichier){ - - var codeLangue = $("#codeLangue").val(); - - +function afficheDonneesTableChoisie(fichier) { + if (!fichier || fichier === '') return; + + const racineWeb = $("#racineWeb").val(); + const $divLister = $('#div_lister_table'); + + // 1. On mémorise les valeurs actuelles avant le refresh if(fichier=="Ajaxtblisterjoursferiers"){ - codePays = $('#codePays').val(); annee = $('#annee').val(); - if(codePays==undefined){ - codePays ="CI" - } - if(annee==undefined){ var ladate=new Date(); annee =ladate.getFullYear(); } - donnees = 'codePays='+codePays+'&annee='+annee; + donnees = 'annee='+annee; }else{ donnees = ''; } - - if(fichier !=''){ - $.ajax({ - url: $("#racineWeb").val()+fichier+"/", - type : 'post', - data: donnees, - error: function(errorData){ - alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - - $('#div_lister_table').html(data); - // - - - if(fichier=="Ajaxtblisterjoursferiers"){ - $('#codePays').val(codePays); - $('#annee').val(annee); - } - if(fichier=="Ajaxtblistertableauajustementgarant"){ - appliquerDataTable(); - }else{ - - if(codeLangue=="en_US") - { - $('#tableLister').DataTable({ - "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() { - - } - }); - } + + // 2. Appel AJAX + $.ajax({ + url: racineWeb + fichier + "/", + type: 'post', + data: donnees, + success: function(data) { + // 3. On remplace tout le bloc + $divLister.html(data); + + // 4. INITIALISATION DATATABLE + // On s'assure que l'ancien ID n'existe plus en mémoire + if ($.fn.DataTable.isDataTable('#tableLister')) { + $('#tableLister').DataTable().destroy(); + } + + initDataTableReference('#tableLister', 'Referentiel_Jours_Feriers',false); + } + }); } // Gère l'affichage des boutons en entête des formulaires -function afficheBoutons($idData){ - - - var div = $('#div_maj_table').children().length; - var codeLangue = $("#codeLangue").val(); - - - if($idData == 0){ - donnees = ''; - }else{ - donnees = 'id='+$idData; - - - if(codeLangue=="en_US") - { - $('#btn-action').text('Save'); - } - else - { - $('#btn-action').text('Enregistrer'); - } - } +// Fonction pour initialiser les boutons d'entête +function afficheBoutons($idData) { + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + const donnees = ($idData == 0) ? '' : { id: $idData }; - $.ajax({ - url: $("#racineWeb").val()+"Ajaxentete/", - type : 'post', - data: donnees, - error: function(errorData){ - alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - - - $('#div_entete_table').html(data); - - if(($('#btn-action').text() == 'Ajouter' || $('#btn-action').text() == 'Add') && div == 0){ - $('#btn-fermer').hide(); - }else{ - $('#btn-fermer').show(); - if(codeLangue=="en_US") - { - $('#btn-action').text('Save'); - } - else - { - $('#btn-action').text('Enregistrer'); - } - } - }, - complete: function(){ - - } - }); - + $.ajax({ + url: racineWeb + "Ajaxentete/", + type: 'post', + data: donnees, + success: function(data) { + // 1. Injection du HTML dans la zone dédiée + $('#div_entete_table').html(data); + + const $btnAction = $('#btn-action'); + const $btnFermer = $('#btn-fermer'); + + // 2. Application des styles de base Neutral Pro + $('#div_entete_table button').addClass('btn btn-sm fw-bold shadow-xs px-3'); + $btnFermer.addClass('btn-light border'); + + // 3. Logique du Switch (Couleur, Texte et Action) + if($idData == 0) { + // --- MODE AJOUT --- + $btnFermer.hide(); + + // Switch vers VERT + $btnAction.removeClass('btn-primary').addClass('btn-success'); + + // Texte dynamique + $btnAction.html(' ' + (codeLangue == "en_US" ? "Add" : "Ajouter")); + + // Action au clic : Charger le formulaire vide + $btnAction.attr('onclick', 'formAjoutTableRef()'); + } else { + // --- MODE MODIFICATION --- + $btnFermer.show(); + + // Switch vers BLEU + $btnAction.removeClass('btn-success').addClass('btn-primary'); + + // Texte dynamique + $btnAction.html(' ' + (codeLangue == "en_US" ? "Update" : "Enregistrer")); + + // Action au clic : Lancer la sauvegarde des données + $btnAction.attr('onclick', 'update_table()'); + } + } + }); } // Ferme le formulaire affiché -function fermeFormulaire(){ - $('#div_maj_table').empty(); - - afficheBoutons(0); - +function fermeFormulaire() { + $('#div_maj_table').empty(); + // On repasse l'ID à 0 pour réafficher le bouton "Ajouter" + afficheBoutons(0); + + // Nettoie les menus orphelins du body + $('.selectpicker').selectpicker('destroy'); } // Affiche le formulaire d'ajout de données -function formAjoutTableRef(){ - - var codeLangue = $("#codeLangue").val(); - var fichier_ajouter = $('#fichier_ajouter').val(), - btn = $('#btn-action').text(); - - //alert(fichier_ajouter); - //return; - if(fichier_ajouter != '' && fichier_ajouter != undefined){ - if(btn == 'Ajouter' || btn == 'Add'){ - donnees = ''; - $('#btn-fermer').show(); - - if(codeLangue=="en_US") - { - $('#btn-action').text('Save'); - } - else - { - $('#btn-action').text('Enregistrer'); - } +function formAjoutTableRef() { + const codeLangue = $("#codeLangue").val(); + const $btn = $('#btn-action'); + const libelleBtn = $btn.text().trim().toLowerCase(); + + // Si le bouton est déjà en mode "Enregistrer/Save", on lance la mise à jour + if (libelleBtn === 'enregistrer' || libelleBtn === 'save') { + update_table(); + return; + } - $.ajax({ - url: fichier_ajouter+"/", - type: 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - - $('#div_maj_table').html(data); - stylechampsRequis(); - $(".datepicker").datepicker(); - $('.selectpicker').selectpicker(); - if(typeof $('#div_maj_table input:first').attr('type') == 'string'){ - $('#div_maj_table input:first').focus(); - }else{ - $('#div_maj_table select:first').focus(); - } - }, - complete: function(){ - } - }); - }else{ - update_table(); - } - }else{ - var nomForm = $('#nomForm').val(); - - if(nomForm == 'frmbaremegarant'){ - fichier_ajouter = 'Ajaxajouterbaremeaccessoiregarant'; - }else if(nomForm == 'frmtrancheaccessoire'){ - fichier_ajouter = 'Ajaxtbajouterbaremeaccessoireavenant'; - }else if(nomForm == 'frmtauxAjustement'){ - fichier_ajouter = 'Ajaxtbajoutertableauajustement'; - }else if(nomForm == 'frmtauxAjustementgarant'){ - fichier_ajouter = 'Ajaxtbajoutertableauajustementgarant'; - }else if(nomForm == 'frmacteconsultation'){ - fichier_ajouter = 'Ajaxtbajouteracteconsultation'; - } - - - if(btn == 'Ajouter' || btn == 'Add'){ - donnees = ''; - if(nomForm == 'frmtauxAjustementgarant'){ - donnees = 'codeGcAssureur='+$("#codeGcAssureur").val(); - } - - $('#btn-fermer').show(); - - if(codeLangue=="en_US") - { - $('#btn-action').text('Save'); - } - else - { - $('#btn-action').text('Enregistrer'); - } - - $.ajax({ - url: fichier_ajouter+"/", - type: 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - $('#div_maj_table').html(data); - $(".datepicker").datepicker(); - $(".selectpicker").selectpicker(); - stylechampsRequis(); - if(typeof $('#div_maj_table input:first').attr('type') == 'string'){ - $('#div_maj_table input:first').focus(); - }else{ - $('#div_maj_table select:first').focus(); - } - - }, - complete: function(){ - } - }); - }else{ - update_table(); - } - - } + // Détermination du fichier + let fichier_ajouter = $('#fichier_ajouter').val(); + if (!fichier_ajouter) { + const mapping = { + 'frmbaremegarant': 'Ajaxajouterbaremeaccessoiregarant', + 'frmtrancheaccessoire': 'Ajaxtbajouterbaremeaccessoireavenant', + 'frmtauxAjustement': 'Ajaxtbajoutertableauajustement', + 'frmtauxAjustementgarant': 'Ajaxtbajoutertableauajustementgarant', + 'frmacteconsultation': 'Ajaxtbajouteracteconsultation' + }; + fichier_ajouter = mapping[$('#nomForm').val()]; + } + if (!fichier_ajouter) { + toastr.warning("Action non configurée pour cette table."); + return; + } + + // Préparation des données spécifiques + let donnees = {}; + if ($('#nomForm').val() == 'frmtauxAjustementgarant') { + donnees.codeGcAssureur = $("#codeGcAssureur").val(); + } + + // UI : Passage en mode enregistrement + $('#btn-fermer').show(); + $btn.html(' ' + (codeLangue == "en_US" ? "Save" : "Enregistrer")); + + $.ajax({ + url: $("#racineWeb").val() + fichier_ajouter + "/", + type: 'post', + data: donnees, + success: function(data) { + $('#div_maj_table').html(data); + + // 1. On initialise tous les selects du nouveau formulaire + // On ne demande PAS le focus ici (paramètre false) pour ne pas forcer l'ouverture du premier select + actualiserSelectPicker('#div_maj_table .selectpicker', false); + + // 2. Initialisation des autres composants + const formatD = (codeLangue === "en_US") ? 'mm/dd/yyyy' : 'dd/mm/yyyy'; + $(".datepicker").datepicker({ + autoclose: true, + format: formatD + }); + + // 3. Focus intelligent sur le PREMIER champ du formulaire + setTimeout(function() { + var $firstField = $('#div_maj_table').find('input:not([type="hidden"]), select').first(); + + // Si le premier champ est un selectpicker, on utilise sa méthode focus dédiée + if ($firstField.hasClass('selectpicker')) { + $firstField.selectpicker('focus'); + } else { + $firstField.focus(); + } + }, 200); + } + }); } // Filtrer la liste des villes par pays -function filtreVilleParPays(){ - var codePays = $('#codePays').val(); +function filtreVilleParPays() { + const $selectVille = $('#codeVille'); + const racineWeb = $("#racineWeb").val(); - donnees ='codePays='+codePays; - $.ajax({ - url: "Ajaxfiltrevilleparpays/", - type: 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - - }, - success: function(data) { - //alert("Success : "+data); - $('#div_ville').empty(); - $('#div_ville').html(data); - //filtreLocaliteParVille(); - }, - complete: function(){ - } - }); - + $.ajax({ + url: racineWeb + "Ajaxfiltrevilleparpays/", + type: 'post', + data: { codePays: $('#codePays').val() }, + success: function(htmlOptions) { + // Injection des options (venant du PHP liste_options modifiée) + $selectVille.html(htmlOptions); + $selectVille.val(''); + + // Initialise, donne le focus et ouvre le menu des villes + actualiserSelectPicker('#codeVille', true); + } + }); } // Filtrer la liste des localités par pays et par ville -function filtreLocaliteParVille(){ - var codePays = $('#codePays').val(), - codeVille = $('#codeVille').val(); +// Filtrer la liste des localités par pays et par ville +function filtreLocaliteParVille() { + var codePays = $('#codePays').val(), + codeVille = $('#codeVille').val(); - if(codePays == ''){ - return; - }else{ - donnees ='codePays='+codePays+'&codeVille='+codeVille; - } + if (codePays == '') { + return; + } else { + var donnees = 'codePays=' + codePays + '&codeVille=' + codeVille; + } - $.ajax({ - url: "Ajaxfiltrelocaliteparville/", - type: 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - - }, - success: function(data) { - //alert("Success : "+data); - $('#div_localite').empty(); + $.ajax({ + url: "Ajaxfiltrelocaliteparville/", + type: 'post', + data: donnees, + success: function(data) { + // 1. Injection du HTML brut envoyé par le PHP $('#div_localite').html(data); - }, - complete: function(){ - } - }); - + + // 2. Appel de VOTRE fonction sur le nouveau SELECT injecté + // On passe 'true' si on veut que le menu s'ouvre tout seul après le filtrage + actualiserSelectPicker('#codeLocalite', true); + } + }); } // Affiche le formulaire de modification de données -function formModifTableRef($idData){ - - var codeLangue = $("#codeLangue").val(); - var fichier_modifier = $('#fichier_modifier').val(), - btn = $('#btn-action').text(); +function formModifTableRef($idData) { + var codeLangue = $("#codeLangue").val(); + var racineWeb = $("#racineWeb").val(); + + // 1. Mise à jour de l'entête (Boutons) + // On appelle afficheBoutons avec l'ID pour passer en mode "Enregistrer" + afficheBoutons($idData); - if(fichier_modifier==undefined){ - var nomForm = $('#nomForm').val(); - - if(nomForm == 'frmbaremegarant'){ - - fichier_modifier = 'Ajaxmodifierbaremeaccessoiregarant'; - }else if(nomForm == 'frmtrancheaccessoire'){ - fichier_modifier = 'Ajaxtbmodifierbaremeaccessoireavenant'; - }else if(nomForm == 'frmtauxAjustement'){ - fichier_modifier = 'Ajaxtbmodifiertableauajustement'; - }else if(nomForm == 'frmtauxAjustementgarant'){ - fichier_modifier = 'Ajaxtbmodifiertableauajustementgarant'; - }else if(nomForm == 'frmacteconsultation'){ - fichier_modifier = 'Ajaxtbmodifieracteconsultation'; - } - } + // 2. Détermination du fichier de modification + var fichier_modifier = $('#fichier_modifier').val(); + if (fichier_modifier == undefined) { + var nomForm = $('#nomForm').val(); + var mapping = { + 'frmbaremegarant': 'Ajaxmodifierbaremeaccessoiregarant', + 'frmtrancheaccessoire': 'Ajaxtbmodifierbaremeaccessoireavenant', + 'frmtauxAjustement': 'Ajaxtbmodifiertableauajustement', + 'frmtauxAjustementgarant': 'Ajaxtbmodifiertableauajustementgarant', + 'frmacteconsultation': 'Ajaxtbmodifieracteconsultation' + }; + fichier_modifier = mapping[nomForm] || ''; + } - if(btn == 'Ajouter' || btn == 'Add'){ - donnees = ''; - $('#btn-fermer').show(); - - if(codeLangue=="en_US") - { - $('#btn-action').text('Save'); - } - else - { - $('#btn-action').text('Enregistrer'); - } - - } + if (fichier_modifier == '') return; - donnees = 'id='+$idData; - - $.ajax({ - url: fichier_modifier+"/", - type : 'post', - data: donnees, - error: function(errorData){ - alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - $('#div_maj_table').html(data); - $(".datepicker").datepicker(); - $(".selectpicker").selectpicker(); - stylechampsRequis(); - if(typeof $('#div_maj_table input:first').attr('type') == 'string'){ - $('#div_maj_table input').eq(1).focus(); - }else{ - $('#div_maj_table select:first').focus(); - } - - }, - complete: function() { - - } - }); + // 3. Chargement du formulaire + $.ajax({ + url: racineWeb + fichier_modifier + "/", + type: 'post', + data: { id: $idData }, + beforeSend: function() { + $('#div_maj_table').html('
'); + }, + success: function(data) { + $('#div_maj_table').html(data); + + // 1. On initialise tous les selects du nouveau formulaire + // On ne demande PAS le focus ici (paramètre false) pour ne pas forcer l'ouverture du premier select + actualiserSelectPicker('#div_maj_table .selectpicker', false); + + // 2. Initialisation des autres composants + const formatD = (codeLangue === "en_US") ? 'mm/dd/yyyy' : 'dd/mm/yyyy'; + $(".datepicker").datepicker({ + autoclose: true, + format: formatD + }); + + if (typeof stylechampsRequis === "function") stylechampsRequis(); + + // 3. Focus intelligent sur le PREMIER champ du formulaire + setTimeout(function() { + var $firstField = $('#div_maj_table').find('input:not([type="hidden"]), select').first(); + + // Si le premier champ est un selectpicker, on utilise sa méthode focus dédiée + if ($firstField.hasClass('selectpicker')) { + $firstField.selectpicker('focus'); + } else { + $firstField.focus(); + } + }, 200); + }, + error: function(xhr) { + toastr.error("Erreur de chargement du formulaire"); + } + }); } // Supprime une ligne du tableau @@ -48049,129 +47947,109 @@ function supprimerprestataireenmoins($idData){ // Enregistrement des données dans les différentes tables (Ajout ou modification) -function update_table(){ - - var fichier_ajouter = $('#fichier_ajouter').val(), - fichier_lister = $('#fichier_lister').val(), - fichier_modifier= $('#fichier_modifier').val(), - id = $('#formData .sr-only').val(), - visible = false, - valide = true; - requis = $('input,select,textarea').filter('[required]:visible'); +function update_table() { + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + const nomForm = $('#nomForm').val(); + + // 1. Récupération dynamique des fichiers (priorité aux champs hidden) + let f_ajouter = $('#fichier_ajouter').val(); + let f_modifier = $('#fichier_modifier').val(); + let f_lister = $('#fichier_lister').val(); - if(fichier_ajouter == undefined && fichier_modifier==undefined && fichier_lister==undefined){ - var nomForm = $('#nomForm').val(); - - if(nomForm == 'frmbaremegarant'){ - fichier_ajouter = 'Ajaxajouterbaremeaccessoiregarant'; - fichier_modifier = 'Ajaxmodifierbaremeaccessoiregarant'; - }else if(nomForm == 'frmtrancheaccessoire'){ - fichier_ajouter = 'Ajaxtbajouterbaremeaccessoireavenant'; - fichier_modifier = 'Ajaxtbmodifierbaremeaccessoireavenant'; - fichier_lister = 'Ajaxtblisterbaremeaccessoireavenant'; - }else if(nomForm == 'frmtauxAjustement'){ - fichier_ajouter = 'Ajaxtbajoutertableauajustement'; - fichier_modifier = 'Ajaxtbmodifiertableauajustement'; - fichier_lister = 'Ajaxtblistertableauajustement'; - }else if(nomForm == 'frmtauxAjustementgarant'){ - fichier_ajouter = 'Ajaxtbajoutertableauajustementgarant'; - fichier_modifier = 'Ajaxtbmodifiertableauajustementgarant'; - fichier_lister = 'Ajaxtblistertableauajustementgarant'; - }else if(nomForm == 'frmacteconsultation'){ - fichier_ajouter = 'Ajaxtbajouteracteconsultation'; - fichier_modifier = 'Ajaxtbmodifieracteconsultation'; - } - } - - if(id == undefined){ - link = $("#racineWeb").val()+fichier_ajouter+"/ajouter/" - }else{ - link = $("#racineWeb").val()+fichier_modifier+"/modifier/" - } - - requis.each(function(){ - if($(this).val() == ''){ - v_msg="Veuillez saisir les champs en rouge !"; - v_msgEng="Please enter the fields in red !"; - alert_ebene(v_msg,v_msgEng); - $(this).css('borderColor','red'); - valide = false; - return false; - }else{ - valide = true; - } - }); + // Mapping de secours si les champs hidden sont absents + if (!f_ajouter && !f_modifier) { + const mapping = { + 'frmbaremegarant': ['Ajaxajouterbaremeaccessoiregarant', 'Ajaxmodifierbaremeaccessoiregarant', ''], + 'frmtrancheaccessoire': ['Ajaxtbajouterbaremeaccessoireavenant', 'Ajaxtbmodifierbaremeaccessoireavenant', 'Ajaxtblisterbaremeaccessoireavenant'], + 'frmtauxAjustement': ['Ajaxtbajoutertableauajustement', 'Ajaxtbmodifiertableauajustement', 'Ajaxtblistertableauajustement'], + 'frmtauxAjustementgarant': ['Ajaxtbajoutertableauajustementgarant', 'Ajaxtbmodifiertableauajustementgarant', 'Ajaxtblistertableauajustementgarant'], + 'frmacteconsultation': ['Ajaxtbajouteracteconsultation', 'Ajaxtbmodifieracteconsultation', ''] + }; + if (mapping[nomForm]) { + [f_ajouter, f_modifier, f_lister] = mapping[nomForm]; + } + } - if(valide){ - donnees = $('#formData').serialize(); - - if(nomForm == 'assures'){ - var dateNaissance = $("#dateNaissance").val(); - var dateEntree = $("#dateEntree").val(); - var dateAdhesion = $("#dateAdhesion").val(); - var dateRetrait = $("#dateRetrait").val(); - - donnees+="&dateNaissance="+dateNaissance+"&dateEntree="+dateEntree; - donnees+="&dateAdhesion="+dateAdhesion+"&dateRetrait="+dateRetrait; - }else if(nomForm == 'ayantdroits'){ - var adDateNaissance = $("#adDateNaissance").val(); - donnees+="&adDateNaissance="+adDateNaissance; - }else if(nomForm == 'frmbaremegarant'){ - var codeGcAssureur = $("#codeGcAssureur").val(); - donnees+="&codeGcAssureur="+codeGcAssureur; - }else if(nomForm == 'frmtauxAjustementgarant'){ - var codeGcAssureur = $("#codeGcAssureur").val(); - donnees+="&codeGcAssureur="+codeGcAssureur; - } - - //alert(donnees); - - //return; - - $.ajax({ - url: link, - type : 'post', - data: donnees, - error: function(errorData) { - - }, - success: function(data) { - // alert(data); - - if(data.length > 5){ - var str = data.split('/'); - alert_ebene(str[0],str[1]); - visible = true; - } - if(nomForm == 'frmbaremegarant'){ - afficher_bareme_accessoire_garant(); - fermeFormulaire(); - return; - }else if(nomForm == "frmtrancheaccessoire"){ - window.location.assign($("#racineWeb" ).val()+"Tranchesaccessoires/"); - }else if(nomForm == "frmtauxAjustement"){ - window.location.assign($("#racineWeb" ).val()+"Tableauajustementprimes/"); - }else if(nomForm == 'frmtauxAjustementgarant'){ - afficher_tauxajustement_garant(); - fermeFormulaire(); - return; - }else if(nomForm == "frmacteconsultation"){ - window.location.assign($("#racineWeb" ).val()+"Actesconsultations/"); - } - - afficheDonneesTableChoisie(fichier_lister); - if(!visible){ - fermeFormulaire(); - }else{ - $('#div_maj_table input:first').css('borderColor','red'); - } - }, - complete: function() { - - } - }); + // 2. Détermination de l'ID et de l'URL (Ajout vs Modif) + const idValue = $('#id').val() || $('#formData .sr-only').val(); + const isEdit = (idValue && idValue != '0' && idValue != ''); + const finalLink = racineWeb + (isEdit ? f_modifier + "/modifier/" : f_ajouter + "/ajouter/"); - } + // 3. Validation des champs requis + let valide = true; + const requis = $('#formData').find('[required]:visible'); + + requis.each(function() { + if ($(this).val().trim() === '') { + const msg = (codeLangue === "en_US") ? "Please fill in the required fields!" : "Veuillez remplir les champs obligatoires !"; + alert_ebene(msg, msg); + $(this).addClass('is-invalid').css('borderColor', '#dc3545').focus(); + valide = false; + return false; // Break loop + } else { + $(this).removeClass('is-invalid').css('borderColor', ''); + } + }); + + if (!valide) return; + + // 4. Collecte et enrichissement des données + let donnees = $('#formData').serialize(); + + // Ajout de l'ID si manquant dans le serialize + if (isEdit && !donnees.includes('id=')) donnees += "&id=" + idValue; + + // Cas spécifiques (Dates et codes parents) + const addParam = (id) => $(id).length ? "&" + $(id).attr('id') + "=" + $(id).val() : ""; + + if (nomForm === 'assures') { + donnees += addParam("#dateNaissance") + addParam("#dateEntree") + addParam("#dateAdhesion") + addParam("#dateRetrait"); + } else if (nomForm === 'ayantdroits') { + donnees += addParam("#adDateNaissance"); + } else if (['frmbaremegarant', 'frmtauxAjustementgarant'].includes(nomForm)) { + donnees += addParam("#codeGcAssureur"); + } + + // 5. Exécution AJAX + $.ajax({ + url: finalLink, + type: 'post', + data: donnees, + beforeSend: function() { + $('#btn-action').prop('disabled', true).html(''); + }, + success: function(data) { + // Gestion de la réponse serveur (Message Succès/Erreur) + if (data && data.length > 5) { + const parts = data.split('/'); + alert_ebene(parts[0], parts[1] || parts[0]); + } + + // Routage après succès + const routes = { + 'frmbaremegarant': () => { if(window.afficher_bareme_accessoire_garant) afficher_bareme_accessoire_garant(); fermeFormulaire(); }, + 'frmtrancheaccessoire': () => window.location.assign(racineWeb + "Tranchesaccessoires/"), + 'frmtauxAjustement': () => window.location.assign(racineWeb + "Tableauajustementprimes/"), + 'frmtauxAjustementgarant': () => { if(window.afficher_tauxajustement_garant) afficher_tauxajustement_garant(); fermeFormulaire(); }, + 'frmacteconsultation': () => window.location.assign(racineWeb + "Actesconsultations/") + }; + + if (routes[nomForm]) { + routes[nomForm](); + } else { + // Comportement par défaut : rafraîchir la liste et fermer + if (f_lister) afficheDonneesTableChoisie(f_lister); + fermeFormulaire(); + } + }, + error: function(xhr) { + toastr.error("Erreur serveur : " + xhr.status); + }, + complete: function() { + $('#btn-action').prop('disabled', false); + } + }); } function cocherDecocherTout(fichier_lister){ @@ -48279,8 +48157,6 @@ function filtreTableReference(numeroTable){ $('#div_fichiers_table').html(""); $('#div_entete_table').html(""); - //alert(donnees); - //return; $.ajax({ url: $("#racineWeb").val()+"Ajaxfiltretablesreference/", type : 'post', @@ -48303,31 +48179,42 @@ function filtreTableReference(numeroTable){ */ function filtreTableReference(numeroTable) { - debugger; const racineWeb = $("#racineWeb").val(); const $divListe = $("#div_listetables"); - const $select = $("#listetables"); - /* // 1. On tue l'existant et on vide le BODY des menus flottants if ($("#listetables").length) { $("#listetables").selectpicker('destroy'); } $('.bootstrap-select.bs-container').remove(); $divListe.empty(); - */ $.ajax({ url: racineWeb + "Ajaxfiltretablesreference/", type : 'post', data: { numeroTable: numeroTable }, success: function(data) { - debugger; // 2. On injecte le HTML $divListe.html(data); - - $select.selectpicker(); - $divListe.find('.dropdown-toggle').focus(); + const $select = $("#listetables"); + + // 3. Initialisation forcée + setTimeout(function() { + $select.selectpicker({ + liveSearch: true, + container: 'body', + width: '100%', + style: 'btn-form-select', + noneSelectedText: '-- Sélectionner --' + }); + + // --- LE FIX RADICAL --- + // On force le nettoyage du texte du bouton pour supprimer les accumulations + const initialText = $select.find('option:selected').text() || '-- Sélectionner --'; + $divListe.find('.filter-option-inner-inner').text(initialText); + + $divListe.find('.dropdown-toggle').focus(); + }, 150); } }); } @@ -89138,4 +89025,3245 @@ function maj_authentification_otp() } }); +} + +// FONCTION OTP +function maj_authentification_otp() { + const activerOtp = $("#activerOtp").val(); + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + + if(activerOtp == "1"){ + v_msg="Etes-vous sur de vouloir activer la double authentification?"; + v_msgEng="Are you sure you want to enable two-factor authentication?"; + }else{ + v_msg="Etes-vous sur de vouloir désactiver la double authentification?"; + v_msgEng="Are you sure you want to disable two-factor authentication?"; + } + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + $.ajax({ + url: racineWeb + "Ajaxparametresgeneraux/majauthentification/", + type: 'POST', + data: { activerOtp: activerOtp }, + success: function() { + let msg = (codeLangue === "en_US") ? "OTP Security updated" : "Sécurité OTP mise à jour"; + toastr.success(msg); + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Paramreinitmotpass/"); + } + }); + } + }); +} + + + +function modifier_param_filtrage_ip() +{ + + window.location.assign($("#racineWeb" ).val()+"Filtreadresseip/"); +} + +function consulter_param_filtrage_ip() +{ + window.location.assign($("#racineWeb" ).val()+"Filtreadresseipcons/"); +} + + +function retour_param_habilitation() +{ + window.location.assign($("#racineWeb" ).val()+"Paramhabilitation/"); +} + +function enregistrer_modif_param_filtreip() +{ + idSocieteuser = $("#idSocieteuser").val(); + donnees = 'idSocieteuser='+idSocieteuser; + + + + filtrerIp = $("#filtrerIp").val(); + filtrerIpPrestataire= $("#filtrerIpPrestataire").val(); + + donnees += '&filtrerIp='+filtrerIp; + donnees += '&filtrerIpPrestataire='+filtrerIpPrestataire; + + v_msg="Confirmez-vous ces modifications?"; + v_msgEng="Do you confirm these modifications?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametresgeneraux/majfiltreip/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + }, + complete: function() { + consulter_param_filtrage_ip(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function tester_disponibiliter_whatsapp() { + // 1. Initialisation des variables + const p_destinataires = $("#destinataires").val(); + const racineWeb = $("#racineWeb").val(); + const div_cible = $('#div_test_gabarit'); + const codeLangue = $("#codeLangue").val(); + + // On force waapi par défaut selon votre logique actuelle, + // mais prêt pour une sélection dynamique si besoin. + const fournisseurWhatsApp = 'waapi'; + + // 2. Validation du destinataire + if (!p_destinataires || p_destinataires.trim() === "") { + alert_ebene("Veuillez saisir un destinataire!", "Please enter a recipient!"); + $("#destinataires").focus(); + return; + } + + // 3. Validation et mapping du message fournisseur + let p_message = ""; + const providers = { + 'waapi': 'Fournisseur WhatsApp : waapi', + 'ultramsg': 'Fournisseur WhatsApp : ultramsg' + }; + + if (providers[fournisseurWhatsApp]) { + p_message = providers[fournisseurWhatsApp]; + } else { + alert_ebene( + fournisseurWhatsApp + " => Fournisseur de WhatsApp inconnu!", + fournisseurWhatsApp + " => Unknown WhatsApp Provider!" + ); + return; + } + + // 4. Préparation des données (Format Objet) + const donnees = { + destinataires: p_destinataires, + message: p_message, + fournisseurWhatsApp: fournisseurWhatsApp + }; + + // 5. Affichage du loader stylisé + div_cible.html(` +
+
+

+ ${(codeLangue === "en_US") ? "Sending WhatsApp message..." : "Envoi du message WhatsApp..."} +

+
+ `); + + // 6. Requête AJAX + $.ajax({ + url: racineWeb + "Ajaxtesterdisponiblitesms/envoyerlewhatsapp/", + type: 'POST', + data: donnees, + success: function(data) { + toastr.success((codeLangue === "en_US") ? "WhatsApp API called" : "API WhatsApp appelée"); + div_cible.html(data); + }, + error: function(xhr) { + toastr.error((codeLangue === "en_US") ? "Connection error" : "Erreur de connexion"); + div_cible.html(`
Error: ${xhr.statusText}
`); + } + }); +} + + +function parametre_produit() +{ + var codeProduit = $('#codeProduit').val(); + + if(codeProduit<=" "){ + $('#div_parametres').html(""); + } + + donnees = 'codeProduit='+codeProduit; + + $("#div_parametres").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametreproduitgarant/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + $('#div_parametres').html(data); + }, + complete: function() { + } + }); +} + +function retour_param_fact_garant() +{ + window.location.assign($("#racineWeb" ).val()+"Paramfacturegarantcons/"); +} + +function inserer_param_fact_produit() +{ + codeGcAssureur = $('#codeGcAssureur').val(); + codeProduit = $('#codeProduit').val(); + + gcTauxFraisReel = $('#gcTauxFraisReel').val(); + gcTauxRedressement = $('#gcTauxRedressement').val(); + gcTauxCommissionGerant = $('#gcTauxCommissionGerant').val(); + + + montantBudget = parseInt($("#montantBudget").val().replace(/ /g,""),10);; + montantBudgetEnfantSupl = parseInt($("#montantBudgetEnfantSupl").val().replace(/ /g,""),10); + montantBudgetConjointSupl = parseInt($("#montantBudgetConjointSupl").val().replace(/ /g,""),10); + + forfaitHonoraire = parseInt($("#forfaitHonoraire").val().replace(/ /g,""),10); + nbAdherent = parseInt($("#nbAdherent").val().replace(/ /g,""),10); + nbBeneficiaire = parseInt($("#nbBeneficiaire").val().replace(/ /g,""),10); + + donnees = 'codeGcAssureur='+codeGcAssureur; + donnees += '&codeProduit='+codeProduit; + donnees += '&gcTauxFraisReel='+gcTauxFraisReel; + + donnees += '&gcTauxRedressement='+gcTauxRedressement; + donnees += '&gcTauxCommissionGerant='+gcTauxCommissionGerant; + donnees += '&montantBudget='+montantBudget; + donnees += '&montantBudgetEnfantSupl='+montantBudgetEnfantSupl; + donnees += '&montantBudgetConjointSupl='+montantBudgetConjointSupl; + donnees += '&forfaitHonoraire='+forfaitHonoraire; + donnees += '&nbAdherent='+nbAdherent; + donnees += '&nbBeneficiaire='+nbBeneficiaire; + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametreproduitgarant/inserer/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + // + + v_msg="Paramètres insérés avec succès!"; + v_msgEng="Parameters inserted successfully!"; + alert_ebene(v_msg, v_msgEng); + + + }, + complete: function() { + retour_param_fact_garant(); + } + }); + +} + +function modifier_param_fact_produit(superUser) +{ + if (superUser != "1"){ + v_msg="Non autorisé!"; + v_msgEng="Unauthorized!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + window.location.assign($("#racineWeb" ).val()+"Paramfactureproduitgarant/"); +} + +function enregistrer_param_fact_produit() +{ + codeGcAssureur = $('#codeGcAssureur').val(); + codeProduit = $('#codeProduit').val(); + + gcTauxFraisReel = $('#gcTauxFraisReel').val(); + gcTauxRedressement = $('#gcTauxRedressement').val(); + gcTauxCommissionGerant = $('#gcTauxCommissionGerant').val(); + + montantBudget = parseInt($("#montantBudget").val().replace(/ /g,""),10);; + montantBudgetEnfantSupl = parseInt($("#montantBudgetEnfantSupl").val().replace(/ /g,""),10); + montantBudgetConjointSupl = parseInt($("#montantBudgetConjointSupl").val().replace(/ /g,""),10); + + forfaitHonoraire = parseInt($("#forfaitHonoraire").val().replace(/ /g,""),10); + nbAdherent = parseInt($("#nbAdherent").val().replace(/ /g,""),10); + nbBeneficiaire = parseInt($("#nbBeneficiaire").val().replace(/ /g,""),10); + + donnees = 'codeGcAssureur='+codeGcAssureur; + donnees += '&codeProduit='+codeProduit; + donnees += '&gcTauxFraisReel='+gcTauxFraisReel; + + donnees += '&gcTauxRedressement='+gcTauxRedressement; + donnees += '&gcTauxCommissionGerant='+gcTauxCommissionGerant; + donnees += '&montantBudget='+montantBudget; + donnees += '&montantBudgetEnfantSupl='+montantBudgetEnfantSupl; + donnees += '&montantBudgetConjointSupl='+montantBudgetConjointSupl; + donnees += '&forfaitHonoraire='+forfaitHonoraire; + donnees += '&nbAdherent='+nbAdherent; + donnees += '&nbBeneficiaire='+nbBeneficiaire; + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametreproduitgarant/enregistrer/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + // + + v_msg="Paramètres enregistrés avec succès!"; + v_msgEng="Settings saved successfully!"; + alert_ebene(v_msg, v_msgEng); + + + }, + complete: function() { + retour_param_fact_garant_cons(); + } + }); + +} + +function retour_param_fact_garant_cons() +{ + window.location.assign($("#racineWeb" ).val()+"Paramfactureproduitgarantcons/"); +} + + +function ouvrir_parametre_produit() +{ + if ( $("#paramFacGcProduit").val() == "0") + { + v_msg="Non autorisée!"; + v_msgEng="Not allowed!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + window.location.assign($("#racineWeb" ).val()+"Paramfactureproduitgarantcons/"); +} + +function change_password() +{ + + v_msg="Attention, vous serez déconnecté par la suite! Voulez-vous changer votre mot de passe?"; + v_msgEng="Attention, you will be logged out afterwards! Do you want to change your password?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + window.location.assign($("#racineWeb" ).val()+"Changermotpass/"); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + + +function infos_entite() +{ + donnees = ""; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxinfosentite/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + // + $('#div_entite').html(data); + + delaiUsageSaas = $("#delaiUsageSaas").val(); + + //dateLimiteUsage = $("#dateLimiteUsage").val(); + + /* + v_msg="Dernière facture SAAS: "+delaiUsageSaas+"\nFin de licence: "+dateLimiteUsage; + v_msgEng="Latest SAAS invoice: "+delaiUsageSaas+"\nEnd of license: "+dateLimiteUsage; + */ + + v_msg="Fin d'abonnement: "+delaiUsageSaas; + v_msgEng="End of subscription: "+delaiUsageSaas; + + + alert_ebene(v_msg, v_msgEng); + + return; + + }, + complete: function() { + + } + }); +} + +function change_password() +{ + + v_msg="Attention, vous serez déconnecté par la suite! Voulez-vous changer votre mot de passe?"; + v_msgEng="Attention, you will be logged out afterwards! Do you want to change your password?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + window.location.assign($("#racineWeb" ).val()+"Changermotpass/"); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function annuler_facture_classique_police(idFactureClassique, idFacture) { + + v_msg="Confirmez-vous cette annulation?"; + v_msgEng="Do you confirm this cancellation?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + donnees = 'idFactureClassique=' + idFactureClassique+'&idFacture='+idFacture; + + $("#div_annuler_facture").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxannulationfacturerdpolice/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + $("#div_annuler_facture").html(data); + $("#div_annuler_facture").modal({backdrop: 'static', keyboard: false, show: true }); + $("#div_annuler_facture").modal("show"); + }, + complete: function () { + + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function valider_annulation_facture_classique_police() +{ + + + idFactureClassique = $("#idFactureClassique").val(); + + motif = $("#motif").val(); + + if(motif <=" ") + { + v_msg="Le motif est obligatoire!"; + v_msgEng="The pattern is mandatory!"; + alert_ebene(v_msg, v_msgEng); + + $("#motif").focus(); + + return; + } + + donnees = "idFactureClassique="+idFactureClassique+'&motif='+motif; + + v_msg="Validez-vous cette annulation?"; + v_msgEng="Do you validate this cancellation?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxannulationfacturerdpolice/annuler/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + + }, + complete: function() { + afficher_dossier_classique_police(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function tarif_applique(tarif) +{ + v_msg="Tarif appliqué : "+tarif; + v_msgEng="Price applied : "+tarif; + + alert_ebene(v_msg, v_msgEng); + + return; + +} + +function consulter_envois_whatsapp() +{ + donnees = ""; + donnees_retour = ""; + + date1 = $("#date1").val(); + date2 = $("#date2").val(); + + donnees += 'date1=' + date1; + donnees += '&date2=' + date2; + + $("#div_sms").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxdestinatairesms/consulterwhatsapp/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_sms").html(donnees_retour); + $("#nbligne").val("Lignes : "+$("#nbligne_info").val()); + } + }); +} + +function genererQRCode(matricule) { + /* + + const container = document.getElementById('qr-code-container'); + container.innerHTML = '
Génération en cours...
'; + + donnees = "matricule="+matricule; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxgenererqrcode/", + type : 'post', + dataType: 'json', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + + + if (data.success) { + // Recharger la page + //modifier_beneficiaire(); + location.reload(); + } else { + container.innerHTML = ` +
+ Erreur: ${data.error || 'Échec de génération'} + +
`; + } + + }, + complete: function() { + + } + }); + */ +} + +function regenererQRCode(matricule) { + /* + + v_msg="Voulez-vous vraiment régénérer ce QR Code ?"; + v_msgEng="Do you really want to regenerate this QR Code?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + genererQRCode(matricule); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + */ +} + +function listerremboursement() +{ + + + d1 = $("#d1").val(); + d2 = $("#d2").val(); + codeEtatDemandeRemboursement = $("#codeEtatDemandeRemboursement").val(); + + donnees = 'd1='+ d1+'&d2='+d2+'&codeEtatDemandeRemboursement='+codeEtatDemandeRemboursement; + + $("#div_dossiers").html('
' + '
'); + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxdemanderemboursement/", + type: 'POST', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + // alert(data); + + + $('#div_dossiers').html(data); + }, + complete: function() { + + } + }); +} + +function selectionner_remboursement(idDemande) +{ + donnees = 'idDemande='+idDemande; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxdemanderemboursement/selectionnerremb/", + type: 'POST', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + // alert(data); + + }, + complete: function() { + actualiser_remboursement(); + } + }); +} + +function actualiser_remboursement() +{ + window.location.assign($("#racineWeb" ).val()+"Demanderemboursement/"); + +} + +function valider_reponse_demande_rd() +{ + idDemandeRemboursement = $("#idDemandeRemboursement").val(); + idBeneficiaire = $("#idBeneficiaire").val(); + codeEtatDemandeRemboursement = $("#codeEtatDemandeRemboursement").val(); + motifReponseDemandeRemboursement = $("#motifReponseDemandeRemboursement").val(); + + nbreFichier = $("#nbreFichier").val(); + + if(codeEtatDemandeRemboursement=="0"){ + + v_msg="Un autre état de réponse est obligatoire!"; + v_msgEng="Another response status is required!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeEtatDemandeRemboursement").focus(); + + return; + } + + if(motifReponseDemandeRemboursement<=" "){ + + v_msg="Le motif est obligatoire!"; + v_msgEng="The pattern is mandatory!"; + alert_ebene(v_msg, v_msgEng); + + $("#motifReponseDemandeRemboursement").focus(); + + return; + } + + if(codeEtatDemandeRemboursement=="1" && nbreFichier=="0"){ + + v_msg="Au moins une facture doit être incluse à la demande !"; + v_msgEng="At least one invoice must be included with the request!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + donnees = 'idDemandeRemboursement='+idDemandeRemboursement; + donnees += '&codeEtatDemandeRemboursement='+codeEtatDemandeRemboursement; + donnees += '&motifReponseDemandeRemboursement='+motifReponseDemandeRemboursement; + + v_msg="Confirmez-vous cette réponse ?"; + v_msgEng="Do you confirm this answer?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxdemanderemboursement/majreponse/", + type: 'POST', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + // alert(data); + + + }, + complete: function() { + + if(codeEtatDemandeRemboursement=="1"){ + ajax_context_adherent(idBeneficiaire); + }else{ + window.location.assign($("#racineWeb" ).val()+"Historiqueremboursement/"); + + } + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function creer_dossier_demande_rd() +{ + + idBeneficiaire = $("#idBeneficiaire").val(); + + v_msg="Confirmez-vous la création du dossier de remboursement ?"; + v_msgEng="Do you confirm the creation of the reimbursement file?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + ajax_context_adherent(idBeneficiaire); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function filtrespoliceencoursgarant(){ + + var codeGcAssureur = $('#codeGcAssureur').val(); + + donnees = 'codeGcAssureur='+codeGcAssureur; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxfiltrespoliceencoursgarant/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + $('#div_policegarant').html(data); + + $("#idPolice" ).selectpicker(); + }, + complete: function() { + reinit_edition_carte(); + } + }); + +} + +function reinit_edition_carte(){ + idPolice =$("#idPolice").val(); + + $("#div_liste_carte").html('
' + '
'); + + donnees = 'idPolice='+idPolice; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/reinitedition/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + $("#div_liste_carte").html(''); + }, + complete: function() { + + } + }); + +} + +function filtrescollegepolicecarte() { + + donnees = "idPolice=" + $("#idPolice").val(); + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxfiltrescollegepolicecarte/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + $("#div_college").html(data); + $("#idCollege").selectpicker(); + }, + complete: function () { + + } + }); +} + +function select_tous_carte_a_editer(p_choix) +{ + + + donnees = 'choix='+p_choix; + + $("#div_liste_carte").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/toutchoisir/", + type: 'POST', + data: donnees, + success: function(data) { + $('#div_liste_carte').html(data); + appliquerDataTable(); + }, + error: function(data) { + }, + complete: function() { + + } + }); +} + +function select_un_assure_a_editer(p_choix, id) +{ + donnees = 'id='+id; + donnees += '&choix='+p_choix; + + //$("#div_liste_carte").html('
' + '
'); + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/selectionunassure/", + type: 'POST', + data: donnees, + success: function(data) { + //$('#div_liste_carte').html(data); + //appliquerDataTable(); + }, + error: function(data) { + }, + complete: function() { + + } + }); +} + +function confirmer_edition_carte(){ + + idPolice =$("#idPolice").val(); + typeEdition =$("#typeEdition").val(); + + $("#div_liste_carte").html('
' + '
'); + + donnees = 'idPolice='+idPolice; + + v_msg="Confirmez-vous l'édition de carte assuré ?"; + v_msgEng="Do you confirm the insured card edition?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + if (numeroBeneficiaire_C>"") + { + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/confirmedition/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + + }, + complete: function() { + afficher_liste_carteassure_commun(); + } + }); + } + } else { + afficher_liste_carteassure_commun(); + } + }); + +} + +function actualiser_carte_assure() +{ + window.location.assign($("#racineWeb" ).val()+"Carteassures/"); +} + +function afficher_detail_emission(idEmission) +{ + if (idEmission>"0") + { + window.location.assign($("#racineWeb" ).val()+"Detailemission/"+idEmission+"/"); + } +} + + +function paiement_mobile_un_dossier() +{ + regle=$("#regle").val(); + + if (regle==1) + { + v_msg="Déjà payé!"; + v_msgEng="Already paid!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + fraisRetenu=$("#fraisRetenu").val(); + if (fraisRetenu<=0) + { + v_msg="Rien à payer!"; + v_msgEng="Nothing to pay!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + demandeReglement=$("#demandeReglement").val(); + demandeReglement = parseInt(demandeReglement); + + if (demandeReglement==0) + { + v_msg="Aucune Demande de Règlement!"; + v_msgEng="No request in progress!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + paiementMobileActif=$("#paiementMobileActif").val(); + paiementMobileActif = parseInt(paiementMobileActif); + + if (paiementMobileActif!=1) + { + v_msg="Module paiement mobile non activé!"; + v_msgEng="Mobile payment module not activated"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + window.location.assign($("#racineWeb" ).val()+"Paiementmobile/"); +} + +function reinitialiser_changementcollege() +{ + v_msg="Confirmez-vous la réinitialisation?"; + v_msgEng="Do you confirm the reset?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + window.location.assign($("#racineWeb" ).val()+"Fichechangementcollege/"); + } + }); +} + +function lister_avenants_sans_primes() +{ + $("#div_page_complet").html('
' + '
'); + + debut=$("#debut").val(); + fin=$("#fin").val(); + + donnees = 'debut='+debut+'&fin='+fin; + + $("#avenant_a_facturer").html('
' + '
'); + $.ajax({ + url: $("#racineWeb").val()+"Ajaxfacturerpolice/listeravenantsanprime/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + $("#div_page_complet").html(data); + appliquerDataTable(); + }, + complete: function() { + } + }); +} + + +function cloturer_avenant_sans_prime(idAvenant) +{ + v_msg="Confirmez-vous cette opération?"; + v_msgEng="Do you confirm this operation?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + + $("#div_page_complet").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxfacturerpolice/clotureravenantsansprime/", + type : 'post', + data: "idAvenant="+idAvenant, + error: function(errorData) { + }, + success: function(data) { + }, + complete: function() + { + lister_avenants_sans_primes(); + } + }); + } else { + } + }); + +} + +function tester_reconnaissance_faciale() +{ + alert("tester_reconnaissance_faciale"); + return; + + p_idReglement = $("#idReglement").val(); + p_fournisseurPaiementMobile = $("#fournisseurPaiementMobile").val(); + p_prefixdestinataire = $("#prefixdestinataire").val(); + p_destinataires = $("#destinataires").val(); + + paiementMobileActif=$("#paiementMobileActif").val(); + paiementMobileActif = parseInt(paiementMobileActif); + + if (paiementMobileActif!=1) + { + v_msg="Module paiement mobile non activé!"; + v_msgEng="Mobile payment module not activated"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + + if (p_idReglement<=" ") + { + v_msg="ID Règlement manquant!"; + v_msgEng="Missing Regulation ID!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (fournisseurPaiementMobile<=" ") + { + v_msg="Fournisseur de paiement mobile non défini!"; + v_msgEng="Mobile payment provide not defined!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (p_prefixdestinataire<=" ") + { + v_msg="Veuillez saisir un préfixe!"; + v_msgEng="Please enter a prefix!"; + alert_ebene(v_msg, v_msgEng); + + $("#prefixdestinataire").focus(); + return; + } + + if (p_destinataires<=" ") + { + v_msg="Veuillez saisir un destinataire!"; + v_msgEng="Please enter a recipient!"; + alert_ebene(v_msg, v_msgEng); + + $("#destinataires").focus(); + return; + } + + const liste_fournisseurs = ["cinetpay", "paydunya", "waveci"]; + + if (!liste_fournisseurs.includes(p_fournisseurPaiementMobile)) + { + v_msg=p_fournisseurPaiementMobile+" => Fournisseur de paiement mobile inconnu!"; + v_msgEng=fournisseurPaiementMobile+" => Unknown Mobile payment provider!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + donnees = "idReglement="+p_idReglement; + donnees += "&fournisseurPaiementMobile="+p_fournisseurPaiementMobile; + donnees += "&prefixdestinataire="+p_prefixdestinataire; + donnees += "&destinataires="+p_destinataires; + + $("#div_test_gabarit").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxtesterpaiementmobile/envoyerargent/", + type: 'POST', + data: donnees, + success: function(data) + { + // alert("success "+data); + $('#div_test_gabarit').html(data); + }, + error: function(errdata) + { + // alert("Error : "+errdata); + $('#div_test_gabarit').html(errdata); + }, + complete: function() + { + } + }); +} + +function tester_paiement_mobile() +{ + p_idReglement = $("#idReglement").val(); + p_fournisseurPaiementMobile = $("#fournisseurPaiementMobile").val(); + p_prefixdestinataire = $("#prefixdestinataire").val(); + p_destinataires = $("#destinataires").val(); + p_withdrawModePaiementMobile = $("#withdrawModePaiementMobile").val(); + + paiementMobileActif=$("#paiementMobileActif").val(); + paiementMobileActif = parseInt(paiementMobileActif); + + if (paiementMobileActif!=1) + { + v_msg="Module paiement mobile non activé!"; + v_msgEng="Mobile payment module not activated"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + + if (p_idReglement<=" ") + { + v_msg="ID Règlement manquant!"; + v_msgEng="Missing Regulation ID!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (fournisseurPaiementMobile<=" ") + { + v_msg="Fournisseur de paiement mobile non défini!"; + v_msgEng="Mobile payment provide not defined!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (p_prefixdestinataire<=" ") + { + v_msg="Veuillez saisir un préfixe!"; + v_msgEng="Please enter a prefix!"; + alert_ebene(v_msg, v_msgEng); + + $("#prefixdestinataire").focus(); + return; + } + + if (p_destinataires<=" ") + { + v_msg="Veuillez saisir un destinataire!"; + v_msgEng="Please enter a recipient!"; + alert_ebene(v_msg, v_msgEng); + + $("#destinataires").focus(); + return; + } + + if (p_withdrawModePaiementMobile<=" ") + { + v_msg="Veuillez indiquer le withdraw mode!"; + v_msgEng="Please indicate the withdraw mode!"; + alert_ebene(v_msg, v_msgEng); + + $("#withdrawModePaiementMobile").focus(); + return; + } + + const liste_fournisseurs = ["cinetpay", "paydunya", "waveci"]; + + if (!liste_fournisseurs.includes(p_fournisseurPaiementMobile)) + { + v_msg=p_fournisseurPaiementMobile+" => Fournisseur de paiement mobile inconnu!"; + v_msgEng=fournisseurPaiementMobile+" => Unknown Mobile payment provider!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + donnees = "idReglement="+p_idReglement; + donnees += "&fournisseurPaiementMobile="+p_fournisseurPaiementMobile; + donnees += "&prefixdestinataire="+p_prefixdestinataire; + donnees += "&destinataires="+p_destinataires; + donnees += "&withdrawModePaiementMobile="+p_withdrawModePaiementMobile; + + $("#div_test_gabarit").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxtesterpaiementmobile/envoyerargent/", + type: 'POST', + data: donnees, + success: function(data) + { + // alert("success "+data); + $('#div_test_gabarit').html(data); + }, + error: function(errdata) + { + // alert("Error : "+errdata); + $('#div_test_gabarit').html(errdata); + }, + complete: function() + { + } + }); +} + +function paiement_par_mobile() +{ + p_idReglement = $("#idReglement").val(); + p_fournisseurPaiementMobile = $("#fournisseurPaiementMobile").val(); + p_prefixePaiementMobile = $("#prefixePaiementMobile").val(); + p_mobilePaiement = $("#mobilePaiement").val(); + p_withdrawModePaiementMobile = $("#withdrawModePaiementMobile").val(); + + paiementMobileActif=$("#paiementMobileActif").val(); + paiementMobileActif = parseInt(paiementMobileActif); + + if (paiementMobileActif!=1) + { + v_msg="Module paiement mobile non activé!"; + v_msgEng="Mobile payment module not activated"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + plafondPaiementMobile=$("#plafondPaiementMobile").val(); + plafondPaiementMobile = parseInt(plafondPaiementMobile); + + montantMobileMoney=$("#montantMobileMoney").val(); + montantMobileMoney = parseInt(montantMobileMoney); + + if (montantMobileMoney > plafondPaiementMobile) + { + v_msg="Plafond mobile monney dépassé!"; + v_msgEng="Mobile money ceiling exceeded!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + if (p_idReglement<=" ") + { + v_msg="Veuillez indiquer un décompte à payer!"; + v_msgEng="Please indicate a statement to pay!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (p_prefixePaiementMobile<=" ") + { + v_msg="L'indicatif du téléphonique est obligatoire!"; + v_msgEng="The telephone code is mandatory!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + if (p_fournisseurPaiementMobile<=" ") + { + v_msg="Fournisseur de paiement mobile non défini!"; + v_msgEng="Mobile payment provide not defined!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (p_mobilePaiement<=" ") + { + v_msg="Le numéro du téléphonique est obligatoire!"; + v_msgEng="The phone number is mandatory!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + + if (p_withdrawModePaiementMobile<=" ") + { + v_msg="Veuillez indiquer un oprérateur!"; + v_msgEng="Please specify an operator!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + $("#btn_paiement").prop("disabled",true); + + donnees = "idReglement="+p_idReglement; + donnees += "&withdrawModePaiementMobile="+p_withdrawModePaiementMobile; + + // alert(donnees); + // return; + + v_msg="Confirmez-vous le paiement mobile?"; + v_msgEng="Do you confirm mobile payment?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + + $("#div_wait").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxpaiementmobile/envoyerargent/", + type: 'POST', + data: donnees, + success: function(data) + { + $('#div_wait').html(data); + + $("#btn_paiement").prop("disabled",false); + + v_msg="Paiement mobile bien effectué!"; + v_msgEng="Mobile payment successful!"; + alert_ebene(v_msg, v_msgEng); + }, + error: function(errdata) + { + // alert("Error : "+errdata); + $('#div_test_gabarit').html(errdata); + }, + complete: function() + { + afficher_dossier_classique(); + } + }); + } else { + afficher_dossier_classique(); + } + }); +} + +function paiement_mobile_un_dossier_police() +{ + regle=$("#regle").val(); + + if (regle==1) + { + v_msg="Déjà payé!"; + v_msgEng="Already paid!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + fraisRetenu=$("#fraisRetenu").val(); + if (fraisRetenu<=0) + { + v_msg="Rien à payer!"; + v_msgEng="Nothing to pay!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + demandeReglement=$("#demandeReglement").val(); + demandeReglement = parseInt(demandeReglement); + + if (demandeReglement==0) + { + v_msg="Aucune Demande de Règlement!"; + v_msgEng="No request in progress!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + paiementMobileActif=$("#paiementMobileActif").val(); + paiementMobileActif = parseInt(paiementMobileActif); + + if (paiementMobileActif!=1) + { + v_msg="Module paiement mobile non activé!"; + v_msgEng="Mobile payment module not activated"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + window.location.assign($("#racineWeb" ).val()+"Paiementmobilepolice/"); +} + + +function paiement_par_mobile_police() +{ + p_idReglement = $("#idReglement").val(); + p_fournisseurPaiementMobile = $("#fournisseurPaiementMobile").val(); + p_prefixePaiementMobile = $("#prefixePaiementMobile").val(); + p_mobilePaiement = $("#mobilePaiement").val(); + p_withdrawModePaiementMobile = $("#withdrawModePaiementMobile").val(); + + paiementMobileActif=$("#paiementMobileActif").val(); + paiementMobileActif = parseInt(paiementMobileActif); + + if (paiementMobileActif!=1) + { + v_msg="Module paiement mobile non activé!"; + v_msgEng="Mobile payment module not activated"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + plafondPaiementMobile=$("#plafondPaiementMobile").val(); + plafondPaiementMobile = parseInt(plafondPaiementMobile); + + montantMobileMoney=$("#montantMobileMoney").val(); + montantMobileMoney = parseInt(montantMobileMoney); + + if (montantMobileMoney > plafondPaiementMobile) + { + v_msg="Plafond mobile monney dépassé!"; + v_msgEng="Mobile money ceiling exceeded!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + if (p_idReglement<=" ") + { + v_msg="Veuillez indiquer un décompte à payer!"; + v_msgEng="Please indicate a statement to pay!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (p_prefixePaiementMobile<=" ") + { + v_msg="L'indicatif du téléphonique est obligatoire!"; + v_msgEng="The telephone code is mandatory!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + if (p_fournisseurPaiementMobile<=" ") + { + v_msg="Fournisseur de paiement mobile non défini!"; + v_msgEng="Mobile payment provide not defined!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + if (p_mobilePaiement<=" ") + { + v_msg="Le numéro du téléphonique est obligatoire!"; + v_msgEng="The phone number is mandatory!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + if (p_withdrawModePaiementMobile<=" ") + { + v_msg="Veuillez indiquer un oprérateur!"; + v_msgEng="Please specify an operator!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + $("#btn_paiement").prop("disabled",true); + + donnees = "idReglement="+p_idReglement; + donnees += "&withdrawModePaiementMobile="+p_withdrawModePaiementMobile; + + // alert(donnees); + // return; + + v_msg="Confirmez-vous le paiement mobile?"; + v_msgEng="Do you confirm mobile payment?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + + $("#div_wait").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxpaiementmobile/envoyerargent/", + type: 'POST', + data: donnees, + success: function(data) + { + $('#div_wait').html(data); + + $("#btn_paiement").prop("disabled",false); + + // $('#div_test_gabarit').html(data); + + v_msg="Paiement mobile bien effectué!"; + v_msgEng="Mobile payment successful!"; + alert_ebene(v_msg, v_msgEng); + }, + error: function(errdata) + { + $('#div_test_gabarit').html(errdata); + }, + complete: function() + { + afficher_dossier_classique_police(); + } + }); + } else { + afficher_dossier_classique_police(); + } + }); +} + + +function exporter_modele_tarif_acte() +{ + $('#div_form_upload').hide(); + + + var div_export = $('#div_exporter_tarif'); + + + div_export.html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximportertarifacte/exportermodele/", + type: 'POST', + //data: donnees, + success: function(data) + { + div_export.html(data); + }, + error : function(resultat, statut, erreur) + { + }, + complete: function() + { + } + }); +} + + +function init_import_tarif_actes() +{ + adminSin=$("#adminSin").val(); + + if (adminSin!="1") + { + v_msg="Non autorisée!"; + v_msgEng="Not allowed!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + codeTarifActe=$("#codeTarifActe").val(); + + if(codeTarifActe<=' ') + { + v_msg="Veuillez sélectionner un tarif!"; + v_msgEng="Please select a rate!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeTarifActe").focus(); + return; + } + + donnees = 'codeTarifActe='+codeTarifActe; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxcomposantetarif/initimport/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) + { + //alert(data); + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Importertarifsactes/"); + } + }); +} + + +function charger_fichier_modele_tarifacte() +{ + $('#div_exporter_tarif').html(""); + + $('#div_form_upload').show(); + + // return; +} + +function importer_modele_tarif_acte() +{ + etape2=$("#etape2").val(); + + if (etape2 != "1") + { + v_msg="Etape 2 incomplète!"; + v_msgEng="Incomplete step 2!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + codeTarifActe=$("#codeTarifActe").val(); + cheminFichier=$("#cheminFichier").val(); + + donnees = 'codeTarifActe='+codeTarifActe+'&cheminFichier='+cheminFichier; + + + $('#div_form_upload').hide(); + + var div_export = $('#div_exporter_tarif'); + + div_export.html('
' + '
'); + + $("#div_erreur_excel").html(""); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximportertarifacte/importermodele/", + type: 'POST', + data: donnees, + success: function(data) + { + div_export.html(''); + $("#div_erreur_excel").html(data); + + v_msg="Opération terminée avec succès!"; + v_msgEng="Operation completed successfully!"; + alert_ebene(v_msg, v_msgEng); + }, + error : function(resultat, statut, erreur) + { + }, + complete: function(data) + { + + div_export.html(''); + + succes_impot_execl=$("#succes_impot_execl").val(); + + if (succes_impot_execl == "1") + { + maj_etape_3_import_actes(); + } + + } + }); +} + +function maj_etape_3_import_actes() +{ + codeTarifActe=$("#codeTarifActe").val(); + + donnees = 'codeTarifActe='+codeTarifActe; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximportertarifacte/majetape/", + type: 'POST', + data: donnees, + success: function(data) + { + }, + error : function(resultat, statut, erreur) + { + }, + complete: function(data) + { + window.location.assign($("#racineWeb" ).val()+"Listeimporttarifacte/"); + } + }); +} + +function traiter_actes_importes() +{ + etape2=$("#etape2").val(); + + if (etape2 != "1") + { + v_msg="Etape 2 incomplète!"; + v_msgEng="Incomplete step 2!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + etape3=$("#etape3").val(); + + if (etape3 != "1") + { + v_msg="Etape 3 incomplète!"; + v_msgEng="Incomplete step 3!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + window.location.assign($("#racineWeb" ).val()+"Listeimporttarifacte/"); +} + +function ajax_composante_tarif_acte_importe() +{ + adminSin=$("#adminSin").val(); + + if (adminSin!="1") + { + v_msg="Non autorisée!"; + v_msgEng="Not allowed!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + codeTarifActe=$("#codeTarifActe").val(); + codeFamilleActe=$("#codeFamilleActe").val(); + + if(codeFamilleActe<=' ') + { + v_msg="Veuillez saisir une famille!"; + v_msgEng="Please select a family!"; + alert_ebene(v_msg, v_msgEng); + $("#codeFamilleActe").focus(); + return; + } + + donnees = 'codeTarifActe='+codeTarifActe+'&codeFamilleActe='+codeFamilleActe; + + var div_attente = $('#div_compsante_tarif'); + + div_attente.html('
' + '
'); + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximportertarifacte/affichercomposantetarif/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) + { + // $('#div_test_gabarit').html(data); + div_attente.html(data); + $(".datepicker").datepicker(); + appliquerDataTable(); + }, + complete: function() { + } + }); +} + +function valider_import_tarif_actes() +{ + codeTarifActe=$("#codeTarifActe").val(); + + if(codeTarifActe<=' ') + { + v_msg="Veuillez sélectionner un tarif!"; + v_msgEng="Please select a rate!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeTarifActe").focus(); + return; + } + + donnees = 'codeTarifActe='+codeTarifActe; + + v_msg="Validez-vous cette importation de tarif?"; + v_msgEng="Do you validate this tariff import?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaximportertarifacte/validerimporttarifacte/", + type: 'POST', + data: donnees, + success: function(data) + { + $('#div_test_gabarit').html(data); + }, + error: function(data) { + $('#div_test_gabarit').html(data); + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Compositiontarifactes/"); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function importer_tarif_medicaments_code() +{ + adminSin=$("#adminSin").val(); + + if (adminSin!="1") + { + v_msg="Non autorisée!"; + v_msgEng="Not allowed!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + codeTarifMedicament=$("#codeTarifMedicament").val(); + + donnees = 'codeTarifMedicament='+codeTarifMedicament; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxcomposantetarifmedicament/initimportcode/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) + { + + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Importertarifmedicament/"); + } + }); +} + +function afficher_liste_carteassure_police() +{ + donnees = ""; + donnees_retour = ""; + + idPolice =$("#idPolice").val(); + if(idPolice<=' ') + { + v_msg="Veuillez saisir une police!"; + v_msgEng="Please select a police!"; + alert_ebene(v_msg, v_msgEng); + + $("#idPolice").focus(); + return; + } + + idCollege=$("#idCollege").val(); + + $("#div_export_a").html(""); + + $("#div_liste_carte").html('
' + '
'); + + donnees = 'idPolice='+idPolice+'&idCollege='+idCollege; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_liste_carte").html(donnees_retour); + appliquerDataTable(); + $("#nbligne").val("Lignes : "+$("#nbligne_info").val()); + } + }); +} + +function tester_edition_carteassure() +{ + idPolice =$("#idPolice").val(); + donnees = 'idPolice='+idPolice; + + $('#div_export_a').html(""); + $('#div_liste_carte').html(""); + + $("#div_liste_carte").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/afficherliste/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_liste_carte").html(donnees_retour); + $("#nbligne").val("Lignes : "+$("#nbligne_info").val()); + + nbChoix = $("#nbChoix").val(); + if (nbChoix<="0") + { + v_msg="Liste vide!"; + v_msgEng="Empty list!"; + alert_ebene(v_msg, v_msgEng); + appliquerDataTable(); + return false; + } + else + { + editer_carteassure(); + } + } + }); +} + +function editer_carteassure() +{ + nbChoix = $("#nbChoix").val(); + if (nbChoix<="0") + { + v_msg="Liste vide!"; + v_msgEng="Empty list!"; + alert_ebene(v_msg, v_msgEng); + return false; + } + + idPolice =$("#idPolice").val(); + idCollege=$("#idCollege").val(); + + $('#div_export_a').html(""); + $('#div_liste_carte').html(""); + + donnees = 'idPolice='+idPolice+'&idCollege='+idCollege; + + v_url = $("#racineWeb").val()+"Ajaxeditioncarteassure/"; + + $("#div_export_a").html('
' + '
'); + + $.ajax({ + url: v_url, + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + $("#div_export_a").html(data); + } + }); +} + +function controler_piece_beneficiaire() +{ + v_codeNaturePiece = $("#codeNaturePiece").val(); + + if(v_codeNaturePiece<=' ') + { + v_msg="Veuillez sélection la nature de la pièce!"; + v_msgEng="Please select the type of document!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeNaturePiece").focus(); + return; + } + + $('#numeroPiece').removeAttr('minlength'); + + if(v_codeNaturePiece=="CNI") + { + $('#div_controle_piece').html(""); + + v_numeroPiece = $("#numeroPiece").val(); + + $('#numeroPiece').attr('minlength', 9); + + donnees = "numeroPiece="+v_numeroPiece; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxcontrolepiece/", + type: 'POST', + data: donnees, + success: function(data) { + $('#div_controle_piece').html(data); + + var resultatPiece = $("#resultatPiece").val(); + + if(resultatPiece!="0") + { + $("#numeroPiece").focus(); + return; + } + }, + error: function(data) { + }, + complete: function() + { + } + }); + } +} + +function enregistrer_encaissement_quittance() +{ + anc_solde = $("#anc_solde").val(); + montant = $("#montant").val(); + montant_ecart = (montant-anc_solde); + montant_ecart = Math.abs(montant_ecart); + + montant = $("#montant").val(); + montant = montant.replace(" ", ""); + montant = parseInt(montant); + montant = Math.abs(montant); + + codeModePaiement = $("#codeModePaiement").val(); + codeMoyenPaiement = $("#codeMoyenPaiement").val(); + referencePaiement = $("#referencePaiement").val(); + libelleOperation = $("#libelleOperation").val(); + codeTypePaiement = $("#codeTypePaiement").val(); + banquePayeur = $("#banquePayeur").val(); + + if(codeModePaiement<=" ") + { + v_msg="Veuillez indiquer le mode de paiement!"; + v_msgEng="Please enter the method of payment"; + alert_ebene(v_msg, v_msgEng); + + $("#codeModePaiement").focus(); + return; + } + + if(codeMoyenPaiement<=" ") + { + v_msg="Veuillez indiquer le moyen de paiement!"; + v_msgEng="Please enter the method of payment!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeMoyenPaiement").focus(); + return; + } + + if(referencePaiement<=" ") + { + v_msg="Veuillez indiquer la référence du paiement!"; + v_msgEng="Please enter the payment reference!"; + alert_ebene(v_msg, v_msgEng); + + $("#referencePaiement").focus(); + return; + } + + if(codeTypePaiement=="B" || codeTypePaiement=="M") + { + if (nomTireur<=" ") + { + v_msg="Veuillez saisir le tireur!"; + v_msgEng="Please enter the issuer of the check! "; + alert_ebene(v_msg, v_msgEng); + + $("#nomTireur").focus(); + return; + } + + if(banquePayeur<=" ") + { + v_msg="Veuillez indiquer l\'établissement payeur!"; + v_msgEng="Please indicate the paying institution!"; + alert_ebene(v_msg, v_msgEng); + + $("#banquePayeur").focus(); + return; + } + } + + if(montant_ecart>"100") + { + v_msg="Veuillez vérifier votre écart!"; + v_msgEng="Please check your gap!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + // if(montant=="100") + if(montant<="100") + { + v_msg="Veuillez saisir un montant!"; + v_msgEng="Please enter an amount"; + alert_ebene(v_msg, v_msgEng); + + $("#montant").focus(); + return; + } + + if(libelleOperation<=" ") + { + v_msg="Veuillez saisir le libellé de l\'opération!"; + v_msgEng="Please enter the text of the transaction!"; + alert_ebene(v_msg, v_msgEng); + + $("#libelleOperation").focus(); + return; + } + + $("#formente_encaissement").submit(); +} + +function suite_encaissement_client() +{ + montant = $("#montant").val(); + montant = montant.replace(" ", ""); + montant = parseInt(montant); + montant = Math.abs(montant); + + codeModePaiement = $("#codeModePaiement").val(); + codeMoyenPaiement = $("#codeMoyenPaiement").val(); + referencePaiement = $("#referencePaiement").val(); + libelleOperation = $("#libelleOperation").val(); + codeTypePaiement = $("#codeTypePaiement").val(); + nomTireur = $("#nomTireur").val(); + banquePayeur = $("#banquePayeur").val(); + + if(codeModePaiement<=" ") + { + v_msg="Veuillez indiquer le mode de paiement!"; + v_msgEng="Please enter the method of payment"; + alert_ebene(v_msg, v_msgEng); + + $("#codeModePaiement").focus(); + return; + } + + if(codeMoyenPaiement<=" ") + { + v_msg="Veuillez indiquer le moyen de paiement!"; + v_msgEng="Please enter the method of payment!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeMoyenPaiement").focus(); + return; + } + + if(referencePaiement<=" ") + { + v_msg="Veuillez indiquer la référence du paiement!"; + v_msgEng="Please enter the payment reference!"; + alert_ebene(v_msg, v_msgEng); + + $("#referencePaiement").focus(); + return; + } + + if(codeTypePaiement=="B" || codeTypePaiement=="M") + { + if (nomTireur<=" ") + { + v_msg="Veuillez saisir le tireur!"; + v_msgEng="Please enter the issuer of the check! "; + alert_ebene(v_msg, v_msgEng); + + $("#nomTireur").focus(); + return; + } + + if(banquePayeur<=" ") + { + v_msg="Veuillez indiquer l\'établissement payeur!"; + v_msgEng="Please indicate the paying institution!"; + alert_ebene(v_msg, v_msgEng); + + $("#banquePayeur").focus(); + return; + } + } + + if(montant<="0") + { + v_msg="Veuillez saisir un montant!"; + v_msgEng="Please enter an amount"; + alert_ebene(v_msg, v_msgEng); + + $("#montant").focus(); + return; + } + + + if(libelleOperation<=" ") + { + v_msg="Veuillez saisir le libellé de l\'opération!"; + v_msgEng="Please enter the text of the transaction!"; + alert_ebene(v_msg, v_msgEng); + + $("#libelleOperation").focus(); + return; + } + + $("#btn_suivant").click(); +} + + +function suite_encaissement_bordreau() +{ + montant = $("#montant").val(); + montant = montant.replace(" ", ""); + montant = parseInt(montant); + montant = Math.abs(montant); + + codeModePaiement = $("#codeModePaiement").val(); + codeMoyenPaiement = $("#codeMoyenPaiement").val(); + referencePaiement = $("#referencePaiement").val(); + libelleOperation = $("#libelleOperation").val(); + codeTypePaiement = $("#codeTypePaiement").val(); + nomTireur = $("#nomTireur").val(); + banquePayeur = $("#banquePayeur").val(); + + if(codeModePaiement<=" ") + { + v_msg="Veuillez indiquer le mode de paiement!"; + v_msgEng="Please enter the method of payment"; + alert_ebene(v_msg, v_msgEng); + + $("#codeModePaiement").focus(); + return; + } + + if(codeMoyenPaiement<=" ") + { + v_msg="Veuillez indiquer le moyen de paiement!"; + v_msgEng="Please enter the method of payment!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeMoyenPaiement").focus(); + return; + } + + if(referencePaiement<=" ") + { + v_msg="Veuillez indiquer la référence du paiement!"; + v_msgEng="Please enter the payment reference!"; + alert_ebene(v_msg, v_msgEng); + + $("#referencePaiement").focus(); + return; + } + + if(codeTypePaiement=="B" || codeTypePaiement=="M") + { + if (nomTireur<=" ") + { + v_msg="Veuillez saisir le tireur!"; + v_msgEng="Please enter the issuer of the check! "; + alert_ebene(v_msg, v_msgEng); + + $("#nomTireur").focus(); + return; + } + + if(banquePayeur<=" ") + { + v_msg="Veuillez indiquer l\'établissement payeur!"; + v_msgEng="Please indicate the paying institution!"; + alert_ebene(v_msg, v_msgEng); + + $("#banquePayeur").focus(); + return; + } + } + + if(montant<="0") + { + v_msg="Veuillez saisir un montant!"; + v_msgEng="Please enter an amount"; + alert_ebene(v_msg, v_msgEng); + + $("#montant").focus(); + return; + } + + + if(libelleOperation<=" ") + { + v_msg="Veuillez saisir le libellé de l\'opération!"; + v_msgEng="Please enter the text of the transaction!"; + alert_ebene(v_msg, v_msgEng); + + $("#libelleOperation").focus(); + return; + } + + $("#btn_suivant").click(); +} + +function suite_encaissement_depot() +{ + montant = $("#montant").val(); + montant = montant.replace(" ", ""); + montant = parseInt(montant); + montant = Math.abs(montant); + + codeModePaiement = $("#codeModePaiement").val(); + codeMoyenPaiement = $("#codeMoyenPaiement").val(); + referencePaiement = $("#referencePaiement").val(); + libelleOperation = $("#libelleOperation").val(); + codeTypePaiement = $("#codeTypePaiement").val(); + nomTireur = $("#nomTireur").val(); + banquePayeur = $("#banquePayeur").val(); + + if(codeModePaiement<=" ") + { + v_msg="Veuillez indiquer le mode de paiement!"; + v_msgEng="Please enter the method of payment"; + alert_ebene(v_msg, v_msgEng); + + $("#codeModePaiement").focus(); + return; + } + + if(codeMoyenPaiement<=" ") + { + v_msg="Veuillez indiquer le moyen de paiement!"; + v_msgEng="Please enter the method of payment!"; + alert_ebene(v_msg, v_msgEng); + + $("#codeMoyenPaiement").focus(); + return; + } + + if(referencePaiement<=" ") + { + v_msg="Veuillez indiquer la référence du paiement!"; + v_msgEng="Please enter the payment reference!"; + alert_ebene(v_msg, v_msgEng); + + $("#referencePaiement").focus(); + return; + } + + if(codeTypePaiement=="B" || codeTypePaiement=="M") + { + if (nomTireur<=" ") + { + v_msg="Veuillez saisir le tireur!"; + v_msgEng="Please enter the issuer of the check! "; + alert_ebene(v_msg, v_msgEng); + + $("#nomTireur").focus(); + return; + } + + if(banquePayeur<=" ") + { + v_msg="Veuillez indiquer l\'établissement payeur!"; + v_msgEng="Please indicate the paying institution!"; + alert_ebene(v_msg, v_msgEng); + + $("#banquePayeur").focus(); + return; + } + } + + if(montant<="0") + { + v_msg="Veuillez saisir un montant!"; + v_msgEng="Please enter an amount"; + alert_ebene(v_msg, v_msgEng); + + $("#montant").focus(); + return; + } + + + if(libelleOperation<=" ") + { + v_msg="Veuillez saisir le libellé de l\'opération!"; + v_msgEng="Please enter the text of the transaction!"; + alert_ebene(v_msg, v_msgEng); + + $("#libelleOperation").focus(); + return; + } + + $("#btn_depot").click(); +} + +function liste_renouvellement_medicament() +{ + demandeTraite = $("#demandeTraite").val(); + debut = $("#debut").val(); + fin = $("#fin").val(); + + donnees = 'demandeTraite='+demandeTraite; + donnees += '&debut='+debut+'&fin='+fin; + + $("#div_ententeprealable").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxententeprealablespha/renouvellementmedicament/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + $("#div_ententeprealable").html(data); + }, + complete: function() { + + } + }); +} + +function afficher_detail_ren_medicament(idPrescription) { + + + donnees = "idPrescription=" + idPrescription; + + + $("#div_patienter").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + //$('#div_test_gabarit').html(data); + //alert(data); + + $("#div_medicaments_prescrits").html(data); + $("#div_medicaments_prescrits").modal({ backdrop: 'static', keyboard: false, show: true }); + $("#div_medicaments_prescrits").modal("show"); + $("#div_patienter").empty(); + + //alert("afficherMasquerMedicaments"); + // afficherMasquerMedicaments(); + + }, + complete: function () { + + } + }); + +} + +function ajax_maj_qte_prescrit_medicament(idMedicament, quantite, controle) { + + donnee_a_affciher = ""; + + quantite = quantite.replace(",", "."); + controle.value = quantite; + + if (controle_numerique(controle)) { + if (quantite == 0) { + controle.focus(); + v_msg = "Veuillez saisir la quantit\u00e9!"; + v_msgEng = "Please enter the quantity!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idMedicament=' + idMedicament + "&quantite=" + quantite; + + //alert(donnees); + //return; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/majquantiteaccorde/", + type: 'POST', + data: donnees, + success: function (data) { + + }, + error: function (data) { + }, + complete: function () { + affiche_liste_phar_renouvellement_provisoire(); + } + }); + } +} + +function affiche_liste_phar_renouvellement_provisoire() +{ + $("#tab_liste").html('
' + '
'); + + donnees = ""; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/traitementprovisoire/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + $("#tab_liste").html(data); + }, + complete: function () { + + } + }); + +} + +function ajax_maj_duree_triatement_renouvelleemnt_medicament(idMedicament, dureeTraitement, controle) { + + donnee_a_affciher = ""; + + dureeTraitement = dureeTraitement.replace(",", "."); + controle.value = dureeTraitement; + + if (controle_numerique(controle)) { + if (dureeTraitement == 0) { + controle.focus(); + v_msg = "Veuillez saisir la durée!"; + v_msgEng = "Please enter the duration!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idMedicament=' + idMedicament + "&dureeTraitement=" + dureeTraitement; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/majdureetraitement/", + + type: 'POST', + data: donnees, + success: function (data) { + + }, + error: function (data) { + }, + complete: function () { + affiche_liste_phar_renouvellement_provisoire(); + } + }); + } +} + +function traitement_tous_ren_medic(codeReponseProvisoire) +{ + donnees = "codeReponseProvisoire=" + codeReponseProvisoire; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/traitertousprovisoire/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + // $('#div_test_gabarit').html(data); + affiche_liste_phar_renouvellement_provisoire(); + }, + complete: function () { + + } + }); + +} + +function traiter_un_provisoire_ren_medic(idMedicament, codeReponseProvisoire) +{ + donnees = "idMedicament=" + idMedicament + "&codeReponseProvisoire=" + codeReponseProvisoire; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/traiterunprovisoire/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + affiche_liste_phar_renouvellement_provisoire(); + }, + complete: function () { + + } + }); + +} + +function valider_renouvellement_medicament() { + + observations = $("#observations").val(); + motifRefusAssure = $("#motifRefusAssure").val(); + + nombreRefus = $("#nombreRefus").val(); + nombreEnAttente = $("#nombreEnAttente").val(); + + if(nombreEnAttente>"0"){ + v_msg = "Veuillez traiter toutes les lignes!"; + v_msgEng = "Please process all lines!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + + if (nombreRefus >"0" && motifRefusAssure <= " ") { + v_msg = "Veuillez saisir le motif pour les refus!"; + v_msgEng = "Please enter the reason for rejections!"; + alert_ebene(v_msg, v_msgEng); + + $("#motifRefusAssure").focus(); + + return; + } + + v_msg = "Confirmez-vous cette validation?"; + v_msgEng = "Do you confirm this validation?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + donnees = 'observations=' + observations + '&motifRefusAssure=' + motifRefusAssure; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxlistemedicamentsrenouvellement/valider/", + type: 'post', + data: donnees, + error: function (errorData) { + }, + success: function (data) { + $('#div_resultat_validation').html(data); + valider = $("#valider").val(); + + if(valider=="1"){ + v_msg = "Validation réussie!"; + v_msgEng = "Validation succeed!"; + alert_ebene(v_msg, v_msgEng); + + $("#btn-fermer-entente").click(); + }else{ + v_msg = "Echèc de la validation!"; + v_msgEng = "Validation failed!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + }, + complete: function () { + liste_renouvellement_medicament(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function afficherMasquerAntecedents() +{ + masquerAntecedents = $("#masquerAntecedents").val(); + + const element = document.getElementById("chevron-antecedents"); + + if(masquerAntecedents=="1"){ + $('#div_antecedents').hide(); + $("#masquerAntecedents").val("0"); + //$("#span_antecedents").text("Voir"); + + element.classList.remove("bi-chevron-up"); + element.classList.add("bi-chevron-down"); + + }else{ + $('#div_antecedents').show(); + $("#masquerAntecedents").val("1"); + //$("#span_antecedents").text("Masquer"); + + element.classList.remove("bi-chevron-down"); + element.classList.add("bi-chevron-up"); + + afficher_diagnostics_beneficiaire_entente(); + } + +} + + +function afficher_diagnostics_beneficiaire_entente() +{ + idBeneficiaire = $("#idBeneficiaire").val(); + + donnees = "idBeneficiaire=" + idBeneficiaire; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxdiagnosticsbeneficiaireentente/", + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_dianostics").html(donnees_retour); + } + }); +} + +function afficher_liste_carteassure_adherent() +{ + donnees = ""; + donnees_retour = ""; + + idAdherent =$("#idAdherent").val(); + if(idAdherent<=' ') + { + v_msg="Veuillez sélectionner une famille!"; + v_msgEng="Please select a family!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + $("#div_export_a").html(""); + + $("#div_liste_carte").html('
' + '
'); + + donnees = 'idAdherent='+idAdherent; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistecarteassure/indexadherent/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_liste_carte").html(donnees_retour); + appliquerDataTable(); + $("#nbligne").val("Lignes : "+$("#nbligne_info").val()); + } + }); +} + + +function afficher_liste_carteassure_commun() +{ + typeEdition =$("#typeEdition").val(); + + switch(typeEdition) { + case "garant": + afficher_liste_carteassure(); + break; + case "police": + afficher_liste_carteassure_police(); + break; + case "adherent": + afficher_liste_carteassure_adherent(); + break; + default: + afficher_liste_carteassure(); + } +} + +function imprimer_carte_assure() +{ + prestationPossible = $("#prestationPossible").val(); + + if (prestationPossible!="1") + { + v_msg="Pas encore couvert!"; + v_msgEng="Not covered yet!"; + alert_ebene(v_msg, v_msgEng); + return; + } + + window.location.assign($("#racineWeb" ).val()+"Carteassuresadherent/"); +} + +function afficherMasquerSituation() +{ + masquerSituation = $("#masquerSituation").val(); + + const element = document.getElementById("chevron-situation"); + + if(masquerSituation=="1"){ + $('#div_situation').hide(); + $("#masquerSituation").val("0"); + + + element.classList.remove("bi-chevron-up"); + element.classList.add("bi-chevron-down"); + + }else{ + $('#div_situation').show(); + $("#masquerSituation").val("1"); + + + element.classList.remove("bi-chevron-down"); + element.classList.add("bi-chevron-up"); + + afficher_situation_beneficiaire(); + } + +} + +function afficherMasquerMedicaments() +{ + masquerMedicament = $("#masquerMedicament").val(); + + const element = document.getElementById("chevron-medicament"); + + if(masquerMedicament=="1"){ + $('#div_medicament').hide(); + $("#masquerMedicament").val("0"); + + element.classList.remove("bi-chevron-up"); + element.classList.add("bi-chevron-down"); + + }else{ + $('#div_medicament').show(); + $("#masquerMedicament").val("1"); + + element.classList.remove("bi-chevron-down"); + element.classList.add("bi-chevron-up"); + + afficher_ordonnance_beneficiaire(); + } +} + +function afficher_situation_beneficiaire() +{ + donnees_retour = ''; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxsituationbeneficiaire/", + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_situation").html(donnees_retour); + } + }); +} + +function afficher_ordonnance_beneficiaire() +{ + numeroFeuilleMaladie = $("#numeroFeuilleMaladie").val(); + + donnees = "numeroFeuilleMaladie="+numeroFeuilleMaladie; + + donnees_retour = ''; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxordonnancebeneficiaire/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + donnees_retour = data; + }, + complete: function() { + $("#div_medicament").html(donnees_retour); + } + }); +} + +// Fonction globale pour tes notifications AJAX (Wahoo Effect) +function notification(type, message) { + const Toast = Swal.mixin({ + toast: true, + position: 'top-end', + showConfirmButton: false, + timer: 3000, + timerProgressBar: true, + didOpen: (toast) => { + toast.addEventListener('mouseenter', Swal.stopTimer) + toast.addEventListener('mouseleave', Swal.resumeTimer) + } + }); + + Toast.fire({ + icon: type, // 'success', 'error', 'warning', 'info' + title: message + }); +} + +function gerer_garant_defaut() +{ + codeGcAssureurDefaut=$("#codeGcAssureurDefaut").val(); + codeGcAssureur=$("#codeGcAssureur").val(); + + if(codeGcAssureurDefaut>" ") + { + $('#codeGcAssureur').val(codeGcAssureurDefaut).trigger('change'); + selectionTauxGarant(); + } +} + +function toggleSidebar() { + document.body.classList.toggle('sidebar-collapsed'); +} + +function init_revoquer_htagcarte(idHtagcarte) { + $("#idHtagcarte").val(idHtagcarte); + $("#div_revoquer_carte").modal({backdrop: 'static', keyboard: false, show: true }); + $("#div_revoquer_carte").modal("show"); +} + +function enregistrer_modif_parametres_prod() +{ + idSocieteuser = $("#idSocieteuser").val(); + donnees = 'idSocieteuser='+idSocieteuser; + + tauxHonoraires = $("#tauxHonoraires").val(); + spMax = $("#spMax").val(); + fraisCarteAN = $("#fraisCarteAN").val(); + donnees += '&tauxHonoraires='+tauxHonoraires+'&spMax='+spMax+'&fraisCarteAN='+fraisCarteAN; + + fraisCarteREN = $("#fraisCarteREN").val(); + fraisCarteImp = $("#fraisCarteImp").val(); + spAlertAdherent = $("#spAlertAdherent").val(); + donnees += '&fraisCarteREN='+fraisCarteREN+'&fraisCarteImp='+fraisCarteImp+'&spAlertAdherent='+spAlertAdherent; + + tauxRistourne = $("#tauxRistourne").val(); + seuilRistourne = $("#seuilRistourne").val(); + + archivageAutomatiquePrime = $("#archivageAutomatiquePrime").val(); + ecartEncaissementTolerable= $("#ecartEncaissementTolerable").val(); + + donnees += '&tauxRistourne='+tauxRistourne+'&seuilRistourne='+seuilRistourne; + donnees += '&archivageAutomatiquePrime='+archivageAutomatiquePrime; + donnees += '&ecartEncaissementTolerable='+ecartEncaissementTolerable; + + notificationSmsNumeroAssure = $("#notificationSmsNumeroAssure").val(); + notificationGroupeNumeroAssure = $("#notificationGroupeNumeroAssure").val(); + lettrageAutoGarant = $("#lettrageAutoGarant").val(); + + parametresFacturationGarantProduit = $("#parametresFacturationGarantProduit").val(); + + assureAjoutPhoto = $("#assureAjoutPhoto").val(); + + donnees += '¬ificationSmsNumeroAssure='+notificationSmsNumeroAssure; + donnees += '¬ificationGroupeNumeroAssure='+notificationGroupeNumeroAssure; + donnees += '&lettrageAutoGarant='+lettrageAutoGarant; + + donnees += '¶metresFacturationGarantProduit='+parametresFacturationGarantProduit; + donnees += '&assureAjoutPhoto='+assureAjoutPhoto; + + + v_msg="Confirmez-vous ces modifications?"; + v_msgEng="Do you confirm these modifications?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametresgeneraux/enregistrermodifprod/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + }, + complete: function() { + afficher_autres_parametresgeneraux(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function enregistrer_modif_parametres_med() +{ + + idSocieteuser = $("#idSocieteuser").val(); + + envoismsactif = $("#s_envoismsactif").val(); + + smsAssure = $("#s_smsAssure").val(); + smsmParFacture = $("#s_smsmParFacture").val(); + + emailParFacture = $("#s_emailParFacture").val(); + copieSmsAssure = $("#s_copieSmsAssure").val(); + + seuilAlerteActif = $("#s_seuilAlerteActif").val(); + + montantTotalExamen = $("#s_montantTotalExamen").val(); + montantTotalMedicament = $("#s_montantTotalMedicament").val(); + + accorderMedecinSouscripteur = $("#s_accorderMedecinSouscripteur").val(); + delaisReponseMedecinSouscripteur = $("#s_delaisReponseMedecinSouscripteur").val(); + + tousActesSoumisOuinon = $("#s_tousActesSoumisOuinon").val(); + + envoismswhatsappactif = $("#s_envoismswhatsappactif").val(); + appliquerTarifBas = $("#s_appliquerTarifBas").val(); + nombreActeEntentePrealable = $("#s_nombreActeEntentePrealable").val(); + + donnees = 'idSocieteuser='+idSocieteuser; + donnees += '&envoismsactif='+envoismsactif; + donnees += '&smsAssure='+smsAssure+'&smsmParFacture='+smsmParFacture; + donnees += '&emailParFacture='+emailParFacture+'&copieSmsAssure='+copieSmsAssure; + donnees += '&seuilAlerteActif='+seuilAlerteActif; + donnees += '&montantTotalExamen='+montantTotalExamen; + donnees += '&montantTotalMedicament='+montantTotalMedicament; + + donnees += '&accorderMedecinSouscripteur='+accorderMedecinSouscripteur; + donnees += '&delaisReponseMedecinSouscripteur='+delaisReponseMedecinSouscripteur; + + donnees += '&tousActesSoumisOuinon='+tousActesSoumisOuinon; + + donnees += '&envoismswhatsappactif='+envoismswhatsappactif; + donnees += '&appliquerTarifBas='+appliquerTarifBas; + donnees += '&nombreActeEntentePrealable='+nombreActeEntentePrealable; + + v_msg="Confirmez-vous ces modifications ?"; + v_msgEng="Do you confirm these modifications?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametresgeneraux/enregistrermodifmed/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) + { + v_msg="Mise à jour effectuée avec succès!"; + v_msgEng="Update done successfully!"; + alert_ebene(v_msg, v_msgEng); + }, + complete: function() + { + afficher_autres_parametresgeneraux(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +/** + * Initialise DataTables avec options d'export et de tri + * @param {string} selector - Sélecteur CSS de la table + * @param {string} pageTitle - Titre pour les exports PDF/Excel + * @param {boolean|array} defaultOrder - Exemple: [1, 'desc'] ou false pour garder l'ordre serveur + */ +function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Données', defaultOrder = false) { + if ($(selector).length === 0) return; + + var hasGlobalSearch = $('#globalSearch').length > 0; + + if ($.fn.DataTable.isDataTable(selector)) { + $(selector).DataTable().destroy(); + } + + 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>'; + + // Détermination de l'option "order" : + // Si defaultOrder est explicitement false, on passe un tableau vide pour désactiver le tri auto + var orderConfig = (defaultOrder === false) ? [] : defaultOrder; + + var table = $(selector).DataTable({ + "dom": domStructure, + "order": orderConfig, // <--- AJOUT ICI + "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() { + 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'); + } + }); + + if (hasGlobalSearch) { + $('#globalSearch').off('keyup').on('keyup', function() { + table.search(this.value).draw(); + }); + } + + return table; +} + + +function loadMessageSection(section) { + let url = ""; + let target = "#content-" + section; + let donnees = ""; + + // Détermination de l'ID du tableau et du titre pour l'export + let tableId = (section === 'Motifs') ? '#tableMotifs' : '#tableTextes'; + let pageTitle = (section === 'Motifs') ? 'Liste des Motifs de Dépassement' : 'Liste des Textes de Facturation'; + + if (section === 'Motifs') url = $("#racineWeb").val() + "Ajaxmotifdepassement/"; + if (section === 'Facturation') url = $("#racineWeb").val() + "Ajaxtextefacturationgarant/"; + + // Si déjà chargé, on ajuste simplement les colonnes pour le rendu visuel + if ($(target).find('table').length > 0) { + if ($.fn.DataTable.isDataTable(tableId)) { + $(tableId).DataTable().columns.adjust(); + } + return; + } + + $.ajax({ + url: url, + type: 'post', + data: donnees, + success: function(data) { + // 1. Injection du contenu HTML + $(target).html(data); + + // 2. Initialisation forcée avec un léger délai pour laisser le DOM respirer + setTimeout(function() { + initSmartTable(tableId, pageTitle, false); + }, 150); + }, + error: function() { + $(target).html('
Erreur de chargement
'); + } + }); +} + +/** + * Initialise, rafraîchit et ouvre le SelectPicker + * @param {string} selector - Le sélecteur du select + * @param {boolean} donnerFocus - Si true, donne le focus et ouvre le menu + */ +function actualiserSelectPicker(selector, donnerFocus = false) { + $(selector).each(function() { + const $el = $(this); + const lang = $("#codeLangue").val(); + const txtDefault = (lang === 'en_US') ? "-- Select --" : "-- Sélectionner --"; + + // 1. Nettoyage anti-doublon (Destruction complète) + if ($el.data('selectpicker')) { + $el.selectpicker('destroy'); + } + $el.siblings('.bootstrap-select').remove(); + $el.removeAttr('title').prop('title', ''); + + // 2. Initialisation Neutral Pro + $el.selectpicker({ + liveSearch: true, + container: 'body', + style: 'btn-white border-2 border-start-0 fw-bold', + width: '100%', + size: 8, + noneSelectedText: txtDefault, + noneResultsText: (lang === 'en_US') ? "No results" : "Aucun résultat", + liveSearchPlaceholder: (lang === 'en_US') ? "Search..." : "Rechercher..." + }); + + // 3. Focus et Ouverture automatique + if (donnerFocus) { + setTimeout(() => { + // Donne le focus au composant + $el.selectpicker('focus'); + // Ouvre le menu déroulant immédiatement + $el.selectpicker('toggle'); + }, 150); // Délai légèrement augmenté pour garantir l'ouverture + } + }); +} + +function changerAnneeFiltre(valeur) { + // 1. On peut forcer le stockage en session via un petit appel rapide si nécessaire + // ou simplement s'assurer que afficheDonneesTableChoisie utilise bien cette valeur. + console.log("Filtrage pour l'année : " + valeur); + + // Appel de votre fonction moteur + // Astuce : vérifiez que dans votre contrôleur PHP, vous récupérez bien $_POST['annee'] + afficheDonneesTableChoisie('Ajaxtblisterjoursferiers'); } \ No newline at end of file diff --git a/Vue/Ajaxentete/index.php b/Vue/Ajaxentete/index.php index 8ad1b549..40c59778 100755 --- a/Vue/Ajaxentete/index.php +++ b/Vue/Ajaxentete/index.php @@ -1,22 +1,8 @@ - - - - - - - - - - - - - -
- - - - - - - -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/Vue/Ajaxfiltretablesreference/index.php b/Vue/Ajaxfiltretablesreference/index.php index b2c3e888..aae796fd 100755 --- a/Vue/Ajaxfiltretablesreference/index.php +++ b/Vue/Ajaxfiltretablesreference/index.php @@ -1,3 +1,3 @@ - + \ No newline at end of file