df
This commit is contained in:
parent
1edb41e656
commit
8b8eed29c9
221
Js/fonctions.js
221
Js/fonctions.js
|
|
@ -47907,130 +47907,109 @@ function supprimerprestataireenmoins($idData){
|
|||
}
|
||||
|
||||
|
||||
// Enregistrement des données dans les différentes tables (Ajout ou modification)
|
||||
function update_table(){
|
||||
|
||||
var fichier_ajouter = $('#fichier_ajouter').val(),
|
||||
fichier_lister = $('#fichier_lister').val(),
|
||||
fichier_modifier= $('#fichier_modifier').val(),
|
||||
id = $('#formData .sr-only').val(),
|
||||
visible = false,
|
||||
valide = true;
|
||||
requis = $('input,select,textarea').filter('[required]:visible');
|
||||
function update_table() {
|
||||
const racineWeb = $("#racineWeb").val();
|
||||
const codeLangue = $("#codeLangue").val();
|
||||
const nomForm = $('#nomForm').val();
|
||||
|
||||
// 1. Récupération dynamique des fichiers (priorité aux champs hidden)
|
||||
let f_ajouter = $('#fichier_ajouter').val();
|
||||
let f_modifier = $('#fichier_modifier').val();
|
||||
let f_lister = $('#fichier_lister').val();
|
||||
|
||||
if(fichier_ajouter == undefined && fichier_modifier==undefined && fichier_lister==undefined){
|
||||
var nomForm = $('#nomForm').val();
|
||||
|
||||
if(nomForm == 'frmbaremegarant'){
|
||||
fichier_ajouter = 'Ajaxajouterbaremeaccessoiregarant';
|
||||
fichier_modifier = 'Ajaxmodifierbaremeaccessoiregarant';
|
||||
}else if(nomForm == 'frmtrancheaccessoire'){
|
||||
fichier_ajouter = 'Ajaxtbajouterbaremeaccessoireavenant';
|
||||
fichier_modifier = 'Ajaxtbmodifierbaremeaccessoireavenant';
|
||||
fichier_lister = 'Ajaxtblisterbaremeaccessoireavenant';
|
||||
}else if(nomForm == 'frmtauxAjustement'){
|
||||
fichier_ajouter = 'Ajaxtbajoutertableauajustement';
|
||||
fichier_modifier = 'Ajaxtbmodifiertableauajustement';
|
||||
fichier_lister = 'Ajaxtblistertableauajustement';
|
||||
}else if(nomForm == 'frmtauxAjustementgarant'){
|
||||
fichier_ajouter = 'Ajaxtbajoutertableauajustementgarant';
|
||||
fichier_modifier = 'Ajaxtbmodifiertableauajustementgarant';
|
||||
fichier_lister = 'Ajaxtblistertableauajustementgarant';
|
||||
}else if(nomForm == 'frmacteconsultation'){
|
||||
fichier_ajouter = 'Ajaxtbajouteracteconsultation';
|
||||
fichier_modifier = 'Ajaxtbmodifieracteconsultation';
|
||||
}
|
||||
}
|
||||
|
||||
if(id == undefined){
|
||||
link = $("#racineWeb").val()+fichier_ajouter+"/ajouter/"
|
||||
}else{
|
||||
link = $("#racineWeb").val()+fichier_modifier+"/modifier/"
|
||||
}
|
||||
|
||||
requis.each(function(){
|
||||
if($(this).val() == ''){
|
||||
v_msg="Veuillez saisir les champs en rouge !";
|
||||
v_msgEng="Please enter the fields in red !";
|
||||
alert_ebene(v_msg,v_msgEng);
|
||||
$(this).css('borderColor','red');
|
||||
valide = false;
|
||||
return false;
|
||||
}else{
|
||||
valide = true;
|
||||
}
|
||||
});
|
||||
// Mapping de secours si les champs hidden sont absents
|
||||
if (!f_ajouter && !f_modifier) {
|
||||
const mapping = {
|
||||
'frmbaremegarant': ['Ajaxajouterbaremeaccessoiregarant', 'Ajaxmodifierbaremeaccessoiregarant', ''],
|
||||
'frmtrancheaccessoire': ['Ajaxtbajouterbaremeaccessoireavenant', 'Ajaxtbmodifierbaremeaccessoireavenant', 'Ajaxtblisterbaremeaccessoireavenant'],
|
||||
'frmtauxAjustement': ['Ajaxtbajoutertableauajustement', 'Ajaxtbmodifiertableauajustement', 'Ajaxtblistertableauajustement'],
|
||||
'frmtauxAjustementgarant': ['Ajaxtbajoutertableauajustementgarant', 'Ajaxtbmodifiertableauajustementgarant', 'Ajaxtblistertableauajustementgarant'],
|
||||
'frmacteconsultation': ['Ajaxtbajouteracteconsultation', 'Ajaxtbmodifieracteconsultation', '']
|
||||
};
|
||||
if (mapping[nomForm]) {
|
||||
[f_ajouter, f_modifier, f_lister] = mapping[nomForm];
|
||||
}
|
||||
}
|
||||
|
||||
if(valide){
|
||||
donnees = $('#formData').serialize();
|
||||
|
||||
if(nomForm == 'assures'){
|
||||
var dateNaissance = $("#dateNaissance").val();
|
||||
var dateEntree = $("#dateEntree").val();
|
||||
var dateAdhesion = $("#dateAdhesion").val();
|
||||
var dateRetrait = $("#dateRetrait").val();
|
||||
|
||||
donnees+="&dateNaissance="+dateNaissance+"&dateEntree="+dateEntree;
|
||||
donnees+="&dateAdhesion="+dateAdhesion+"&dateRetrait="+dateRetrait;
|
||||
}else if(nomForm == 'ayantdroits'){
|
||||
var adDateNaissance = $("#adDateNaissance").val();
|
||||
donnees+="&adDateNaissance="+adDateNaissance;
|
||||
}else if(nomForm == 'frmbaremegarant'){
|
||||
var codeGcAssureur = $("#codeGcAssureur").val();
|
||||
donnees+="&codeGcAssureur="+codeGcAssureur;
|
||||
}else if(nomForm == 'frmtauxAjustementgarant'){
|
||||
var codeGcAssureur = $("#codeGcAssureur").val();
|
||||
donnees+="&codeGcAssureur="+codeGcAssureur;
|
||||
}
|
||||
|
||||
//alert(donnees);
|
||||
|
||||
//return;
|
||||
|
||||
$.ajax({
|
||||
url: link,
|
||||
type : 'post',
|
||||
data: donnees,
|
||||
error: function(errorData) {
|
||||
|
||||
},
|
||||
success: function(data) {
|
||||
// alert(data);
|
||||
|
||||
if(data.length > 5){
|
||||
var str = data.split('/');
|
||||
alert_ebene(str[0],str[1]);
|
||||
visible = true;
|
||||
}
|
||||
if(nomForm == 'frmbaremegarant'){
|
||||
afficher_bareme_accessoire_garant();
|
||||
fermeFormulaire();
|
||||
return;
|
||||
}else if(nomForm == "frmtrancheaccessoire"){
|
||||
window.location.assign($("#racineWeb" ).val()+"Tranchesaccessoires/");
|
||||
}else if(nomForm == "frmtauxAjustement"){
|
||||
window.location.assign($("#racineWeb" ).val()+"Tableauajustementprimes/");
|
||||
}else if(nomForm == 'frmtauxAjustementgarant'){
|
||||
afficher_tauxajustement_garant();
|
||||
fermeFormulaire();
|
||||
return;
|
||||
}else if(nomForm == "frmacteconsultation"){
|
||||
window.location.assign($("#racineWeb" ).val()+"Actesconsultations/");
|
||||
}
|
||||
|
||||
afficheDonneesTableChoisie(fichier_lister);
|
||||
if(!visible){
|
||||
fermeFormulaire();
|
||||
}else{
|
||||
$('#div_maj_table input:first').css('borderColor','red');
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
|
||||
}
|
||||
});
|
||||
// 2. Détermination de l'ID et de l'URL (Ajout vs Modif)
|
||||
const idValue = $('#id').val() || $('#formData .sr-only').val();
|
||||
const isEdit = (idValue && idValue != '0' && idValue != '');
|
||||
const finalLink = racineWeb + (isEdit ? f_modifier + "/modifier/" : f_ajouter + "/ajouter/");
|
||||
|
||||
}
|
||||
// 3. Validation des champs requis
|
||||
let valide = true;
|
||||
const requis = $('#formData').find('[required]:visible');
|
||||
|
||||
requis.each(function() {
|
||||
if ($(this).val().trim() === '') {
|
||||
const msg = (codeLangue === "en_US") ? "Please fill in the required fields!" : "Veuillez remplir les champs obligatoires !";
|
||||
alert_ebene(msg, msg);
|
||||
$(this).addClass('is-invalid').css('borderColor', '#dc3545').focus();
|
||||
valide = false;
|
||||
return false; // Break loop
|
||||
} else {
|
||||
$(this).removeClass('is-invalid').css('borderColor', '');
|
||||
}
|
||||
});
|
||||
|
||||
if (!valide) return;
|
||||
|
||||
// 4. Collecte et enrichissement des données
|
||||
let donnees = $('#formData').serialize();
|
||||
|
||||
// Ajout de l'ID si manquant dans le serialize
|
||||
if (isEdit && !donnees.includes('id=')) donnees += "&id=" + idValue;
|
||||
|
||||
// Cas spécifiques (Dates et codes parents)
|
||||
const addParam = (id) => $(id).length ? "&" + $(id).attr('id') + "=" + $(id).val() : "";
|
||||
|
||||
if (nomForm === 'assures') {
|
||||
donnees += addParam("#dateNaissance") + addParam("#dateEntree") + addParam("#dateAdhesion") + addParam("#dateRetrait");
|
||||
} else if (nomForm === 'ayantdroits') {
|
||||
donnees += addParam("#adDateNaissance");
|
||||
} else if (['frmbaremegarant', 'frmtauxAjustementgarant'].includes(nomForm)) {
|
||||
donnees += addParam("#codeGcAssureur");
|
||||
}
|
||||
|
||||
// 5. Exécution AJAX
|
||||
$.ajax({
|
||||
url: finalLink,
|
||||
type: 'post',
|
||||
data: donnees,
|
||||
beforeSend: function() {
|
||||
$('#btn-action').prop('disabled', true).html('<span class="spinner-border spinner-border-sm"></span>');
|
||||
},
|
||||
success: function(data) {
|
||||
// Gestion de la réponse serveur (Message Succès/Erreur)
|
||||
if (data && data.length > 5) {
|
||||
const parts = data.split('/');
|
||||
alert_ebene(parts[0], parts[1] || parts[0]);
|
||||
}
|
||||
|
||||
// Routage après succès
|
||||
const routes = {
|
||||
'frmbaremegarant': () => { if(window.afficher_bareme_accessoire_garant) afficher_bareme_accessoire_garant(); fermeFormulaire(); },
|
||||
'frmtrancheaccessoire': () => window.location.assign(racineWeb + "Tranchesaccessoires/"),
|
||||
'frmtauxAjustement': () => window.location.assign(racineWeb + "Tableauajustementprimes/"),
|
||||
'frmtauxAjustementgarant': () => { if(window.afficher_tauxajustement_garant) afficher_tauxajustement_garant(); fermeFormulaire(); },
|
||||
'frmacteconsultation': () => window.location.assign(racineWeb + "Actesconsultations/")
|
||||
};
|
||||
|
||||
if (routes[nomForm]) {
|
||||
routes[nomForm]();
|
||||
} else {
|
||||
// Comportement par défaut : rafraîchir la liste et fermer
|
||||
if (f_lister) afficheDonneesTableChoisie(f_lister);
|
||||
fermeFormulaire();
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
toastr.error("Erreur serveur : " + xhr.status);
|
||||
},
|
||||
complete: function() {
|
||||
$('#btn-action').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function cocherDecocherTout(fichier_lister){
|
||||
|
|
|
|||
|
|
@ -1,14 +1,61 @@
|
|||
<form id="formData">
|
||||
<legend id="titre_formData"><?= _("Ajouter des données") ?></legend>
|
||||
<table class="table table-responsive table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="5%" align="center" class="required">Code</td>
|
||||
<td width="10%" ><INPUT class="form-control majuscule" TYPE="text" id="codePays" NAME="codePays" required AUTOCOMPLETE="OFF" autofocus ></td>
|
||||
<div class="card border-0 shadow-sm border-start border-success border-4 mb-4">
|
||||
<div class="card-header bg-white py-3 border-0">
|
||||
<h6 class="mb-0 fw-bold text-uppercase text-success small" id="titre_formData">
|
||||
<i class="fas fa-plus-circle me-2"></i><?= _("Ajouter un Pays") ?>
|
||||
</h6>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form id="formData">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small fw-bold text-muted required">Code</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-barcode text-muted"></i></span>
|
||||
<input class="form-control border-2 border-start-0 ps-0 majuscule fw-bold"
|
||||
type="text"
|
||||
id="codePays"
|
||||
name="codePays"
|
||||
maxlength="3"
|
||||
required
|
||||
autocomplete="off"
|
||||
autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
<label class="form-label small fw-bold text-muted required"><?= _("Libellé du Pays") ?></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-globe-africa text-muted"></i></span>
|
||||
<input class="form-control border-2 border-start-0 ps-0 majuscule"
|
||||
type="text"
|
||||
id="libelle"
|
||||
name="libelle"
|
||||
required
|
||||
autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<td width="5%" align="center" class="required"><?= _("Libellé") ?></td>
|
||||
<td width="70%" ><INPUT class="form-control majuscule" TYPE="text" id="libelle" NAME="libelle" required AUTOCOMPLETE="OFF" ></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<div id="form-errors" class="alert alert-danger mt-3 d-none small py-2"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Force la majuscule pendant la saisie */
|
||||
.majuscule { text-transform: uppercase; }
|
||||
|
||||
/* Style spécifique pour les champs requis */
|
||||
.required:after {
|
||||
content: " *";
|
||||
color: #dc3545;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Animation au focus */
|
||||
.form-control:focus {
|
||||
border-color: #28a745 !important;
|
||||
box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.15) !important;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,15 +1,57 @@
|
|||
<form id="formData">
|
||||
<legend id="titre_formData"><?= _("Modification des données") ?></legend>
|
||||
<INPUT class="sr-only" TYPE="text" id = "id" name = "id" value="<?=$pays['id']?>">
|
||||
<table class="table table-responsive table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="5%" align="center">Code</td>
|
||||
<td width="10%" ><INPUT class="form-control majuscule" TYPE="text" id="codePays" NAME="codePays" required AUTOCOMPLETE="OFF" autofocus value="<?= $this->nettoyer($pays['codePays']); ?>" readonly></td>
|
||||
<div class="card border-0 shadow-sm border-start border-primary border-4 mb-4">
|
||||
<div class="card-header bg-white py-3 border-0">
|
||||
<h6 class="mb-0 fw-bold text-uppercase text-primary small" id="titre_formData">
|
||||
<i class="fas fa-edit me-2"></i><?= _("Modification du Pays") ?>
|
||||
</h6>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form id="formData">
|
||||
<input type="hidden" id="id" name="id" value="<?= $pays['id'] ?>">
|
||||
|
||||
<td width="5%" align="center" class="required"><?= _("Libellé") ?></td>
|
||||
<td width="70%" ><INPUT class="form-control majuscule" TYPE="text" id="libelle" NAME="libelle" required AUTOCOMPLETE="OFF" value="<?= $this->nettoyer($pays['libelle']); ?>"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small fw-bold text-muted">Code</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-lock text-muted"></i></span>
|
||||
<input class="form-control border-2 border-start-0 ps-0 majuscule fw-bold bg-white"
|
||||
type="text"
|
||||
id="codePays"
|
||||
name="codePays"
|
||||
value="<?= $this->nettoyer($pays['codePays']); ?>"
|
||||
readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
<label class="form-label small fw-bold text-muted required"><?= _("Libellé du Pays") ?></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-globe-africa text-muted"></i></span>
|
||||
<input class="form-control border-2 border-start-0 ps-0 majuscule"
|
||||
type="text"
|
||||
id="libelle"
|
||||
name="libelle"
|
||||
value="<?= $this->nettoyer($pays['libelle']); ?>"
|
||||
required
|
||||
autocomplete="off"
|
||||
autofocus>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Focus Ring spécifique au mode édition */
|
||||
.form-control:focus {
|
||||
border-color: #212e53 !important;
|
||||
box-shadow: 0 0 0 0.25rem rgba(33, 46, 83, 0.15) !important;
|
||||
}
|
||||
|
||||
/* Style champ readonly pour qu'il ne paraisse pas désactivé mais protégé */
|
||||
input[readonly] {
|
||||
cursor: not-allowed;
|
||||
color: #6c757d !important;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user