diff --git a/Js/fonctions.js b/Js/fonctions.js index 0a0d1bb0..5667644a 100755 --- a/Js/fonctions.js +++ b/Js/fonctions.js @@ -52324,7 +52324,6 @@ function afficher_bareme_accessoire_garant() { if (!codeGcAssureur) return; - afficheBoutons(0); // 1. Feedback visuel (SaaS UX) const loadingMsg = (codeLangue === "en_US") ? "Loading schedule..." : "Chargement du barème..."; @@ -87727,4 +87726,5366 @@ function maj_etape_3_import_assures_d(numeroOptionTarif) { donnees = 'numeroOptionTarif='+numeroOptionTarif; - $.ajax( \ No newline at end of file + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/majetape/", + type: 'POST', + data: donnees, + success: function(data) + { + }, + error : function(resultat, statut, erreur) + { + }, + complete: function(data) + { + window.location.assign($("#racineWeb" ).val()+"Listeimportassuredevis/"); + } + }); +} + +function afficher_adherent_importee_devis() +{ + idCollege=$("#idCollege").val(); + + if (idCollege<=" ") + { + v_msg="Veuillez sélectionner un collège!"; + v_msgEng="Please select a college!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idCollege='+idCollege; + + var div_attente = $('#div_adherents_importes'); + + div_attente.html('
' + '
'); + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/afficheradherentimportee/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + div_attente.html(data); + }, + complete: function() { + } + }); +} + +function ajouter_tous_adherent_importe_college_devis() +{ + idCollege=$("#idCollege").val(); + + if (idCollege<=" ") + { + v_msg="Veuillez sélectionner un collège!"; + v_msgEng="Please select a college!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idCollege='+idCollege; + + + v_msg="Attention, cela va vider tous les autres collèges! Confirmez-vous?"; + v_msgEng="Be careful, this will empty all other colleges! Do you confirm?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/ajoutertousadherentaucollege/", + type: 'POST', + data: donnees, + success: function(data) { + }, + error: function(data) { + }, + complete: function() { + afficher_adherent_importee_devis(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function ajouter_sans_college_adherent_importe_college_devis() +{ + idCollege=$("#idCollege").val(); + + if (idCollege<=" ") + { + v_msg="Veuillez sélectionner un collège!"; + v_msgEng="Please select a college!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idCollege='+idCollege; + + v_msg="Attention! Confirmez-vous cette opération?"; + v_msgEng="Warning! Do you confirm this operation?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/ajoutersanscollegeadherentaucollege/", + type: 'POST', + data: donnees, + success: function(data) { + }, + error: function(data) { + }, + complete: function() { + afficher_adherent_importee_devis(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function retirer_tous_adherent_importe_college_devis() +{ + idCollege=$("#idCollege").val(); + + if (idCollege<=" ") + { + v_msg="Veuillez sélectionner un collège!"; + v_msgEng="Please select a college!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idCollege='+idCollege; + + v_msg="Attention, cela va vider ce collège! Confirmez-vous?"; + v_msgEng="Attention, this will empty this college! Do you confirm?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/retirertousadherentaucollege/", + type: 'POST', + data: donnees, + success: function(data) { + // $("#div_test_gabarit").html(data); + }, + error: function(data) { + // $("#div_test_gabarit").html(data); + }, + complete: function() { + afficher_adherent_importee_devis(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function retirer_un_adherent_importe_college_devis(idBeneficiairemodel) +{ + donnees = 'idBeneficiairemodel='+idBeneficiairemodel; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/retirerunadherentaucollege/", + type: 'POST', + data: donnees, + success: function(data) { + + }, + error: function(data) { + + }, + complete: function() { + afficher_adherent_importee_devis(); + } + }); +} + +function ajouter_un_adherent_importe_college_devis(idBeneficiairemodel) +{ + idCollege=$("#idCollege").val(); + + if (idCollege<=" ") + { + v_msg="Veuillez sélectionner un collège!"; + v_msgEng="Please select a college!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + donnees = 'idBeneficiairemodel='+idBeneficiairemodel+'&idCollege='+idCollege; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/ajouterunadherentaucollege/", + type: 'POST', + data: donnees, + success: function(data) { + }, + error: function(data) { + }, + complete: function() { + afficher_adherent_importee_devis(); + } + }); +} + +function calculer_population_lien_parente_temp() +{ + $.ajax({ + url: $("#racineWeb").val()+"Ajaxgarantiescollege/majpopulationcollegeliste/", + type: 'POST', + // data: donnees, + success: function(data) { + $("#div_garanties").html(data); + }, + error: function(data) { + }, + complete: function() { + } + }); +} + +function incorporer_assures_inmportes_devis() +{ + nb_adh=$("#nb_adh").val(); + + if (nb_adh>"0") + { + v_msg="Veuillez revoir les collèges et relancer le calcul des primes!"; + v_msgEng="Please review the colleges and restart the premium calculation!!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + nb_ligne_ass=$("#nb_ligne_ass").val(); + + if (nb_ligne_ass=="0") + { + v_msg="Rien à importer!"; + v_msgEng="Nothing to import!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + v_msg="Avez-vous fait l\'étape 2 => calcul des primes?"; + v_msgEng="Did you do step 2 => premium calculation?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + console.log("Confirmation confirmé"); + } else { + // L'utilisateur a annulé + return; + console.log("Confirmation refusée"); + } + }); + + primeTtcTotal=$("#primeTtcTotal").val(); + + if (primeTtcTotal=="0") + { + v_msg="Pas de primes! souhaitez-vous recalculer les primes?"; + v_msgEng="No premiums! do you want to recalculate the premiums?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + return; + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + + v_msg="Notez que vous avez accepté l\'incorporation sans primes!"; + v_msgEng="Note that you accepted the incorporation without premium!"; + alert_ebene(v_msg, v_msgEng); + } + + nbBeneficiaireFamilleAtteint = $("#nbBeneficiaireFamilleAtteint").val(); + + if(nbBeneficiaireFamilleAtteint>"0"){ + v_msg = "Population maximum atteinte pour les lignes en rouge!"; + v_msgEng = "Maximum population reached for red lines!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + nbGgeMaxBeneficiaireAtteint = $("#nbGgeMaxBeneficiaireAtteint").val(); + + if(nbGgeMaxBeneficiaireAtteint>"0"){ + v_msg = "Âge limite atteinte pour certaines personnes!"; + v_msgEng = "Age limit reached for certain people!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + + v_msg="Confirmez-vous l\'incorporation de cette liste?"; + v_msgEng="Do you confirm the incorporation of this list?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + var div_attente = $('#div_liste_assure_importe'); + + div_attente.html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/incorpoerassuresimportes/", + type: 'POST', + // data: donnees, + success: function(data) { + v_msg="Incorporation terminée avec succès!"; + v_msgEng="Incorporation completed successfully!"; + alert_ebene(v_msg, v_msgEng); + }, + error: function(data) { + }, + complete: function() { + afficher_police_d_id(); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function traiter_lignes_importees_d() +{ + 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()+"Listeimportassuredevis/"); +} + +function lister_assures_devis() +{ + window.location.assign($("#racineWeb" ).val()+"Listeassuredevis/"); +} + +function calculer_population_lien_parente_valide() +{ + $.ajax({ + url: $("#racineWeb").val()+"Ajaxgarantiescollege/majpopulationcollegelistevalide/", + type: 'POST', + // data: donnees, + success: function(data) { + $("#div_garanties").html(data); + }, + error: function(data) { + }, + complete: function() { + } + }); +} + + +function afficher_adherents_devis() +{ + $("#div_liste_adherent").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlisteadherentdevis/", + type : 'post', + // data: donnees, + error: function(errorData) { + }, + success: function(data) { + $("#div_liste_adherent").html(data); + $(".selectpicker").selectpicker(); + appliquerDataTable(); + } + }); +} + +function pop_adherent_devis(idAdherent) +{ + if (idAdherent>"0") + { + donnees = 'idAdherent='+idAdherent; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlisteadherentdevis/beneficiairesfamille/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) { + // $("#div_test_gabarit").html(data); + $("#div_deatil_pop").html(data); + }, + complete: function() { + $("#btn_pop").click(); + } + }); + } +} + +function exporter_liste_assures_devis() +{ + $("#div_deatil_pop").html('
' + '
'); + + $("#btn_pop").click(); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlisteadherentdevis/exporterlisteassuresdevis/", + type : 'post', + error: function(errorData) { + }, + success: function(data) { + $("#div_deatil_pop").html(data); + }, + complete: function() { + } + }); +} + +function imprimer_liste_assures_devis() +{ + $("#div_deatil_pop").html('
' + '
'); + + $("#btn_pop").click(); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlisteadherentdevis/imprimerlisteassuresdevis/", + type : 'post', + error: function(errorData) { + }, + success: function(data) { + $("#div_deatil_pop").html(data); + }, + complete: function() { + } + }); +} + +// transformer devis en Contrat +function init_transformer_devis() +{ + + + idDevis = $("#idPolice_d_C").val(); + + transforme = $("#transforme").val(); + if (transforme=="1") + { + v_msg="Cotation déjà transformée!"; + v_msgEng="Quote already transformed!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + primeTtc_total = $("#primeTtc_total").val(); + nbTotalCollege = $("#nbTotalCollege").val(); + + // if (primeTtc_total=="0") + if (nbTotalCollege=="0") + { + v_msg="Rien à transformer!"; + v_msgEng="Nothing to transform!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + v_msg="Confirmez-vous la transformation en contrat?"; + v_msgEng="Do you confirm the transformation into a contract?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $("#btn_pop").click(); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function clients_transformer_devis() +{ + idDevis = $("#idPolice_d_C").val(); + donnees = 'idDevis='+idDevis; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxtransformerdevis/clientsexistants/", + type: 'POST', + data: donnees, + success: function(data) { + $("#div_clients_existants").html(data); + }, + error: function(data) { + }, + complete: function() { + } + }); +} + +function transformer_devis(idClientExistant) +{ + idDevis = $("#idPolice_d_C").val(); + dateEffetContrat = $("#dateEffetContrat").val(); + + transforme = $("#transforme").val(); + if (transforme=="1") + { + v_msg="Cotation déjà transformée!"; + v_msgEng="Quote already transformed!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + primeTtc_total = $("#primeTtc_total").val(); + nbTotalCollege = $("#nbTotalCollege").val(); + + // if (primeTtc_total=="0") + if (nbTotalCollege=="0") + { + v_msg="Rien à transformer!"; + v_msgEng="Nothing to transform!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + v_msg="Confirmez-vous la transformation en contrat?"; + v_msgEng="Do you confirm the transformation into a contract?"; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + numeroOptionTarif = $("#numeroOptionTarif").val(); + donnees = 'idDevis='+idDevis+"&numeroOptionTarif="+numeroOptionTarif; + donnees += '&idClientExistant='+idClientExistant+"&dateEffetContrat="+dateEffetContrat; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxtransformerdevis/", + type: 'POST', + data: donnees, + success: function() { + }, + error: function(data) { + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Fichepolice/"); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + +function enregistrer_college_temp_d() +{ + + idCollegeTemp = $('#idCollegeTemp').val(); + codeProduit = $('#codeProduit').val(); + codeCollegeType = $('#codeCollegeType').val(); + codeReseau = $('#codeReseau').val(); + codeTypeRemboursement = $('#codeTypeRemboursement').val(); + codeTerritoire = $('#codeTerritoire').val(); + codeLienParente = $('#codeLienParente').val(); + libelleCollege = $('#libelleCollege').val(); + ticketModerateurCollege = $('#ticketModerateurCollege').val(); + + delaiCarenceCollege = $('#delaiCarenceCollege').val(); + plafondCollege = parseInt($('#plafondCollege').val().replace(/ /g,""),10); + + plafondAdherent = parseInt($('#plafondAdherent').val().replace(/ /g,""),10); + + idPolice = $('#idPolice').val(); + numeroPolice = $('#numeroPolice').val(); + accessoireManuel = parseInt($('#accessoireManuel').val().replace(/ /g,""),10); + rachatTm = $('#rachatTm').val(); + tauxRachatTm = $('#tauxRachatTm').val(); + tauxPrimeRachatTm = $('#tauxPrimeRachatTm').val(); + budgetDefini = "0"; + montantBudget = "0"; + nbAdherent = $('#nbAdherent').val(); + nbAyantdroit = $('#nbAyantdroit').val(); + codeTypeTarifActe = $('#codeTypeTarifActe').val(); + codeTarifActe = $('#codeTarifActe').val(); + codeGcAssureur = $('#codeGcAssureur').val(); + + codeGcAssureur = $('#codeGcAssureur').val(); + idBaremePriseEnCharge = $('#idBaremePriseEnCharge').val(); + + codeBaseTarification = $('#codeBaseTarification').val(); + + seuilRdCollege = $('#seuilRdCollege').val(); + + numeroOptionTarif = $('#numeroOptionTarif').val(); + + + + forfaitHonoraire = 0; //parseInt($('#forfaitHonoraire').val().replace(/ /g,""),10); + forfaitAppelFond = 0; //parseInt($('#forfaitAppelFond').val().replace(/ /g,""),10); + forfaitAppelCotisation = 0; // parseInt($('#forfaitAppelCotisation').val().replace(/ /g,""),10); + + ticketModerateurHorsReseau = $('#ticketModerateurHorsReseau').val(); + ageLimiteEnfantEleve = $('#ageLimiteEnfantEleve').val(); + + donnees = 'id='+idCollegeTemp+'&codeProduit='+codeProduit+'&codeCollegeType='+codeCollegeType+'&codeReseau='+codeReseau; + donnees += '&codeTypeRemboursement='+codeTypeRemboursement+'&codeTerritoire='+codeTerritoire+'&codeLienParente='+codeLienParente; + donnees += '&libelleCollege='+libelleCollege+'&ticketModerateurCollege='+ticketModerateurCollege+'&delaiCarenceCollege='+delaiCarenceCollege; + donnees += '&plafondCollege='+plafondCollege+'&idPolice='+idPolice+'&numeroPolice='+numeroPolice+'&accessoireManuel='+accessoireManuel; + donnees += '&rachatTm='+rachatTm+'&tauxRachatTm='+tauxRachatTm+'&tauxPrimeRachatTm='+tauxPrimeRachatTm+'&budgetDefini='+budgetDefini; + donnees += '&montantBudget='+montantBudget+'&nbAdherent='+nbAdherent+'&nbAyantdroit='+nbAyantdroit+'&codeTypeTarifActe='+codeTypeTarifActe; + donnees += '&codeTarifActe='+codeTarifActe+'&codeGcAssureur='+codeGcAssureur+'&idBaremePriseEnCharge='+idBaremePriseEnCharge; + donnees += '&codeBaseTarification='+codeBaseTarification+'&seuilRdCollege='+seuilRdCollege+'&plafondAdherent='+plafondAdherent; + + //donnees += '&forfaitHonoraire='+forfaitHonoraire+'&forfaitAppelFond='+forfaitAppelFond+'&forfaitAppelCotisation='+forfaitAppelCotisation; + donnees += '&forfaitHonoraire='+forfaitHonoraire+'&forfaitAppelFond='+forfaitAppelFond+'&forfaitAppelCotisation='+forfaitAppelCotisation; + donnees += '&ticketModerateurHorsReseau='+ticketModerateurHorsReseau+'&ageLimiteEnfantEleve='+ageLimiteEnfantEleve; + donnees += '&numeroOptionTarif='+numeroOptionTarif; + + //console.log(donnees); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxgarantiescolleged/enregistrercollegelienparentetemp/", + type: 'POST', + data: donnees, + success: function(data) + { + + }, + complete: function(data) + { + } + }); +} + +function change_categorie_college_temp_d() +{ + codeProduit = $('#codeProduit').val(); + + codeLienParente = "A"; + + codeBaseTarification = $('#codeBaseTarification').val(); + + + if($('#codeProduit').val()<=" ") + { + v_msg="Veuillez sélectionner un produit!"; + v_msgEng="Please select a category!"; + alert_ebene(v_msg, v_msgEng); + + $('#codeProduit').focus(); + return; + } + + + if(codeBaseTarification=="AUC") + { + $("#div_prime_categorie").empty(); + $("#div_recapituler").empty(); + + return; + } + + donnees = 'codeProduit='+codeProduit+'&codeBaseTarification='+codeBaseTarification; + + $("#div_prime_categorie").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxprimescategoried/", + type: 'POST', + data: donnees, + success: function(data) + { + // + $("#div_prime_categorie").html(data); + + enregistrer_college_temp_d(); + recapitulercollege_d(); + }, + error : function(resultat, statut, erreur) + { + }, + complete: function(data) + { + + } + }); +} + +function init_prime_college_temp_d() +{ + codeProduit = $("#codeProduit").val(); + + donnees = 'codeProduit='+codeProduit; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxprimescategoried/initprimelienparente/", + type: 'POST', + data: donnees, + success: function(data) { + + + }, + error: function(data) { + }, + complete: function() { + + } + }); + +} + +function init_trancheage_college_temp_d() +{ + codeProduit = $("#codeProduit").val(); + + donnees = 'codeProduit='+codeProduit; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxprimescategoried/inittrancheage/", + type: 'POST', + data: donnees, + success: function(data) { + + + }, + error: function(data) { + }, + complete: function() { + + } + }); + +} + +function init_prime_college_base_tarif_d() +{ + + codeProduit = $("#codeProduit").val(); + codeBaseTarification = $("#codeBaseTarification").val(); + + donnees = 'codeProduit='+codeProduit+'&codeBaseTarification='+codeBaseTarification; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxprimescategoried/initprimebasetarif/", + type: 'POST', + data: donnees, + success: function(data) { + + + }, + error: function(data) { + }, + complete: function() { + + } + }); + +} + +function init_bareme_d() +{ + idBaremePriseEnCharge = $("#idBaremePriseEnCharge").val(); + + donnees = 'idBaremePriseEnCharge='+idBaremePriseEnCharge; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxplafondfamilleproduitd/initbareme/", + type: 'POST', + data: donnees, + success: function(data) + { + + }, + error: function(data) { + }, + complete: function() { + + } + }); + +} + +function recapitulercollege_d(){ + idCollegeTemp = $('#idCollegeTemp').val(); + codeProduit = $('#codeProduit').val(); + codeCollegeType = $('#codeCollegeType').val(); + codeReseau = $('#codeReseau').val(); + codeTypeRemboursement = $('#codeTypeRemboursement').val(); + codeTerritoire = $('#codeTerritoire').val(); + codeLienParente = $('#codeLienParente').val(); + libelleCollege = $('#libelleCollege').val(); + ticketModerateurCollege = $('#ticketModerateurCollege').val(); + delaiCarenceCollege = $('#delaiCarenceCollege').val(); + plafondCollege = parseInt($('#plafondCollege').val().replace(/ /g,""),10); + + plafondAdherent = parseInt($('#plafondAdherent').val().replace(/ /g,""),10); + + idPolice = $('#idPolice').val(); + numeroPolice = $('#numeroPolice').val(); + accessoireManuel = parseInt($('#accessoireManuel').val().replace(/ /g,""),10); + rachatTm = $('#rachatTm').val(); + tauxRachatTm = $('#tauxRachatTm').val(); + tauxPrimeRachatTm = $('#tauxPrimeRachatTm').val(); + budgetDefini = "0"; + montantBudget = "0"; + nbAdherent = $('#nbAdherent').val(); + nbAyantdroit = $('#nbAyantdroit').val(); + codeTypeTarifActe = $('#codeTypeTarifActe').val(); + codeTarifActe = $('#codeTarifActe').val(); + codeGcAssureur = $('#codeGcAssureur').val(); + idBaremePriseEnCharge = $('#idBaremePriseEnCharge').val(); + codeBaseTarification = $('#codeBaseTarification').val(); + seuilRdCollege = $('#seuilRdCollege').val(); + plafondAdherent = $('#plafondAdherent').val(); + + /* + forfaitHonoraire = parseInt($('#forfaitHonoraire').val().replace(/ /g,""),10); + forfaitAppelFond = parseInt($('#forfaitAppelFond').val().replace(/ /g,""),10); + forfaitAppelCotisation = parseInt($('#forfaitAppelCotisation').val().replace(/ /g,""),10); + */ + + + forfaitHonoraire = 0; //parseInt($('#forfaitHonoraire').val().replace(/ /g,""),10); + forfaitAppelFond = 0; //parseInt($('#forfaitAppelFond').val().replace(/ /g,""),10); + forfaitAppelCotisation = 0; //parseInt($('#forfaitAppelCotisation').val().replace(/ /g,""),10); + + numeroOptionTarif = $('#numeroOptionTarif').val(); + + + if(codeBaseTarification <=" " || codeBaseTarification ==undefined) + { + v_msg="Veuillez sélectionner la base de tarification!"; + v_msgEng="Please select pricing basis!"; + alert_ebene(v_msg, v_msgEng); + + $('#codeBaseTarification').focus(); + return; + } + + $('#div_recapituler').html('
' + '
'); + + + donnees = 'id='+idCollegeTemp+'&codeProduit='+codeProduit+'&codeCollegeType='+codeCollegeType+'&codeReseau='+codeReseau; + donnees += '&codeTypeRemboursement='+codeTypeRemboursement+'&codeTerritoire='+codeTerritoire+'&codeLienParente='+codeLienParente; + donnees += '&libelleCollege='+libelleCollege+'&ticketModerateurCollege='+ticketModerateurCollege+'&delaiCarenceCollege='+delaiCarenceCollege; + donnees += '&plafondCollege='+plafondCollege+'&idPolice='+idPolice+'&numeroPolice='+numeroPolice+'&accessoireManuel='+accessoireManuel; + donnees += '&rachatTm='+rachatTm+'&tauxRachatTm='+tauxRachatTm+'&tauxPrimeRachatTm='+tauxPrimeRachatTm+'&budgetDefini='+budgetDefini; + donnees += '&montantBudget='+montantBudget+'&nbAdherent='+nbAdherent+'&nbAyantdroit='+nbAyantdroit+'&codeTypeTarifActe='+codeTypeTarifActe; + donnees += '&codeTarifActe='+codeTarifActe+'&codeGcAssureur='+codeGcAssureur+'&idBaremePriseEnCharge='+idBaremePriseEnCharge+'&codeBaseTarification='+codeBaseTarification; + donnees += '&seuilRdCollege='+seuilRdCollege+'&plafondAdherent='+plafondAdherent; + + //donnees += '&forfaitHonoraire='+forfaitHonoraire+'&forfaitAppelFond='+forfaitAppelFond+'&forfaitAppelCotisation='+forfaitAppelCotisation; + donnees += '&forfaitHonoraire='+forfaitHonoraire+'&forfaitAppelFond='+forfaitAppelFond+'&forfaitAppelCotisation='+forfaitAppelCotisation; + donnees += '&numeroOptionTarif='+numeroOptionTarif; + //console.log(donnees); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxrecapitulercolleged/recapituler/", + type: 'POST', + data: donnees, + success: function(data) + { + $('#div_recapituler').empty(); + $('#div_recapituler').html(data); + }, + complete: function(data) + { + enregistrer_college_temp_d(); + + actualisercollege_temp_d(); + } + }); + +} + +function affiche_garanties_par_statut_d() +{ + codeLienParente=$("#codeLienParente").val(); + + if($('#codeLienParente').val()<=" ") + { + v_msg="Veuillez revoir le status!"; + v_msgEng="Please review the status"; + alert_ebene(v_msg, v_msgEng); + + $('#codeLienParente').focus(); + return; + } + + donnees = 'codeLienParente='+codeLienParente; + + //$("#div_garanties_status").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxgarantiescolleged/", + type: 'POST', + data: donnees, + success: function(data) + { + $("#div_garanties_status").html(data); + + + }, + complete: function(data) + { + enregistrer_college_temp_d(); + } + }); +} + +function actualisercollege_temp_d(){ + + donnees = "" + $.ajax({ + url: $("#racineWeb").val()+"Ajaxmajcolleged/", + type: 'POST', + data: donnees, + success: function(data) + { + $('#div_majcollege').empty(); + $('#div_majcollege').html(data); + $('.selectpicker').selectpicker(); + }, + complete: function(data) + { + + } + }); + +} + +function calculer_prime_inmportation_devis() +{ + nb_adh=$("#nb_adh").val(); + + if (nb_adh>"0") + { + v_msg="Veuillez lier toutes les famille à leur collège!"; + v_msgEng="Please link all the family to their college!"; + alert_ebene(v_msg, v_msgEng); + + return; + } + + v_msg="Confirmez-vous le calcul de primes?"; + v_msgEng="Do you confirm the premium calculation?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + var div_attente = $('#div_liste_assure_importe'); + + div_attente.html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaximporterlisteassuredevis/calculerprimeimportee/", + type: 'POST', + // data: donnees, + success: function(data) { + v_msg="Calcul de primes terminée avec succès!"; + v_msgEng="Premium calculation completed successfully!"; + alert_ebene(v_msg, v_msgEng); + }, + error: function(data) { + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Listeimportassuredevis/"); + } + }); + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); +} + + +function filtreadherentparcollege_d() +{ + + + var idCollegePolice = $('#idCollegePolice').val(); + + if(idCollegePolice ==""){ + idCollegePolice = "0"; + } + + donnees = 'idCollegePolice='+idCollegePolice; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxfiltreadherentparcollegedevis/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + afficher_adherents_devis(); + }, + complete: function() { + + } + }); + +} + +function transformer_client_d(idClient) +{ + donnees = 'idClient='+idClient; + + v_msg="Confirmez-vous la transformation de ce client en prospect?"; + v_msgEng="Do you confirm the transformation of this customer into a prospect?"; + + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlisterprospects/transformer/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + $('#div_prospect').html(data); + + idProspect = $("#idProspect").val(); + numeroProspect = $("#numeroProspect").val(); + + $("#idClient_d_C").val(idProspect); + $("#numeroClient_d_C").val(numeroProspect); + + if (idProspect>"") + { + ajax_context_client_d_afficher(idProspect); + } + }, + complete: function() { + + } + }); + + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +function filtre_facture_abonnement() +{ + codeExercice = $("#codeExercice").val(); + + donnees = 'codeExercice='+codeExercice; + + + var div_attente = $('#div_facture'); + + div_attente.html('
' + '
'); + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistefacturesabonnement/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + div_attente.html(data); + }, + complete: function() { + + } + }); +} + +function facture_impayees_abonnement() +{ + + + donnees = ""; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistefacturesabonnement/listeimpayees/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + $('#div_impayees').html(data); + }, + complete: function() { + $("#btn_modal").click(); + } + }); + +} + +function select_toutes_factures_impayees(p_choix) +{ + + + donnees = 'choix='+p_choix; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistefacturesabonnement/selectiontoutes/", + type: 'POST', + data: donnees, + success: function(data) { + + $('#div_impayees').html(data); + + }, + error: function(data) { + }, + complete: function() { + + //affichertoutfacturationprime(); + } + }); +} + +function select_une_facture_impayee(p_choix, id) +{ + donnees = 'id='+id; + donnees += '&choix='+p_choix; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistefacturesabonnement/selectionneune/", + type: 'POST', + data: donnees, + success: function(data) { + $('#div_impayees').html(data); + + + }, + error: function(data) { + }, + complete: function() { + + } + }); +} + +function affiche_montant_a_payer_saas() +{ + donnees = ""; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistefacturesabonnement/montantapayer/", + type: 'POST', + data: donnees, + success: function(data) { + $('#div_historique').html(data); + }, + error: function(data) { + }, + complete: function() { + + } + }); + +} + +function proceder_paiement_saas() +{ + window.location.assign($("#racineWeb" ).val()+"Payerabonnement/"); +} + +function maj_facture_payer_saas() +{ + donnees = ""; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxlistefacturesabonnement/majfacturespayees/", + type: 'POST', + data: donnees, + success: function(data) { + + }, + error: function(data) { + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Abonnement/"); + } + }); + +} + +function filtreproduitexclusion(){ + + + var codeGcAssureur = $('#codeGcAssureur').val(); + + if(codeGcAssureur<=" "){ + $('#div_actesproduit').html(""); + } + + donnees = 'codeGcAssureur='+codeGcAssureur; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxfiltreproduitexclusion/", + type : 'post', + data: donnees, + error: function(errorData){ + //alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + // + $('#div_produit').html(data); + + $("#codeProduit").selectpicker(); + }, + complete: function() { + + } + }); + +} + +function modifier_lien_parente(idLien) +{ + donnees = 'idLien='+idLien; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparamlienparente/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) + { + // 1. Injecter le contenu dans le conteneur de la modale + $('#div_maj_lien').html(data); + + // 2. Initialiser et afficher la modale Bootstrap + var myModal = new bootstrap.Modal(document.getElementById('div_maj_lien')); + myModal.show(); + } + + }); +} + +function enregistrer_modif_lien_parente() +{ + idLien = $("#idLien").val(); + enVigueur = $("#enVigueur").val(); + + + donnees = 'idLien='+idLien+'&enVigueur='+enVigueur; + + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparamlienparente/historiser/", + type : 'post', + data: donnees, + error: function(errorData) { + }, + success: function(data) + { + //alert("Success : "+data); + // + + v_msg="Mis à jour effectuée avec succès!"; + v_msgEng="Updated successfully!"; + alert_ebene(v_msg, v_msgEng); + }, + complete: function() + { + window.location.assign($("#racineWeb" ).val()+"Paramlienparente/"); + } + }); +} + +function activation_prestataire(codePrestataire){ + + let idPrestataire = $('#idPrestataire').val(); + + $("#div_patienter").html('
' + '
'); + + donnees = 'codePrestataire='+codePrestataire; + donnees += '&idPrestataire='+idPrestataire; + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxactivationprestataire/", + type : 'post', + data: donnees, + error: function(errorData){ + alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + $("#div_patienter").html(''); + $('#div_activation').html(data); + //appliquerDataTable(); + $('#div_activation').modal("show"); + + }, + complete: function() { + + } + }); +} + +function historique_activation_prestataire(codePrestataire) +{ + donnees = 'codePrestataire='+codePrestataire; + + $("#div_historique").html('
' + '
'); + + $.ajax({ + url: $("#racineWeb").val()+"Ajaxactivationprestataire/historique/", + type : 'post', + data: donnees, + error: function(errorData){ + alert("Erreur : "+errorData); + }, + success: function(data) { + //alert("Success : "+data); + $('#div_historique').html(data); + }, + complete: function() { + retour_prestataire_id(); + } + }); +} + +function maj_authentification_otp() +{ + activerOtp = $("#activerOtp").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?"; + } + + donnees = 'activerOtp='+activerOtp; + + confirm_ebene(v_msg, v_msgEng) + .then((isConfirmed) => { + if (isConfirmed) { + // L'utilisateur a confirmé + $.ajax({ + url: $("#racineWeb").val()+"Ajaxparametresgeneraux/majauthentification/", + type: 'POST', + data: donnees, + success: function(data) { + $("#div_complexite_pass").html(data); + v_msg="Mise à jour effectuée avec succès!"; + v_msgEng="Update done successfully!"; + alert_ebene(v_msg, v_msgEng); + }, + error: function(data) { + }, + complete: function() { + window.location.assign($("#racineWeb" ).val()+"Paramreinitmotpass/"); + } + }); + + } else { + // L'utilisateur a annulé + console.log("Confirmation refusée"); + } + }); + +} + +// 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(); + var racineWeb = $("#racineWeb").val(); + + if (codeProduit <= " ") { + $('#div_parametres').html('

Veuillez sélectionner un produit.

'); + return; + } + + // Loader Standard + $("#div_parametres").html( + '
' + + '
' + + 'Chargement...
' + ); + + $.ajax({ + url: racineWeb + "Ajaxparametreproduitgarant/", + type: 'post', + data: { codeProduit: codeProduit }, + success: function(data) { + $('#div_parametres').hide().html(data).fadeIn(); + }, + error: function() { + $('#div_parametres').html('
Erreur lors du chargement des paramètres.
'); + } + }); +} + +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 (Version ESI Optimisée) + * @param {string} selector - Sélecteur CSS de la table + * @param {string} pageTitle - Titre pour les exports PDF/Excel + * @param {boolean|array} defaultOrder - [1, 'desc'] ou false pour l'ordre serveur + * @param {boolean} showButtons - Affiche ou masque les boutons d'export (Défaut: true) + */ +function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Données', defaultOrder = false, showButtons = true) { + if ($(selector).length === 0) return; + + var hasGlobalSearch = $('#globalSearch').length > 0; + + if ($.fn.DataTable.isDataTable(selector)) { + $(selector).DataTable().destroy(); + } + + // Structure du DOM : B=Buttons, f=Filter, t=Table, i=Info, p=Pagination + // ms-auto pousse la recherche à l'extrême droite + 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 p-3 border-bottom"' + (showButtons ? 'B' : '') + '<"ms-auto"f>>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>'; + + var orderConfig = (defaultOrder === false) ? [] : defaultOrder; + + var table = $(selector).DataTable({ + "dom": domStructure, + "order": orderConfig, + "pagingType": "full_numbers", // Indispensable pour afficher First et Last + "buttons": showButtons ? [ + { + extend: 'excelHtml5', + text: 'Excel', + className: 'btn btn-success btn-sm fw-bold border-0 shadow-sm px-3', + title: pageTitle, + exportOptions: { columns: ':not(.no-export)' } + }, + { + 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', + exportOptions: { columns: ':not(.no-export)' }, + customize: function(doc) { + if (doc.content[1].table) { + doc.content[1].table.widths = Array(doc.content[1].table.body[0].length).fill('*'); + } + doc.styles.tableHeader.alignment = 'center'; + doc.defaultStyle.alignment = 'center'; + } + } + ] : [], + "language": { + "url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json", + "search": "", + "searchPlaceholder": "Rechercher...", + "paginate": { + "first": '', + "last": '', + "next": '', + "previous": '' + } + }, + "pageLength": 10, + "autoWidth": false, + "drawCallback": function() { + // Style de l'input de recherche (si pas de recherche globale) + if (!hasGlobalSearch) { + $('.dataTables_filter input') + .addClass('form-control form-control-sm shadow-none border-primary-subtle') + .css({ + 'width': '200px', + 'border-radius': '20px', + 'padding-left': '15px' + }); + } + + // Style des boutons de pagination (btn-xs et marges) + $('.dataTables_paginate .paginate_button').addClass('btn btn-xs mx-1'); + + // Correction visuelle : on s'assure que les icônes sont bien centrées + $('.dataTables_paginate .paginate_button').css({ + 'display': 'inline-flex', + 'align-items': 'center', + 'justify-content': 'center', + 'min-width': '30px', + 'height': '30px' + }); + } + }); + + // Gestion de la recherche globale si elle existe + 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'); +} + +/** + * Initialise une DataTable standard pour les tables de référence + * @param {string} selector - L'ID ou la classe de la table (ex: '#tableLister') + * @param {string} exportTitle - Le nom du fichier lors de l'export + * @param {boolean|array} defaultOrder - Exemple: [1, 'desc'] ou false pour garder l'ordre serveur + */ +function initDataTableReference(selector, exportTitle = 'Export_Donnees', defaultOrder = false) { + const codeLangue = $("#codeLangue").val(); + + // Objet de traduction interne + const langConfig = (codeLangue === "en_US") ? { + search: "Search:", + lengthMenu: "Show _MENU_ entries", + info: "Showing _START_ to _END_ of _TOTAL_ entries", + infoEmpty: "Showing 0 to 0 of 0 entries", + infoFiltered: "(filtered from _MAX_ total entries)", + zeroRecords: "No matching records found", + paginate: { next: "Next", previous: "Previous" } + } : { + search: "Recherche :", + lengthMenu: "Afficher _MENU_ lignes", + info: "Affichage de _START_ à _END_ sur _TOTAL_ lignes", + infoEmpty: "Affichage de 0 à 0 sur 0 ligne", + infoFiltered: "(filtré de _MAX_ lignes au total)", + zeroRecords: "Aucune donnée trouvée", + paginate: { next: "Suivant", previous: "Précédent" } + }; + + if ($.fn.DataTable.isDataTable(selector)) { + $(selector).DataTable().destroy(); + } + + // Gestion du tri par défaut (false = pas de tri forcé) + const orderConfig = (defaultOrder === false) ? [] : defaultOrder; + + const table = $(selector).DataTable({ + dom: 'frtip', + responsive: true, + pageLength: 10, + order: orderConfig, // <-- Application de la configuration de tri + language: langConfig, + buttons: [ + { + extend: 'excelHtml5', + text: ' Excel', + className: 'btn btn-sm btn-success-light border-success fw-bold text-success rounded-pill shadow-xs', + title: exportTitle, + exportOptions: { columns: ':not(:last-child)' } + }, + { + extend: 'pdfHtml5', + text: ' PDF', + className: 'btn btn-sm btn-danger-light border-danger fw-bold text-danger rounded-pill shadow-xs', + title: exportTitle, + exportOptions: { columns: ':not(:last-child)' }, + customize: function (doc) { + doc.styles.tableHeader.fillColor = '#212e53'; + doc.styles.tableHeader.color = 'white'; + doc.content[1].table.widths = Array(doc.content[1].table.body[0].length + 1).join('*').split(''); + } + } + ], + drawCallback: function() { + const info = this.api().page.info(); + const label = (codeLangue === "en_US") ? " Lines" : " Lignes"; + $("#badge-total").text(info.recordsTotal + label); + } + }); + + table.buttons().container().appendTo('#table-buttons'); + return table; +} + +function ajouter_utilisateur_gc() +{ + window.location.assign($("#racineWeb" ).val()+"Creerusergc/"); +} + +function nouveau_produit() +{ + window.location.assign($("#racineWeb" ).val()+"Nouveauproduit/"); +} + +function actualiser_garantie_produit() { + // 1. Définition des constantes et cibles + const codeGcAssureur = $("#codeGcAssureur").val(); + const codeProduit = $("#codeProduit").val(); + const div_cible = $('#div_garantieproduit'); + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + + // 2. Validation du Garant via alert_ebene + if (!codeGcAssureur || codeGcAssureur.trim() === "") { + let v_msg = "Garant manquant ! Veuillez sélectionner un garant pour continuer."; + let v_msg_eng = "Guarantor missing ! Please select a guarantor to continue."; + + alert_ebene(v_msg, v_msg_eng); + + $("#codeGcAssureur").focus(); + div_cible.html(""); + return; + } + + // 3. Validation du Produit via alert_ebene + if (!codeProduit || codeProduit.trim() === "") { + let v_msg = "Produit manquant ! Veuillez sélectionner un produit."; + let v_msg_eng = "Product missing ! Please select a product."; + + alert_ebene(v_msg, v_msg_eng); + + div_cible.html(""); + return; + } + + // 4. Préparation et affichage du loader bilingue + const donnees = { codeProduit: codeProduit }; + let loadingTxt = (codeLangue === "en_US") ? "Loading the entry form..." : "Chargement du formulaire de saisie..."; + + div_cible.html(` +
+
+ Loading... +
+
${loadingTxt}
+
+ `); + + // 5. Exécution de la requête AJAX + $.ajax({ + url: racineWeb + "Ajaxparamseuilalerte/actualisegarantieproduit/", + type: 'post', + data: donnees, + success: function(data) { + div_cible.html(data); + }, + error: function() { + let errorTxt = (codeLangue === "en_US") ? "Technical error while retrieving the form." : "Erreur technique lors de la récupération du formulaire."; + div_cible.html(` + + `); + } + }); +} + +let timerDispo, timerAffect; +/** + * Recherche Serveur Multi-critères + * @param {string} target - 'dispo' ou 'affect' + */ +function rechercheServeur(target) { + // 1. Récupération des critères selon la colonne + let nom = $("#search_nom_" + target).val(); + let ville = $("#search_ville_" + target).val(); + let type = $("#search_type_" + target).val(); + let query = (nom + " " + ville + " " + type).trim(); + + // 2. Sécurité : On ne lance rien si c'est trop court (sauf si vide pour réinitialiser) + if (query.length > 0 && query.length < 3) return; + + // 3. Gestion du Timer (Debounce) + let timer = (target === 'dispo') ? timerDispo : timerAffect; + clearTimeout(timer); + + let currentTimer = setTimeout(function() { + let action = (target === 'dispo') ? 'rechercherdispos' : 'rechercheraffectes'; + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxprestatairesreseau/" + action + "/", + type: 'post', + data: { query: query }, + beforeSend: function() { + $("#count_" + target).html(''); + }, + success: function(data) { + // On remplace le corps du tableau + $("#tab_" + target + " tbody").html(data); + + // Mise à jour du compteur de lignes + let nbre = $("#tab_" + target + " tbody tr").length; + $("#count_" + target).text(nbre); + } + }); + }, 400); + + // Mise à jour de la référence du timer + if (target === 'dispo') timerDispo = currentTimer; + else timerAffect = currentTimer; +} + +// On initialise le tableau global s'il n'existe pas +if (typeof tab === 'undefined') { + var tab = { "libelle": "BAREME", "client": "", "taux": "", "territoire": "", "produit": "" }; +} + +function filtresouscripteur() { + const codeGcAssureur = $('#codeGcAssureur').val(); + + $.ajax({ + url: $("#racineWeb").val() + "Ajaxfiltresouscripteur/", + type: 'post', + data: { codeGcAssureur: codeGcAssureur }, + success: function(data) { + // Injection du HTML + $('#div_souscripteur').html(data); + + // Réactivation Neutral Pro + actualiserSelectPicker('#numeroClient'); + + // On vide la valeur dans le tableau et on rafraîchit le libellé + tab["client"] = ""; + libelleBareme(); + } + }); +} + +function filtreproduitcreerbareme() { + const codeGcAssureur = $('#codeGcAssureur').val(); + + if (codeGcAssureur !== "") { + $.ajax({ + url: $("#racineWeb").val() + "Ajaxfiltreproduit/creerbareme/", + type: 'post', + data: { codeGcAssureur: codeGcAssureur }, + success: function(data) { + $('#div_produit').html(data); + + // Réactivation Neutral Pro + actualiserSelectPicker('#codeProduit'); + + tab["produit"] = ""; + libelleBareme(); + } + }); + } +} + +// Version sécurisée de la construction du libellé +function libelleBareme() { + // On nettoie les undefined pour éviter d'afficher "undefined" dans l'input + const parts = [ + tab["libelle"] || "BAREME", + tab["client"] || "", + tab["taux"] || "", + tab["territoire"] || "", + (tab["produit"] ? "- " + tab["produit"] : "") + ]; + + // On joint les éléments avec un espace et on nettoie les doubles espaces + const finalLibelle = parts.filter(p => p !== "").join(' ').replace(/\s\s+/g, ' '); + $('#libelle').val(finalLibelle.trim().toUpperCase()); +} + +function libelleClientBareme(controle) { + // Si l'option vide est choisie, on ne met rien + tab["client"] = (controle.value === "") ? "" : $(controle).find('option:selected').text(); + libelleBareme(); +} + +function libelleProduitBareme(controle) { + tab["produit"] = (controle.value === "") ? "" : $(controle).find('option:selected').text(); + libelleBareme(); +} + +function libelleTauxBareme(controle) { + tab["taux"] = $(controle).find('option:selected').text(); + libelleBareme(); +} + +function libelleTerritoireBareme(codeTerritoire) { + // On peut mapper le code à un nom si besoin, ou utiliser le code directement + tab["territoire"] = codeTerritoire; + libelleBareme(); +} + +function retour_bereme_initial() +{ + idBaremePriseEnCharge=$("#idBaremePriseEnCharge").val(); + + if (idBaremePriseEnCharge>"0") + { + detail_baremepriseencharge(idBaremePriseEnCharge); + } +} + +/** + * Contrôle la validité chronologique de la date d'effet pour une Lettre Clé + */ +function validiteDateEffetBaremeLettreCle() { + // 1. Collecte des informations + const racineWeb = $("#racineWeb").val(); + const dateEffetSaisieStr = $("#dateEffetActe").val(); + const dateJourSystemeStr = $("#datejour_C").val(); // Format YYYY-MM-DD + + const donneesControle = { + idBaremePriseEnCharge: $("#idBaremePriseEnCharge").val(), + lettreCle: $("#lettreCle").val() + }; + + // Validation immédiate : Lettre clé obligatoire + if (!donneesControle.lettreCle || donneesControle.lettreCle.trim() === "") { + alert_ebene("Veuillez sélectionner une lettre clé !", "Please select a key letter !"); + return; + } + + // Validation immédiate : Date obligatoire + if (!dateEffetSaisieStr || dateEffetSaisieStr.trim() === "") { + alert_ebene("Veuillez entrer une date d'effet !", "Please enter an effective date !"); + $("#dateEffetActe").focus(); + return; + } + + // 2. Préparation des objets Date + const parts = dateEffetSaisieStr.split('/'); + const dateEffetSaisie = new Date(parts[2], parts[1] - 1, parts[0]); + const dateJourSysteme = new Date(dateJourSystemeStr); + + // 3. Appel AJAX de contrôle + $.ajax({ + url: racineWeb + "Ajaxbaremelettrecle/controle/", + type: 'post', + data: donneesControle, + success: function(data) { + // Injection du champ hidden maxDateEffetActeBareme retourné par le serveur + $('#div_maxdateeffetactebareme').html(data); + + const maxDateBaseStr = $("#maxDateEffetActeBareme").val(); + + // Calcul des timestamps en jours (pour une comparaison fiable) + const dte = Math.round(dateEffetSaisie.getTime() / (1000 * 3600 * 24)); + const dtj = Math.round(dateJourSysteme.getTime() / (1000 * 3600 * 24)); + + // 4. Logique de validation chronologique + if (dte < dtj && maxDateBaseStr) { + const maxDateBase = new Date(maxDateBaseStr); + const dtm = Math.round(maxDateBase.getTime() / (1000 * 3600 * 24)); + + if (dte < dtm) { + // Date invalide car antérieure à la dernière modification connue + alert_ebene( + "Date d'effet invalide ! Elle ne peut être antérieure à la dernière mise à jour de cette lettre clé.", + "Invalid effective date ! It cannot be earlier than the last update of this key letter." + ); + $("#dateEffetActe").val('').focus(); + return; + } + } + + // 5. Validation réussie : Passage à l'insertion + if (typeof inserer_bareme_lettre_cle === 'function') { + inserer_bareme_lettre_cle(); + } + }, + error: function() { + alert_ebene("Erreur lors de la vérification de la date.", "Error during date verification."); + } + }); +} + +/** + * Insère une nouvelle ligne de barème pour une lettre clé après confirmation + */ +function inserer_bareme_lettre_cle() { + // 1. Récupération des éléments d'environnement + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + const $conteneurDetail = $("#div_detail_bareme"); + + // 2. Collecte et nettoyage des données + const donnees = { + idBaremePriseEnCharge: $("#idBaremePriseEnCharge").val(), + lettreCle: $("#lettreCle").val(), + dateEffetActe: $("#dateEffetActe").val(), + forfaitPlafondActe: $("#forfaitPlafondActe").val().replace(/\s/g, ""), // Supprime tous les types d'espaces + ticketModerateurActe: $("#ticketModerateurActe").val() + }; + + // 3. Validations de saisie + if (!donnees.lettreCle || donnees.lettreCle.trim() === "") { + alert_ebene("Veuillez entrer une lettre clé !", "Please enter a key letter !"); + $("#lettreCle").focus(); + return; + } + + if (!donnees.dateEffetActe || donnees.dateEffetActe.trim() === "") { + alert_ebene("Veuillez entrer une date d'effet !", "Please enter an effective date !"); + $("#dateEffetActe").focus(); + return; + } + + // Validation du montant (doit être supérieur à 0) + if (parseFloat(donnees.forfaitPlafondActe) <= 0 || donnees.forfaitPlafondActe === "") { + alert_ebene("Veuillez entrer un montant valide !", "Please enter a valid amount !"); + $("#forfaitPlafondActe").focus(); + return; + } + + // 4. Processus de confirmation et envoi + confirm_ebene("Confirmez-vous cette opération ?", "Do you confirm this transaction ?") + .then((isConfirmed) => { + if (isConfirmed) { + // Affichage du loader (SaaS UX) + const loadingTxt = (codeLangue === "en_US") ? "Processing..." : "Traitement en cours..."; + $conteneurDetail.html(` +
+
+
${loadingTxt}
+
+ `); + + // Appel AJAX + $.ajax({ + url: racineWeb + "Ajaxbaremelettrecle/ajouter/", + type: 'post', + data: donnees, // Envoi sous forme d'objet (plus propre) + success: function(response) { + // Actualisation de l'historique (table de détail) + if (typeof actualiser_bareme_acte_lettre_cle === 'function') { + actualiser_bareme_acte_lettre_cle(); + } + }, + error: function() { + alert_ebene("Erreur lors de l'enregistrement.", "Error during saving."); + } + }); + } + }); +} + +/** + * Actualise l'historique des barèmes par lettres clés + */ +function actualiser_bareme_acte_lettre_cle() { + // 1. Initialisation des variables d'environnement + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + const $conteneur = $('#div_detail_bareme'); + + const donnees = { + idBaremePriseEnCharge: $("#idBaremePriseEnCharge").val() + }; + + // 2. Feedback visuel de mise à jour (SaaS UX) + // On affiche un spinner discret pour indiquer le rafraîchissement + const refreshMsg = (codeLangue === "en_US") ? "Updating history..." : "Mise à jour de l'historique..."; + + $conteneur.html(` +
+
+ ${refreshMsg} +
+ `); + + // 3. Appel AJAX + $.ajax({ + url: racineWeb + "Ajaxbaremelettrecle/", + type: 'post', + data: donnees, + success: function(data) { + // Injection du nouveau contenu avec une transition fluide + $conteneur.hide().html(data).fadeIn(200); + }, + error: function(xhr, status, error) { + $conteneur.html(` +
+ + ${(codeLangue === "en_US") ? "Error refreshing data." : "Erreur lors du rafraîchissement des données."} +
+ `); + } + }); +} + +/** + * Récupère et affiche le détail des actes liés à une lettre clé dans une modale + * @param {number} idActesbaremeinitiallettrecle + * @param {string} lettreCle + */ +async function detail_baremeacte_lettre_cle(idInitial, lettre) { + // 1. On charge le contenu (qui va injecter le HTML dans la div) + // On attend que le HTML soit injecté avant de demander à Bootstrap d'afficher la modale + await chargerContenuDetailActe(idInitial, lettre); + + // 2. Une fois le contenu chargé, on ouvre la modale + // On utilise le sélecteur jQuery standard pour éviter "Illegal invocation" + $("#div_detail_bareme_actes").modal("show"); +} + +/** + * Charge ou actualise uniquement le contenu interne de la modale de détail + * sans manipuler l'état d'ouverture de la modale Bootstrap. + * * @param {number|string} idInitial - ID du barème initial (idActesbaremeinitiallettrecle) + * @param {string} lettre - La lettre clé concernée (ex: 'K', 'B', 'V') + */ +async function chargerContenuDetailActe(idInitial, lettre, mode = 'complet') { + const racineWeb = document.getElementById("racineWeb").value; + const url = `${racineWeb}Ajaxbaremelettrecle/detailactes/`; + + const formData = new FormData(); + formData.append("idActesbaremeinitiallettrecle", idInitial); + formData.append("lettreCle", lettre); + + try { + const response = await fetch(url, { method: "POST", body: formData }); + const html = await response.text(); + + if (mode === 'complet') { + document.getElementById("div_detail_bareme_actes").innerHTML = html; + } else { + // MODE REFRESH : On remplace uniquement le contenu du tableau + const parser = new DOMParser(); + const doc = parser.parseFromString(html, 'text/html'); + const nouveauContenu = doc.getElementById('div_table_detail_lettrecle'); + const zoneCible = document.getElementById('div_table_detail_lettrecle'); + + if (nouveauContenu && zoneCible) { + // On écrase le contenu actuel par le nouveau + zoneCible.innerHTML = nouveauContenu.innerHTML; + console.log("Zone cible actualisée."); + } else { + console.error("Erreur : Zone cible div_table_detail_lettrecle non trouvée."); + } + } + + // On recrée DataTable après l'injection + initDataTableDetail(); + + } catch (error) { + console.error("Erreur Fetch :", error); + } +} + +// Petite fonction pour éviter de dupliquer le code DataTable +function initDataTableDetail() { + const codeLangue = document.getElementById("codeLangue")?.value || 'fr_FR'; + + if ($.fn.DataTable.isDataTable('#table_detail_actes')) { + $('#table_detail_actes').DataTable().destroy(); + } + + $('#table_detail_actes').DataTable({ + "language": { + "url": codeLangue === "en_US" + ? "//cdn.datatables.net/plug-ins/1.13.6/i18n/en-GB.json" + : "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json" + }, + "pageLength": 10, + "responsive": true, + /* Explication du DOM : + - <'row' ... > : On crée une ligne Bootstrap + - <'col-md-6'l> : La colonne de gauche (50%) pour le 'l' (Length / Sélecteur de nombre de lignes) + - <'col-md-6 text-end'f> : La colonne de droite (50%) avec 'text-end' pour le 'f' (Filter / Recherche) + */ + "dom": "<'row mb-2'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6 text-end'f>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row mt-3'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 text-end'p>>" + }); +} + +/** + * Supprime un acte spécifique du détail d'une lettre clé + * @param {string} adminProd - Niveau d'autorisation + * @param {number} idActe - ID de la ligne à supprimer + */ +function supprimer_baremeacte_lettre_cle_detail(adminProd, idActe) { + if (String(adminProd) !== "1") { + alert_ebene("Vous n'êtes pas autorisé !", "You are not authorized!"); + return; + } + + confirm_ebene("Confirmez-vous cette suppression ?", "Do you confirm this deletion ?") + .then((isConfirmed) => { + if (isConfirmed) { + $.ajax({ + url: $("#racineWeb").val() + "Ajaxbaremelettrecle/supprimerdetailacte/", + type: 'post', + data: { idActe: idActe }, + // On s'assure que le succès du serveur déclenche l'actualisation + success: function(response) { + console.log("Suppression réussie côté serveur."); + + // 1. Récupération des IDs dans la modale + const idInitial = $("#idInitial_hidden").val(); + const lettre = $("#lettre_hidden").val(); + + // 2. Lancement du rafraîchissement CHIRURGICAL + // On ajoute un petit délai de sécurité pour laisser le temps à la DB + setTimeout(() => { + chargerContenuDetailActe(idInitial, lettre, 'refresh'); + }, 100); + }, + error: function() { + alert_ebene("Erreur lors de la suppression.", "Error during deletion."); + } + }); + } + }); +} + +/** + * Supprime une ligne de barème (historique principal) + * @param {string} adminProd - Niveau d'autorisation + * @param {number} idActe - ID de la ligne à supprimer + */ +function supprimer_baremeacte_lettre_cle(adminProd, idActe) { + // 1. Contrôle de sécurité strict + if (String(adminProd) !== "1") { + alert_ebene("Vous n'êtes pas autorisé !", "You are not authorized!"); + return; + } + + // 2. Demande de confirmation + confirm_ebene("Confirmez-vous cette suppression ?", "Do you confirm this deletion ?") + .then((isConfirmed) => { + if (isConfirmed) { + + // 3. Appel AJAX + $.ajax({ + url: $("#racineWeb").val() + "Ajaxbaremelettrecle/supprimer/", + type: 'post', + data: { idActe: idActe }, // Envoi sous forme d'objet pour plus de sécurité + success: function(response) { + // Optionnel : Vous pouvez ajouter un petit toast de succès ici + console.log("Suppression effectuée : ID " + idActe); + }, + error: function() { + alert_ebene("Erreur lors de la suppression.", "Error during deletion."); + }, + complete: function() { + // 4. Actualisation de la table principale + // On utilise un petit timeout pour laisser la base de données finaliser l'opération + setTimeout(() => { + actualiser_bareme_acte_lettre_cle(); + }, 100); + } + }); + } else { + console.log("Suppression annulée par l'utilisateur."); + } + }); +} \ No newline at end of file