radiantrh/Js/fonctions.js
2026-01-28 18:24:05 +00:00

6483 lines
163 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 toggleSidebar() {
document.body.classList.toggle('sidebar-collapsed');
}
$(function() {
// Initialisation des composants au chargement de la page
appliquerDataTable('.tabliste');
dataTableSpeciale();
let nomForm = $("#nomForm").val();
/*
if(nomForm == "remboursementClassic")
{
let filtre = "0";
d1 = $("#d1").val();
d2 = $("#d2").val();
lister_dossiers_classiques(filtre);
}
*/
});
function raffraichier_gabarit()
{
//controleSession();
$.ajax({
url: $("#racineWeb").val()+"Ajaxgabarit/",
success: function(data)
{
$("#div_ajaxgabarit").html(data);
codeSociete = $("#codeSociete_C").val();
vue = $("#vue").val();
if((codeSociete == undefined || codeSociete <= " ") && vue !="Connexion"){
showMessageDeconnexion();
}
},
error: function(errorData)
{
// alert("Erreur : "+errorData);
},
complete: function()
{
$(".datepicker" ).datepicker();
// raffraichier_messagerie();
}
});
}
function controleSession() {
// Récupérer la durée de session depuis le DOM
const dureeSession = parseInt(document.getElementById('dureeSession')?.value) || 30;
const dureeMinutes = dureeSession * 60 * 1000; // Conversion en millisecondes
// Vérifier régulièrement l'activité de l'utilisateur
//setInterval(() => {
const derniereAction = sessionStorage.getItem('derniere_action');
const maintenant = Date.now();
// Si inactivité dépassant la durée autorisée
if (derniereAction && (maintenant - derniereAction > dureeMinutes)) {
showMessageDeconnexion();
}
//}, 60000); // Vérification toutes les minutes
}
function showMessageDeconnexion()
{
//const msg = "Votre session a expiré. Vous serez déconnecté.";
//const msgEng = "Your session has expired. You will be disconnected.";
//alert_ebene(msg, msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
window.location.assign($("#racineWeb" ).val()+"Connexion/deconnecter/");
//});
}
/**
* 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: (popup) => {
// Ajuste ton contenu responsive
adjustSwalContent(popup);
// Trouver le z-index le plus élevé parmi les modals ouverts
const highestModalZ = [...document.querySelectorAll('.modal.show')]
.map(m => parseInt(window.getComputedStyle(m).zIndex) || 1050)
.reduce((a, b) => Math.max(a, b), 1050);
// Forcer SweetAlert à passer au-dessus
const swalContainer = popup.closest('.swal2-container');
if (swalContainer) {
swalContainer.style.zIndex = highestModalZ + 50;
}
},
willOpen: () => { document.body.style.overflow = 'hidden'; },
willClose: () => { document.body.style.overflow = 'auto'; }
});
}
// 🔒 Fonction utilitaire pour fermer SweetAlert
function closeSwal() {
Swal.close();
}
/**
* ALERTE SIMPLE
* Affiche une information bilingue.
*/
async function alert_ebene(msgFr, msgEn) {
const codeLangue = document.querySelector("#codeLangue")?.value || "fr_FR";
const message = (codeLangue === "en_US") ? msgEn : msgFr;
// On attend que l'utilisateur clique sur OK avant de sortir
await baseSwal({
text: message,
icon: 'info',
confirmButtonText: (codeLangue === "en_US") ? "OK" : "D'accord",
allowOutsideClick: false,
allowEscapeKey: false
});
}
/*
function alert_ebene(msgFr, msgEn) {
const codeLangue = document.querySelector("#codeLangue")?.value || "fr_FR";
const message = (codeLangue === "en_US") ? msgEn : msgFr;
// Bloquant : l'utilisateur doit cliquer sur OK
window.alert(message);
}
*/
/**
* CONFIRMATION
* Affiche une boîte de dialogue Oui/Non et retourne une promesse.
*/
function confirm_ebene(p_msg, p_msg_eng) {
const codeLangue = $("#codeLangue").val();
const message = (codeLangue === "en_US") ? p_msg_eng : p_msg;
return baseSwal({
title: formatMessageForSwal(message),
icon: 'warning',
showCancelButton: true,
confirmButtonText: codeLangue === "en_US" ? 'Yes' : 'Oui',
cancelButtonText: codeLangue === "en_US" ? 'No' : 'Non'
}).then(result => result.isConfirmed);
}
/*
function confirm_ebene(p_msg, p_msg_eng)
{
codeLangue = $("#codeLangue").val();
if(codeLangue=="en_US")
{
return confirm(p_msg_eng);
}
else
{
return confirm(p_msg);
}
}
*/
/**
* SAISIE TEXTE (PROMPT)
* Ouvre une modale avec champ de saisie et exécute un callback avec la valeur.
*/
function prompt_ebene(p_msg, p_msg_eng, p_retour, callback) {
const codeLangue = $("#codeLangue").val();
const message = (codeLangue === "en_US") ? p_msg_eng : p_msg;
baseSwal({
title: formatMessageForSwal(message),
input: 'text',
inputValue: p_retour,
showCancelButton: true,
confirmButtonText: 'OK',
cancelButtonText: codeLangue === "en_US" ? 'Cancel' : 'Annuler'
}).then(result => {
callback(result.isConfirmed ? result.value : null);
});
}
/**
* CHANGEMENT DE MOT DE PASSE
* Demande confirmation avant redirection.
*/
function change_password() {
const v_msg = "Attention, vous serez déconnecté par la suite! Voulez-vous changer votre mot de passe?";
const v_msgEng = "Attention, you will be logged out afterwards! Do you want to change your password?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
window.location.assign($("#racineWeb").val() + "Changermotpass/");
}
});
}
/**
* AFFICHAGE BÉNÉFICIAIRE
* Prépare le contexte serveur avant de charger la fiche bénéficiaire.
*/
function ajax_context_beneficiaire_afficher(idBeneficiaire, okId) {
// Affiche un loader pendant le chargement
$("#contenu").html('<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();
}
});
});
}
function dataTableSpeciale() {
const $table = $('.tabspeciale');
const codeLangue = $("#codeLangue").val() || "fr_FR";
// Détruire l'instance existante si elle existe
if ($.fn.DataTable.isDataTable($table)) {
$table.DataTable().clear().destroy();
// ⚠️ Ne pas vider le contenu, sinon tu perds <thead>/<th>
// $table.empty();
}
// Définition des traductions
const langOptions = {
en_US: {
lengthMenu: "Display _MENU_ records per page",
zeroRecords: "Nothing found - sorry",
info: "Showing page _PAGE_ of _PAGES_",
infoEmpty: "No records available",
search: "Search:",
paginate: {
next: "►",
previous: "◄",
first: "|◄",
last: "►|"
},
infoFiltered: "(filtered from _MAX_ total records)"
},
fr_FR: {
lengthMenu: "Affiche _MENU_ par page",
zeroRecords: "Désolé - Aucune donnée trouvée",
info: "_PAGE_ sur _PAGES_ pages",
infoEmpty: "Pas d'enregistrement",
search: "Recherche:",
paginate: {
next: "►",
previous: "◄",
first: "|◄",
last: "►|"
},
infoFiltered: "(filtré de _MAX_ total enregistrements)"
}
};
// Définition des lengthMenu selon la langue
const lengthMenuOptions = [10, 50, 100];
try {
const dt = $table.DataTable({
responsive: true,
lengthMenu: lengthMenuOptions,
scrollX: true,
scrollY: "75vh",
scrollCollapse: true, // ✅ aide à harmoniser header/body
pagingType: "full_numbers",
autoWidth: false,
searching: true, // ✅ réactive la recherche
ordering: false,
lengthChange: false,
orderMulti: true,
fixedHeader: true, // ✅ garde lentête aligné
language: langOptions[codeLangue] || langOptions.fr_FR
});
// Ajuster les colonnes après init
dt.columns.adjust().draw();
// Ajuster encore après un petit délai (utile après Ajax)
setTimeout(() => {
dt.columns.adjust().draw();
}, 200);
} catch (err) {
console.error("Erreur DataTable:", err);
return false;
}
}
/**
* MESSAGERIE ET NOTIFICATIONS
* Récupère le nombre de messages et déconnecte si session expirée.
*/
function raffraichier_messagerie() {
if (!navigator.onLine) {
$("#test_connexion").css('background-color', 'red');
return;
}
$.ajax({
url: $("#racineWeb").val() + "Ajaxmessagerie/",
success: (data) => {
$("#nbMessagesNonLus").html(data);
$("#span_notification").text($("#msgNonLus").val());
// Sécurité : redirection forcée si le serveur indique une déconnexion nécessaire
if ($("#deconnexion").val() === '1') {
window.location.assign($("#racineWeb").val() + "Connexion/deconnecter/");
}
}
});
}
// Réajuster les popups SweetAlert lors du redimensionnement de la fenêtre
window.addEventListener('resize', () => {
if (Swal.isVisible()) setTimeout(adjustSwalContent, 100);
});
/**
* Sélectionne une police d'assurance et met à jour les champs cachés globaux.
* Cette fonction est généralement appelée lors d'un clic sur une ligne de tableau
* ou un bouton de sélection dans une liste de polices.
*/
function selectionner_police(id, no) {
// Mise à jour de l'ID de la police dans le champ caché prévu pour le traitement serveur
$("#idPolice_C").val(id);
// Mise à jour du numéro de police pour l'affichage ou les recherches secondaires
$("#numeroPolice_C").val(no);
// Note : On pourrait ajouter ici un retour visuel (ex: surbrillance de la ligne sélectionnée)
console.log(`Police sélectionnée : ID ${id} / N° ${no}`);
afficher_police_id(id);
}
/**
* Vérifie la sélection d'une police et lance la mise à jour du contexte.
* Utilisée généralement avant d'afficher le détail d'un contrat.
*/
function afficher_police_id(idPolice) {
// Récupération de l'ID depuis le champ caché
//const idPolice = $("#idPolice_C").val();
// Vérifie si l'ID est présent et non composé uniquement d'espaces
if (idPolice > "0") {
ajax_context_police_afficher(idPolice);
} else {
// Optionnel : Alerte si aucune police n'est sélectionnée
console.warn("Aucun identifiant de police trouvé pour l'affichage.");
}
}
/**
* Définit le contexte de la police côté serveur via AJAX avant redirection.
* @param {string|number} idPolice - L'identifiant de la police à mettre en session.
*/
function ajax_context_police_afficher(idPolice) {
const racine = $("#racineWeb").val() || "/";
$.ajax({
url: racine + "Ajaxcontextpolice/",
type: 'POST',
// On envoie un objet pour que jQuery gère proprement l'encodage
data: { idPolice: idPolice },
beforeSend: function() {
// Optionnel : On pourrait afficher un petit loader ici
},
success: function() {
// Le contexte est mis à jour avec succès
console.log("Contexte police mis à jour.");
},
error: function(xhr, status, error) {
// Alerte l'utilisateur en cas de problème technique
const msg = "Erreur lors de la préparation du dossier police.";
const msgEng = "Error while preparing the policy file.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
},
complete: function() {
// Redirection vers la fiche de la police après le traitement AJAX
window.location.assign(racine + "Fichepolice/");
}
});
}
/**
* Charge la liste des quittances pour une police sur une période donnée.
*/
function afficher_quittances_police_periode() {
// 1. Récupération des paramètres
const racine = $("#racineWeb").val() || "/";
const idPolice = $("#idPolice_C").val();
const debut = $("#debut").val();
const fin = $("#fin").val();
const $conteneur = $("#div_quittancepolice");
// 2. Vérification de l'ID Police (Correction du bug numeroPolice)
if (!idPolice || idPolice.trim() === "") {
console.warn("Affichage quittances impossible : ID Police manquant.");
return;
}
// 3. Préparation de l'interface (Loader)
showLoader("#div_quittancepolice", { size: 3 });
// 4. Appel AJAX
$.ajax({
url: racine + "Ajaxfichepolice/",
type: 'POST',
data: {
idPolice: idPolice,
debut: debut,
fin: fin
},
success: function(data) {
// Injection du résultat
$conteneur.hide().html(data).fadeIn();
appliquerDataTable('.tabliste');
},
error: function(xhr, status, error) {
$conteneur.html(`
<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!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
/* ===================================================
* 2. Initialisation et EXTRACTION du Modal (Solution 3)
* =================================================== */
const modalEl = document.getElementById('pop_export_quittance');
if (!modalEl) {
console.error("Erreur : Le modal #pop_export_quittance est introuvable dans le DOM.");
return;
}
// On déplace le modal directement sous <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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Assuranceindividuelle/");
}
function est_ce_police_famille()
{
codeTypeContrat = $("#codeTypeContrat_C").val();
return (codeTypeContrat=="F");
}
function creer_adherents()
{
debugger;
// 06/11/2020
if(est_ce_police_famille())
{
window.location.assign($("#racineWeb" ).val()+"Assuranceindividuelle/");
return;
}
nbAdh = $("#nbAdh_C").val();
codeTypeContrat = $("#codeTypeContrat_C").val();
if ( (codeTypeContrat!="G") && (nbAdh>0) )
{
v_msg="Ce n\'est pas une police GROUPE!";
v_msgEng="This is not a GROUP policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Creeradherent/");
}
function prorater_prime_adherent()
{
idCollege=$("#idCollege").val();
dateEntree=$("#dateEntree").val();
prorata=$("#prorata").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
donnees += '&dateEntree='+dateEntree;
donnees += '&prorata='+prorata;
$.ajax({
url: $("#racineWeb").val()+"Ajaxproraterprime/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_prime").html(data);
},
complete: function() {
}
});
}
function imprimer_contrat()
{
window.location.assign($("#racineWeb" ).val()+"Contrat/");
}
function adherents_police()
{
if ($("#idPolice_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Listeadherent/");
}
}
function afficher_adherents_police()
{
showLoader("#div_liste_adherent", { size: 3 });
$.ajax({
url: $("#racineWeb").val()+"Ajaxlisteadherent/",
type : 'post',
// data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_liste_adherent").html(data);
}
});
}
// --- I18n dictionary ---
const I18N = {
fr_FR: {
loading: "Affichage en cours...",
exportPdf: "Exporter les graphiques en PDF",
dashboardTitle: "Graphiques des sinistres",
charts: {
claimsTitle: "Répartition des sinistres",
claimsCount: "Nombre de sinistres",
monthlyTitle: "Évolution mensuelle",
monthlyCumulative: "Sinistres cumulés",
monthlySingle: "Sinistres uniques",
lossRatioTitle: "Ratio de sinistralité",
lossRatioLabel: "Ratio de sinistralité"
},
months: ["Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", "Août", "Sep", "Oct", "Nov", "Déc"],
errors: {
ajax: "Impossible de charger les graphiques.",
pdfLib: "Erreur : jsPDF n'est pas chargé."
}
},
en_US: {
loading: "Loading in progress...",
exportPdf: "Export charts to PDF",
dashboardTitle: "Claims Charts",
charts: {
claimsTitle: "Claims distribution",
claimsCount: "Number of claims",
monthlyTitle: "Monthly trend",
monthlyCumulative: "Claims cumulative",
monthlySingle: "Claims single",
lossRatioTitle: "Loss ratio",
lossRatioLabel: "Loss ratio"
},
months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
errors: {
ajax: "Unable to load charts.",
pdfLib: "Error: jsPDF is not loaded."
}
}
};
// --- Helpers ---
function getLang() {
const codeLangue = $("#codeLangue").val() || "fr_FR";
return I18N[codeLangue] ? codeLangue : "fr_FR";
}
function t(path) {
const lang = getLang();
return path.split(".").reduce((acc, key) => (acc && acc[key] != null ? acc[key] : null), I18N[lang]);
}
// Optional: normalize backend month keys to localized labels
function localizeMonths(months) {
const map = {
Jan: "Jan", Feb: "Feb", Mar: "Mar", Apr: "Apr", May: "May", Jun: "Jun",
Jul: "Jul", Aug: "Aug", Sep: "Sep", Oct: "Oct", Nov: "Nov", Dec: "Dec"
};
const langMonths = t("months");
// If backend already provides localized months, keep them; else map to language months by index
if (!Array.isArray(months) || months.length !== 12) return months;
const canonical = months.map(m => map[m] || m);
// Use the language month names but preserve array length and order
return langMonths && langMonths.length === 12 ? langMonths : canonical;
}
function showLoader(selector, options = {}) {
const { message = null, size = 3 } = options;
const text = message || t("loading");
const loaderHtml = `
<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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
donnees += '&dateEntree='+dateEntree;
donnees += '&prorata='+prorata;
$.ajax({
url: $("#racineWeb").val()+"Ajaxproraterprime/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_prime").html(data);
},
complete: function() {
}
});
}
function changer_avenant_incorporation()
{
idAvenant = $("#idAvenant").val();
if(idAvenant<=" ")
{
v_msg="Veuillez sélectionner un avenant!";
v_msgEng="Please select an Amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#idAvenant").focus();
return;
});
}
donnees = 'idAvenant='+idAvenant;
$.ajax({
url: $("#racineWeb").val()+"Ajaxavenant/getdateavenant/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_date_avenant").html(data);
$(".datepicker" ).datepicker();
},
complete: function()
{
prorater_prime_adherent();
}
});
}
function get_age(td2) {
// Vérifie si td2 est déjà un objet Date
if (!(td2 instanceof Date)) {
td2 = new Date(td2); // Convertit une chaîne ou un timestamp en Date
}
const today = new Date();
let age = today.getFullYear() - td2.getFullYear();
const m = today.getMonth() - td2.getMonth();
if (m < 0 || (m === 0 && today.getDate() < td2.getDate())) {
age--;
}
return age;
}
function controle_age(dater, codeLienParente)
{
age = get_age(dater);
$("#agepersonne").val("Âge : "+age);
if (age>65)
{
v_msg="Âge "+age+" supérieur à 65 ans!";
v_msgEng="Age "+age+" over 65!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return false;
});
}
if ( (codeLienParente=="E")&& (age>21) )
{
v_msg="Âge "+age+" => Enfant âgé de plus de 21 ans!";
v_msgEng="Âge "+age+" => Child over 21 years old!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return false;
});
}
if ( (codeLienParente=="O")&& (age>21) )
{
v_msg="Âge "+age+" => Enfant âgé de plus de 21 ans!";
v_msgEng="Âge "+age+" => Child over 21 years old!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return false;
});
}
return true;
}
function controler_piece_beneficiaire()
{
v_codeNaturePiece = $("#codeNaturePiece").val();
if(v_codeNaturePiece<=' ')
{
v_msg="Veuillez sélection la nature de la pièce!";
v_msgEng="Please select the type of document!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeNaturePiece").focus();
return;
});
}
$('#numeroPiece').removeAttr('minlength');
if(v_codeNaturePiece=="CNI")
{
$('#div_controle_piece').html("");
v_numeroPiece = $("#numeroPiece").val();
$('#numeroPiece').attr('minlength', 13);
donnees = "numeroPiece="+v_numeroPiece;
$.ajax({
url: $("#racineWeb").val()+"Ajaxcontrolepiece/",
type: 'POST',
data: donnees,
success: function(data) {
$('#div_controle_piece').html(data);
var resultatPiece = $("#resultatPiece").val();
if(resultatPiece!="0")
{
$("#numeroPiece").focus();
return;
}
},
error: function(data) {
},
complete: function()
{
}
});
}
}
function ajaxListerVille()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaxville/",
type : 'post',
data: "codePays="+$("#codePays").val(),
error: function(errorData) {
},
success: function(data) {
$("#listeville").html(data);
},
complete: function() {
}
});
}
function ajaxListerLocalite()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaxlocalite/",
type : 'post',
data: "codePays="+$("#codePays").val()+"&codeVille="+$("#codeVille").val(),
error: function(errorData) {
},
success: function(data) {
$("#listelocalite").html(data);
}
});
}
function imprimer_contrat()
{
window.location.assign($("#racineWeb" ).val()+"Contrat/");
}
function imprimer_cp(lienEtat)
{
var div_export = $('#div_export_a');
div_export.html(`
<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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Creeravenant/");
}
function enregistrer_avenant()
{
codeTypeAvenant=$("#codeTypeAvenant").val();
oldCodeTypeAvenant=$("#oldCodeTypeAvenant").val();
if ($("#codeTypeAvenant").val()<" ")
{
v_msg="Veuillez sélectionner le type d\'avenant!";
v_msgEng="Please select the type of amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
var d_effet = new Date($("#dateEffetSql").val());
var d_fin = new Date($("#dateFinSql").val());
var d_avenant = $("#dateAvenant").datepicker("getDate");
dt_effet = Math.round(Date.parse(d_effet)/(1000*3600*24));
dt_fin = Math.round(Date.parse(d_fin)/(1000*3600*24));
dt_avenant = Math.round(Date.parse(d_avenant)/(1000*3600*24));
/*
alert("dt_effet => "+dt_effet);
alert("dt_fin => "+dt_fin);
alert("dt_avenant => "+dt_avenant);
return;
*/
if (dt_avenant>dt_fin || dt_avenant<dt_effet)
{
v_msg="Veuillez revoir la date!";
v_msgEng="Please review the date!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
motifavenant=$("#motifavenant").val();
if ($("#motifavenant").val()<" ")
{
v_msg="Veuillez fournir le motif!";
v_msgEng="Please provide the reason";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
v_msg="Confirmez-vous cet avenant?";
v_msgEng="Do you confirm this amendment to the contract?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
var div_attente = $('#div_attente');
div_attente.html(`
<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>
`);
document.getElementById("formAvenant").submit();
}
});
}
function pop_afficher_selection_retrait() {
const div_selection_assure = $('#div_selection_assure');
// 1. Affichage du Loader
div_selection_assure.html(`
<div class="d-flex flex-column align-items-center justify-content-center" style="padding-top:80px; min-height:300px;">
<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 text-muted">
Chargement de la liste... / Loading list...
</span>
</div>
`);
// 2. Appel Ajax
$.ajax({
url: $("#racineWeb").val() + "Ajaxselectionretrait/",
type: 'post',
error: function(xhr, status, error) {
div_selection_assure.html(`
<div class="alert alert-danger m-3">
<i class="fas fa-exclamation-circle me-2"></i>
Erreur lors du chargement : ${error}
<br><small>${xhr.responseText || ''}</small>
</div>
`);
},
success: function(data) {
// Injection des données
div_selection_assure.html(data);
// 3. Initialisation du DataTable si la table existe
const $table = div_selection_assure.find('.tabspeciale');
if ($table.length > 0 && $table.find('thead th').length > 0) {
try {
dataTableSpeciale();
} catch (err) {
console.error("Erreur DataTable:", err);
}
} else {
console.warn("Table .tabspeciale non trouvée ou mal formée");
}
},
complete: function() {
// 4. Gestion propre du Modal
const modalEl = document.getElementById("popdetailassure");
if (modalEl) {
if (modalEl.parentNode !== document.body) {
document.body.appendChild(modalEl);
}
const myModal = bootstrap.Modal.getOrCreateInstance(modalEl);
myModal.show();
}
}
});
}
function beneficiaire_a_retirer(p_choix, p_id_beneficiaire)
{
donnees = 'idBeneficiaire='+p_id_beneficiaire;
donnees += '&choix='+p_choix;
$.ajax({
url: $("#racineWeb").val()+"Ajaxselectionretrait/selectionner/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
}
});
}
function recapituler_retrait()
{
var div_assure_a_retirer = $('#div_assure_a_retirer');
$.ajax({
url: $("#racineWeb").val()+"Ajaxdetailretrait/recapituler/",
type: 'POST',
success: function(data) {
div_assure_a_retirer.html(data);
var oTable = $('.tabliste').DataTable();
oTable.destroy();
setTimeout(function() {
appliquerDataTable('.tabliste');
}, 500);
},
error: function(data) {
},
complete: function() {
}
});
}
function enregistrer_retrait()
{
var div_assure_a_retirer = $('#div_assure_a_retirer');
$.ajax({
url: $("#racineWeb").val()+"Ajaxdetailretrait/recapituler/",
type: 'POST',
success: function(data) {
div_assure_a_retirer.html(data);
},
error: function(data) {
},
complete: function() {
nbAliment=$("#nbAliment").val();
if (nbAliment<"1")
{
v_msg="Veuillez sélectionner les personnes à retirer!";
v_msgEng="Please select the people to remove!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
v_msg="Confirmez-vous le retrait des personnes sélectionnées de cette police?";
v_msgEng="Do you confirm the withdrawal of the selected people from this policy?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
window.location.assign($("#racineWeb" ).val()+"Ficheretrait/enregistrerretrait/");
} else {
// L'utilisateur a annulé
console.log("Confirmation refusée");
}
});
}
});
}
function liste_avenant()
{
window.location.assign($("#racineWeb" ).val()+"Listeavenant/");
}
function controle_date_avenant() {
let codeTypeAvenant = $("#codeTypeAvenant").val();
$("#div_periodidite").html("");
$("#dateAvenant").val($("#datejourfr_C").val());
//$("#dateAvenant").prop("readonly", true);
//$("#motifavenant").prop("readonly", true);
}
function init_import_assures()
{
nbCollege = $("#nbCollege_C").val();
if (nbCollege<="0")
{
v_msg="Aucun collège!";
v_msgEng="No college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
nbAdh = $("#nbAdh_C").val();
codeTypeContrat = $("#codeTypeContrat_C").val();
if (codeTypeContrat=="P")
{
v_msg="Ce n\'est pas une police GROUPE!";
v_msgEng="This is not a GROUP policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Importassure/");
}
function exporter_modele_assure()
{
$('#div_form_upload').hide();
var div_export = $('#div_exporter_liste_assures');
div_export.html(`
<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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
// etatadh=$("#codeEtatAdherent_C").val();
etatadh=$("#codeEtatAdherent").val();
if (etatadh != "V" && etatadh != "W")
{
v_msg="Attention! cette famille n\'est pas en vigueur!";
v_msgEng="Warning! this family is not in force!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Creerbeneficiaire/");
}
function afficher_adherent_id()
{
idAdherent = $("#idAdherent_C" ).val();
if (idAdherent>"0")
{
window.location.assign($("#racineWeb" ).val()+"Ficheadherent/"+$("#idAdherent_C" ).val()+"/");
}
}
//Face KANE 26-09-2025
function re_init_photo_face()
{
var photo = document.getElementById('photo_face');
photo.setAttribute('src', "");
$('#message_face').html("");
$('#image_face').val("");
$("#div_wait_face_ebene").html('');
}
function ebene_init_photo_face() // OK
{
faceRegistered = $("#faceRegistered").val();
if(faceRegistered=="1")
{
v_msg="Cettte personne a déjà une face dans le système!";
v_msgEng="This person already has a face in the system!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$('#message_face').html("");
return;
});
}
re_init_photo_face();
$("#btn_pop_save_face").click();
}
function ebene_enregistrer_photo_face() // OK
{
$("#ebene_confirmer_photo_face").prop('disabled', true);
$("#ebene_supprimer_photo_face").prop('disabled', true);
$("#ebene_take_photo_face").prop('disabled', true);
$("#motif").prop('disabled', true);
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("ebene_take_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
$('#message_face').html("");
$("#div_wait_face_ebene").html('');
$("#okId").val("-1");
$("#okId_face").val("-1");
$("#del_face").val("0");
image_face = $("#image_face").val();
if(image_face<=" ")
{
v_msg="Veuillez prendre une photo!";
v_msgEng="Please take a photo!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
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!!";
setTimeout(() => {
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+v_idBeneficiaire);
}, 1000)
}
},
error: function(data) {
},
complete: function(data) {
$("#div_wait_face_ebene").html('');
}
});
}
function fiche_beneficiaire()
{
idBeneficiaire = $("#idBeneficiaire_C").val();
if (idBeneficiaire>" ")
{
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+idBeneficiaire);
}
/*
if ($("#numeroBeneficiaire_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Fichebeneficiaire/"+$("#numeroBeneficiaire_C" ).val()+"/");
}
*/
}
function ebene_init_confirm_photo_face() // OK
{
faceRegistered = $("#faceRegistered").val();
if(faceRegistered!="1")
{
v_msg="Cettte personne n'a pas encore de face dans le système!";
v_msgEng="This person doesn't have a face in the system yet!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$('#message_face').html("");
return;
});
}
re_init_photo_face();
$("#btn_pop_save_face").click();
}
function ebene_confirmer_photo_face() // OK
{
$("#ebene_confirmer_photo_face").disable();
$("#ebene_supprimer_photo_face").disable();
$("#ebene_take_photo_face").disable();
$("#motif").disable();
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("ebene_take_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
$('#message_face').html("");
$("#div_wait_face_ebene").html('');
$("#del_face").val("0");
faceRegistered = $("#faceRegistered").val();
if(faceRegistered!="1")
{
v_msg="Cette personne n'a pas encore de photo dans le système!";
v_msgEng="This person does not have a photo in the system yet!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$('#message_face').html("");
return;
});
}
image_face = $("#image_face").val();
if(image_face<=" ")
{
v_msg="Veuillez prendre une photo!";
v_msgEng="Please take a photo!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$('#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!";
setTimeout(() => {
prestations();
}, 2000)
}
else
{
$("#okId").val("-1");
$("#okId_face").val("-1");
}
},
error: function(data) {
},
complete: function(data) {
$("#div_wait_face_ebene").html('');
}
});
}
function ebene_supprimer_photo_face() // OK
{
$('#message_face').html("");
$("#div_wait_face_ebene").html('');
motif=$("#motif").val();
motif= motif.trim();
$("#motif").val(motif);
if (motif<=" ")
{
v_msg="Veuillez saisir un motif!";
v_msgEng="Please enter a reaon!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#motif").focus();
return;
});
}
$("#del_face").val("1");
faceRegistered = $("#faceRegistered").val();
if(faceRegistered!="1")
{
v_msg="Cette personne n'a pas encore de photo dans le système!";
v_msgEng="This person does not have a photo in the system yet!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
image_face = $("#image_face").val();
if(image_face<=" ")
{
v_msg="Veuillez prendre une photo!";
v_msgEng="Please take a photo!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
v_msg="Confirmez-vous cette suppression?";
v_msgEng="Do you confirm this deletion?";
if(confirm_ebene(v_msg, v_msgEng))
{
$("#ebene_confirmer_photo_face").disable();
$("#ebene_supprimer_photo_face").disable();
$("#ebene_take_photo_face").disable();
$("#motif").disable();
$("ebene_confirmer_photo_face").prop('disabled', true);
$("ebene_supprimer_photo_face").prop('disabled', true);
$("ebene_take_photo_face").prop('disabled', true);
$("motif").prop('disabled', true);
$("#div_wait_face_ebene").html(`
<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!";
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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
},
complete: function() {
}
});
}
function changer_avenant_incorporation_beneficiaire()
{
idAvenant = $("#idAvenant").val();
if(idAvenant<=" ")
{
v_msg="Veuillez sélectionner un avenant!";
v_msgEng="Please select an Amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#idAvenant").focus();
return;
});
}
donnees = 'idAvenant='+idAvenant;
$.ajax({
url: $("#racineWeb").val()+"Ajaxavenant/getdateavenantbeneficiaire/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_date_avenant").html(data);
$(".datepicker" ).datepicker();
},
complete: function()
{
prorater_prime_beneficiaire();
}
});
}
function filtrergenreconjoint()
{
codeLienParente = $('#codeLienParente').val();
genreAdherent = $('#genreAdherent').val();
if(codeLienParente=='C'){
if(genreAdherent=="F"){
$('#sexe').val('M');
$('#sexeConjoint').val('M');
}else{
$('#sexe').val('F');
$('#sexeConjoint').val('F');
}
$('#sexe').disable();
return;
}
$('#sexe').enable();
}
function prorater_prime_beneficiaire()
{
idAvenant = $("#idAvenant").val();
if(idAvenant<=" ")
{
v_msg="Veuillez sélectionner un avenant!";
v_msgEng="Please select an Amendment!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#idAvenant").focus();
return;
});
}
codeLienParente=$("#codeLienParente").val();
if (codeLienParente=="A")
{
v_msg="Veuillez revoir le lien de parenté!";
v_msgEng="Please review the relationship";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeLienParente").focus();
return;
});
}
dateEntree=$("#dateEntree").val();
fraisCarte=$("#fraisCarte").val();
prorata=$("#prorata").val();
donnees = '&dateEntree='+dateEntree;
donnees += '&fraisCarte='+fraisCarte;
donnees += '&prorata='+prorata;
$("#div_prime").html(`
<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!").then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
// Si OK, on continue le workflow
$('#div_form_upload').slideUp();
var div_export = $('#div_exporter_liste_assures');
// Affichage du chargement
div_export.html('<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.").then(() => {
// Ce code ne sexécute quaprès clic sur OK
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!").then(() => {
// Ce code ne sexécute quaprès clic sur OK
maj_etape_3_import_assures();
});
} else {
div_export.html(''); // On cache le spinner
// Le message d'erreur est déjà affiché par $("#div_erreur_excel").html(data)
}
},
error: function() {
alert_ebene("Erreur technique lors de l'importation.", "Technical error during import.").then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
});
}
function maj_etape_3_import_assures()
{
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/majetape/",
type: 'POST',
success: function(data)
{
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
afficher_liste_assures_a_importer();
}
});
}
function afficher_liste_assures_a_importer()
{
window.location.assign($("#racineWeb" ).val()+"Listeimportassure/");
}
function calculer_prime_inmportation()
{
nb_adh=$("#nb_adh").val();
if (nb_adh>"0")
{
v_msg="Veuillez lier toutes les famille à leur collège!";
v_msgEng="Please link all the family to their college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
afficher_liste_assures_a_importer();
});
},
error: function(data) {
},
complete: function()
{
//afficher_liste_assures_a_importer();
}
});
}
function incorporer_assures_inmportes()
{
nb_adh=$("#nb_adh").val();
if (nb_adh>"0")
{
v_msg="Veuillez revoir les collèges et relancer le calcul des primes!";
v_msgEng="Please review the colleges and restart the premium calculation!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
nb_ligne_ass=$("#nb_ligne_ass").val();
if (nb_ligne_ass=="0")
{
v_msg="Rien à importer!";
v_msgEng="Nothing to import!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
v_msg="Avez-vous fait l\'étape 2 => calcul des primes?";
v_msgEng="Did you do step 2 => premium calculation?";
if(!confirm_ebene(v_msg, v_msgEng))
{
return;
}
primeTtcTotal=$("#primeTtcTotal").val();
if (primeTtcTotal=="0")
{
v_msg="Pas de primes! souhaitez-vous recalculer les primes?";
v_msgEng="No premiums! do you want to recalculate the premiums?";
if(confirm_ebene(v_msg, v_msgEng))
{
return;
}
v_msg="Notez que vous avez accepté l\'incorporation sans primes!";
v_msgEng="Note that you accepted the incorporation without premium!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
});
}
v_msg="Confirmez-vous l\'incorporation de cette liste?";
v_msgEng="Do you confirm the incorporation of this list?";
if(confirm_ebene(v_msg, v_msgEng))
{
var div_attente = $('#div_liste_assure_importe');
div_attente.html(`
<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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
//return;
afficher_police_id();
});
},
error: function(data) {
},
complete: function() {
}
});
}
}
function traiter_lignes_importees()
{
etape2=$("#etape2").val();
if (etape2 != "1")
{
v_msg="Etape 2 incomplète!";
v_msgEng="Incomplete step 2!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
etape3=$("#etape3").val();
if (etape3 != "1")
{
v_msg="Etape 3 incomplète!";
v_msgEng="Incomplete step 3!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
afficher_liste_assures_a_importer();
}
function afficher_adherent_importee()
{
idCollege=$("#idCollege").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'idBeneficiairemodel='+idBeneficiairemodel+'&idCollege='+idCollege;
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/ajouterunadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
function ajouter_tous_adherent_importe_college()
{
idCollege=$("#idCollege").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
v_msg="Attention, cela va vider tous les autres collèges! Confirmez-vous?";
v_msgEng="Be careful, this will empty all other colleges! Do you confirm?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/ajoutertousadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
});
}
function ajouter_sans_college_adherent_importe_college()
{
idCollege=$("#idCollege").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
v_msg="Attention! Confirmez-vous cette opération?";
v_msgEng="Warning! Do you confirm this operation?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/ajoutersanscollegeadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
});
}
function retirer_tous_adherent_importe_college()
{
idCollege=$("#idCollege").val();
if (idCollege<=" ")
{
v_msg="Veuillez sélectionner un collège!";
v_msgEng="Please select a college!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'idCollege='+idCollege;
v_msg="Attention, cela va vider ce collège! Confirmez-vous?";
v_msgEng="Attention, this will empty this college! Do you confirm?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/retirertousadherentaucollege/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_adherent_importee();
}
});
}
});
}
function incorporer_assures_inmportes()
{
nb_adh=$("#nb_adh").val();
if (nb_adh>"0")
{
v_msg="Veuillez revoir les collèges et relancer le calcul des primes!";
v_msgEng="Please review the colleges and restart the premium calculation!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
nb_ligne_ass=$("#nb_ligne_ass").val();
if (nb_ligne_ass=="0")
{
v_msg="Rien à importer!";
v_msgEng="Nothing to import!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
v_msg="Avez-vous fait l\'étape 2 => calcul des primes?";
v_msgEng="Did you do step 2 => premium calculation?";
if(!confirm_ebene(v_msg, v_msgEng))
{
return;
}
primeTtcTotal=$("#primeTtcTotal").val();
if (primeTtcTotal=="0")
{
v_msg="Pas de primes! souhaitez-vous recalculer les primes?";
v_msgEng="No premiums! do you want to recalculate the premiums?";
/*
if(confirm_ebene(v_msg, v_msgEng))
{
return;
}
*/
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
return;
}
});
v_msg="Notez que vous avez accepté l\'incorporation sans primes!";
v_msgEng="Note that you accepted the incorporation without premium!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
//return;
});
}
v_msg="Confirmez-vous l\'incorporation de cette liste?";
v_msgEng="Do you confirm the incorporation of this list?";
confirm_ebene(v_msg, v_msgEng).then(isConfirmed => {
if (isConfirmed) {
var div_attente = $('#div_liste_assure_importe');
div_attente.html(`
<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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
//return;
afficher_police_id();
});
},
error: function(data) {
},
complete: function() {
}
});
}
});
}
function afficher_police_id()
{
idPolice=$("#idPolice_C" ).val();
if (idPolice>"")
{
ajax_context_police_afficher(idPolice);
}
}
function ajax_context_police_afficher(idPolice)
{
donnees = 'idPolice='+idPolice;
$.ajax({
url: $("#racineWeb").val()+"Ajaxcontextpolice/",
type : 'post',
data: donnees,
error: function(errorData) {
},
complete: function() {
window.location.assign($("#racineWeb" ).val()+"Fichepolice/");
}
});
}
function plafond_adherent()
{
if ($("#idAdherent_C" ).val()>"")
{
window.location.assign($("#racineWeb" ).val()+"Plafondadherent/");
}
}
function afficher_garantieadherent_entete_contrat()
{
var div_attente = $('#div_gar_exo');
idEntetecontrat=$("#idEntetecontrat").val();
if (idEntetecontrat<="0")
{
v_msg="Veuillez sélectionner une période!";
v_msgEng="Please select a period!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Changeretatadherent/");
}
function rapport_sp_adherent()
{
window.location.assign($("#racineWeb" ).val()+"Spadherent/");
}
function factures_famille_2()
{
window.location.assign($("#racineWeb" ).val()+"Facturesfamilleadh/");
}
function listerfacturefamille()
{
d1=$("#d1").val();
d2=$("#d2").val();
donnees = 'd1='+d1+'&d2='+d2;
$("#div_dossiers").html(`
<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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#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+"/");
}
function afficher_users_client_id(idUtilisateur)
{
window.location.assign($("#racineWeb" ).val()+"Ficheuserrhclient/"+idUtilisateur+"/");
}
function retour_a_users_rh_client()
{
window.location.assign($("#racineWeb" ).val()+"Usersrhclient/");
}
function verifMailValeur(v_mail)
{
if (v_mail.length==0)
{
return true;
}
else
{
var regex = /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$/;
if(!regex.test(v_mail))
{
return false;
}
else
{
return true;
}
}
}
function enregistrer_modif_user_rh()
{
idUtilisateur = $("#idUtilisateur").val();
nom = $("#nom").val();
prenoms = $("#prenoms").val();
actif = $("#actif").val();
actVisible = "0";
codeLangue = $("#codeLangueUser").val();
AffectionVisible = "0";
telephone = $("#telephone").val();
email = $("#email").val();
codeProfil = $("#codeProfil").val();
if (nom<=" ")
{
v_msg="Veuillez saisir le nom!";
v_msgEng="Please enter the name!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nom").focus();
return;
});
}
if (actif<=" ")
{
v_msg="Utilisateur actif oui ou non?";
v_msgEng="Is the user active yes or no?";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#actif").focus();
return;
});
}
if(codeLangue<=" ")
{
v_msg="Veuillez indiquer la langue!";
v_msgEng="Please select the language";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeLangueUser").focus();
return;
});
}
if (codeProfil<=" ")
{
v_msg="Le profil utilisateur est obligatoire!";
v_msgEng="The user profile is required!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
if(!verifMailValeur(email))
{
v_msg="Veuillez revoir l'adresse mail!";
v_msgEng="Please review the email address!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#email").focus();
return;
});
}
donnees = 'idUtilisateur=' + idUtilisateur;
donnees += '&nom=' + nom;
donnees += '&prenoms=' + prenoms;
donnees += '&actif=' + actif;
donnees += '&actVisible=' + actVisible;
donnees += '&codeLangue=' + codeLangue;
donnees += '&codeProfil=' + codeProfil;
donnees += '&AffectionVisible=' + AffectionVisible;
donnees += '&telephone='+telephone+'&email='+email;
v_msg="Confirmez-vous ces modifications?";
v_msgEng="Do you confirm these modifications?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
$.ajax({
url: $("#racineWeb").val()+"Ajaxuserrhclient/enregistrermodifuser/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
//$('#div_test_gabarit').html(data);
},
complete: function() {
retour_a_users_rh_client();
}
});
} else {
// L'utilisateur a annulé
console.log("Confirmation refusée");
}
});
}
function creer_user_rh_client()
{
codeUtilisateur = $("#codeUtilisateur").val();
codeUtilisateur = codeUtilisateur.trim();
codeUtilisateur = supprimer_espace_string(codeUtilisateur);
codeUtilisateur = codeUtilisateur.toLowerCase();
codeModeGenerationPass = $("#codeModeGenerationPass").val();
codeModeEnvoiPass = $("#codeModeEnvoiPass").val();
nom = $("#nom").val();
prenoms = $("#prenoms").val();
telephone = $("#telephone").val();
email = $("#email").val();
codeProfil = $("#codeProfil").val();
codeLangue = $("#codeLangueUser").val();
nvmdp = $("#nvmdp").val();
cfnvmdp = $("#cfnvmdp").val();
if(nom<=" ")
{
v_msg="Veuillez indiquer le nom!";
v_msgEng="Please enter the name!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nom").focus();
return;
});
}
if(codeUtilisateur<=" ")
{
v_msg="Veuillez indiquer le login!";
v_msgEng="Please enter the login!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeUtilisateur").focus();
return;
});
}
if(codeLangue<=" ")
{
v_msg="Veuillez indiquer la langue!";
v_msgEng="Please select the language";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeLangueUser").focus();
return;
});
}
if (codeProfil<=" ")
{
v_msg="Le profil utilisateur est obligatoire!";
v_msgEng="The user profile is required!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
if ((codeModeEnvoiPass=="1" || codeModeEnvoiPass=="2") && (telephone <=" ") )
{
v_msg="Veuillez revoir le téléphone!";
v_msgEng="Please review the phone!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#telephone").focus();
return;
});
}
if ((codeModeEnvoiPass=="0" || codeModeEnvoiPass=="2") && (email <=" ") )
{
v_msg="Veuillez revoir l'adresse mail!";
v_msgEng="Please review the email address!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#email").focus();
return;
});
}
if(codeModeGenerationPass=="0")
{
if(nvmdp<=" ")
{
v_msg="Veuillez indiquer le mot de passe!";
v_msgEng="Please enter the password!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nvmdp").focus();
return;
});
}
if(nvmdp != cfnvmdp)
{
v_msg="Veuillez confirmer votre mot de passe!";
v_msgEng="Please confirm your password!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#cfnvmdp").focus();
return;
});
}
}
if(!verifMailValeur(email))
{
v_msg="Veuillez revoir l'adresse mail!";
v_msgEng="Please review the email address!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#email").focus();
return;
});
}
motPass = nvmdp;
donnees = 'codeUtilisateur='+codeUtilisateur;
donnees += '&nom='+nom+'&prenoms='+prenoms;
donnees += '&telephone='+telephone+'&email='+email+'&motPass='+motPass;
donnees += '&codeLangue='+codeLangue,
donnees += '&codeModeGenerationPass='+codeModeGenerationPass;
donnees += '&codeModeEnvoiPass='+codeModeEnvoiPass;
donnees += '&codeProfil=' + codeProfil;
v_msg="Confirmez-vous ce nouvel utilisateur?";
v_msgEng="Do you confirm this new user?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
$.ajax({
url: $("#racineWeb").val()+"Ajaxuserrhclient/creeruser/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$('#div_unicite_login').html(data);
},
complete: function()
{
uniciteLogin = $("#uniciteLogin").val();
if(uniciteLogin==1)
{
v_msg="Utilisateur ( "+codeUtilisateur+" ) créé avec succès!";
v_msgEng="User ( "+codeUtilisateur+" ) created succssfully!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
retour_a_users_rh_client();
});
}
else
{
v_msg="Login " + codeUtilisateur +" déjà utilisé!";
v_msgEng="Login " + codeUtilisateur +" already in use!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeUtilisateur").focus();
return;
});
}
}
});
}
});
}
function reinitpaswd_user_rh(codeUtilisateur)
{
v_msg="Confirmez-vous la réinitialisation?";
v_msgEng="Do you confirm the reset?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
donnees = "codeUtilisateur="+codeUtilisateur;
$.ajax({
url: $("#racineWeb").val()+"Ajaxuserrhclient/reinitpaswd/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
},
complete: function() {
v_msg="Opération effectuée avec succès!";
v_msgEng="Operation successfully completed";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
users_gc();
});
}
});
return;
} else {
// L'utilisateur a annulé
v_msg="Opération annulée!";
v_msgEng="Operation canceled!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
});
}
function users_rh_client()
{
window.location.assign($("#racineWeb" ).val()+"Usersrhclient/");
}
function desactiver_user_rh_client(codeUtilisateur)
{
v_msg="Confirmez-vous la désactivation?";
v_msgEng="Do you confirm the deactivation?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
donnees = "codeUtilisateur="+codeUtilisateur;
$.ajax({
url: $("#racineWeb").val()+"Ajaxuserrhclient/desactiver/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
},
complete: function() {
v_msg="Opération effectuée avec succès!";
v_msgEng="Operation successfully completed";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
users_rh_client();
});
}
});
return;
} else {
// L'utilisateur a annulé
v_msg="Opération annulée!";
v_msgEng="Operation canceled!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
});
}
function activer_user_rh_client(codeUtilisateur)
{
v_msg="Confirmez-vous l\'activation?";
v_msgEng="Do you confirm the activation?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
donnees = "codeUtilisateur="+codeUtilisateur;
$.ajax({
url: $("#racineWeb").val()+"Ajaxuserrhclient/activer/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
},
complete: function() {
v_msg="Opération effectuée avec succès!";
v_msgEng="Operation successfully completed";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
users_rh_client();
});
}
});
return;
} else {
// L'utilisateur a annulé
v_msg="Opération annulée!";
v_msgEng="Operation canceled!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
});
}
function ajax_saisir_pass_new_user()
{
codeModeGenerationPass = $("#codeModeGenerationPass").val();
donnees = 'codeModeGenerationPass='+codeModeGenerationPass;
$("#div_passwd").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()+"Ajaxsaisirpassnewuser/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_passwd").html(data);
},
error: function(data) {
},
complete: function()
{
if(codeModeGenerationPass=="0")
{
$("#nvmdp").focus();
}
else
{
$("#btn_enreg").focus();
}
}
});
}
function controle_longeur_passe(controle)
{
longueur = controle.value.length;
if(longueur==0)
{
return false;
}
if(longueur<8)
{
v_msg="8 caractères minimum exigé!";
v_msgEng="8 characters minmum required!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
controle.value="";
controle.focus();
return false;
});
}
}
function controle_new_pass()
{
if ($("#nvmdp" ).val()<=' ')
{
v_msg="Veuillez saisir un mot de passe!";
v_msgEng="Please enter a password!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nvmdp").focus();
return false;
});
}
longueur = $("#nvmdp").val().length;
if(longueur>0 && longueur<8)
{
v_msg="8 caractères minimum exigé!";
v_msgEng="8 characters minmum required!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nvmdp").focus();
return false;
});
}
if ($("#cfnvmdp" ).val()!=$("#nvmdp" ).val())
{
v_msg="Veuillez confirmer votre mot de passe!";
v_msgEng="Please confirm your password!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nvmdp").focus();
return false;
});
}
}
function supprimer_espace_string(p_mot)
{
p_mot = p_mot.trim();
p_mot = p_mot.replace(/ /g, "");
return p_mot;
}
function afficher_menu_principal_profil_rh()
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
var div_attente = $('#div_menu_profil');
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()+"Ajaxhabilitation/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
div_attente.html(data);
},
complete: function() {
}
});
}
function ajouter_tous_menus_principal_profil_rh()
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/ajoutertousmenusprofilrh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_principal_profil_rh();
}
});
}
function ajouter_un_menu_principal_profil_rh(codeMenu)
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil+'&codeMenu='+codeMenu;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/ajouterunmenuprofilrh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_principal_profil_rh();
}
});
}
function retirer_tous_menus_principal_profil_rh()
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/retirertousmenuprofilrh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_principal_profil_rh();
}
});
}
function retirer_un_menu_principal_profil_rh(codeMenu)
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil+'&codeMenu='+codeMenu;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/retirerunmenuprofilrh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_principal_profil_rh();
}
});
}
function changer_langue()
{
codeLangue = $("#codeLangue").val();
v_msg="Attention, vous serez déconnecté! Confirmez-vous le changement de langue?";
v_msgEng="Attention, you will be logged out! Do you confirm the language change?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
$.ajax({
url: $("#racineWeb").val()+"Ajaxchangerlangue/changerlangue/",
type : 'post',
// data: donnees,
error: function(errorData)
{
},
success: function(data)
{
// $("#div_test_gabarit").html(data);
},
complete: function()
{
window.location.assign($("#racineWeb" ).val()+"Connexion/deconnecter/");
}
});
} else {
// L'utilisateur a annulé
console.log("Confirmation refusée");
}
});
}
function ajax_menus_profil()
{
var codeProfil = $("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
$.ajax({
url: $("#racineWeb").val()+"Ajaxmenusprofil/",
type: 'POST',
data: donnees,
success: function(data) {
$("#div_menu").html(data);
},
error: function(data) {
},
complete: function() {
}
});
}
function afficher_menu_vue_profil()
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
codeVue = $("#codeVue").val();
if (codeVue<=" ")
{
v_msg="Veuillez sélectionner une vue!";
v_msgEng="Please select a view!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeVue").focus();
$('#div_menu_profil').html(data);
return;
});
}
donnees = 'codeProfil='+codeProfil;
donnees += '&codeVue='+codeVue;
var div_attente = $('#div_menu_profil');
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()+"Ajaxhabilitation/afficheraccessousmenus/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data)
{
div_attente.html(data);
},
complete: function() {
}
});
}
function ajouter_tous_menu_vue_profil()
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
codeVue=$("#codeVue").val();
if (codeVue<=" ")
{
v_msg="Veuillez sélectionner une vue!";
v_msgEng="Please select a view!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeVue").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
donnees += '&codeVue='+codeVue;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/ajoutertoussousmenusrh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_vue_profil();
}
});
}
function ajouter_un_menu_vue_profil(codeMenu)
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
codeVue=$("#codeVue").val();
if (codeVue<=" ")
{
v_msg="Veuillez sélectionner une vue!";
v_msgEng="Please select a view!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeVue").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
donnees += '&codeVue='+codeVue;
donnees += '&codeMenu='+codeMenu;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/ajouterunsousmenurh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_vue_profil();
}
});
}
function retirer_tous_menu_vue_profil()
{
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
codeVue=$("#codeVue").val();
if (codeVue<=" ")
{
v_msg="Veuillez sélectionner une vue!";
v_msgEng="Please select a view!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeVue").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
donnees += '&codeVue='+codeVue;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/retirertoussousmenusrh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_vue_profil();
}
});
}
function retirer_un_menu_vue_profil(codeMenu)
{
debugger;
codeProfil=$("#codeProfil").val();
if (codeProfil<=" ")
{
v_msg="Veuillez sélectionner un profil!";
v_msgEng="Please select a user profile!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeProfil").focus();
return;
});
}
codeVue=$("#codeVue").val();
if (codeVue<=" ")
{
v_msg="Veuillez sélectionner une vue!";
v_msgEng="Please select a view!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeVue").focus();
return;
});
}
donnees = 'codeProfil='+codeProfil;
donnees += '&codeVue='+codeVue;
donnees += '&codeMenu='+codeMenu;
$.ajax({
url: $("#racineWeb").val()+"Ajaxhabilitation/retirerunsousmenurh/",
type: 'POST',
data: donnees,
success: function(data) {
},
error: function(data) {
},
complete: function() {
afficher_menu_vue_profil();
}
});
}
function verifier_Echeance_ren()
{
codeTypeAvenant=$("#codeTypeAvenant").val();
if(codeTypeAvenant!="REN")
{
return;
}
CalculerEcheanceRen();
CalculerFinRen();
}
function CalculerEcheanceRen()
{
$("#dateEcheanceRen").disable();
codePeriodicite=$("#codePeriodicite").val();
var typdate = $("#dateAvenant").datepicker("getDate");
switch (codePeriodicite) {
case "A":
typdate.addMonths(12);
break;
case "S":
typdate.addMonths(6);
break;
case "T":
typdate.addMonths(3);
break;
case "M":
typdate.addMonths(1);
break;
case "L":
$("#dateEcheanceRen").enable();
typdate = $("#dateEcheanceRen").datepicker("getDate");
break;
default:
typdate.addMonths(12);
}
$( "#dateEcheanceRen" ).datepicker( "setDate", typdate );
}
function CalculerFinRen()
{
$("#dateFinRen").disable();
codeFractionnement=$("#codeFractionnement").val();
var typdate = $("#dateAvenant").datepicker("getDate");
var dtech = $("#dateEcheanceRen").datepicker("getDate");
switch (codeFractionnement) {
case "A":
typdate.addMonths(12);
break;
case "S":
typdate.addMonths(6);
break;
case "T":
typdate.addMonths(3);
break;
case "M":
typdate.addMonths(1);
break;
default:
typdate.addMonths(12);
}
if (typdate>dtech)
{
typdate=dtech;
}
$( "#dateFinRen" ).datepicker( "setDate", typdate );
}
function ControlerEcheanceRen()
{
codePeriodicite=$("#codePeriodicite").val();
if (codePeriodicite!="L") return true;
else {
var eff = $("#dateAvenant").datepicker("getDate");
var ech = $("#dateEcheanceRen").datepicker("getDate");
if (ech<eff) {
$("#dateEcheance").focus();
return false;
}
if (ech>eff.addMonths(12)) {
v_msg="Période supérieur à un an!";
v_msgEng="Period greater than one year!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
}
}
/**
* Gère le changement d'état du switch dans le tableau
*/
function toggleBeneficiaireSelection(checkbox, id) {
// On met à jour la valeur interne
const newValue = checkbox.checked ? '1' : '0';
checkbox.value = newValue;
// Appel de votre fonction métier existante
beneficiaire_a_retirer(newValue, id);
// Optionnel : On peut ajouter un effet visuel sur la ligne
const row = $(checkbox).closest('tr');
if (checkbox.checked) {
row.addClass('table-info');
} else {
row.removeClass('table-info');
}
}
function lister_dossiers_classiques(filtre)
{
var libelle = "";
d1 = $("#d1").val();
d2 = $("#d2").val();
codeLangue = $("#codeLangue").val();
if(filtre=="0"){
libelle = "Tous";
}else if(filtre=="1"){
libelle = "Assurés";
}else if(filtre=="2"){
libelle = "Polices";
}
if(codeLangue=="en_US")
{
if(filtre=="0"){
libelle = "All";
}else if(filtre=="1"){
libelle = "Insured";
}else if(filtre=="2"){
libelle = "Insurance policy";
}
}
$("#libelleFiltre").val(libelle);
$("#filtre").val(filtre);
donnees = 'd1='+d1+'&d2='+d2+'&filtre='+filtre;
$("#div_export_a").html('');
$("#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()+"Ajaxfacturesclassiques/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_dossiers").html(data);
dataTableSpeciale();
},
complete: function() {
}
});
}
function lister_dossiers_classiques_police()
{
d1=$("#d1").val();
d2=$("#d2").val();
donnees = 'd1='+d1+'&d2='+d2;
$("#div_bordereau").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()+"Ajaxdossiersclassiquespolice/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// $('#div_test_gabarit').html(data);
$("#div_dossiers").html(data);
dataTableSpeciale();
},
complete: function() {
}
});
}
function lister_dossiers_classiques_export()
{
//alert("lister_dossiers_classiques_export");
//return;
d1 = $("#d1").val();
d2 = $("#d2").val();
filtre = $("#filtre").val();
nbLigne = $("#nbLigne").val();
if(nbLigne==undefined || nbLigne=="0"){
v_msg="Aucune données à exporter!";
v_msgEng="No data to export!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
donnees = 'd1='+d1+'&d2='+d2+'&filtre='+filtre;
$("#div_export_a").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()+"Ajaxfacturesclassiquesexport/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data) {
$("#div_export_a").html(data);
},
complete: function() {
}
});
}
function consulter_un_bordereau_rbcl(idDossierClassiquePolice)
{
donnees = 'idDossierClassiquePolice='+idDossierClassiquePolice;
$.ajax({
url: $("#racineWeb").val()+"Ajaxdossiersclassiquespolice/getcontextbyidbordereau/",
type : 'post',
data: donnees,
error: function(errorData) {
},
complete: function() {
afficher_dossier_classique_police();
}
});
}
function afficher_dossier_classique_police()
{
window.location.assign($("#racineWeb" ).val()+"Dossierclassiquepolice/");
}
function consulter_dossier_classique(idDossierClassique)
{
donnees = 'idDossierClassique='+idDossierClassique;
$.ajax({
url: $("#racineWeb").val()+"Ajaxdossierclassique/getcontextbyid/",
type : 'post',
data: donnees,
error: function(errorData) {
},
complete: function() {
afficher_dossier_classique();
}
});
}
function afficher_dossier_classique()
{
window.location.assign($("#racineWeb" ).val()+"Dossierclassique/");
}
function listerremboursement()
{
d1 = $("#d1").val();
d2 = $("#d2").val();
codeStatutPaiement = $("#codeStatutPaiement").val();
donnees = 'd1='+ d1+'&d2='+d2+'&codeStatutPaiement='+codeStatutPaiement;
$("#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()+"Ajaxdemanderemboursement/",
type: 'POST',
data: donnees,
error: function(errorData) {
},
success: function(data) {
// alert(data);
$('#div_dossiers').html(data);
},
complete: function() {
}
});
}
function selectionner_remboursement(idDemande)
{
donnees = 'idDemande='+idDemande;
$.ajax({
url: $("#racineWeb").val()+"Ajaxdemanderemboursement/selectionnerremb/",
type: 'POST',
data: donnees,
error: function(errorData) {
},
success: function(data) {
},
complete: function() {
actualiser_remboursement();
}
});
}
function actualiser_remboursement()
{
window.location.assign($("#racineWeb" ).val()+"Remboursement/");
}
function valider_remboursement(idDemande){
$("#div_patienter").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 = 'idDemande='+idDemande;
$.ajax({
url: $("#racineWeb").val()+"Ajaxrhvalidationrd/",
type : 'post',
data: donnees,
error: function(errorData){
alert("Erreur : "+errorData);
},
success: function(data) {
//alert("Success : "+data);
$("#div_patienter").html('');
$('#div_validation').html(data);
//appliquerDataTable();
$('#div_validation').modal("show");
},
complete: function() {
}
});
}
function enregistrer_validation_rd(idDemande){
debugger;
codeStatutPaiement = $("#codeStatutPaiementAjax").val();
motifRejetRh = $("#motifRejetRh").val();
if(codeStatutPaiement == "2"){
const msg = "Une décision de validation est obligatoire.";
const msgEng = "A validation approval is required.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeStatutPaiementAjax").focus();
return;
});
}
if(codeStatutPaiement=="9" && motifRejetRh <=" "){
const msg = "Un motif est obligatoire en cas de refus.";
const msgEng = "A reason is required in case of refusal.";
alert_ebene(msg, msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#motifRejetRh").focus();
return;
});
}
donnees = 'idDemande='+idDemande;
donnees += '&codeStatutPaiement='+codeStatutPaiement;
donnees += '&motifRejetRh='+motifRejetRh;
$.ajax({
url: $("#racineWeb").val()+"Ajaxrhvalidationrd/enregistrer/",
type : 'post',
data: donnees,
error: function(errorData){
alert("Erreur : "+errorData);
},
success: function(data) {
//alert("Success : "+data);
$('#div_validation').modal("hide");
},
complete: function() {
listerremboursement();
}
});
}
function remplacer_adherent()
{
nbAdh = $("#nbAdh_C").val();
codeTypeContrat = $("#codeTypeContrat_C").val();
adherentRetire = $("#adherentRetire").val();
if ( (codeTypeContrat!="G") && (nbAdh>0) )
{
v_msg="Ce n\'est pas une police GROUPE!";
v_msgEng="This is not a GROUP policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if ($("#idAdherent_C" ).val()<= " ")
{
v_msg="Veuillez sélectionner une famille!";
v_msgEng="Please select a family!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (adherentRetire == "1")
{
v_msg="Famille déjà retirée.";
v_msgEng="Family already removed.";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
return;
}
remplacementAdherent=$("#remplacementAdherent").val();
if (remplacementAdherent!="1")
{
v_msg="Remplacement de famille non actif pour cette police!";
v_msgEng="Family replacement inactive for this policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
remplace=$("#remplace").val();
remplacant=$("#remplacant").val();
if (remplacant=="1")
{
if (remplace=="1")
{
v_msg="Famille déjà remplacée!";
v_msgEng="Family already replaced!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
consulter_remplacement_adherent();
});
}
else
{
v_msg="Cette famille en a déjà remplacé une autre, confirmez-vous son remplacement à son tour?";
v_msgEng="This family has already replaced another, do you confirm its replacement in turn?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
fiche_remplacer_adherent();
} else {
// L'utilisateur a annulé
consulter_remplacant_adherent();
}
});
}
}
else
if (remplace=="1")
{
v_msg="Famille déjà remplacée!";
v_msgEng="Family already replaced!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
consulter_remplacement_adherent();
});
}
else
{
fiche_remplacer_adherent();
// window.location.assign($("#racineWeb" ).val()+"Remplaceradherent/");
}
}
function consulter_remplacement_adherent()
{
idAdherent = $("#idAdherent_C" ).val();
if (idAdherent>"0")
{
window.location.assign($("#racineWeb" ).val()+"Remplaceradherentcons/");
}
}
function fiche_remplacer_adherent()
{
etat=$("#codeEtatPolice_C").val();
if (etat=="RE")
{
v_msg="Attention! Police résiliée!";
v_msgEng="Warning! Terminated policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="SU")
{
v_msg="Attention! Police suspendue!";
v_msgEng="Warning! Suspended policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
if (etat=="AN")
{
v_msg="Attention! Police annulée!";
v_msgEng="Warning! Canceled policy!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
window.location.assign($("#racineWeb" ).val()+"Remplaceradherent/");
}
function init_remplacement_adherent()
{
dateSortieAdh = $("#dateSortieAdh").datepicker("getDate");
dateRemplacement = $("#dateRemplacement").datepicker("getDate");
dateEffetPolice = $("#dateEffetPolice_C").val();
dateEffetAdherent = $("#dateEffetAdherent").val();
dateEcheancePolice = $("#dateEcheancePolice_C").val();
var td0 = new Date(dateEffetAdherent);
var td1 = new Date(dateSortieAdh);
var td11 = new Date(dateRemplacement);
var td2 = new Date(dateEcheancePolice);
dt0=Math.round(Date.parse(td0)/(1000*3600*24));
dt1=Math.round(Date.parse(td1)/(1000*3600*24));
dt11=Math.round(Date.parse(td11)/(1000*3600*24));
dt2=Math.round(Date.parse(td2)/(1000*3600*24));
if (td11<=td1)
{
v_msg="Attention! Veuillez revoir vos dates!";
v_msgEng="Warning! Please review your dates!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return false;
});
}
if (dt1>dt2 || dt1<dt0)
{
v_msg="Attention! cette police n'est pas couverte à cette date!";
v_msgEng="Warning! This insurance policy is not valid on this date!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return false;
});
}
etatRetrait = $("#etatRetrait").val();
dateRetrait = $("#dateRetrait").val();
ristourneRetrait = $("#ristourneRetrait").val();
ristourneRetrait = parseInt(ristourneRetrait);
if(etatRetrait=="R" && ristourneRetrait<0)
{
v_msg="Attention! cette personne a été retirée avec une ristourne!";
v_msgEng=" Warning! this person was withdrawn with premium!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return false;
});
}
motifavenant=$("#motifavenant").val();
if ($("#motifavenant").val()<" ")
{
v_msg="Veuillez fournir le motif!";
v_msgEng="Please provide the reason";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
return;
});
}
dateS = $("#dateSortieAdh").val();
dateR = $("#dateRemplacement").val();
fraisCarte = $("#fraisCarte").val();
donnees = 'dateSortie='+dateS+'&dateRemplacement='+dateR+'&motifavenant='+motifavenant+'&fraisCarte='+fraisCarte;
$("#div_remplacement_adherent").html('<div style="padding-top:80px;"><img src="Bootstrap/images/loading.gif"/>&nbsp;&nbsp;<span style="font-size:15pt;">' + 'Veuillez patienter... / Please wait...' + '</span></div>');
$.ajax({
url: $("#racineWeb").val()+"Ajaxremplaceradherent/init/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data)
{
$("#div_remplacement_adherent").html(data);
},
complete: function() {
$(".datepicker" ).datepicker();
}
});
}
function enregistrer_remplacement_adherent()
{
nom = $("#nom").val();
if ($("#nom").val()<" ")
{
v_msg="Veuillez saisir le nom de famille!";
v_msgEng="Please enter the last name!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#nom").focus();
return;
});
}
prenoms = $("#prenoms").val();
if ($("#prenoms").val()<" ")
{
v_msg="Veuillez saisir le prénom!";
v_msgEng="Please enter the first name!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#prenoms").focus();
return;
});
}
codeNaturePiece = $("#codeNaturePiece").val();
if ($("#codeNaturePiece").val()<" ")
{
v_msg="Veuillez saisir la nature de pièce d\'identité!";
v_msgEng="Please enter the nature of ID!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeNaturePiece").focus();
return;
});
}
numeroPiece = $("#numeroPiece").val();
if ($("#numeroPiece").val()<" ")
{
v_msg="Veuillez saisir le No de la pièce d\'identité!";
v_msgEng="Please enter the ID number!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#numeroPiece").focus();
return;
});
}
sexe = $("#sexe").val();
if ($("#sexe").val()<" ")
{
v_msg="Veuillez saisir le sexe!";
v_msgEng="Please enter the sex!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#sexe").focus();
return;
});
}
dateNaissance = $("#dateNaissance").val();
if ($("#dateNaissance").val()<" ")
{
v_msg="Veuillez saisir la date de naissance!";
v_msgEng="Please enter the date of birth!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#dateNaissance").focus();
return;
});
}
codeGroupeSanguin = $("#codeGroupeSanguin").val();
if ($("#codeGroupeSanguin").val()<" ")
{
v_msg="Veuillez saisir le groupe sanguin!";
v_msgEng="Please enter the blood type!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeGroupeSanguin").focus();
return;
});
}
codeSituationFamille = $("#codeSituationFamille").val();
if ($("#codeSituationFamille").val()<" ")
{
v_msg="Veuillez saisir la situation familiale!";
v_msgEng="Please enter the family situation!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codeSituationFamille").focus();
return;
});
}
nombreEnfants = $("#nombreEnfants").val();
adresseGeo = $("#adresseGeo").val();
adressePostale = $("#adressePostale").val();
codePays = $("#codePays").val();
if ($("#codePays").val()<" ")
{
v_msg="Veuillez indiquer le pays!";
v_msgEng="Please indicate the country!";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
$("#codePays").focus();
return;
});
}
telephonFixe = $("#telephonFixe").val();
telephonePortable = $("#telephonePortable").val();
email = $("#email").val();
fraisCarte = $("#fraisCarte").val();
donnees = 'nom='+nom+'&prenoms='+prenoms+'&codeNaturePiece='+codeNaturePiece;
donnees += '&numeroPiece='+numeroPiece+'&sexe='+sexe+'&dateNaissance='+dateNaissance;
donnees += '&codeGroupeSanguin='+codeGroupeSanguin+'&codeSituationFamille='+codeSituationFamille+'&nombreEnfants='+nombreEnfants;
donnees += '&adresseGeo='+adresseGeo+'&adressePostale='+adressePostale+'&codePays='+codePays;
donnees += '&telephonFixe='+telephonFixe+'&telephonePortable='+telephonePortable+'&email='+email+'&fraisCarte='+fraisCarte;
v_msg="Confirmez-vous le remplacement de famille?";
v_msgEng="Do you confirm family replacement?";
confirm_ebene(v_msg, v_msgEng)
.then((isConfirmed) => {
if (isConfirmed) {
// L'utilisateur a confirmé
$("#div_remplacement_adherent").html('<div style="padding-top:80px;"><img src="Bootstrap/images/loading.gif"/>&nbsp;&nbsp;<span style="font-size:15pt;">' + 'Veuillez patienter... / Please wait...' + '</span></div>');
$.ajax({
url: $("#racineWeb").val()+"Ajaxremplaceradherent/enregistrerremplacementadherent/",
type : 'post',
data: donnees,
error: function(errorData) {
},
success: function(data)
{
},
complete: function()
{
v_msg="Opération effectuée avec succès!";
v_msgEng="Operation successfully completed";
alert_ebene(v_msg, v_msgEng).then(() => {
// Ce code ne sexécute quaprès clic sur OK
consulter_remplacement_adherent();
});
}
});
}
});
}