/**
* 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() {
// Initialisation des composants au chargement de la page
appliquerDataTable('.tabliste');
const vueOuverte = $("#vue").val();
/*
if(vueOuverte === "Accueil"){
reset_graphique();
}
*/
});
function raffraichier_gabarit()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaxgabarit/",
success: function(data)
{
$("#div_ajaxgabarit").html(data);
codeSociete = $("#codeSociete").val();
vue = $("#vue").val();
if((codeSociete == undefined || codeSociete <= " ") && vue !="Connexion"){
window.location.assign($("#racineWeb" ).val()+"Connexion/");
}
},
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: adjustSwalContent,
willOpen: () => { document.body.style.overflow = 'hidden'; },
willClose: () => { document.body.style.overflow = 'auto'; }
});
}
/**
* ALERTE SIMPLE
* Affiche une information bilingue.
*/
/* mis en commentaire le temps que cela fonctionne 04/01/2026
function alert_ebene(p_msg, p_msg_eng) {
const codeLangue = $("#codeLangue").val();
const message = (codeLangue === "en_US") ? p_msg_eng : p_msg;
baseSwal({
title: formatMessageForSwal(message),
icon: 'info',
confirmButtonText: codeLangue === "en_US" ? 'OK' : 'D\'accord'
});
}
*/
function alert_ebene(p_msg, p_msg_eng)
{
codeLangue = $("#codeLangue").val();
if(codeLangue=="en_US")
{
alert(p_msg_eng);
}
else
{
alert(p_msg);
}
}
/**
* 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();
}
});
});
}
/**
* 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) {
debugger;
// 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) {
debugger;
// 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) {
debugger;
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.";
if (typeof alert_ebene === "function") {
alert_ebene(msg, msgEng);
} else {
alert(msg);
}
},
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() {
debugger;
// 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!";
if (typeof alert_ebene === "function") {
alert_ebene(v_msg, v_msgEng);
} else {
alert(v_msg);
}
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);
return;
}
window.location.assign($("#racineWeb" ).val()+"Assuranceindividuelle/");
}
function est_ce_police_famille()
{
codeTypeContrat = $("#codeTypeContrat_C").val();
return (codeTypeContrat=="F");
}
function creer_adherents()
{
// 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);
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);
return;
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng);
return;
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng);
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);
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);
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);
$("#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) {
debugger;
// 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)
{
debugger;
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);
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);
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);
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);
$("#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('
' + '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);
return;
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng);
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);
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' + 'Chargement en cours! Veuillez patienter...' + '');
$("#btn_enreg").click();
}
*/
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
var div_attente = $('#div_attente');
div_attente.html('
' + 'Chargement en cours! Veuillez patienter...' + '
');
$("#btn_enreg").click();
}
});
}
function pop_afficher_selection_retrait()
{
var div_selection_assure = $('#div_selection_assure');
div_selection_assure.html('
' + 'Veuillez patienter... / Please wait...' + '
');
$.ajax({
url: $("#racineWeb").val()+"Ajaxselectionretrait/",
type : 'post',
error: function(errorData) {
},
success: function(data) {
div_selection_assure.html(data);
// $('#div_test_gabarit').html(data);
},
complete: function() {
const modal = document.getElementById("popdetailassure");
if (modal && modal.parentNode !== document.body) {
document.body.appendChild(modal);
}
// Ouvrir le modal via le bouton caché
document.getElementById("btn_pop").click();
}
});
}
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();
}, 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);
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);
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);
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('
' + '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()
{
debugger;
if ($("#numeroAdherent_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Ficheadherent/"+$("#numeroAdherent_C" ).val()+"/");
}
}
function afficher_adherent_id()
{
debugger;
codeTypeContrat = $("#codeTypeContrat_C").val();
if (codeTypeContrat=="F")
{
afficher_adherent_familiale_id();
return;
}
idAdherent = $("#idAdherent_C" ).val();
if (idAdherent>"0")
{
window.location.assign($("#racineWeb" ).val()+"Ficheadherent/"+$("#idAdherent_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);
return;
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng);
return;
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng);
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);
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);
$('#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);
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!!";
// alert_ebene(v_msg, v_msgEng);
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);
$('#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);
$('#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);
$('#message_face').html("");
return;
}
$("#div_wait_face_ebene").html('
' + '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!";
// alert_ebene(v_msg, v_msgEng);
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);
$("#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);
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);
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('
' + 'Chargement en cours! Veuillez patienter...' + '
');
cheminFichier=$("#cheminFichier").val();
donnees = 'idAvenant='+idAvenant+'&cheminFichier='+cheminFichier;
$("#div_erreur_excel").html("");
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/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_assures();
}
}
});
}
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);
return;
}
var div_attente = $('#div_liste_assure_importe');
div_attente.html('
' + 'Chargement en cours! Veuillez patienter...' + '
');
$.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);
alert("Calcul de primes terminée avec succès!");
*/
},
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);
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?";
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);
}
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('
' + 'Chargement en cours! Veuillez patienter...' + '