radiantrh/Js/fonctions.js
2026-01-13 14:18:22 +00:00

4217 lines
107 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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 <br> 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('<br>');
}
/**
* 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);
}
}
*/
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);
}
/*
function alert_ebene(p_msg, p_msg_eng) {
const codeLangue = document.querySelector("#codeLangue")?.value || "fr_FR";
const message = (codeLangue === "en_US") ? p_msg_eng : p_msg;
return Swal.fire({
text: message,
icon: 'info',
confirmButtonText: (codeLangue === "en_US") ? 'OK' : 'D\'accord'
}).then(() => {
// Ici tu mets l'action suivante, elle ne s'exécute qu'après clic sur OK
console.log("Utilisateur a validé le message");
});
}
*/
/*
function alert_ebene(msgFr, msgEn) {
const codeLangue = document.querySelector("#codeLangue")?.value || "fr_FR";
const message = (codeLangue === "en_US") ? msgEn : msgFr;
return Swal.fire({
text: message,
icon: 'info',
confirmButtonText: (codeLangue === "en_US") ? 'OK' : 'D\'accord'
});
}
*/
/**
* 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('<div class="spinner-responsive"><span><i class="fa fa-spinner fa-spin"></i></span></div>');
$.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) {
// 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.";
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() {
// 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(`
<div class="alert alert-danger shadow-sm m-3">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
${_("Erreur lors du chargement des quittances.")}
</div>
`);
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 lidentifiant
* =================================================== */
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 <body> 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 = `
<div class="alert alert-danger m-3 shadow-sm">
<strong>Erreur :</strong> Impossible de générer la quittance.
<small class="d-block text-muted mt-1">${error}</small>
</div>
`;
}
});
});
/* ===================================================
* 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 = `
<div class="text-center my-5 py-5 js-generic-loader">
<div class="spinner-border text-primary" role="status" style="width: ${size}rem; height: ${size}rem;">
<span class="visually-hidden">${text}</span>
</div>
<p class="mt-3 text-muted fw-bold">${text}</p>
</div>
`;
$(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 = `
<div class="text-end my-3">
<button id="exportPdfBtn" class="btn btn-danger">
<i class="fas fa-file-pdf"></i> ${exportLabel}
</button>
</div>
<div class="row">
<div class="col-md-6 mb-4">
<div class="card shadow-sm">
<div class="card-body">
<h5 class="card-title text-primary">${t("charts.claimsTitle")}</h5>
<canvas id="claimsChart"></canvas>
</div>
</div>
</div>
<div class="col-md-6 mb-4">
<div class="card shadow-sm">
<div class="card-body">
<h5 class="card-title text-success">${t("charts.monthlyTitle")}</h5>
<canvas id="claimsMonthChart"></canvas>
</div>
</div>
</div>
<div class="col-md-12 mb-4">
<div class="card shadow-sm">
<div class="card-body">
<h5 class="card-title text-danger">${t("charts.lossRatioTitle")}</h5>
<canvas id="lossRatioChart"></canvas>
</div>
</div>
</div>
</div>
`;
hideLoader("#div_graphique", html);
// Render charts with localized labels
renderClaimsChart(data.claims);
renderClaimsMonthChart(data.claimsMonth);
renderLossRatioChart(data.lossRatio);
setupExportPdf();
},
error: function (err) {
console.error("Erreur AJAX:", err);
hideLoader("#div_graphique", `
<div class="alert alert-danger">${t("errors.ajax")}</div>
`);
}
});
}
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 <body> 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) {
// 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);
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
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<dt_effet)
{
v_msg="Veuillez revoir la date!";
v_msgEng="Please review the date!";
alert_ebene(v_msg, v_msgEng);
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);
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
}
});
}
function pop_afficher_selection_retrait()
{
var div_selection_assure = $('#div_selection_assure');
div_selection_assure.html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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('.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);
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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);
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('<div class="spinner-responsive">' + '<span><i class="fa fa-spinner"></i></span>' + '</div>');
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
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' : "1", 'motif' : motif},
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").val("-1");
$("#okId_face").val("-1");
document.getElementById('photo_face').setAttribute('src', "");
$("#faceRegistered").val("0");
$("#ebene_confirmer_photo_face").disable();
$("#ebene_supprimer_photo_face").disable();
$("#motif").disable();
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
v_msg="Face supprimée avec succès!";
v_msgEng="Face removed successfully!";
// alert_ebene(v_msg, v_msgEng);
setTimeout(() => {
prestations();
}, 2000)
}
},
error: function(data) {
},
complete: function(data) {
$("#div_wait_face_ebene").html('');
}
});
}
}
function histsupprface()
{
$("#div_detail_suppr_face").html("");
debut=$("#debut").val();
fin=$("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_detail_suppr_face").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxhistsupprface/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_detail_suppr_face").html(data);
},
complete: function() {
}
});
}
function histsupprface_export()
{
$("#div_detail_suppr_face").html("");
debut=$("#debut").val();
fin=$("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
donnees_retour = "";
$("#div_detail_suppr_face").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxhistsupprfaceexport/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
donnees_retour = data;
},
complete: function() {
$("#div_detail_suppr_face").html(donnees_retour);
}
});
}
function histo_enrollement_face()
{
$("#div_detail_suppr_face").html("");
debut=$("#debut").val();
fin=$("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
donnees_retour = "";
$("#div_detail_suppr_face").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxhistsupprfaceexport/historiqueenrollement/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
donnees_retour = data;
},
complete: function() {
$("#div_detail_suppr_face").html(donnees_retour);
}
});
}
function afficher_liste_log_reconnaissance_faciale()
{
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogreconnaissancefaciale/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_detail").html(data);
},
complete: function() {
}
});
}
function exporter_log_reconnaissance_faciale()
{
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_deatil_pop").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$("#btn_pop").click();
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogreconnaissancefaciale/exporterlogreconnaissancefaciale/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_deatil_pop").html(data);
},
complete: function() {
}
});
}
function afficher_liste_log_register_face()
{
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogregisterface/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_detail").html(data);
},
complete: function() {
}
});
}
function exporter_log_register_face()
{
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_deatil_pop").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$("#btn_pop").click();
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogregisterface/getlogreregisterfaceexport/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_deatil_pop").html(data);
},
complete: function() {
}
});
}
function afficher_liste_log_remove_face()
{
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogremoveface/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_detail").html(data);
},
complete: function() {
}
});
}
function exporter_log_remove_face()
{
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'debut='+debut+'&fin='+fin;
$("#div_deatil_pop").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$("#btn_pop").click();
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogremoveface/getlogreremovefaceexport/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_deatil_pop").html(data);
},
complete: function() {
}
});
}
function ctrlkeypress_liste_logconnexion(ev)
{
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if(keycode == '13')
{
afficher_liste_logconnexion();
}
}
function afficher_liste_logconnexion()
{
login = $("#login").val();
ipConnexion = $("#ipConnexion").val();
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'login='+login+'&ipConnexion='+ipConnexion+'&debut='+debut+'&fin='+fin;
$("#div_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxlogconnexion/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $("#div_test_gabarit").html(data);
$("#div_detail").html(data);
},
complete: function() {
}
});
}
function exporter_liste_logconnexion()
{
login = $("#login").val();
ipConnexion = $("#ipConnexion").val();
debut = $("#debut").val();
fin = $("#fin").val();
donnees = 'login='+login+'&ipConnexion='+ipConnexion+'&debut='+debut+'&fin='+fin;
$("#div_deatil_pop").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$("#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);
}
},
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);
$("#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);
$("#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);
$("#codeLienParente").focus();
return;
}
dateEntree=$("#dateEntree").val();
fraisCarte=$("#fraisCarte").val();
prorata=$("#prorata").val();
donnees = '&dateEntree='+dateEntree;
donnees += '&fraisCarte='+fraisCarte;
donnees += '&prorata='+prorata;
$("#div_prime").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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!");
return;
}
// Si OK, on continue le workflow
$('#div_form_upload').slideUp();
var div_export = $('#div_exporter_liste_assures');
// Affichage du chargement
div_export.html('<div class="text-center p-5"><div class="spinner-border text-primary"></div><br>Préparation de la liste...</div>');
$.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.");
return;
}
var div_export = $('#div_exporter_liste_assures');
div_export.html('<div class="text-center py-5"><div class="spinner-border text-info" role="status"></div><p class="mt-2">Analyse du fichier et liaison à l\'avenant...</p></div>');
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!");
// On attend un tout petit peu que le DOM soit stable avant de passer à la suite
setTimeout(function(){
maj_etape_3_import_assures();
}, 500);
} 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.");
}
});
}
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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);
},
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);
return;
}
etape3=$("#etape3").val();
if (etape3 != "1")
{
v_msg="Etape 3 incomplète!";
v_msgEng="Incomplete step 3!";
alert_ebene(v_msg, v_msgEng);
return;
}
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);
return;
}
donnees = 'idCollege='+idCollege;
var div_attente = $('#div_adherents_importes');
div_attente.html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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);
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);
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);
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);
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);
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;
}
*/
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);
}
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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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);
},
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);
$("#idEntetecontrat").focus();
div_attente.html('');
return;
}
// donnees = 'exercieReference='+exercieReference;
donnees = 'idEntetecontrat='+idEntetecontrat;
div_attente.html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.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);
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()+"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(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxfacturesfamille/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_dossiers").html(data);
},
complete: function() {
}
});
}
function afficher_beneficiare_prime_adherent()
{
debutPeriode = $("#debutPeriode").val();
finPeriode = $("#finPeriode").val();
donnees_retour = "";
donnees = 'debutPeriode='+debutPeriode+"&finPeriode="+finPeriode;
$("#div_detail_requete").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxbeneficiaireprimeadherent/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
donnees_retour = data;
},
complete: function() {
$("#div_detail_requete").html(donnees_retour);
}
});
}
function rapport_sp_police()
{
window.location.assign($("#racineWeb" ).val()+"Sppolice/");
}
function sinistres_a_prime_police()
{
$("#div_detail_sp").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxsppolice/police/",
type: 'POST',
success: function(data) {
$("#div_detail_sp").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function sinistres_a_prime_categorie()
{
$("#div_detail_sp").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxsppolice/categorie/",
type: 'POST',
success: function(data) {
$("#div_detail_sp").html(data);
},
error: function(data) {
},
complete: function() {
return;
}
});
}
function sinistres_a_prime_college()
{
$("#div_detail_sp").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxsppolice/college/",
type: 'POST',
success: function(data) {
$("#div_detail_sp").html(data);
},
error: function(data) {
},
complete: function() {
return;
}
});
}
function requetes_synthese_consommation_police()
{
v_url = $("#racineWeb").val()+"Ajaxsyntheseconsopolice/";
$("#div_detail_sp").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: v_url,
type : 'post',
error: function(errorData)
{
},
success: function(data)
{
donnees_retour = data;
},
complete: function()
{
$("#div_detail_sp").html(donnees_retour);
}
});
}
function requetes_synthese_consommation_police_export()
{
v_url = $("#racineWeb").val()+"Ajaxsyntheseconsopolice/exportxls/";
$("#div_detail_exp").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: v_url,
type : 'post',
error: function(errorData)
{
},
success: function(data)
{
donnees_retour = data;
},
complete: function() {
$('#div_detail_exp').html(donnees_retour);
}
});
}
function lister_ged_police()
{
d1 = $("#d1").val();
d2 = $("#d2").val();
nomOrigine = $("#nomOrigine").val();
donnees = 'd1='+d1+'&d2='+d2+'&nomOrigine='+nomOrigine;
$("#div_ged").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxlistegedpolice/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_ged").html(data);
},
complete: function() {
}
});
}
function imprimer_liste_assures()
{
$('#div_export_assures').html('');
$("#btn_liste_assures").click();
}
function imprimer_liste_assures_date()
{
dateAnalyse = $("#dateAnalyse").val();
if (dateAnalyse<=" ")
{
v_msg="Veuillez indiquer une date!";
v_msgEng="Please enter a date!";
alert_ebene(v_msg, v_msgEng);
$("#dateAnalyse").focus();
return;
}
donnees = 'dateAnalyse='+dateAnalyse;
var div_export = $('#div_export_assures');
div_export.html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaximprimerlisteassure/",
type: 'POST',
data: donnees,
success: function(data)
{
div_export.html(data);
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
}
});
}
function exporter_liste_assures()
{
$('#div_exporter_liste_assures').html('');
$("#btn_exporter_liste_assures").click();
}
function exporter_liste_assures_date()
{
dateAnalyse = $("#dateAnalyse_export").val();
if (dateAnalyse<=" ")
{
v_msg="Veuillez indiquer une date!";
v_msgEng="Please enter a date!";
alert_ebene(v_msg, v_msgEng);
$("#dateAnalyse").focus();
return;
}
donnees = 'dateAnalyse='+dateAnalyse;
var div_export = $('#div_exporter_liste_assures');
div_export.html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxexporterlisteassure/",
type: 'POST',
data: donnees,
success: function(data)
{
div_export.html(data);
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
}
});
}
function retour_recherche_assure()
{
idPolice=$("#idPolice_C" ).val();
if (idPolice>"")
{
window.location.assign($("#racineWeb" ).val()+"Listeadherent/");
}else{
window.location.assign($("#racineWeb" ).val()+"Accueil/");
}
}
function liste_mouvemements_assures()
{
ajoutClient=$("#ajoutClient").val();
codeSensMouvement=$("#codeSensMouvement").val();
valide=$("#valide").val();
debut=$("#debut").val();
fin=$("#fin").val();
donnees = 'codeSensMouvement='+codeSensMouvement;
donnees += '&ajoutClient='+ajoutClient;
donnees += '&valide='+valide;
donnees += '&debut='+debut+'&fin='+fin;
$("#div_mvt").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxmouvementassure/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_mvt").html(data);
appliquerDataTable('.tabliste');
},
complete: function() {
}
});
}
function retour_fiche_police()
{
idPolice=$("#idPolice_C" ).val();
if (idPolice>"")
{
window.location.assign($("#racineWeb" ).val()+"Fichepolice/");
}else{
window.location.assign($("#racineWeb" ).val()+"Accueil/");
}
}
function liste_mouvemements_assures_client()
{
idPolice=$("#idPolice").val();
if (idPolice<=" ")
{
v_msg="Veuillez sélectionner une police!";
v_msgEng="Please select a policy!";
alert_ebene(v_msg, v_msgEng);
return;
}
codeSensMouvement=$("#codeSensMouvement").val();
ajoutClient=$("#ajoutClient").val();
valide=$("#valide").val();
debut=$("#debut").val();
fin=$("#fin").val();
donnees = 'idPolice='+idPolice;
donnees += '&codeSensMouvement='+codeSensMouvement;
donnees += '&ajoutClient='+ajoutClient;
donnees += '&valide='+valide;
donnees += '&debut='+debut+'&fin='+fin;
$("#div_mvt").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
$.ajax({
url: $("#racineWeb").val()+"Ajaxmouvementassure/client/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_mvt").html(data);
appliquerDataTable('.tabliste');
},
complete: function() {
}
});
}
function consulter_facture_pop(idFacture)
{
$("#div_facture_detail").html('');
$("#div_consulter_facture_pop").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
donnees = 'idFacture='+idFacture;
if(isNaN(idFacture))
{
v_msg="Valeur numérique exigée!";
v_msgEng="Numeric value required!";
alert_ebene(v_msg, v_msgEng);
$("#idFacture").val("0");
$("#idFacture").focus();
return;
}
$.ajax({
url: $("#racineWeb").val()+"Ajaxfactureconspop/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_consulter_facture_pop").html(data);
},
error: function(data) {
},
complete: function() {
$('#btn_pop_consulter_facture').click();
}
});
}
function consulterfacturefeuillemaladie_pop()
{
idFacture = $("#idFacture").val();
$("#div_facture_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
donnees = 'idFacture='+idFacture;
if(isNaN(idFacture))
{
v_msg="Valeur numérique exigée!";
v_msgEng="Numeric value required!";
alert_ebene(v_msg, v_msgEng);
$("#idFacture").val("0");
$("#idFacture").focus();
return;
}
$.ajax({
url: $("#racineWeb").val()+"Ajaxfactureconspop/feuillemaladie/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_facture_detail").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function consulterfactureprestationactes_pop()
{
idFacture = $("#idFacture").val();
$("#div_facture_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
donnees = 'idFacture='+idFacture;
if(isNaN(idFacture))
{
v_msg="Valeur numérique exigée!";
v_msgEng="Numeric value required!";
alert_ebene(v_msg, v_msgEng);
$("#idFacture").val("0");
$("#idFacture").focus();
return;
}
$.ajax({
url: $("#racineWeb").val()+"Ajaxfactureconspop/prestationactes/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_facture_detail").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function consulterfacturemedicaments_pop()
{
idFacture = $("#idFacture").val();
$("#div_facture_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
donnees = 'idFacture='+idFacture;
if(isNaN(idFacture))
{
v_msg="Valeur numérique exigée!";
v_msgEng="Numeric value required!";
alert_ebene(v_msg, v_msgEng);
$("#idFacture").val("0");
$("#idFacture").focus();
return;
}
$.ajax({
url: $("#racineWeb").val()+"Ajaxfactureconspop/medicaments/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_facture_detail").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function consulterfactureverres_pop()
{
idFacture = $("#idFacture").val();
$("#div_facture_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
donnees = 'idFacture='+idFacture;
if(isNaN(idFacture))
{
v_msg="Valeur numérique exigée!";
v_msgEng="Numeric value required!";
alert_ebene(v_msg, v_msgEng);
$("#idFacture").val("0");
$("#idFacture").focus();
return;
}
$.ajax({
url: $("#racineWeb").val()+"Ajaxfactureconspop/verres/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_facture_detail").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function consulterfactureged_pop()
{
idFacture = $("#idFacture").val();
$("#div_facture_detail").html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px;">
<div class="spinner-border text-primary" role="status" style="width:3rem; height:3rem;">
<span class="visually-hidden">Loading...</span>
</div>
<span class="mt-3 fs-5 fw-bold">
Veuillez patienter... / Please wait...
</span>
</div>
`);
donnees = 'idFacture='+idFacture;
if(isNaN(idFacture))
{
v_msg="Valeur numérique exigée!";
v_msgEng="Numeric value required!";
alert_ebene(v_msg, v_msgEng);
$("#idFacture").val("0");
$("#idFacture").focus();
return;
}
$.ajax({
url: $("#racineWeb").val()+"Ajaxfactureconspop/geds/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_facture_detail").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function lister_polices_client(id) {
const vues = {
1: "Rechercherassure",
2: "Syntheseconsopolice",
3: "Sppolice"
};
vue = vues[id] || null; // null si id ne correspond à rien
const modalEl = document.getElementById('pop_police');
// On déplace le modal directement sous <body> 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 divPolice = document.getElementById('div_police');
/* ===================================================
* Préparation visuelle (Spinner)
* =================================================== */
showLoader("#div_police", { size: 3 });
/* ===================================================
* Initialisation de l'instance Bootstrap
* =================================================== */
const modal = bootstrap.Modal.getOrCreateInstance(modalEl, {
backdrop: 'static',
keyboard: false
});
/* ===================================================
* 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 + "Ajaxlisterpolicesclient/",
type: 'POST',
data: { vue: vue },
success: function (data) {
divPolice.innerHTML = data;
},
error: function (xhr, status, error) {
divPolice.innerHTML = `
<div class="alert alert-danger m-3 shadow-sm">
<strong>Erreur :</strong> Impossible de générer la liste des polices.
<small class="d-block text-muted mt-1">${error}</small>
</div>
`;
}
});
});
/* ===================================================
* 6. Affichage final
* =================================================== */
modal.show();
}
function ajax_contexter_police(){
idPolice = $("#idPolice").val();
donnees = 'idPolice='+idPolice;
$.ajax({
url: $("#racineWeb").val()+"Ajaxcontextpolice/",
type : 'post',
data: donnees,
error: function(errorData) {
},
complete: function() {
}
});
}
function ouvrir_vue(vue)
{
window.location.assign($("#racineWeb" ).val()+vue+"/");
}