diff --git a/Js/fonctions.js b/Js/fonctions.js index 7a534b47..646f4405 100755 --- a/Js/fonctions.js +++ b/Js/fonctions.js @@ -62448,146 +62448,147 @@ function intit_saisie_garantiebareme() // 23-02-20233 -function actualiser_bareme_garantie_lienparente() -{ - codeGarantie = $("#codeGarantie").val(); - idBaremePriseEnCharge = $("#idBaremePriseEnCharge").val(); - - - - donnees = 'codeGarantie='+codeGarantie; - donnees += '&idBaremePriseEnCharge='+idBaremePriseEnCharge; - - $.ajax({ - url: $("#racineWeb").val()+"Ajaxinsererbaremegarantielienparente/", - type : 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - $('#div_garanties_bareme_lienparente').html(data); - - - }, - complete: function() { - - } - }); - +/** + * Actualise la liste de l'historique des liens de parenté pour la garantie sélectionnée + */ +function actualiser_bareme_garantie_lienparente() { + // 1. Récupération des paramètres + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + const $conteneurHistorique = $('#div_garanties_bareme_lienparente'); + + const donnees = { + codeGarantie: $("#codeGarantie").val(), + idBaremePriseEnCharge: $("#idBaremePriseEnCharge").val() + }; + + // 2. Feedback visuel avant l'appel (SaaS UX) + $conteneurHistorique.html(` +
+
+ + ${(codeLangue === "en_US") ? "Updating history..." : "Mise à jour de l'historique..."} + +
+ `); + + // 3. Appel AJAX + $.ajax({ + url: racineWeb + "Ajaxinsererbaremegarantielienparente/", + type: 'post', + data: donnees, + success: function(data) { + // Injection du tableau HTML retourné par le contrôleur + $conteneurHistorique.hide().html(data).fadeIn(300); + }, + error: function(xhr, status, error) { + $conteneurHistorique.html(` +
+ + ${(codeLangue === "en_US") ? "Unable to refresh history." : "Impossible d'actualiser l'historique."} +
+ `); + } + }); } -function inserer_bareme_garantie_lienparente() -{ - - - codeGarantie = $("#codeGarantie").val(); - idBaremePriseEnCharge = $("#idBaremePriseEnCharge").val(); - - dateEffetGarantieLienParente = $("#dateEffetGarantieLienParente").val(); - codeLienParente = $("#codeLienParente").val(); - forfaitPlafondGarantieLienParente = $("#forfaitPlafondGarantieLienParente").val(); - codePeriodicitePlafondGarantieLienParente = $("#codePeriodicitePlafondGarantieLienParente").val(); - nbreTransactionGarantieLienParente = $("#nbreTransactionGarantieLienParente").val(); - codePeriodiciteGarantieLienParente = $("#codePeriodiciteGarantieLienParente").val(); - //codeObservationFamilleActeLienParente = $("#codeObservationFamilleActeLienParente").val(); - codeTypeRemboursementLienParente = $("#codeTypeRemboursementLienParente").val(); - delaiCarenceFamilleActeLienParente = $("#delaiCarenceFamilleActeLienParente").val(); - ticketModerateurFamilleActeLienParente = $("#ticketModerateurFamilleActeLienParente").val(); - - - forfaitTmGarantieLienParente = $("#forfaitTmGarantieLienParente").val(); - - ageMinimumFamilleActeLienParente = $("#ageMinimumFamilleActeLienParente").val(); - ageMaximumFamilleActeLienParente = $("#ageMaximumFamilleActeLienParente").val(); - actifFamilleActeLienParente = $("#actifFamilleActeLienParente").val(); - - - forfaitPlafondGarantieLienParente = forfaitPlafondGarantieLienParente.replace(/ /g,""); - forfaitTmGarantieLienParente = forfaitTmGarantieLienParente.replace(/ /g,""); - - if(dateEffetGarantieLienParente <= " "){ - - v_msg="Veuillez entrer une date d'effet!"; - v_msgEng="Please enter an effective date!"; - alert_ebene(v_msg, v_msgEng); +/** + * Insertion d'une règle spécifique par Lien de Parenté + */ +function inserer_bareme_garantie_lienparente() { + // 1. Récupération des constantes et éléments UI + const racineWeb = $("#racineWeb").val(); + const codeLangue = $("#codeLangue").val(); + const $divHistorique = $("#div_garanties_bareme_lienparente"); - $("#dateEffetGarantieLienParente").focus(); - return; - - } - - if(codeLienParente <= " "){ - - v_msg="Veuillez entrer le lien de parenté!"; - v_msgEng="Please enter the relationship!"; - alert_ebene(v_msg, v_msgEng); + // 2. Collecte et nettoyage des données + const donnees = { + codeGarantie: $("#codeGarantie").val(), + idBaremePriseEnCharge: $("#idBaremePriseEnCharge").val(), + dateEffetGarantieLienParente: $("#dateEffetGarantieLienParente").val(), + codeLienParente: $("#codeLienParente").val(), + + // Plafonds (Nettoyage des espaces pour les montants) + forfaitPlafondGarantieLienParente: $("#forfaitPlafondGarantieLienParente").val().replace(/\s/g, ""), + codePeriodicitePlafondGarantieLienParente: $("#codePeriodicitePlafondGarantieLienParente").val(), + nbreTransactionGarantieLienParente: $("#nbreTransactionGarantieLienParente").val(), + codePeriodiciteGarantieLienParente: $("#codePeriodiciteGarantieLienParente").val(), + + // Remboursement & Calculs + codeTypeRemboursementLienParente: $("#codeTypeRemboursementLienParente").val(), + delaiCarenceFamilleActeLienParente: $("#delaiCarenceFamilleActeLienParente").val(), + ticketModerateurFamilleActeLienParente: $("#ticketModerateurFamilleActeLienParente").val(), + forfaitTmGarantieLienParente: $("#forfaitTmGarantieLienParente").val().replace(/\s/g, ""), + + // Éligibilité + ageMinimumFamilleActeLienParente: $("#ageMinimumFamilleActeLienParente").val(), + ageMaximumFamilleActeLienParente: $("#ageMaximumFamilleActeLienParente").val(), + actifFamilleActeLienParente: $("#actifFamilleActeLienParente").val() + }; - $("#codeLienParente").focus(); - return; - - } - - if(actifFamilleActeLienParente <= " "){ - - v_msg="Veuillez indiquer le statut de cet barème!"; - v_msgEng="Please indicate the status of this scale!"; - alert_ebene(v_msg, v_msgEng); + // 3. Validations de sécurité avec alertes bilingues + if (!donnees.dateEffetGarantieLienParente || donnees.dateEffetGarantieLienParente.trim() === "") { + alert_ebene("Veuillez entrer une date d'effet !", "Please enter an effective date!"); + $("#dateEffetGarantieLienParente").focus(); + return; + } - $("#actifFamilleActeLienParente").focus(); - return; - - } - - $("#div_garanties_bareme_lienparente").html('
' + '
'); - - - donnees = 'codeGarantie='+codeGarantie; - donnees += '&idBaremePriseEnCharge='+idBaremePriseEnCharge; - - donnees += '&dateEffetGarantieLienParente='+dateEffetGarantieLienParente; - donnees += '&codeLienParente='+codeLienParente; - donnees += '&forfaitPlafondGarantieLienParente='+forfaitPlafondGarantieLienParente; - donnees += '&codePeriodicitePlafondGarantieLienParente='+codePeriodicitePlafondGarantieLienParente; - donnees += '&nbreTransactionGarantieLienParente='+nbreTransactionGarantieLienParente; - donnees += '&codePeriodiciteGarantieLienParente='+codePeriodiciteGarantieLienParente; - - - //donnees += '&codeObservationFamilleActeLienParente='+codeObservationFamilleActeLienParente; - donnees += '&codeTypeRemboursementLienParente='+codeTypeRemboursementLienParente; - donnees += '&delaiCarenceFamilleActeLienParente='+delaiCarenceFamilleActeLienParente; - donnees += '&ticketModerateurFamilleActeLienParente='+ticketModerateurFamilleActeLienParente; - donnees += '&ageMinimumFamilleActeLienParente='+ageMinimumFamilleActeLienParente; - donnees += '&ageMaximumFamilleActeLienParente='+ageMaximumFamilleActeLienParente; - donnees += '&actifFamilleActeLienParente='+actifFamilleActeLienParente; - - donnees += '&forfaitTmGarantieLienParente='+forfaitTmGarantieLienParente; - - - - - $.ajax({ - url: $("#racineWeb").val()+"Ajaxinsererbaremegarantielienparente/ajouter/", - type : 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - - intit_saisie_garantiebareme_lienparente(); - actualiser_bareme_garantie_lienparente(); - - }, - complete: function() { - afficheNombreLigneBareme('garantiesbaremepriseenchargelienparente'); - - } - }); + if (!donnees.codeLienParente || donnees.codeLienParente.trim() === "") { + alert_ebene("Veuillez choisir le lien de parenté !", "Please select the relationship!"); + $("#codeLienParente").focus(); + return; + } + + if (!donnees.actifFamilleActeLienParente || donnees.actifFamilleActeLienParente.trim() === "") { + alert_ebene("Veuillez indiquer le statut !", "Please indicate the status!"); + $("#actifFamilleActeLienParente").focus(); + return; + } + + // 4. Feedback visuel (Loader moderne) + const loadingMsg = (codeLangue === "en_US") ? "Saving relationship rule..." : "Enregistrement de la règle parenté..."; + $divHistorique.html(` +
+
+
+ ${loadingMsg} +
+
+ `); + + // 5. Exécution AJAX + $.ajax({ + url: racineWeb + "Ajaxinsererbaremegarantielienparente/ajouter/", + type: 'post', + data: donnees, + success: function(response) { + // Réinitialisation du formulaire spécifique + if (typeof intit_saisie_garantiebareme_lienparente === 'function') { + intit_saisie_garantiebareme_lienparente(); + } + // Rafraîchissement de la liste sous le formulaire + if (typeof actualiser_bareme_garantie_lienparente === 'function') { + actualiser_bareme_garantie_lienparente(); + } + }, + error: function(xhr) { + $divHistorique.html(` +
+ + ${(codeLangue === "en_US") ? "Error during save process." : "Erreur lors de l'enregistrement."} +
+ `); + }, + complete: function() { + // Mise à jour du badge de comptage global + if (typeof afficheNombreLigneBareme === 'function') { + afficheNombreLigneBareme('garantiesbaremepriseenchargelienparente'); + } + } + }); } + function intit_saisie_garantiebareme_lienparente() { $("#dateEffetGarantieLienParente").val(""); @@ -62997,74 +62998,73 @@ function controleDateEffetGarantieBareme(){ //24-02-2023 -function validiteDateEffetGarantieLienParente(){ - - var codeGarantie = $("#codeGarantie").val(); - var idBaremePriseEnCharge = $("#idBaremePriseEnCharge").val(); - - var dateEffetGarantieLienParente = $("#dateEffetGarantieLienParente").val(); - var codeLienParente = $("#codeLienParente").val(); - - var datejour = $("#datejour_C").val(); - - var str = dateEffetGarantieLienParente.split('/'); - var effet = str[2]+'-'+str[1]+'-'+str[0]; - - - donnees = 'codeGarantie='+codeGarantie; - donnees += '&idBaremePriseEnCharge='+idBaremePriseEnCharge; - donnees += '&codeLienParente='+codeLienParente; - - //alert(donnees); - //return; - - $.ajax({ - url: $("#racineWeb").val()+"Ajaxinsererbaremegarantielienparente/controle/", - type : 'post', - data: donnees, - error: function(errorData){ - //alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - $('#div_maxdateeffetGarantieLienParente').html(data); - - var tdj = new Date(datejour); - var tde = new Date(effet); - - maxDateEffetGarantieLienParente = $("#maxDateEffetGarantieLienParente").val(); - - dte=Math.round(Date.parse(tde)/(1000*3600*24)); - dtj=Math.round(Date.parse(tdj)/(1000*3600*24)); - - if((dte < dtj) && (maxDateEffetGarantieLienParente!=undefined || maxDateEffetGarantieLienParente!='')){ - var tdm = new Date(maxDateEffetGarantieLienParente); - dtm = Math.round(Date.parse(tdm)/(1000*3600*24)); - - if(dte < dtm){ - - v_msg="Date d'effet invalide!"; - v_msgEng="Invalid effective date!"; - alert_ebene(v_msg, v_msgEng); - - $("#dateEffetGarantieLienParente").val(''); - $("#dateEffetGarantieLienParente").focus(); - return; - }else{ - inserer_bareme_garantie_lienparente(); - } - }else{ - - inserer_bareme_garantie_lienparente(); - } - - }, - complete: function() { - - - } - }); - +/** + * Contrôle la validité de la date d'effet avant l'insertion par Lien de Parenté + */ +function validiteDateEffetGarantieLienParente() { + // 1. Récupération des données + const racineWeb = $("#racineWeb").val(); + const dateEffetStr = $("#dateEffetGarantieLienParente").val(); + const dateJourStr = $("#datejour_C").val(); // Format YYYY-MM-DD attendu + + const donnees = { + codeGarantie: $("#codeGarantie").val(), + idBaremePriseEnCharge: $("#idBaremePriseEnCharge").val(), + codeLienParente: $("#codeLienParente").val() + }; + + // Validation immédiate si vide + if (!dateEffetStr || dateEffetStr.trim() === "") { + alert_ebene("Veuillez entrer une date d'effet !", "Please enter an effective date !"); + $("#dateEffetGarantieLienParente").focus(); + return; + } + + // Conversion de la date saisie (DD/MM/YYYY) en objet Date + const parts = dateEffetStr.split('/'); + const dateEffetSaisie = new Date(parts[2], parts[1] - 1, parts[0]); + const dateJour = new Date(dateJourStr); + + // 2. Appel AJAX de contrôle (Récupération de la dernière date en base) + $.ajax({ + url: racineWeb + "Ajaxinsererbaremegarantielienparente/controle/", + type: 'post', + data: donnees, + success: function(data) { + // Injection du champ hidden maxDateEffetGarantieLienParente retourné par le serveur + $('#div_maxdateeffetGarantieLienParente').html(data); + + const maxDateBaseStr = $("#maxDateEffetGarantieLienParente").val(); + + // Calcul des timestamps en jours (pour comparaison simplifiée) + const dte = Math.round(dateEffetSaisie.getTime() / (1000 * 3600 * 24)); + const dtj = Math.round(dateJour.getTime() / (1000 * 3600 * 24)); + + // 3. Logique de validation chronologique + if (dte < dtj && maxDateBaseStr) { + const maxDateBase = new Date(maxDateBaseStr); + const dtm = Math.round(maxDateBase.getTime() / (1000 * 3600 * 24)); + + if (dte < dtm) { + // Échec : La date est antérieure à la dernière date enregistrée + alert_ebene( + "Date d'effet invalide ! Elle ne peut être antérieure à la dernière modification.", + "Invalid effective date ! It cannot be earlier than the last modification." + ); + $("#dateEffetGarantieLienParente").val('').focus(); + return; + } + } + + // Si tous les contrôles passent : Appel de la fonction d'insertion + if (typeof inserer_bareme_garantie_lienparente === 'function') { + inserer_bareme_garantie_lienparente(); + } + }, + error: function() { + alert_ebene("Erreur lors du contrôle de validité.", "Error during validity check."); + } + }); } diff --git a/Vue/Ajaxactesgarantiebareme/index.php b/Vue/Ajaxactesgarantiebareme/index.php index afad574d..ab9d0a66 100755 --- a/Vue/Ajaxactesgarantiebareme/index.php +++ b/Vue/Ajaxactesgarantiebareme/index.php @@ -353,7 +353,7 @@ -
+
diff --git a/Vue/Ajaxinsererbaremegarantielienparente/index.php b/Vue/Ajaxinsererbaremegarantielienparente/index.php index 02407178..24e187da 100755 --- a/Vue/Ajaxinsererbaremegarantielienparente/index.php +++ b/Vue/Ajaxinsererbaremegarantielienparente/index.php @@ -1,95 +1,99 @@ - - "0"): ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - nettoyer($v['codeObservation'])=="VD"){ - $codeObservation = ""; - }else{ - $codeObservation = $this->nettoyer($v['codeObservation']); - } - - if($this->nettoyer($v['actif'])=="1"){ - $actif = "Oui"; - }else{ - $actif = "Non"; - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nettoyer($v['dateEffet'])); ?>nettoyer($v['codeLienParente']);?>nettoyer($v['forfaitPlafond']));?>nettoyer($v['codePeriodicitePlafond']);?>nettoyer($v['nbreTransaction']);?>nettoyer($v['codePeriodicite']); ?> nettoyer($v['codeTypeRemboursement']); ?>nettoyer($v['delaiCarenceFamilleActe']);?>nettoyer($v['ticketModerateur']);?>nettoyer($v['forfaitTm']));?>nettoyer($v['ageMinimum']);?>nettoyer($v['ageMaximum']);?> - -
- -
- + 0): ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + nettoyer($v['actif']) == "1"); + ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
nettoyer($v['dateEffet'])); ?> + + nettoyer($v['codeLienParente']);?> + + nettoyer($v['forfaitPlafond']));?>nettoyer($v['codePeriodicitePlafond']);?>nettoyer($v['nbreTransaction']);?>nettoyer($v['codePeriodicite']); ?>nettoyer($v['codeTypeRemboursement']); ?>nettoyer($v['delaiCarenceFamilleActe']);?> mnettoyer($v['ticketModerateur']);?> %nettoyer($v['forfaitTm']));?>nettoyer($v['ageMinimum']);?>nettoyer($v['ageMaximum']);?> + + + + + + + + + + + +
- + + +
+ +

+
+ + + \ No newline at end of file