This commit is contained in:
KONE SOREL 2026-02-18 13:42:40 +00:00
parent 6cfca4e52b
commit fa42409901
2 changed files with 104 additions and 8 deletions

View File

@ -1568,6 +1568,7 @@ function creer_avenant()
window.location.assign($("#racineWeb" ).val()+"Creeravenant/");
}
/*
function enregistrer_avenant()
{
codeTypeAvenant=$("#codeTypeAvenant").val();
@ -1593,13 +1594,6 @@ function enregistrer_avenant()
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)
{
@ -1653,7 +1647,94 @@ function enregistrer_avenant()
});
}
*/
function enregistrer_avenant() {
let codeTypeAvenant = $("#codeTypeAvenant").val();
// 1. Vérification si le type d'avenant est sélectionné
if (!codeTypeAvenant || codeTypeAvenant.trim() === "") {
let v_msg = "Veuillez sélectionner le type d'avenant !";
let v_msgEng = "Please select the type of amendment!";
alert_ebene(v_msg, v_msgEng);
return;
}
// 2. Préparation des dates pour comparaison
var d_effet = new Date($("#dateEffetSql").val());
var d_fin = new Date($("#dateFinSql").val());
var d_avenant = $("#dateAvenant").datepicker("getDate");
var d_aujourdhui = new Date();
// On retire les heures pour comparer uniquement les jours
d_aujourdhui.setHours(0, 0, 0, 0);
if (d_avenant) d_avenant.setHours(0, 0, 0, 0);
// Conversion en timestamps (jours)
dt_effet = Math.round(d_effet.getTime() / (1000 * 3600 * 24));
dt_fin = Math.round(d_fin.getTime() / (1000 * 3600 * 24));
dt_avenant = Math.round(d_avenant.getTime() / (1000 * 3600 * 24));
dt_aujourdhui = Math.round(d_aujourdhui.getTime() / (1000 * 3600 * 24));
// --- NOUVELLE RÈGLE : Restriction Incorporation/Retrait ---
// Remplacez 'INC' et 'RET' par vos codes réels issus de la DB
var codesRestrictifs = ['INC', 'RET', 'INCORPORATION', 'RETRAIT'];
if (codesRestrictifs.includes(codeTypeAvenant.toUpperCase())) {
if (dt_avenant < dt_aujourdhui) {
let v_msg = "Pour une incorporation ou un retrait, la date ne peut pas être antérieure à aujourd'hui.";
let v_msgEng = "For additions or removals, the date cannot be earlier than today.";
alert_ebene(v_msg, v_msgEng);
return; // Bloque l'exécution
}
}
// ---------------------------------------------------------
// 3. Vérification des bornes du contrat (déjà existant)
if (dt_avenant > dt_fin || dt_avenant < dt_effet) {
let v_msg = "Veuillez revoir la date ! Elle doit être comprise dans la période de validité du contrat.";
let v_msgEng = "Please review the date! It must be within the contract validity period.";
alert_ebene(v_msg, v_msgEng);
return;
}
// 4. Vérification du Motif
motifavenant=$("#motifavenant").val();
if ($("#motifavenant").val()<" ")
{
v_msg="Veuillez fournir le motif!";
v_msgEng="Please provide the reason";
alert_ebene(v_msg, v_msgEng);
return;
}
// 5. Confirmation de l'avenant
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');
@ -1805,6 +1886,7 @@ function liste_avenant()
window.location.assign($("#racineWeb" ).val()+"Listeavenant/");
}
/*
function controle_date_avenant() {
let codeTypeAvenant = $("#codeTypeAvenant").val();
$("#div_periodidite").html("");
@ -1812,6 +1894,20 @@ function controle_date_avenant() {
//$("#dateAvenant").prop("readonly", true);
//$("#motifavenant").prop("readonly", true);
}
*/
function controle_date_avenant() {
let codeTypeAvenant = $("#codeTypeAvenant").val();
let codesRestrictifs = ['INC', 'RET', 'INCORPORATION', 'RETRAIT'];
if (codesRestrictifs.includes(codeTypeAvenant.toUpperCase())) {
// Restreindre le calendrier à partir d'aujourd'hui
$("#dateAvenant").datepicker("option", "minDate", 0);
} else {
// Autoriser les dates passées (selon les bornes du contrat)
$("#dateAvenant").datepicker("option", "minDate", null);
}
}
function init_import_assures()
{

View File

@ -707,7 +707,7 @@ $photoAssureCrypte = $_SESSION['photoAssureCrypte'];
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Application Scripts -->
<script src="/Js/fonctions.js?ver=2026.02.17.07"></script>
<script src="/Js/fonctions.js?ver=2026.02.18.00"></script>
<script type="text/javascript">
raffraichier_gabarit();