/**
* INITIALISATION GÉNÉRALE
*/
/**
* Gère la pré-connexion via cookie (chargement du formulaire et focus intelligent).
* Récupère le login mémorisé et place le curseur dans le champ approprié.
*/
function connexion_cookie()
{
msgErreur=$("#msgErreur").val();
donnees = 'msgErreur='+msgErreur;
$.ajax({
url: $("#racineWeb").val()+"Ajaxconnexioncookie/",
type: 'POST',
data: donnees,
success: function(data)
{
$("#div_ajaxconnexion").html(data);
},
error: function(errorData)
{
},
complete: function()
{
var login = document.getElementById("login").value;
if (login>" ")
{
$("#mdp").focus();
}
else
{
$("#login").focus();
}
}
});
}
function toggleSidebar() {
document.body.classList.toggle('sidebar-collapsed');
}
$(function() {
// Initialisation des composants au chargement de la page
appliquerDataTable('.tabliste');
dataTableSpeciale();
let nomForm = $("#nomForm").val();
/*
if(nomForm == "remboursementClassic")
{
let filtre = "0";
d1 = $("#d1").val();
d2 = $("#d2").val();
lister_dossiers_classiques(filtre);
}
*/
});
function raffraichier_gabarit()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaxgabarit/",
success: function(data)
{
$("#div_ajaxgabarit").html(data);
codeSociete = $("#codeSociete_C").val();
vue = $("#vue").val();
if((codeSociete == undefined || codeSociete <= " ") && vue !="Connexion"){
const msg = "Votre session a expiré. Vous serez déconnecté.";
const msgEng = "Your session has expired. You will be disconnected.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
window.location.assign($("#racineWeb" ).val()+"Connexion/deconnecter/");
});
}
},
error: function(errorData)
{
// alert("Erreur : "+errorData);
},
complete: function()
{
$(".datepicker" ).datepicker();
// raffraichier_messagerie();
}
});
}
/**
* GESTION DU MENU BURGER
* Gère l'affichage mobile et la fermeture lors d'un clic extérieur.
*/
document.addEventListener('DOMContentLoaded', () => {
const burgerToggle = document.getElementById('burgerMenuToggle');
const burgerDropdown = document.getElementById('burgerDropdown');
if (burgerToggle && burgerDropdown) {
// Alterne la classe 'show' au clic sur le bouton
burgerToggle.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
burgerDropdown.classList.toggle('show');
});
// Ferme le menu si on clique n'importe où ailleurs sur le document
document.addEventListener('click', (e) => {
if (!e.target.closest('.burger-menu-container')) {
burgerDropdown.classList.remove('show');
}
});
// Empêche la fermeture si on clique à l'intérieur du menu lui-même
burgerDropdown.addEventListener('click', (e) => e.stopPropagation());
}
});
/**
* FORMATAGE DES MESSAGES (Responsive)
* Ajoute des balises pour forcer le retour à la ligne selon la taille d'écran.
*/
function formatMessageForSwal(message) {
if (!message) return '';
const screenWidth = window.innerWidth;
// Détermine la limite de caractères avant le saut de ligne
const maxLineLength = screenWidth < 576 ? 40 : (screenWidth < 768 ? 60 : 80);
if (message.length <= maxLineLength && !message.includes('\n')) return message;
const words = message.split(' ');
let lines = [];
let currentLine = '';
words.forEach(word => {
if ((currentLine + ' ' + word).length > maxLineLength && currentLine !== '') {
lines.push(currentLine);
currentLine = word;
} else {
currentLine = currentLine ? currentLine + ' ' + word : word;
}
});
if (currentLine) lines.push(currentLine);
return lines.join(' ');
}
/**
* AJUSTEMENT DYNAMIQUE SWEETALERT
* Redimensionne la popup et gère le scroll interne pour les longs textes.
*/
function adjustSwalContent() {
const popup = Swal.getPopup();
const title = Swal.getTitle();
const htmlContainer = Swal.getHtmlContainer();
if (popup && title) {
const screenWidth = window.innerWidth;
// Application de styles responsives directs
if (screenWidth < 576) {
Object.assign(popup.style, { maxWidth: '95vw', width: '95vw', margin: '10px' });
} else {
Object.assign(popup.style, { maxWidth: screenWidth < 768 ? '85vw' : '500px', width: '100%' });
}
// Gestion du scroll si le titre est trop grand
const maxTitleHeight = Math.min(window.innerHeight * 0.6, 400);
if (title.scrollHeight > maxTitleHeight) {
Object.assign(title.style, { overflowY: 'auto', maxHeight: maxTitleHeight + 'px', paddingRight: '10px' });
}
}
}
/**
* WRAPPER GÉNÉRIQUE SWEETALERT
* Centralise les paramètres communs pour alert_ebene, confirm_ebene, etc.
*/
function baseSwal(options) {
return Swal.fire({
...options,
customClass: {
popup: 'responsive-swal-popup',
title: 'responsive-swal-title',
htmlContainer: 'responsive-swal-html'
},
didOpen: (popup) => {
// Ajuste ton contenu responsive
adjustSwalContent(popup);
// Trouver le z-index le plus élevé parmi les modals ouverts
const highestModalZ = [...document.querySelectorAll('.modal.show')]
.map(m => parseInt(window.getComputedStyle(m).zIndex) || 1050)
.reduce((a, b) => Math.max(a, b), 1050);
// Forcer SweetAlert à passer au-dessus
const swalContainer = popup.closest('.swal2-container');
if (swalContainer) {
swalContainer.style.zIndex = highestModalZ + 50;
}
},
willOpen: () => { document.body.style.overflow = 'hidden'; },
willClose: () => { document.body.style.overflow = 'auto'; }
});
}
// 🔒 Fonction utilitaire pour fermer SweetAlert
function closeSwal() {
Swal.close();
}
/**
* ALERTE SIMPLE
* Affiche une information bilingue.
*/
async function alert_ebene(msgFr, msgEn) {
const codeLangue = document.querySelector("#codeLangue")?.value || "fr_FR";
const message = (codeLangue === "en_US") ? msgEn : msgFr;
// On attend que l'utilisateur clique sur OK avant de sortir
await baseSwal({
text: message,
icon: 'info',
confirmButtonText: (codeLangue === "en_US") ? "OK" : "D'accord",
allowOutsideClick: false,
allowEscapeKey: false
});
}
/*
function alert_ebene(msgFr, msgEn) {
const codeLangue = document.querySelector("#codeLangue")?.value || "fr_FR";
const message = (codeLangue === "en_US") ? msgEn : msgFr;
// Bloquant : l'utilisateur doit cliquer sur OK
window.alert(message);
}
*/
/**
* CONFIRMATION
* Affiche une boîte de dialogue Oui/Non et retourne une promesse.
*/
function confirm_ebene(p_msg, p_msg_eng) {
const codeLangue = $("#codeLangue").val();
const message = (codeLangue === "en_US") ? p_msg_eng : p_msg;
return baseSwal({
title: formatMessageForSwal(message),
icon: 'warning',
showCancelButton: true,
confirmButtonText: codeLangue === "en_US" ? 'Yes' : 'Oui',
cancelButtonText: codeLangue === "en_US" ? 'No' : 'Non'
}).then(result => result.isConfirmed);
}
/*
function confirm_ebene(p_msg, p_msg_eng)
{
codeLangue = $("#codeLangue").val();
if(codeLangue=="en_US")
{
return confirm(p_msg_eng);
}
else
{
return confirm(p_msg);
}
}
*/
/**
* SAISIE TEXTE (PROMPT)
* Ouvre une modale avec champ de saisie et exécute un callback avec la valeur.
*/
function prompt_ebene(p_msg, p_msg_eng, p_retour, callback) {
const codeLangue = $("#codeLangue").val();
const message = (codeLangue === "en_US") ? p_msg_eng : p_msg;
baseSwal({
title: formatMessageForSwal(message),
input: 'text',
inputValue: p_retour,
showCancelButton: true,
confirmButtonText: 'OK',
cancelButtonText: codeLangue === "en_US" ? 'Cancel' : 'Annuler'
}).then(result => {
callback(result.isConfirmed ? result.value : null);
});
}
/**
* CHANGEMENT DE MOT DE PASSE
* Demande confirmation avant redirection.
*/
function change_password() {
const v_msg = "Attention, vous serez déconnecté par la suite! Voulez-vous changer votre mot de passe?";
const 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) {
window.location.assign($("#racineWeb").val() + "Changermotpass/");
}
});
}
/**
* AFFICHAGE BÉNÉFICIAIRE
* Prépare le contexte serveur avant de charger la fiche bénéficiaire.
*/
function ajax_context_beneficiaire_afficher(idBeneficiaire, okId) {
// Affiche un loader pendant le chargement
$("#contenu").html('
');
$.ajax({
url: $("#racineWeb").val() + "Ajaxcontextbeneficiaire/",
type: 'post',
data: { idBeneficiaire, okId },
complete: () => {
window.location.assign($("#racineWeb").val() + "Fichebeneficiaire/" + idBeneficiaire);
}
});
}
/**
* GESTION DE LA LANGUE À LA CONNEXION
* Met à jour le bloc de connexion via AJAX lors du changement de langue.
*/
function changer_langue_connexion() {
const codeLangue = $("#langue").val();
$.ajax({
url: $("#racineWeb").val() + "Ajaxconnexioncookie/changerlangue/",
type: 'post',
data: { codeLangue },
success: (data) => $("#div_detail_connexion").html(data),
complete: () => $(".selectpicker").selectpicker('refresh')
});
}
/**
* CONFIGURATION DATATABLES
* Initialise un tableau DataTable avec options génériques.
*
* @param {string|jQuery} selector - Sélecteur du tableau (ex: '.tabliste' ou '#myTable')
* @param {object} options - Options personnalisées (langue, boutons, ordre, etc.)
*/
function appliquerDataTable(selector = '.tabliste', options = {}) {
const codeLangue = $("#codeLangue").val() || 'fr_FR';
const translations = {
fr_FR: {
lengthMenu: "Affiche _MENU_ par page",
zeroRecords: "Aucune donnée trouvée",
info: "_PAGE_ sur _PAGES_",
search: "Recherche:",
paginate: { next: "►", previous: "◄" }
},
en_US: {
lengthMenu: "Display _MENU_ records",
zeroRecords: "Nothing found",
info: "Showing page _PAGE_ of _PAGES_",
search: "Search:",
paginate: { next: "►", previous: "◄" }
}
};
$(selector).each(function() {
const $table = $(this);
// Colonnes marquées comme 'data-hidden'
const hiddenTargets = [];
$table.find('thead th').each((idx, th) => {
if ($(th).data('hidden')) hiddenTargets.push(idx);
});
const instance = $table.DataTable($.extend(true, {
destroy: true,
responsive: true,
order: [[0, "desc"]],
language: translations[codeLangue] || translations.fr_FR,
columnDefs: [{ targets: hiddenTargets, visible: false }],
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
}, options));
// Ajustement après rendu
$table.on('init.dt', function () {
if (instance && instance.responsive) {
instance.columns.adjust();
instance.responsive.recalc();
}
});
});
}
function dataTableSpeciale() {
const $table = $('.tabspeciale');
const codeLangue = $("#codeLangue").val() || "fr_FR";
// Détruire l'instance existante si elle existe
if ($.fn.DataTable.isDataTable($table)) {
$table.DataTable().clear().destroy();
// ⚠️ Ne pas vider le contenu, sinon tu perds /
// $table.empty();
}
// Définition des traductions
const langOptions = {
en_US: {
lengthMenu: "Display _MENU_ records per page",
zeroRecords: "Nothing found - sorry",
info: "Showing page _PAGE_ of _PAGES_",
infoEmpty: "No records available",
search: "Search:",
paginate: {
next: "►",
previous: "◄",
first: "|◄",
last: "►|"
},
infoFiltered: "(filtered from _MAX_ total records)"
},
fr_FR: {
lengthMenu: "Affiche _MENU_ par page",
zeroRecords: "Désolé - Aucune donnée trouvée",
info: "_PAGE_ sur _PAGES_ pages",
infoEmpty: "Pas d'enregistrement",
search: "Recherche:",
paginate: {
next: "►",
previous: "◄",
first: "|◄",
last: "►|"
},
infoFiltered: "(filtré de _MAX_ total enregistrements)"
}
};
// Définition des lengthMenu selon la langue
const lengthMenuOptions = [10, 50, 100];
try {
const dt = $table.DataTable({
responsive: true,
lengthMenu: lengthMenuOptions,
scrollX: true,
scrollY: "75vh",
scrollCollapse: true, // ✅ aide à harmoniser header/body
pagingType: "full_numbers",
autoWidth: false,
searching: true, // ✅ réactive la recherche
ordering: false,
lengthChange: false,
orderMulti: true,
fixedHeader: true, // ✅ garde l’entête aligné
language: langOptions[codeLangue] || langOptions.fr_FR
});
// Ajuster les colonnes après init
dt.columns.adjust().draw();
// Ajuster encore après un petit délai (utile après Ajax)
setTimeout(() => {
dt.columns.adjust().draw();
}, 200);
} catch (err) {
console.error("Erreur DataTable:", err);
return false;
}
}
/**
* MESSAGERIE ET NOTIFICATIONS
* Récupère le nombre de messages et déconnecte si session expirée.
*/
function raffraichier_messagerie() {
if (!navigator.onLine) {
$("#test_connexion").css('background-color', 'red');
return;
}
$.ajax({
url: $("#racineWeb").val() + "Ajaxmessagerie/",
success: (data) => {
$("#nbMessagesNonLus").html(data);
$("#span_notification").text($("#msgNonLus").val());
// Sécurité : redirection forcée si le serveur indique une déconnexion nécessaire
if ($("#deconnexion").val() === '1') {
window.location.assign($("#racineWeb").val() + "Connexion/deconnecter/");
}
}
});
}
// Réajuster les popups SweetAlert lors du redimensionnement de la fenêtre
window.addEventListener('resize', () => {
if (Swal.isVisible()) setTimeout(adjustSwalContent, 100);
});
/**
* Sélectionne une police d'assurance et met à jour les champs cachés globaux.
* Cette fonction est généralement appelée lors d'un clic sur une ligne de tableau
* ou un bouton de sélection dans une liste de polices.
*/
function selectionner_police(id, no) {
// Mise à jour de l'ID de la police dans le champ caché prévu pour le traitement serveur
$("#idPolice_C").val(id);
// Mise à jour du numéro de police pour l'affichage ou les recherches secondaires
$("#numeroPolice_C").val(no);
// Note : On pourrait ajouter ici un retour visuel (ex: surbrillance de la ligne sélectionnée)
console.log(`Police sélectionnée : ID ${id} / N° ${no}`);
afficher_police_id(id);
}
/**
* Vérifie la sélection d'une police et lance la mise à jour du contexte.
* Utilisée généralement avant d'afficher le détail d'un contrat.
*/
function afficher_police_id(idPolice) {
// Récupération de l'ID depuis le champ caché
//const idPolice = $("#idPolice_C").val();
// Vérifie si l'ID est présent et non composé uniquement d'espaces
if (idPolice > "0") {
ajax_context_police_afficher(idPolice);
} else {
// Optionnel : Alerte si aucune police n'est sélectionnée
console.warn("Aucun identifiant de police trouvé pour l'affichage.");
}
}
/**
* Définit le contexte de la police côté serveur via AJAX avant redirection.
* @param {string|number} idPolice - L'identifiant de la police à mettre en session.
*/
function ajax_context_police_afficher(idPolice) {
const racine = $("#racineWeb").val() || "/";
$.ajax({
url: racine + "Ajaxcontextpolice/",
type: 'POST',
// On envoie un objet pour que jQuery gère proprement l'encodage
data: { idPolice: idPolice },
beforeSend: function() {
// Optionnel : On pourrait afficher un petit loader ici
},
success: function() {
// Le contexte est mis à jour avec succès
console.log("Contexte police mis à jour.");
},
error: function(xhr, status, error) {
// Alerte l'utilisateur en cas de problème technique
const msg = "Erreur lors de la préparation du dossier police.";
const msgEng = "Error while preparing the policy file.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
},
complete: function() {
// Redirection vers la fiche de la police après le traitement AJAX
window.location.assign(racine + "Fichepolice/");
}
});
}
/**
* Charge la liste des quittances pour une police sur une période donnée.
*/
function afficher_quittances_police_periode() {
// 1. Récupération des paramètres
const racine = $("#racineWeb").val() || "/";
const idPolice = $("#idPolice_C").val();
const debut = $("#debut").val();
const fin = $("#fin").val();
const $conteneur = $("#div_quittancepolice");
// 2. Vérification de l'ID Police (Correction du bug numeroPolice)
if (!idPolice || idPolice.trim() === "") {
console.warn("Affichage quittances impossible : ID Police manquant.");
return;
}
// 3. Préparation de l'interface (Loader)
showLoader("#div_quittancepolice", { size: 3 });
// 4. Appel AJAX
$.ajax({
url: racine + "Ajaxfichepolice/",
type: 'POST',
data: {
idPolice: idPolice,
debut: debut,
fin: fin
},
success: function(data) {
// Injection du résultat
$conteneur.hide().html(data).fadeIn();
appliquerDataTable('.tabliste');
},
error: function(xhr, status, error) {
$conteneur.html(`
${_("Erreur lors du chargement des quittances.")}
`);
console.error("Erreur AJAX Quittances:", status, error);
}
});
}
function afficher_emission(idEmission)
{
if (idEmission>"0")
{
window.location.assign($("#racineWeb" ).val()+"Emission/"+idEmission+"/");
}
}
function texte_cp()
{
window.location.assign($("#racineWeb" ).val()+"Textecp/");
}
/**
* Ouvre le modal d'impression de quittance et charge son contenu via AJAX.
* Utilise le déplacement DOM (Solution 3) pour éviter les conflits de z-index.
*
* @param {number|string} idQuittance - Identifiant de la quittance à imprimer
*/
function imprimer_quittance_client(idQuittance) {
/* ===================================================
* 1. Validation de l’identifiant
* =================================================== */
if (!idQuittance || parseInt(idQuittance) <= 0) {
const v_msg = "Rien à imprimer !";
const v_msgEng = "Nothing to print!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
/* ===================================================
* 2. Initialisation et EXTRACTION du Modal (Solution 3)
* =================================================== */
const modalEl = document.getElementById('pop_export_quittance');
if (!modalEl) {
console.error("Erreur : Le modal #pop_export_quittance est introuvable dans le DOM.");
return;
}
// On déplace le modal directement sous s'il n'y est pas déjà.
// Cela permet de passer outre les z-index des conteneurs parents (Sidebar, Header).
if (modalEl.parentElement !== document.body) {
document.body.appendChild(modalEl);
}
const racine = $("#racineWeb").val() || "/";
const divExport = document.getElementById('div_export_quittance');
/* ===================================================
* 3. Préparation visuelle (Spinner)
* =================================================== */
showLoader("#div_export_quittance", { size: 3 });
/* ===================================================
* 4. Initialisation de l'instance Bootstrap
* =================================================== */
const modal = bootstrap.Modal.getOrCreateInstance(modalEl, {
backdrop: 'static',
keyboard: false
});
/* ===================================================
* 5. Gestion de l'événement d'affichage et AJAX
* =================================================== */
// On utilise 'shown.bs.modal' pour lancer l'AJAX une fois le modal visible
$(modalEl).one('shown.bs.modal', function () {
$.ajax({
url: racine + "Ajaxexporterunequittanceclient/",
type: 'POST',
data: { idQuittance: idQuittance },
success: function (data) {
divExport.innerHTML = data;
},
error: function (xhr, status, error) {
divExport.innerHTML = `
Erreur : Impossible de générer la quittance.
${error}
`;
}
});
});
/* ===================================================
* 6. Affichage final
* =================================================== */
modal.show();
}
function college_police()
{
if ($("#idPolice_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Collegepolice/");
}
}
function assurance_familiale()
{
codeTypeContrat = $("#codeTypeContrat_C").val();
if (codeTypeContrat!="F")
{
v_msg="Ce n\'est pas une police FAMILIALE!";
v_msgEng="This is not a FAMILIY policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Assuranceindividuelle/");
}
function est_ce_police_famille()
{
codeTypeContrat = $("#codeTypeContrat_C").val();
return (codeTypeContrat=="F");
}
function creer_adherents()
{
debugger;
// 06/11/2020
if(est_ce_police_famille())
{
window.location.assign($("#racineWeb" ).val()+"Assuranceindividuelle/");
return;
}
nbAdh = $("#nbAdh_C").val();
codeTypeContrat = $("#codeTypeContrat_C").val();
if ( (codeTypeContrat!="G") && (nbAdh>0) )
{
v_msg="Ce n\'est pas une police GROUPE!";
v_msgEng="This is not a GROUP policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Creeradherent/");
}
function prorater_prime_adherent()
{
idCollege=$("#idCollege").val();
dateEntree=$("#dateEntree").val();
prorata=$("#prorata").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
donnees += '&dateEntree='+dateEntree;
donnees += '&prorata='+prorata;
$.ajax({
url: $("#racineWeb").val()+"Ajaxproraterprime/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_prime").html(data);
},
complete: function() {
}
});
}
function imprimer_contrat()
{
window.location.assign($("#racineWeb" ).val()+"Contrat/");
}
function adherents_police()
{
if ($("#idPolice_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Listeadherent/");
}
}
function afficher_adherents_police()
{
showLoader("#div_liste_adherent", { size: 3 });
$.ajax({
url: $("#racineWeb").val()+"Ajaxlisteadherent/",
type : 'post',
// data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_liste_adherent").html(data);
}
});
}
// --- I18n dictionary ---
const I18N = {
fr_FR: {
loading: "Affichage en cours...",
exportPdf: "Exporter les graphiques en PDF",
dashboardTitle: "Graphiques des sinistres",
charts: {
claimsTitle: "Répartition des sinistres",
claimsCount: "Nombre de sinistres",
monthlyTitle: "Évolution mensuelle",
monthlyCumulative: "Sinistres cumulés",
monthlySingle: "Sinistres uniques",
lossRatioTitle: "Ratio de sinistralité",
lossRatioLabel: "Ratio de sinistralité"
},
months: ["Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", "Août", "Sep", "Oct", "Nov", "Déc"],
errors: {
ajax: "Impossible de charger les graphiques.",
pdfLib: "Erreur : jsPDF n'est pas chargé."
}
},
en_US: {
loading: "Loading in progress...",
exportPdf: "Export charts to PDF",
dashboardTitle: "Claims Charts",
charts: {
claimsTitle: "Claims distribution",
claimsCount: "Number of claims",
monthlyTitle: "Monthly trend",
monthlyCumulative: "Claims cumulative",
monthlySingle: "Claims single",
lossRatioTitle: "Loss ratio",
lossRatioLabel: "Loss ratio"
},
months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
errors: {
ajax: "Unable to load charts.",
pdfLib: "Error: jsPDF is not loaded."
}
}
};
// --- Helpers ---
function getLang() {
const codeLangue = $("#codeLangue").val() || "fr_FR";
return I18N[codeLangue] ? codeLangue : "fr_FR";
}
function t(path) {
const lang = getLang();
return path.split(".").reduce((acc, key) => (acc && acc[key] != null ? acc[key] : null), I18N[lang]);
}
// Optional: normalize backend month keys to localized labels
function localizeMonths(months) {
const map = {
Jan: "Jan", Feb: "Feb", Mar: "Mar", Apr: "Apr", May: "May", Jun: "Jun",
Jul: "Jul", Aug: "Aug", Sep: "Sep", Oct: "Oct", Nov: "Nov", Dec: "Dec"
};
const langMonths = t("months");
// If backend already provides localized months, keep them; else map to language months by index
if (!Array.isArray(months) || months.length !== 12) return months;
const canonical = months.map(m => map[m] || m);
// Use the language month names but preserve array length and order
return langMonths && langMonths.length === 12 ? langMonths : canonical;
}
function showLoader(selector, options = {}) {
const { message = null, size = 3 } = options;
const text = message || t("loading");
const loaderHtml = `
${text}
${text}
`;
$(selector).html(loaderHtml);
}
function hideLoader(selector, contentHtml = "") {
$(selector).html(contentHtml);
}
function graphique_sinistre() {
showLoader("#div_graphique", { size: 3 });
$.ajax({
url: $("#racineWeb").val() + "Ajaxgraphiquesinistres/api/",
type: "get",
dataType: "json",
success: function (data) {
const exportLabel = t("exportPdf");
const html = `
`);
}
});
}
function reset_graphique() {
// Vide complètement la zone des graphiques
$("#div_graphique").empty();
}
// --- Charts ---
function renderClaimsChart(claims) {
new Chart(document.getElementById("claimsChart"), {
type: "bar",
data: {
labels: claims.claimsLabels,
datasets: [{
label: t("charts.claimsCount"),
data: claims.claimsValues,
backgroundColor: "rgba(54, 162, 235, 0.6)"
}]
},
options: {
plugins: {
legend: { display: true }
},
scales: {
x: { title: { display: false } },
y: { title: { display: false }, beginAtZero: true }
}
}
});
}
function renderClaimsMonthChart(claimsMonth) {
const labels = localizeMonths(claimsMonth.months);
new Chart(document.getElementById("claimsMonthChart"), {
type: "line",
data: {
labels,
datasets: [
{
label: t("charts.monthlyCumulative"),
data: claimsMonth.monthlyClaims,
borderColor: "rgba(255, 99, 132, 0.8)",
backgroundColor: "rgba(255, 99, 132, 0.2)",
tension: 0.25,
fill: false
},
{
label: t("charts.monthlySingle"),
data: claimsMonth.singleClaims,
borderColor: "rgba(75, 192, 192, 0.8)",
backgroundColor: "rgba(75, 192, 192, 0.2)",
tension: 0.25,
fill: false
}
]
},
options: {
plugins: {
legend: { display: true }
},
scales: {
x: { title: { display: false } },
y: { title: { display: false }, beginAtZero: true }
}
}
});
}
function renderLossRatioChart(lossRatio) {
const labels = localizeMonths(lossRatio.lossRatioLabels);
new Chart(document.getElementById("lossRatioChart"), {
type: "line",
data: {
labels,
datasets: [{
label: t("charts.lossRatioLabel"),
data: lossRatio.lossRatioValues,
borderColor: "rgba(255, 206, 86, 0.8)",
backgroundColor: "rgba(255, 206, 86, 0.2)",
tension: 0.25,
fill: false
}]
},
options: {
plugins: {
legend: { display: true }
},
scales: {
x: { title: { display: false } },
y: { title: { display: false }, beginAtZero: true }
}
}
});
}
// --- Export PDF ---
function setupExportPdf() {
$("#exportPdfBtn").on("click", function () {
if (!window.jspdf) {
alert(t("errors.pdfLib"));
return;
}
const { jsPDF } = window.jspdf;
const pdf = new jsPDF("p", "mm", "a4");
pdf.setFontSize(18);
pdf.text(t("dashboardTitle"), 10, 20);
addChartToPdf(pdf, "claimsChart", t("charts.claimsTitle"), 40);
addChartToPdf(pdf, "claimsMonthChart", t("charts.monthlyTitle"), 120);
pdf.addPage();
addChartToPdf(pdf, "lossRatioChart", t("charts.lossRatioTitle"), 40);
pdf.save("Tableau_de_bord.pdf"); // you can also localize the filename if needed
});
}
function addChartToPdf(pdf, canvasId, title, startY) {
const canvas = document.getElementById(canvasId);
if (canvas) {
const imgData = canvas.toDataURL("image/png", 1.0);
pdf.setFontSize(14);
pdf.text(title, 10, startY);
pdf.addImage(imgData, "PNG", 10, startY + 5, 180, 60);
}
}
function charger_contrats(){
showLoader("#div_liste_contrats", { size: 3 });
$.ajax({
url: $("#racineWeb").val()+"Ajaxlistepolicesclient/",
type : 'post',
// data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_liste_contrats").html(data);
appliquerDataTable('.tabliste');
}
});
}
function reset_contrats()
{
$("#div_liste_contrats").empty();
}
function selectionner_college(idCollege)
{
$("#idCollege" ).val(idCollege);
}
function consulter_college(idCollege)
{
if (idCollege>"0")
{
window.location.assign($("#racineWeb" ).val()+"Consultercollege/"+idCollege+"/");
}
}
function pop_consulter_tableau_prestation() {
$.ajax({
url: $("#racineWeb").val() + "Ajaxconsultertableauprestation/",
type: 'post',
error: function(errorData) {
// Optionnel : gestion d'erreur
},
success: function(data) {
$("#div_tableau_prestation").html(data);
},
complete: function() {
// Déplacer le modal sous avant ouverture
const modal = document.getElementById("poptableauprestation");
if (modal && modal.parentNode !== document.body) {
document.body.appendChild(modal);
}
// Ouvrir le modal via le bouton caché
document.getElementById("btn_pop").click();
}
});
}
function prorater_prime_adherent()
{
idCollege=$("#idCollege").val();
dateEntree=$("#dateEntree").val();
prorata=$("#prorata").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
donnees += '&dateEntree='+dateEntree;
donnees += '&prorata='+prorata;
$.ajax({
url: $("#racineWeb").val()+"Ajaxproraterprime/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_prime").html(data);
},
complete: function() {
}
});
}
function changer_avenant_incorporation()
{
idAvenant = $("#idAvenant").val();
if(idAvenant<=" ")
{
v_msg="Veuillez sélectionner un avenant!";
v_msgEng="Please select an Amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#idAvenant").focus();
return;
});
}
donnees = 'idAvenant='+idAvenant;
$.ajax({
url: $("#racineWeb").val()+"Ajaxavenant/getdateavenant/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_date_avenant").html(data);
$(".datepicker" ).datepicker();
},
complete: function()
{
prorater_prime_adherent();
}
});
}
function get_age(td2) {
// Vérifie si td2 est déjà un objet Date
if (!(td2 instanceof Date)) {
td2 = new Date(td2); // Convertit une chaîne ou un timestamp en Date
}
const today = new Date();
let age = today.getFullYear() - td2.getFullYear();
const m = today.getMonth() - td2.getMonth();
if (m < 0 || (m === 0 && today.getDate() < td2.getDate())) {
age--;
}
return age;
}
function controle_age(dater, codeLienParente)
{
age = get_age(dater);
$("#agepersonne").val("Âge : "+age);
if (age>65)
{
v_msg="Âge "+age+" supérieur à 65 ans!";
v_msgEng="Age "+age+" over 65!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return false;
});
}
if ( (codeLienParente=="E")&& (age>21) )
{
v_msg="Âge "+age+" => Enfant âgé de plus de 21 ans!";
v_msgEng="Âge "+age+" => Child over 21 years old!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return false;
});
}
if ( (codeLienParente=="O")&& (age>21) )
{
v_msg="Âge "+age+" => Enfant âgé de plus de 21 ans!";
v_msgEng="Âge "+age+" => Child over 21 years old!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return false;
});
}
return true;
}
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codeNaturePiece").focus();
return;
});
}
$('#numeroPiece').removeAttr('minlength');
if(v_codeNaturePiece=="CNI")
{
$('#div_controle_piece').html("");
v_numeroPiece = $("#numeroPiece").val();
$('#numeroPiece').attr('minlength', 13);
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 ajaxListerVille()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaxville/",
type : 'post',
data: "codePays="+$("#codePays").val(),
error: function(errorData) {
},
success: function(data) {
$("#listeville").html(data);
},
complete: function() {
}
});
}
function ajaxListerLocalite()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaxlocalite/",
type : 'post',
data: "codePays="+$("#codePays").val()+"&codeVille="+$("#codeVille").val(),
error: function(errorData) {
},
success: function(data) {
$("#listelocalite").html(data);
}
});
}
function imprimer_contrat()
{
window.location.assign($("#racineWeb" ).val()+"Contrat/");
}
function imprimer_cp(lienEtat)
{
var div_export = $('#div_export_a');
div_export.html(`
Loading...
Veuillez patienter... / Please wait...
`);
donnees = 'lienEtat='+lienEtat;
$.ajax({
url: $("#racineWeb").val()+"Ajaximprimercp/",
type: 'POST',
data: donnees,
success: function(data)
{
div_export.html(data);
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
}
});
}
function creer_avenant()
{
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Creeravenant/");
}
function enregistrer_avenant()
{
codeTypeAvenant=$("#codeTypeAvenant").val();
oldCodeTypeAvenant=$("#oldCodeTypeAvenant").val();
if ($("#codeTypeAvenant").val()<" ")
{
v_msg="Veuillez sélectionner le type d\'avenant!";
v_msgEng="Please select the type of amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
var d_effet = new Date($("#dateEffetSql").val());
var d_fin = new Date($("#dateFinSql").val());
var d_avenant = $("#dateAvenant").datepicker("getDate");
dt_effet = Math.round(Date.parse(d_effet)/(1000*3600*24));
dt_fin = Math.round(Date.parse(d_fin)/(1000*3600*24));
dt_avenant = Math.round(Date.parse(d_avenant)/(1000*3600*24));
/*
alert("dt_effet => "+dt_effet);
alert("dt_fin => "+dt_fin);
alert("dt_avenant => "+dt_avenant);
return;
*/
if (dt_avenant>dt_fin || dt_avenant {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
motifavenant=$("#motifavenant").val();
if ($("#motifavenant").val()<" ")
{
v_msg="Veuillez fournir le motif!";
v_msgEng="Please provide the reason";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
v_msg="Confirmez-vous cet avenant?";
v_msgEng="Do you confirm this amendment to the contract?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
var div_attente = $('#div_attente');
div_attente.html(`
Loading...
Veuillez patienter... / Please wait...
`);
document.getElementById("formAvenant").submit();
}
});
}
function pop_afficher_selection_retrait() {
const div_selection_assure = $('#div_selection_assure');
// 1. Affichage du Loader
div_selection_assure.html(`
Erreur lors du chargement : ${error}
${xhr.responseText || ''}
`);
},
success: function(data) {
// Injection des données
div_selection_assure.html(data);
// 3. Initialisation du DataTable si la table existe
const $table = div_selection_assure.find('.tabspeciale');
if ($table.length > 0 && $table.find('thead th').length > 0) {
try {
dataTableSpeciale();
} catch (err) {
console.error("Erreur DataTable:", err);
}
} else {
console.warn("Table .tabspeciale non trouvée ou mal formée");
}
},
complete: function() {
// 4. Gestion propre du Modal
const modalEl = document.getElementById("popdetailassure");
if (modalEl) {
if (modalEl.parentNode !== document.body) {
document.body.appendChild(modalEl);
}
const myModal = bootstrap.Modal.getOrCreateInstance(modalEl);
myModal.show();
}
}
});
}
function beneficiaire_a_retirer(p_choix, p_id_beneficiaire)
{
donnees = 'idBeneficiaire='+p_id_beneficiaire;
donnees += '&choix='+p_choix;
$.ajax({
url: $("#racineWeb").val()+"Ajaxselectionretrait/selectionner/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
}
});
}
function recapituler_retrait()
{
var div_assure_a_retirer = $('#div_assure_a_retirer');
$.ajax({
url: $("#racineWeb").val()+"Ajaxdetailretrait/recapituler/",
type: 'POST',
success: function(data) {
div_assure_a_retirer.html(data);
var oTable = $('.tabliste').DataTable();
oTable.destroy();
setTimeout(function() {
appliquerDataTable('.tabliste');
}, 500);
},
error: function(data) {
},
complete: function() {
}
});
}
function enregistrer_retrait()
{
var div_assure_a_retirer = $('#div_assure_a_retirer');
$.ajax({
url: $("#racineWeb").val()+"Ajaxdetailretrait/recapituler/",
type: 'POST',
success: function(data) {
div_assure_a_retirer.html(data);
},
error: function(data) {
},
complete: function() {
nbAliment=$("#nbAliment").val();
if (nbAliment<"1")
{
v_msg="Veuillez sélectionner les personnes à retirer!";
v_msgEng="Please select the people to remove!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
v_msg="Confirmez-vous le retrait des personnes sélectionnées de cette police?";
v_msgEng="Do you confirm the withdrawal of the selected people from this policy?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
window.location.assign($("#racineWeb" ).val()+"Ficheretrait/enregistrerretrait/");
} else {
// L'utilisateur a annulé
console.log("Confirmation refusée");
}
});
}
});
}
function liste_avenant()
{
window.location.assign($("#racineWeb" ).val()+"Listeavenant/");
}
function controle_date_avenant() {
let codeTypeAvenant = $("#codeTypeAvenant").val();
$("#div_periodidite").html("");
$("#dateAvenant").val($("#datejourfr_C").val());
//$("#dateAvenant").prop("readonly", true);
//$("#motifavenant").prop("readonly", true);
}
function init_import_assures()
{
nbCollege = $("#nbCollege_C").val();
if (nbCollege<="0")
{
v_msg="Aucun collège!";
v_msgEng="No college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
nbAdh = $("#nbAdh_C").val();
codeTypeContrat = $("#codeTypeContrat_C").val();
if (codeTypeContrat=="P")
{
v_msg="Ce n\'est pas une police GROUPE!";
v_msgEng="This is not a GROUP policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Importassure/");
}
function exporter_modele_assure()
{
$('#div_form_upload').hide();
var div_export = $('#div_exporter_liste_assures');
div_export.html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/exportermodele/",
type: 'POST',
// data: donnees,
success: function(data)
{
div_export.html(data);
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
}
});
}
function selectionner_adherent(id,no)
{
$("#idAdherent_C").val(id);
$("#numeroAdherent_C").val(no);
}
function afficher_adherent()
{
if ($("#numeroAdherent_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Ficheadherent/"+$("#numeroAdherent_C" ).val()+"/");
}
}
function afficher_adherent_id_plus(idAdherent)
{
if (idAdherent>"0")
{
window.location.assign($("#racineWeb" ).val()+"Ficheadherent/"+idAdherent+"/");
}
}
function selectionner_beneficiaire(id,no)
{
$("#idBeneficiaire_C" ).val(id);
$("#numeroBeneficiaire_C" ).val(no);
}
function afficher_beneficiaire()
{
if ($("#numeroBeneficiaire_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+$("#numeroBeneficiaire_C" ).val()+"/");
}
}
function afficher_beneficiaire_id()
{
idBeneficiaire = $("#idBeneficiaire_C" ).val();
if ($("#idBeneficiaire_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+idBeneficiaire+"/");
}
}
function creer_beneficiaires()
{
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
// etatadh=$("#codeEtatAdherent_C").val();
etatadh=$("#codeEtatAdherent").val();
if (etatadh != "V" && etatadh != "W")
{
v_msg="Attention! cette famille n\'est pas en vigueur!";
v_msgEng="Warning! this family is not in force!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Creerbeneficiaire/");
}
function afficher_adherent_id()
{
idAdherent = $("#idAdherent_C" ).val();
if (idAdherent>"0")
{
window.location.assign($("#racineWeb" ).val()+"Ficheadherent/"+$("#idAdherent_C" ).val()+"/");
}
}
//Face KANE 26-09-2025
function re_init_photo_face()
{
var photo = document.getElementById('photo_face');
photo.setAttribute('src', "");
$('#message_face').html("");
$('#image_face').val("");
$("#div_wait_face_ebene").html('');
}
function ebene_init_photo_face() // OK
{
faceRegistered = $("#faceRegistered").val();
if(faceRegistered=="1")
{
v_msg="Cettte personne a déjà une face dans le système!";
v_msgEng="This person already has a face in the system!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$('#message_face').html("");
return;
});
}
re_init_photo_face();
$("#btn_pop_save_face").click();
}
function ebene_enregistrer_photo_face() // OK
{
$("#ebene_confirmer_photo_face").prop('disabled', true);
$("#ebene_supprimer_photo_face").prop('disabled', true);
$("#ebene_take_photo_face").prop('disabled', true);
$("#motif").prop('disabled', true);
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("ebene_take_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
$('#message_face').html("");
$("#div_wait_face_ebene").html('');
$("#okId").val("-1");
$("#okId_face").val("-1");
$("#del_face").val("0");
image_face = $("#image_face").val();
if(image_face<=" ")
{
v_msg="Veuillez prendre une photo!";
v_msgEng="Please take a photo!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
$("#div_wait_face_ebene").html('
' + '' + '
');
compare_face = $("#compare_face").val();
v_idBeneficiaire=$("#idBeneficiaire_C").val();
var dataURL = canvas.toDataURL("image/jpeg");
$.ajax({
url: $("#racineWeb").val()+"Fichebeneficiaire/ebeneenregistrerface/",
type: 'POST',
data: {'image_face' : dataURL, 'compare_face' : compare_face , 'del_face' : "0"},
success: function(data) {
$("#ebene_take_photo_face").prop('disabled', false);
$("#div_wait_face_ebene").html('');
$("#message_face").html(data);
photo_succes = $("#photo_succes").val();
if(photo_succes=="1")
{
v_msg="Enrôlement effectué avec succès!";
v_msgEng="Enrollment completed successfully!!";
setTimeout(() => {
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+v_idBeneficiaire);
}, 1000)
}
},
error: function(data) {
},
complete: function(data) {
$("#div_wait_face_ebene").html('');
}
});
}
function fiche_beneficiaire()
{
idBeneficiaire = $("#idBeneficiaire_C").val();
if (idBeneficiaire>" ")
{
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+idBeneficiaire);
}
/*
if ($("#numeroBeneficiaire_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+$("#numeroBeneficiaire_C" ).val()+"/");
}
*/
}
function ebene_init_confirm_photo_face() // OK
{
faceRegistered = $("#faceRegistered").val();
if(faceRegistered!="1")
{
v_msg="Cettte personne n'a pas encore de face dans le système!";
v_msgEng="This person doesn't have a face in the system yet!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$('#message_face').html("");
return;
});
}
re_init_photo_face();
$("#btn_pop_save_face").click();
}
function ebene_confirmer_photo_face() // OK
{
$("#ebene_confirmer_photo_face").disable();
$("#ebene_supprimer_photo_face").disable();
$("#ebene_take_photo_face").disable();
$("#motif").disable();
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("ebene_take_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
$('#message_face').html("");
$("#div_wait_face_ebene").html('');
$("#del_face").val("0");
faceRegistered = $("#faceRegistered").val();
if(faceRegistered!="1")
{
v_msg="Cette personne n'a pas encore de photo dans le système!";
v_msgEng="This person does not have a photo in the system yet!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$('#message_face').html("");
return;
});
}
image_face = $("#image_face").val();
if(image_face<=" ")
{
v_msg="Veuillez prendre une photo!";
v_msgEng="Please take a photo!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$('#message_face').html("");
return;
});
}
$("#div_wait_face_ebene").html(`
Loading...
Veuillez patienter... / Please wait...
`);
compare_face = $("#compare_face").val();
var dataURL = canvas.toDataURL("image/jpeg");
$.ajax({
url: $("#racineWeb").val()+"Fichebeneficiaire/ebeneenregistrerface/",
type: 'POST',
data: {'image_face' : dataURL, 'compare_face' : compare_face , 'del_face' : "0"},
success: function(data) {
$("#ebene_take_photo_face").enable();
$("#div_wait_face_ebene").html('');
$("#message_face").html(data);
photo_succes = $("#photo_succes").val();
if(photo_succes=="1")
{
$("#okId_face").val("1");
v_msg="Face confirmée!";
v_msgEng="Face confirmed!";
setTimeout(() => {
prestations();
}, 2000)
}
else
{
$("#okId").val("-1");
$("#okId_face").val("-1");
}
},
error: function(data) {
},
complete: function(data) {
$("#div_wait_face_ebene").html('');
}
});
}
function ebene_supprimer_photo_face() // OK
{
$('#message_face').html("");
$("#div_wait_face_ebene").html('');
motif=$("#motif").val();
motif= motif.trim();
$("#motif").val(motif);
if (motif<=" ")
{
v_msg="Veuillez saisir un motif!";
v_msgEng="Please enter a reaon!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#motif").focus();
return;
});
}
$("#del_face").val("1");
faceRegistered = $("#faceRegistered").val();
if(faceRegistered!="1")
{
v_msg="Cette personne n'a pas encore de photo dans le système!";
v_msgEng="This person does not have a photo in the system yet!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
image_face = $("#image_face").val();
if(image_face<=" ")
{
v_msg="Veuillez prendre une photo!";
v_msgEng="Please take a photo!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
v_msg="Confirmez-vous cette suppression?";
v_msgEng="Do you confirm this deletion?";
if(confirm_ebene(v_msg, v_msgEng))
{
$("#ebene_confirmer_photo_face").disable();
$("#ebene_supprimer_photo_face").disable();
$("#ebene_take_photo_face").disable();
$("#motif").disable();
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("ebene_take_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
$("#div_wait_face_ebene").html(`
`);
$("#btn_pop").click();
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogconnexion/exporterlogconnexion/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_deatil_pop").html(data);
},
complete: function() {
}
});
}
// Récupère les coordonnées géographiques à partir de l'adresse IP entrée en paramètre
// et l'affiche sur une carte google Map
function trouve_coordonnees_geo_ip(ip)
{
donnees='ipConnexion='+ip;
$.ajax({
url: "Ajaxlogconnexion/getcoordonneesgeoip/",
type : 'post',
data: donnees,
error: function(errorData){
},
success: function(data) {
if(data !='false')
{
var str = data.split('/'),
lat = str[0], // Latitude de l'adresse IP retourné
lon = str[1], // Longitude de l'adresse IP retourné
out = "&output=embed"
src="https://maps.google.com/maps?q="+lat+","+lon+out; // Source de l'iframe
$('#map').attr("src", src);
$('#div_contenu_map').modal("show"); // Affiche en modal = carte google
$('#div_contenu_map').on('hidden.bs.modal', function(){
$('#map').html("").attr("src", ""); // Réinitialise la source de l'iframe à la fermeture du modal
});
}
else
{
v_msg="Impossible de trouver les coordonnées géographiques de l'adresse IP: "+ip;
v_msgEng="Unable to find the geographic coordinates of the IP address: "+ip;
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
},
complete: function() {
}
});
}
function changer_avenant_incorporation_beneficiaire()
{
idAvenant = $("#idAvenant").val();
if(idAvenant<=" ")
{
v_msg="Veuillez sélectionner un avenant!";
v_msgEng="Please select an Amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#idAvenant").focus();
return;
});
}
donnees = 'idAvenant='+idAvenant;
$.ajax({
url: $("#racineWeb").val()+"Ajaxavenant/getdateavenantbeneficiaire/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_date_avenant").html(data);
$(".datepicker" ).datepicker();
},
complete: function()
{
prorater_prime_beneficiaire();
}
});
}
function filtrergenreconjoint()
{
codeLienParente = $('#codeLienParente').val();
genreAdherent = $('#genreAdherent').val();
if(codeLienParente=='C'){
if(genreAdherent=="F"){
$('#sexe').val('M');
$('#sexeConjoint').val('M');
}else{
$('#sexe').val('F');
$('#sexeConjoint').val('F');
}
$('#sexe').disable();
return;
}
$('#sexe').enable();
}
function prorater_prime_beneficiaire()
{
idAvenant = $("#idAvenant").val();
if(idAvenant<=" ")
{
v_msg="Veuillez sélectionner un avenant!";
v_msgEng="Please select an Amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#idAvenant").focus();
return;
});
}
codeLienParente=$("#codeLienParente").val();
if (codeLienParente=="A")
{
v_msg="Veuillez revoir le lien de parenté!";
v_msgEng="Please review the relationship";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codeLienParente").focus();
return;
});
}
dateEntree=$("#dateEntree").val();
fraisCarte=$("#fraisCarte").val();
prorata=$("#prorata").val();
donnees = '&dateEntree='+dateEntree;
donnees += '&fraisCarte='+fraisCarte;
donnees += '&prorata='+prorata;
$("#div_prime").html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxproraterprimebeneficiaire/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_prime").html(data);
},
complete: function() {
}
});
}
$.prototype.enable = function () {
$.each(this, function (index, el) {
$(el).removeAttr('disabled');
});
}
$.prototype.disable = function () {
$.each(this, function (index, el) {
$(el).attr('disabled', 'disabled');
});
}
$.prototype.unreadable = function () {
$.each(this, function (index, el) {
$(el).attr('READONLY', 'READONLY');
});
}
$.prototype.readable = function () {
$.each(this, function (index, el) {
$(el).removeAttr('READONLY');
});
}
Date.estAnneeBissextile = function (annee) {
return (((annee % 4 === 0) && (annee % 100 !== 0)) || (annee % 400 === 0));
};
Date.getDaysInMonth = function (annee, month) {
return [31, (Date.estAnneeBissextile(annee) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
};
Date.prototype.estAnneeBissextile = function () {
return Date.estAnneeBissextile(this.getFullYear());
};
Date.prototype.getDaysInMonth = function () {
return Date.getDaysInMonth(this.getFullYear(), this.getMonth());
};
Date.prototype.addMonths = function (value) {
var n = this.getDate();
this.setDate(1);
this.setMonth(this.getMonth() + value);
this.setDate(Math.min(n, this.getDaysInMonth()));
this.setDate(this.getDate()-1);
return this;
};
$( ".datepicker" ).datepicker({
inline: true,
changeMonth: true,
changeYear: true,
yearRange: "c-60:c+20"
});
/**
* ETAPE 2 : Affichage du formulaire d'upload
*/
function charger_fichier_modele_assure() {
// Nettoie la zone de prévisualisation avant un nouvel upload
$('#div_exporter_liste_assures').empty();
// Animation fluide pour afficher le formulaire
$('#div_form_upload').slideDown();
// Scroll automatique vers le formulaire pour l'utilisateur
$('html, body').animate({
scrollTop: $("#div_form_upload").offset().top - 100
}, 500);
}
/**
* ETAPE 3 (Init) : Chargement de la liste des avenants
*/
function init_importer_modele_assure() {
// On récupère la valeur du champ caché
var statusEtape2 = $("#etape2").val();
if (statusEtape2 !== "1") {
// Message d'alerte stylisé
alert_ebene("L'étape 2 (Chargement du fichier) n'est pas finalisée.", "Step 2 is not completed!").then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
// Si OK, on continue le workflow
$('#div_form_upload').slideUp();
var div_export = $('#div_exporter_liste_assures');
// Affichage du chargement
div_export.html('
Préparation de la liste...
');
$.ajax({
url: $("#racineWeb").val() + "Ajaximporterlisteassure/initimportermodele/",
type: 'POST',
success: function(data) {
div_export.html(data);
// Optionnel : on peut mettre à jour un indicateur visuel ici
}
});
}
/**
* ETAPE 3 (Action) : Liaison du fichier à l'avenant choisi
*/
function importer_modele_assure(idAvenant) {
debugger;
// On re-vérifie la présence du fichier par sécurité
var cheminFichier = $("#cheminFichier").val();
if (!cheminFichier || cheminFichier === "") {
alert_ebene("Erreur: Aucun fichier trouvé.", "Error: No file found.").then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
var div_export = $('#div_exporter_liste_assures');
div_export.html('
Analyse du fichier et liaison à l\'avenant...
');
var donnees = {
idAvenant: idAvenant,
cheminFichier: cheminFichier
};
$("#div_erreur_excel").empty();
$.ajax({
url: $("#racineWeb").val() + "Ajaximporterlisteassure/importermodele/",
type: 'POST',
data: donnees,
success: function(data) {
debugger;
// 1. On injecte d'abord le contenu dans le div
$("#div_erreur_excel").html(data);
// 2. On cherche l'input spécifiquement DANS le contenu qu'on vient de recevoir
// On utilise .find() si l'input est à l'intérieur d'un div,
// ou .filter() s'il est à la racine du HTML renvoyé.
var isSuccess = $(data).filter("#succes_impot_execl").val() || $(data).find("#succes_impot_execl").val();
console.log("Valeur détectée :", isSuccess); // Pour votre débogage
if (isSuccess === "1") {
alert_ebene("Opération terminée avec succès!", "Operation completed successfully!").then(() => {
// Ce code ne s’exécute qu’après clic sur OK
maj_etape_3_import_assures();
});
} else {
div_export.html(''); // On cache le spinner
// Le message d'erreur est déjà affiché par $("#div_erreur_excel").html(data)
}
},
error: function() {
alert_ebene("Erreur technique lors de l'importation.", "Technical error during import.").then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
});
}
function maj_etape_3_import_assures()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/majetape/",
type: 'POST',
success: function(data)
{
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
afficher_liste_assures_a_importer();
}
});
}
function afficher_liste_assures_a_importer()
{
window.location.assign($("#racineWeb" ).val()+"Listeimportassure/");
}
function calculer_prime_inmportation()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
var div_attente = $('#div_liste_assure_importe');
div_attente.html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
//afficher_liste_assures_a_importer();
});
},
error: function(data) {
},
complete: function()
{
afficher_liste_assures_a_importer();
}
});
}
function incorporer_assures_inmportes()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
v_msg="Avez-vous fait l\'étape 2 => calcul des primes?";
v_msgEng="Did you do step 2 => premium calculation?";
if(!confirm_ebene(v_msg, v_msgEng))
{
return;
}
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?";
if(confirm_ebene(v_msg, v_msgEng))
{
return;
}
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
});
}
v_msg="Confirmez-vous l\'incorporation de cette liste?";
v_msgEng="Do you confirm the incorporation of this list?";
if(confirm_ebene(v_msg, v_msgEng))
{
var div_attente = $('#div_liste_assure_importe');
div_attente.html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
//return;
});
},
error: function(data) {
},
complete: function() {
afficher_police_id();
}
});
}
}
function traiter_lignes_importees()
{
etape2=$("#etape2").val();
if (etape2 != "1")
{
v_msg="Etape 2 incomplète!";
v_msgEng="Incomplete step 2!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
etape3=$("#etape3").val();
if (etape3 != "1")
{
v_msg="Etape 3 incomplète!";
v_msgEng="Incomplete step 3!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
afficher_liste_assures_a_importer();
}
function afficher_adherent_importee()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
var div_attente = $('#div_adherents_importes');
div_attente.html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/afficheradherentimportee/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
div_attente.html(data);
},
complete: function() {
}
});
}
function retirer_un_adherent_importe_college(idBeneficiairemodel)
{
donnees = 'idBeneficiairemodel='+idBeneficiairemodel;
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/retirerunadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
function ajouter_un_adherent_importe_college(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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
donnees = 'idBeneficiairemodel='+idBeneficiairemodel+'&idCollege='+idCollege;
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/ajouterunadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
function ajouter_tous_adherent_importe_college()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
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) {
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/ajoutertousadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
});
}
function ajouter_sans_college_adherent_importe_college()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
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) {
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/ajoutersanscollegeadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
});
}
function retirer_tous_adherent_importe_college()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
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) {
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/retirertousadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
});
}
function incorporer_assures_inmportes()
{
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
v_msg="Avez-vous fait l\'étape 2 => calcul des primes?";
v_msgEng="Did you do step 2 => premium calculation?";
if(!confirm_ebene(v_msg, v_msgEng))
{
return;
}
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?";
/*
if(confirm_ebene(v_msg, v_msgEng))
{
return;
}
*/
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
return;
}
});
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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
//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) {
var div_attente = $('#div_liste_assure_importe');
div_attente.html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/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).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
//return;
});
},
error: function(data) {
},
complete: function() {
afficher_police_id();
}
});
}
});
}
function afficher_police_id()
{
idPolice=$("#idPolice_C" ).val();
if (idPolice>"")
{
ajax_context_police_afficher(idPolice);
}
}
function ajax_context_police_afficher(idPolice)
{
donnees = 'idPolice='+idPolice;
$.ajax({
url: $("#racineWeb").val()+"Ajaxcontextpolice/",
type : 'post',
data: donnees,
error: function(errorData) {
},
complete: function() {
window.location.assign($("#racineWeb" ).val()+"Fichepolice/");
}
});
}
function plafond_adherent()
{
if ($("#idAdherent_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Plafondadherent/");
}
}
function afficher_garantieadherent_entete_contrat()
{
var div_attente = $('#div_gar_exo');
idEntetecontrat=$("#idEntetecontrat").val();
if (idEntetecontrat<="0")
{
v_msg="Veuillez sélectionner une période!";
v_msgEng="Please select a period!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#idEntetecontrat").focus();
div_attente.html('');
return;
});
}
// donnees = 'exercieReference='+exercieReference;
donnees = 'idEntetecontrat='+idEntetecontrat;
div_attente.html(`
Loading...
Veuillez patienter... / Please wait...
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxplafondadherent/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
div_attente.html(data);
},
complete: function() {
}
});
}
function changer_etat_adherent()
{
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Changeretatadherent/");
}
function rapport_sp_adherent()
{
window.location.assign($("#racineWeb" ).val()+"Spadherent/");
}
function factures_famille_2()
{
window.location.assign($("#racineWeb" ).val()+"Facturesfamilleadh/");
}
function listerfacturefamille()
{
d1=$("#d1").val();
d2=$("#d2").val();
donnees = 'd1='+d1+'&d2='+d2;
$("#div_dossiers").html(`
`);
donnees = 'idDemande='+idDemande;
$.ajax({
url: $("#racineWeb").val()+"Ajaxrhvalidationrd/",
type : 'post',
data: donnees,
error: function(errorData){
alert("Erreur : "+errorData);
},
success: function(data) {
//alert("Success : "+data);
$("#div_patienter").html('');
$('#div_validation').html(data);
//appliquerDataTable();
$('#div_validation').modal("show");
},
complete: function() {
}
});
}
function enregistrer_validation_rd(idDemande){
debugger;
codeStatutPaiement = $("#codeStatutPaiementAjax").val();
motifRejetRh = $("#motifRejetRh").val();
if(codeStatutPaiement == "2"){
const msg = "Une décision de validation est obligatoire.";
const msgEng = "A validation approval is required.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codeStatutPaiementAjax").focus();
return;
});
}
if(codeStatutPaiement=="9" && motifRejetRh <=" "){
const msg = "Un motif est obligatoire en cas de refus.";
const msgEng = "A reason is required in case of refusal.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#motifRejetRh").focus();
return;
});
}
donnees = 'idDemande='+idDemande;
donnees += '&codeStatutPaiement='+codeStatutPaiement;
donnees += '&motifRejetRh='+motifRejetRh;
$.ajax({
url: $("#racineWeb").val()+"Ajaxrhvalidationrd/enregistrer/",
type : 'post',
data: donnees,
error: function(errorData){
alert("Erreur : "+errorData);
},
success: function(data) {
//alert("Success : "+data);
$('#div_validation').modal("hide");
},
complete: function() {
listerremboursement();
}
});
}
function remplacer_adherent()
{
nbAdh = $("#nbAdh_C").val();
codeTypeContrat = $("#codeTypeContrat_C").val();
if ( (codeTypeContrat!="G") && (nbAdh>0) )
{
v_msg="Ce n\'est pas une police GROUPE!";
v_msgEng="This is not a GROUP policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if ($("#idAdherent_C" ).val()<= " ")
{
v_msg="Veuillez sélectionner une famille!";
v_msgEng="Please select a family!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
remplacementAdherent=$("#remplacementAdherent").val();
if (remplacementAdherent!="1")
{
v_msg="Remplacement de famille non actif pour cette police!";
v_msgEng="Family replacement inactive for this policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
remplace=$("#remplace").val();
remplacant=$("#remplacant").val();
if (remplacant=="1")
{
if (remplace=="1")
{
v_msg="Famille déjà remplacée!";
v_msgEng="Family already replaced!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
consulter_remplacement_adherent();
});
}
else
{
v_msg="Cette famille en a déjà remplacé une autre, confirmez-vous son remplacement à son tour?";
v_msgEng="This family has already replaced another, do you confirm its replacement in turn?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
fiche_remplacer_adherent();
} else {
// L'utilisateur a annulé
consulter_remplacant_adherent();
}
});
}
}
else
if (remplace=="1")
{
v_msg="Famille déjà remplacée!";
v_msgEng="Family already replaced!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
consulter_remplacement_adherent();
});
}
else
{
fiche_remplacer_adherent();
// window.location.assign($("#racineWeb" ).val()+"Remplaceradherent/");
}
}
function consulter_remplacement_adherent()
{
idAdherent = $("#idAdherent_C" ).val();
if (idAdherent>"0")
{
window.location.assign($("#racineWeb" ).val()+"Remplaceradherentcons/");
}
}
function fiche_remplacer_adherent()
{
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Remplaceradherent/");
}
function init_remplacement_adherent()
{
dateSortieAdh = $("#dateSortieAdh").datepicker("getDate");
dateRemplacement = $("#dateRemplacement").datepicker("getDate");
dateEffetPolice = $("#dateEffetPolice_C").val();
dateEffetAdherent = $("#dateEffetAdherent").val();
dateEcheancePolice = $("#dateEcheancePolice_C").val();
var td0 = new Date(dateEffetAdherent);
var td1 = new Date(dateSortieAdh);
var td11 = new Date(dateRemplacement);
var td2 = new Date(dateEcheancePolice);
dt0=Math.round(Date.parse(td0)/(1000*3600*24));
dt1=Math.round(Date.parse(td1)/(1000*3600*24));
dt11=Math.round(Date.parse(td11)/(1000*3600*24));
dt2=Math.round(Date.parse(td2)/(1000*3600*24));
if (td11<=td1)
{
v_msg="Attention! Veuillez revoir vos dates!";
v_msgEng="Warning! Please review your dates!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return false;
});
}
if (dt1>dt2 || dt1 {
// Ce code ne s’exécute qu’après clic sur OK
return false;
});
}
etatRetrait = $("#etatRetrait").val();
dateRetrait = $("#dateRetrait").val();
ristourneRetrait = $("#ristourneRetrait").val();
ristourneRetrait = parseInt(ristourneRetrait);
if(etatRetrait=="R" && ristourneRetrait<0)
{
v_msg="Attention! cette personne a été retirée avec une ristourne!";
v_msgEng=" Warning! this person was withdrawn with premium!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return false;
});
}
motifavenant=$("#motifavenant").val();
if ($("#motifavenant").val()<" ")
{
v_msg="Veuillez fournir le motif!";
v_msgEng="Please provide the reason";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
return;
});
}
dateS = $("#dateSortieAdh").val();
dateR = $("#dateRemplacement").val();
fraisCarte = $("#fraisCarte").val();
donnees = 'dateSortie='+dateS+'&dateRemplacement='+dateR+'&motifavenant='+motifavenant+'&fraisCarte='+fraisCarte;
$("#div_remplacement_adherent").html('
' + 'Veuillez patienter... / Please wait...' + '
');
$.ajax({
url: $("#racineWeb").val()+"Ajaxremplaceradherent/init/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data)
{
$("#div_remplacement_adherent").html(data);
},
complete: function() {
$(".datepicker" ).datepicker();
}
});
}
function enregistrer_remplacement_adherent()
{
nom = $("#nom").val();
if ($("#nom").val()<" ")
{
v_msg="Veuillez saisir le nom de famille!";
v_msgEng="Please enter the last name!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#nom").focus();
return;
});
}
prenoms = $("#prenoms").val();
if ($("#prenoms").val()<" ")
{
v_msg="Veuillez saisir le prénom!";
v_msgEng="Please enter the first name!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#prenoms").focus();
return;
});
}
codeNaturePiece = $("#codeNaturePiece").val();
if ($("#codeNaturePiece").val()<" ")
{
v_msg="Veuillez saisir la nature de pièce d\'identité!";
v_msgEng="Please enter the nature of ID!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codeNaturePiece").focus();
return;
});
}
numeroPiece = $("#numeroPiece").val();
if ($("#numeroPiece").val()<" ")
{
v_msg="Veuillez saisir le No de la pièce d\'identité!";
v_msgEng="Please enter the ID number!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#numeroPiece").focus();
return;
});
}
sexe = $("#sexe").val();
if ($("#sexe").val()<" ")
{
v_msg="Veuillez saisir le sexe!";
v_msgEng="Please enter the sex!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#sexe").focus();
return;
});
}
dateNaissance = $("#dateNaissance").val();
if ($("#dateNaissance").val()<" ")
{
v_msg="Veuillez saisir la date de naissance!";
v_msgEng="Please enter the date of birth!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#dateNaissance").focus();
return;
});
}
codeGroupeSanguin = $("#codeGroupeSanguin").val();
if ($("#codeGroupeSanguin").val()<" ")
{
v_msg="Veuillez saisir le groupe sanguin!";
v_msgEng="Please enter the blood type!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codeGroupeSanguin").focus();
return;
});
}
codeSituationFamille = $("#codeSituationFamille").val();
if ($("#codeSituationFamille").val()<" ")
{
v_msg="Veuillez saisir la situation familiale!";
v_msgEng="Please enter the family situation!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codeSituationFamille").focus();
return;
});
}
nombreEnfants = $("#nombreEnfants").val();
adresseGeo = $("#adresseGeo").val();
adressePostale = $("#adressePostale").val();
codePays = $("#codePays").val();
if ($("#codePays").val()<" ")
{
v_msg="Veuillez indiquer le pays!";
v_msgEng="Please indicate the country!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
$("#codePays").focus();
return;
});
}
telephonFixe = $("#telephonFixe").val();
telephonePortable = $("#telephonePortable").val();
email = $("#email").val();
fraisCarte = $("#fraisCarte").val();
donnees = 'nom='+nom+'&prenoms='+prenoms+'&codeNaturePiece='+codeNaturePiece;
donnees += '&numeroPiece='+numeroPiece+'&sexe='+sexe+'&dateNaissance='+dateNaissance;
donnees += '&codeGroupeSanguin='+codeGroupeSanguin+'&codeSituationFamille='+codeSituationFamille+'&nombreEnfants='+nombreEnfants;
donnees += '&adresseGeo='+adresseGeo+'&adressePostale='+adressePostale+'&codePays='+codePays;
donnees += '&telephonFixe='+telephonFixe+'&telephonePortable='+telephonePortable+'&email='+email+'&fraisCarte='+fraisCarte;
v_msg="Confirmez-vous le remplacement de famille?";
v_msgEng="Do you confirm family replacement?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
$("#div_remplacement_adherent").html('
' + 'Veuillez patienter... / Please wait...' + '
');
$.ajax({
url: $("#racineWeb").val()+"Ajaxremplaceradherent/enregistrerremplacementadherent/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data)
{
},
complete: function()
{
v_msg="Opération effectuée avec succès!";
v_msgEng="Operation successfully completed";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne s’exécute qu’après clic sur OK
consulter_remplacement_adherent();
});
}
});
}
});
}