azas
This commit is contained in:
parent
68ca72e275
commit
d8b1e7fe63
246
Js/fonctions.js
246
Js/fonctions.js
|
|
@ -46279,121 +46279,151 @@ function afficheDonneesTable(fichier){
|
|||
|
||||
}
|
||||
|
||||
function addgctypegarant(){
|
||||
$('#div_edit_typegarant').empty();
|
||||
donnees = '';
|
||||
$.ajax({
|
||||
url: $("#racineWeb").val()+"Ajaxouvrirtypegarant/",
|
||||
type : 'post',
|
||||
data: donnees,
|
||||
error: function(errorData){
|
||||
alert("Erreur : "+errorData);
|
||||
},
|
||||
success: function(data) {
|
||||
//alert("Success : "+data);
|
||||
$('#div_add_typegarant').html(data);
|
||||
$('#div_add_typegarant').modal("show");
|
||||
$('#div_add_typegarant').on('shown.bs.modal', function(){
|
||||
stylechampsRequis();
|
||||
$('#codeTypeGarant').focus();
|
||||
});
|
||||
},
|
||||
complete: function() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
function addgctypegarant() {
|
||||
const racineWeb = $("#racineWeb").val();
|
||||
const $modalAdd = $('#div_add_typegarant');
|
||||
const $modalEdit = $('#div_edit_typegarant');
|
||||
|
||||
// Nettoyage de l'autre modale pour éviter les conflits d'IDs
|
||||
$modalEdit.empty();
|
||||
|
||||
function editgctypegarant(id){
|
||||
$.ajax({
|
||||
url: racineWeb + "Ajaxouvrirtypegarant/",
|
||||
type: 'POST',
|
||||
beforeSend: function() {
|
||||
// Optionnel : Vous pouvez ajouter un loader global ici
|
||||
},
|
||||
success: function(data) {
|
||||
// Injection du contenu dans la modale
|
||||
$modalAdd.html(data);
|
||||
|
||||
// Affichage de la modale
|
||||
$modalAdd.modal("show");
|
||||
|
||||
$('#div_add_typegarant').empty();
|
||||
|
||||
donnees ='id='+id;
|
||||
|
||||
$.ajax({
|
||||
url: $("#racineWeb").val()+"Ajaxmodifiertypegarant/",
|
||||
type : 'post',
|
||||
data: donnees,
|
||||
error: function(errorData){
|
||||
alert("Erreur : "+errorData);
|
||||
},
|
||||
success: function(data) {
|
||||
//alert("Success : "+data);
|
||||
$('#div_edit_typegarant').html(data);
|
||||
$('#div_edit_typegarant').modal("show");
|
||||
$('#div_edit_typegarant').on('shown.bs.modal', function(){
|
||||
stylechampsRequis();
|
||||
$('#codeTypeGarant').focus();
|
||||
});
|
||||
|
||||
},
|
||||
complete: function() {
|
||||
|
||||
}
|
||||
});
|
||||
// Actions une fois que la modale est visible
|
||||
$modalAdd.off('shown.bs.modal').on('shown.bs.modal', function() {
|
||||
// Focus sur le premier champ pour une saisie rapide
|
||||
$('#codeTypeGarant').focus();
|
||||
|
||||
// Application du style Neutral Pro aux champs requis
|
||||
if (typeof stylechampsRequis === 'function') {
|
||||
stylechampsRequis();
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Erreur Ouverture Modale:", error);
|
||||
if (typeof toastr !== 'undefined') {
|
||||
toastr.error("Impossible d'ouvrir le formulaire d'ajout");
|
||||
} else {
|
||||
alert("Erreur lors de l'ouverture du formulaire.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function enregistrerTypeGarant(){
|
||||
var codeTypeGarant = $('#codeTypeGarant').val(),
|
||||
libelle = $('#libelle').val(),
|
||||
id = $('#id').val();
|
||||
|
||||
|
||||
fichier_lister = 'Ajaxlistergctypegarant';
|
||||
|
||||
if(id == undefined){
|
||||
link = 'Ajaxouvrirtypegarant';
|
||||
}else{
|
||||
//fichier_lister = 'Ajaxlistercolleges';
|
||||
link = 'Ajaxmodifiertypegarant';
|
||||
}
|
||||
|
||||
function editgctypegarant(id) {
|
||||
const racineWeb = $("#racineWeb").val();
|
||||
const codeLangue = $("#codeLangue").val();
|
||||
const $modalEdit = $('#div_edit_typegarant');
|
||||
const $modalAdd = $('#div_add_typegarant');
|
||||
|
||||
if(libelle <=' '){
|
||||
v_msg="Le libellé est obligatoire !";
|
||||
v_msgEng="The label is required !";
|
||||
|
||||
alert_ebene(v_msg,v_msgEng);
|
||||
|
||||
$('#libelle').css('borderColor','red');
|
||||
return;
|
||||
}
|
||||
donnees = $('#formModal').serialize();
|
||||
|
||||
$.ajax({
|
||||
url: $("#racineWeb").val()+link+"/enregistrer/",
|
||||
type : 'post',
|
||||
data: donnees,
|
||||
error: function(errorData){
|
||||
alert("Erreur : "+errorData);
|
||||
},
|
||||
success: function(data) {
|
||||
//alert("Success : "+data);
|
||||
/*if(data.length > 5){
|
||||
var str = data.split('/');
|
||||
alert_ebene(str[0],str[1]);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if(id==undefined){
|
||||
afficheDonneesTable(fichier_lister);
|
||||
$("#div_add_typegarant .close").click();
|
||||
}else{
|
||||
afficheDonneesTable(fichier_lister);
|
||||
$("#div_edit_typegarant .close").click();
|
||||
}
|
||||
//dataTableSpeciale();
|
||||
|
||||
|
||||
},
|
||||
complete: function() {
|
||||
window.location.assign($("#racineWeb" ).val()+"Gctypegarant/");
|
||||
}
|
||||
});
|
||||
|
||||
// Nettoyage de la modale d'ajout pour éviter les conflits
|
||||
$modalAdd.empty();
|
||||
|
||||
const msgError = (codeLangue === "en_US")
|
||||
? "Error loading data"
|
||||
: "Erreur lors du chargement des données";
|
||||
|
||||
$.ajax({
|
||||
url: racineWeb + "Ajaxmodifiertypegarant/",
|
||||
type: 'POST',
|
||||
data: { id: id },
|
||||
success: function(data) {
|
||||
$modalEdit.html(data);
|
||||
$modalEdit.modal("show");
|
||||
|
||||
$modalEdit.off('shown.bs.modal').on('shown.bs.modal', function() {
|
||||
// Focus sur le libellé car le code est généralement readonly en édition
|
||||
$('#libelle').focus();
|
||||
|
||||
if (typeof stylechampsRequis === 'function') {
|
||||
stylechampsRequis();
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.error("Edit Error:", xhr.responseText);
|
||||
if (typeof toastr !== 'undefined') {
|
||||
toastr.error(msgError);
|
||||
} else {
|
||||
alert(msgError);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function enregistrerTypeGarant() {
|
||||
// 1. Initialisation des variables et sélecteurs
|
||||
const libelle = $('#libelle').val().trim();
|
||||
const id = $('#id').val(); // Sera undefined en création
|
||||
const racineWeb = $("#racineWeb").val();
|
||||
const codeLangue = $("#codeLangue").val();
|
||||
const $btn = $('#btn-enreg-typegarant');
|
||||
|
||||
// Détermination de l'URL cible (Link)
|
||||
let link = (id === undefined) ? 'Ajaxouvrirtypegarant' : 'Ajaxmodifiertypegarant';
|
||||
|
||||
// 2. Gestion des traductions
|
||||
const msgRequired = (codeLangue === "en_US") ? "The label is required !" : "Le libellé est obligatoire !";
|
||||
const msgSuccess = (codeLangue === "en_US") ? "Saved successfully" : "Enregistrement réussi";
|
||||
|
||||
// 3. Validation
|
||||
if (libelle === '') {
|
||||
if (typeof toastr !== 'undefined') {
|
||||
toastr.warning(msgRequired);
|
||||
} else {
|
||||
alert(msgRequired);
|
||||
}
|
||||
$('#libelle').addClass('border-danger').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. Préparation de l'envoi
|
||||
const donnees = $('#formModal').serialize();
|
||||
$btn.prop('disabled', true).html('<i class="fas fa-spinner fa-spin me-2"></i>...');
|
||||
|
||||
$.ajax({
|
||||
url: racineWeb + link + "/enregistrer/",
|
||||
type: 'post',
|
||||
data: donnees,
|
||||
success: function(data) {
|
||||
// Fermeture des modales selon le cas (standard Bootstrap 5)
|
||||
const modalId = (id === undefined) ? '#div_add_typegarant' : '#div_edit_typegarant';
|
||||
const modalInstance = bootstrap.Modal.getInstance(document.querySelector(modalId));
|
||||
|
||||
if (modalInstance) {
|
||||
modalInstance.hide();
|
||||
}
|
||||
|
||||
if (typeof toastr !== 'undefined') {
|
||||
toastr.success(msgSuccess);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.error("Erreur Enregistrement:", xhr.responseText);
|
||||
$btn.prop('disabled', false).html('<i class="fas fa-save me-2"></i> Enregistrer');
|
||||
if (typeof toastr !== 'undefined') {
|
||||
toastr.error("Erreur serveur");
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
// Redirection ou rafraîchissement propre
|
||||
window.location.assign(racineWeb + "Gctypegarant/");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Supprime une ligne du tableau
|
||||
|
|
|
|||
|
|
@ -1,41 +1,69 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-bs-dismiss="modal">×</button>
|
||||
<legend class="modal-title text-center"><?= _("Modifier un Type de Garant") ?></legend>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="formModal">
|
||||
<INPUT class="sr-only" TYPE="text" id = "id" name = "id" value="<?=$gc_typegarant['id']?>">
|
||||
<table class="table table-responsive table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="13%" >Code</td>
|
||||
<td colspan="3" ><INPUT class="form-control majuscule" TYPE="text" id="codeTypeGarant" NAME="codeTypeGarant" disabled value="<?=$gc_typegarant['codeTypeGarant']?>"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="required"><?= _("Libellé") ?></td>
|
||||
<td colspan="3"><INPUT class="form-control majuscule" TYPE="text" id="libelle" NAME="libelle" required AUTOCOMPLETE="OFF" value="<?=$gc_typegarant['libelle']?>" autofocus></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="4" align="center" height="50" style="vertical-align: top; color: #551210; background-color: #ffffff; font-size: 20px;">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<input type="button" name="btn-enreg-typegarant" id="btn-enreg-typegarant" class="btn btn-primary form-control" value="Enregistrer"
|
||||
onclick="JAVASCRIPT:enregistrerTypeGarant();">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="btn-fermer-modal" class="btn btn-default" data-bs-dismiss="modal">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content border-0 shadow-lg">
|
||||
<div class="modal-header bg-primary text-white py-3">
|
||||
<h6 class="modal-title fw-bold text-uppercase small">
|
||||
<i class="fas fa-edit me-2"></i><?= _("Modifier le Type de Garant") ?>
|
||||
</h6>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-4">
|
||||
<form id="formModal">
|
||||
<input type="hidden" id="id" name="id" value="<?= $this->nettoyer($gc_typegarant['id']) ?>">
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-bold text-muted text-uppercase">
|
||||
<?= _("Code") ?>
|
||||
</label>
|
||||
<input class="form-control bg-light border-2 fw-bold shadow-none"
|
||||
type="text"
|
||||
id="codeTypeGarant"
|
||||
name="codeTypeGarant"
|
||||
value="<?= $this->nettoyer($gc_typegarant['codeTypeGarant']) ?>"
|
||||
disabled>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<label class="form-label small fw-bold text-muted text-uppercase">
|
||||
<?= _("Libellé") ?> <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input class="form-control majuscule shadow-none border-2"
|
||||
type="text"
|
||||
id="libelle"
|
||||
name="libelle"
|
||||
value="<?= $this->nettoyer($gc_typegarant['libelle']) ?>"
|
||||
required
|
||||
autocomplete="OFF"
|
||||
autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="msg_info_modal" class="mt-3 text-center small fw-bold" style="display:none;"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-light border-0 py-3">
|
||||
<button type="button" class="btn btn-light rounded-pill px-4 fw-bold text-muted shadow-xs" data-bs-dismiss="modal">
|
||||
<?= _("Fermer") ?>
|
||||
</button>
|
||||
<button type="button"
|
||||
id="btn-enreg-typegarant"
|
||||
class="btn btn-primary rounded-pill px-4 fw-bold shadow-sm"
|
||||
onclick="enregistrerTypeGarant();">
|
||||
<i class="fas fa-save me-2"></i> <?= _("Enregistrer") ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.majuscule { text-transform: uppercase; }
|
||||
|
||||
/* Style Neutral Pro : désactivation visuelle propre */
|
||||
input:disabled {
|
||||
cursor: not-allowed;
|
||||
background-color: #f8f9fa !important;
|
||||
color: #adb5bd !important;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,40 +1,68 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-bs-dismiss="modal">×</button>
|
||||
<legend class="modal-title text-center"><?= _("Ajouter un Type de Garant") ?></legend>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="formModal">
|
||||
<table class="table table-responsive table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<!--
|
||||
<td width="10%" align="center" class="required">Code</td>
|
||||
<td width="15%" ><INPUT class="form-control majuscule" TYPE="text" id="codeTypeGarant" NAME="codeTypeGarant" autofocus required AUTOCOMPLETE="OFF" onchange="javascript:test_code(this,this.value);recherchecode(this,this.value,'typegarant');"></td>
|
||||
-->
|
||||
<td width="12%" class="required"><?= _("Libellé") ?></td>
|
||||
<td width="88%"><INPUT class="form-control majuscule" TYPE="text" id="libelle" NAME="libelle" required AUTOCOMPLETE="OFF"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" align="center" height="50" style="vertical-align: top; color: #551210; background-color: #ffffff; font-size: 20px;">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<input type="button" name="btn-enreg-typegarant" id="btn-enreg-typegarant" class="btn btn-primary form-control" value="Enregistrer"
|
||||
onclick="JAVASCRIPT:enregistrerTypeGarant();">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="btn-fermer-modal" class="btn btn-default" data-bs-dismiss="modal">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content border-0 shadow-lg">
|
||||
<div class="modal-header bg-primary text-white py-3">
|
||||
<h6 class="modal-title fw-bold text-uppercase small">
|
||||
<i class="fas fa-plus-circle me-2"></i><?= _("Ajouter un Type de Garant") ?>
|
||||
</h6>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-4">
|
||||
<form id="formModal">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-bold text-muted text-uppercase">
|
||||
<?= _("Code") ?> <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input class="form-control majuscule shadow-none border-2"
|
||||
type="text"
|
||||
id="codeTypeGarant"
|
||||
name="codeTypeGarant"
|
||||
placeholder="Ex: CIE"
|
||||
required
|
||||
autocomplete="OFF"
|
||||
onchange="test_code(this,this.value); recherchecode(this,this.value,'typegarant');">
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<label class="form-label small fw-bold text-muted text-uppercase">
|
||||
<?= _("Libellé") ?> <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input class="form-control majuscule shadow-none border-2"
|
||||
type="text"
|
||||
id="libelle"
|
||||
name="libelle"
|
||||
placeholder="<?= _("Saisir le nom...") ?>"
|
||||
required
|
||||
autocomplete="OFF">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="msg_info_modal" class="mt-3 text-center small fw-bold" style="display:none;"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-light border-0 py-3">
|
||||
<button type="button" class="btn btn-light rounded-pill px-4 fw-bold text-muted shadow-xs" data-bs-dismiss="modal">
|
||||
<?= _("Annuler") ?>
|
||||
</button>
|
||||
<button type="button"
|
||||
id="btn-enreg-typegarant"
|
||||
class="btn btn-primary rounded-pill px-4 fw-bold shadow-sm"
|
||||
onclick="enregistrerTypeGarant();">
|
||||
<i class="fas fa-save me-2"></i> <?= _("Enregistrer") ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Forcer la majuscule sur les champs identifiés */
|
||||
.majuscule { text-transform: uppercase; }
|
||||
|
||||
/* Style Neutral Pro pour les inputs au focus */
|
||||
.modal-content .form-control:focus {
|
||||
border-color: var(--bs-primary);
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user