This commit is contained in:
KONE SOREL 2026-03-06 10:53:09 +00:00
parent 7d301a619a
commit 05b2b07ba8
3 changed files with 274 additions and 197 deletions

View File

@ -47,7 +47,6 @@ function alert_ebene(p_msg, p_msg_eng) {
}); });
} }
function confirm_ebene(p_msg, p_msg_eng) { function confirm_ebene(p_msg, p_msg_eng) {
// Récupération de la langue sélectionnée // Récupération de la langue sélectionnée
let codeLangue = $("#codeLangue").val(); let codeLangue = $("#codeLangue").val();
@ -34428,99 +34427,125 @@ function afficher_garantie_produit_cons() {
}); });
} }
function afficher_garantie_produit() function afficher_garantie_produit() {
{ // 1. Définition des constantes et cibles
codeGcAssureur =$("#codeGcAssureur").val(); const codeGcAssureur = $("#codeGcAssureur").val();
const codeProduit = $("#codeProduit").val();
const div_cible = $('#div_garantieproduit');
if(codeGcAssureur<=" ") const racineWeb = $("#racineWeb").val();
{
v_msg="Veuillez s\u00e9lectionner un garant!";
v_msgEng="Please select a guarantor!";
alert_ebene(v_msg, v_msgEng);
$("#codeGcAssureur").focus(); // 2. Validation du Garant (avec SweetAlert2)
if (!codeGcAssureur || codeGcAssureur.trim() === "") {
$('#div_garantieproduit').html(""); Swal.fire({
icon: 'warning',
return; title: '<?= _("Garant manquant") ?>',
} text: '<?= _("Veuillez sélectionner un garant pour continuer.") ?>',
confirmButtonColor: '#212e53'
});
$("#codeGcAssureur").focus();
div_cible.html("");
return;
}
codeProduit=$("#codeProduit").val(); // 3. Validation du Produit
if (!codeProduit || codeProduit.trim() === "") {
if (codeProduit<=" ") Swal.fire({
{ icon: 'warning',
v_msg="Veuillez s\u00e9lectionner un produit!"; title: '<?= _("Produit manquant") ?>',
v_msgEng="Please select a product!"; text: '<?= _("Veuillez sélectionner un produit !") ?>',
alert_ebene(v_msg, v_msgEng); confirmButtonColor: '#212e53'
});
$('#div_garantieproduit').html(""); div_cible.html("");
return; return;
} }
donnees = 'codeProduit='+codeProduit;
var div_attente = $('#div_garantieproduit'); // 4. Préparation des paramètres et affichage du loader "Ghost"
const donnees = { codeProduit: codeProduit };
div_attente.html('<div style="padding-top:80px; text-align:center; font-size:14px; color: #0088cf; "><span><i class="fa fa-spinner fa-spin fa-5x" >' + '</span></div>');
$.ajax({ div_cible.html(`
url: $("#racineWeb").val()+"Ajaxparamseuilalerte/affichergarantieproduit/", <div class="d-flex flex-column align-items-center justify-content-center p-5">
type : 'post', <div class="spinner-grow text-warning" role="status" style="width: 3rem; height: 3rem;">
data: donnees, <span class="visually-hidden">Loading...</span>
error: function(errorData) { </div>
}, <h5 class="mt-4 text-warning fw-bold text-uppercase italic">${'<?= _("Chargement du formulaire de saisie...") ?>'}</h5>
success: function(data) { </div>
div_attente.html(data); `);
},
complete: function() { // 5. Exécution de la requête AJAX
} $.ajax({
}); url: racineWeb + "Ajaxparamseuilalerte/affichergarantieproduit/",
type: 'post',
data: donnees,
success: function(data) {
// Injection du contenu (Tableau avec inputs de modification)
div_cible.html(data);
// INITIALISATION DATATABLE
// On utilise l'ID #tableSeuilsModif qui doit être présent dans le retour AJAX
setTimeout(function() {
const nomProduit = $("#codeProduit option:selected").text();
initSmartTable('#tableSeuilsModif', 'Modif Seuils - ' + nomProduit);
}, 150);
},
error: function() {
div_cible.html(`
<div class="alert alert-danger d-flex align-items-center m-3" role="alert">
<i class="fas fa-exclamation-triangle me-2"></i>
<div>${'<?= _("Erreur technique lors de la récupération du formulaire.") ?>'}</div>
</div>
`);
}
});
} }
function ajouter_tous_garantie_produit() function ajouter_tous_garantie_produit() {
{ const codeProduit = $("#codeProduit").val();
codeProduit=$("#codeProduit").val(); const racineWeb = $("#racineWeb").val();
const codeLangue = $("#codeLangue").val();
if (codeProduit<=" ") // 1. Validation de sécurité (Messages manuels selon la langue)
{ if (!codeProduit || codeProduit.trim() === "") {
v_msg="Veuillez sélectionner un produit!"; let v_err = (codeLangue === "en_US") ? "Please select a product!" : "Veuillez sélectionner un produit !";
v_msgEng="Please select a category!"; toastr.warning(v_err);
alert_ebene(v_msg, v_msgEng); return;
}
return; // 2. Définition des messages pour confirm_ebene
} let v_msg = "Confirmez-vous l'ajout de toutes les garanties ?";
let v_msgEng = "Do you confirm the addition of all guarantees?";
donnees = 'codeProduit='+codeProduit; // 3. Appel de votre fonction de confirmation personnalisée
confirm_ebene(v_msg, v_msgEng).then((isConfirmed) => {
if (isConfirmed) {
// Affichage d'un indicateur de traitement (Loading)
Swal.showLoading();
v_msg="Confirmez-vous cette opération?"; $.ajax({
v_msgEng="Do you confirm this operation?"; url: racineWeb + "Ajaxparamseuilalerte/ajoutertousgarantieproduit/",
type: 'POST',
data: { codeProduit: codeProduit },
confirm_ebene(v_msg, v_msgEng) success: function(data) {
.then((isConfirmed) => { // Notification discrète de succès
if (isConfirmed) { let v_suc = (codeLangue === "en_US") ? "Operation successful" : "Opération réussie";
// L'utilisateur a confirmé toastr.success(v_suc);
$.ajax({ },
url: $("#racineWeb").val()+"Ajaxparamseuilalerte/ajoutertousgarantieproduit/", error: function() {
type: 'POST', let v_err_ajax = (codeLangue === "en_US") ? "Server error" : "Erreur serveur";
data: donnees, toastr.error(v_err_ajax);
success: function(data) { },
}, complete: function() {
error: function(data) { // 4. Rafraîchissement automatique de la vue
}, afficher_garantie_produit();
complete: function() { }
afficher_garantie_produit(); });
} }
}); });
} else {
// L'utilisateur a annulé
console.log("Confirmation refusée");
}
});
} }
function retirer_tous_garantie_produit() function retirer_tous_garantie_produit()
{ {
codeProduit=$("#codeProduit").val(); codeProduit=$("#codeProduit").val();
@ -46244,7 +46269,7 @@ $(function(){
afficher_bareme_produit(); afficher_bareme_produit();
} }
}else if($('#nomForm').val()=="modifierseuilalerte"){ }/*else if($('#nomForm').val()=="modifierseuilalerte"){
codeGcAssureur = $("#codeGcAssureur").val(); codeGcAssureur = $("#codeGcAssureur").val();
codeProduit = $("#codeProduit").val(); codeProduit = $("#codeProduit").val();
@ -46252,7 +46277,7 @@ $(function(){
afficher_garantie_produit(); afficher_garantie_produit();
} }
}else if($('#nomForm').val()=="Paramfacproduit"){ }*/else if($('#nomForm').val()=="Paramfacproduit"){
codeProduit = $("#codeProduit").val(); codeProduit = $("#codeProduit").val();
if(codeProduit > ""){ if(codeProduit > ""){

View File

@ -1,79 +1,117 @@
<div class="row"> <div class="row g-4">
<div id="div_sans_seuil" class="col-5" > <div id="div_sans_seuil" class="col-md-5">
<legend> <?= _("Sans seuil") ?> </legend> <div class="card border-0 shadow-sm" style="border-radius: var(--radius-md);">
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:10pt;"> <div class="card-header bg-white border-0 py-3 d-flex align-items-center justify-content-between">
<thead> <h6 class="mb-0 fw-bold text-uppercase text-muted small">
<tr> <i class="fas fa-list-ul me-2"></i><?= _("Garanties Sans seuil") ?>
<th style='text-align:center'> <?= _("Garantie") ?> </th> </h6>
<th width="20%" style='text-align:center'> => </th> <span class="badge bg-light text-dark rounded-pill"><?= count($garanties_sans_seuils) ?></span>
</tr> </div>
<div class="p-2 border-top border-bottom bg-light">
<button type="button" class="btn btn-primary btn-sm w-100 fw-bold shadow-sm" onclick="javascript:ajouter_tous_garantie_produit();">
<?= _("Tout Ajouter") ?> <i class="fas fa-angle-double-right ms-2"></i>
</button>
</div>
<tr> <div class="table-responsive" style="max-height: 500px; overflow-y: auto;">
<th colspan="2"> <button type="button" style="font-size:10pt;" class="form-control btn btn-primary" onclick="javascript:ajouter_tous_garantie_produit();" > <?= _("Ajouter tous"). " ==>" ?> </button> </th> <table class="table table-hover align-middle mb-0" style="font-size: 9pt;">
</tr> <thead class="bg-white sticky-top shadow-xs">
<tr>
</thead> <th class="ps-3"><?= _("Libellé Garantie") ?></th>
<th width="15%" class="text-center"><?= _("Action") ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($garanties_sans_seuils as $v): $codeGarantie = $v['codeGarantie']; ?>
<tr>
<td class="ps-3 fw-medium text-dark"><?= $this->nettoyer($v['garantie']) ?></td>
<td class="text-center">
<button class="btn btn-outline-primary btn-xs rounded-circle" title="<?= _('Ajouter') ?>"
onClick="javascript:ajouter_un_garantie_produit('<?=$codeGarantie?>');">
<i class="fas fa-chevron-right"></i>
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<tbody> <div id="div_avec_seuil" class="col-md-7">
<?php foreach ($garanties_sans_seuils as $garanties_sans_seuil): <div class="card border-0 shadow-sm" style="border-radius: var(--radius-md);">
$codeGarantie = $garanties_sans_seuil['codeGarantie']; <div class="card-header bg-white border-0 py-3 d-flex align-items-center justify-content-between">
?> <h6 class="mb-0 fw-bold text-uppercase text-warning small">
<tr valign="top"> <i class="fas fa-check-double me-2"></i><?= _("Garanties avec Seuil d'alerte") ?>
<td align='center'><?= $this->nettoyer($garanties_sans_seuil['garantie']) ?></td> </h6>
<td align='center'> <input type="button" value="=>" onClick="javascript:ajouter_un_garantie_produit('<?=$codeGarantie?>');" ></td> <button type="button" class="btn btn-outline-danger btn-xs fw-bold px-3" onclick="javascript:retirer_tous_garantie_produit();">
</tr> <i class="fas fa-trash-alt me-1"></i> <?= _("Tout Retirer") ?>
<?php endforeach; ?> </button>
</tbody> </div>
</table>
</div>
<div id="div_avec_seuil" class="col-7" > <div class="table-responsive">
<legend> <?= _("Avec seuil") ?> </legend> <table id="tableSeuilsModif" class="table table-hover align-middle mb-0" style="font-size: 9pt;">
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:10pt;"> <thead class="bg-light text-muted small">
<thead> <tr>
<th width="5%" class="text-center">#</th>
<tr> <th><?= _("Garantie") ?></th>
<th rowspan="2" width="10%" style='text-align:center'> <= </th> <th width="20%" class="text-center"><?= _("Taux (%)") ?></th>
<th rowspan="2" style='text-align:center'> <?= _("Garantie") ?> </th> <th width="25%" class="text-center"><?= _("Forfait (Montant)") ?></th>
<th colspan="4" style='text-align:center'> <?= _("Seuil") ?> </th> </tr>
</tr> </thead>
<tbody>
<tr> <?php foreach ($garanties_avec_seuils as $v):
<th colspan="2" style='text-align:center'> <?= _("Taux") ?> </th> $id = $v['id'];
<th colspan="2" style='text-align:center'> <?= _("Forfait") ?> </th> $taux = $v['tauxSeuilAlerte'];
</tr> $montant = $v['seuilAlerte'];
?>
<tr> <tr>
<td colspan="6"> <button type="button" style="font-size:10pt;" class="form-control btn btn-danger" onclick="javascript:retirer_tous_garantie_produit();" > <?= "<== " . _("Retirer tous") ?> </button> </td> <td class="text-center">
</tr> <button class="btn btn-link text-danger p-0" title="<?= _('Retirer') ?>"
onClick="javascript:retirer_un_garantie_produit('<?=$id?>');">
</thead> <i class="fas fa-minus-circle"></i>
</button>
</td>
<td class="fw-bold text-dark"><?= $this->nettoyer($v['garantie']) ?></td>
<td>
<div class="input-group input-group-sm">
<input type="number" class="form-control text-center border-warning-subtle fw-bold" value="<?= $taux ?>"
onchange="if(controle_numerique(this)){maj_taux_seuil_alerte_garantie('<?=$id?>', this.value);}">
<span class="input-group-text bg-white"><i class="fas fa-percent text-muted small"></i></span>
</div>
</td>
<td>
<div class="input-group input-group-sm">
<input type="number" class="form-control text-end pe-2 border-warning-subtle fw-bold" value="<?= $montant ?>"
onchange="if(controle_numerique(this)){maj_seuil_alerte_garantie('<?=$id?>', this.value);}">
<span class="input-group-text bg-white small">CFA</span>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<tbody> <style>
<?php foreach ($garanties_avec_seuils as $garanties_avec_seuil): /* Style spécifique pour les inputs de modification */
$id = $garanties_avec_seuil['id']; #tableSeuilsModif .form-control:focus {
$tauxSeuilAlerte = $garanties_avec_seuil['tauxSeuilAlerte']; background-color: #fff9f0;
$seuilAlerte = $garanties_avec_seuil['seuilAlerte']; border-color: #f39c12;
?> box-shadow: none;
<tr valign="top"> }
<td align='center'> <input type="button" value="<=" onClick="javascript:retirer_un_garantie_produit('<?=$id?>');" ></td>
<td align='center'><?= $this->nettoyer($garanties_avec_seuil['garantie']) ?></td>
<td <th width="10%" align='center'><?= $tauxSeuilAlerte ?></td> #tableSeuilsModif .form-control {
<td <th width="15%" > background-color: #fafafa;
<INPUT style="font-size:10pt; text-align:center;" class="form-control" TYPE="number" value="<?= $tauxSeuilAlerte ?>" border-radius: 4px;
onChange="this.value=supprimer_espace_nombre(this.value);if(controle_numerique(this)){maj_taux_seuil_alerte_garantie('<?=$id?>', this.value);}"> }
</td>
/* Scroll personnalisé pour la liste de gauche */
<td <th width="15%" align='center'><?= format_N($seuilAlerte) ?></td> #div_sans_seuil .table-responsive::-webkit-scrollbar { width: 6px; }
<td <th width="20%" > #div_sans_seuil .table-responsive::-webkit-scrollbar-thumb { background: #dcdcdc; border-radius: 10px; }
<INPUT style="font-size:10pt; text-align:center;" class="form-control" TYPE="number" value="<?= $seuilAlerte ?>" </style>
onChange="this.value=supprimer_espace_nombre(this.value);if(controle_numerique(this)){maj_seuil_alerte_garantie('<?=$id?>', this.value);}">
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>

View File

@ -1,45 +1,59 @@
<?php $this->titre = "INTER SANTE - Seuil alerte consommation"; <div class="page-content">
<div class="header-section mb-4">
<div class="bg-white p-3 shadow-sm border-start border-warning border-4" style="border-radius: var(--radius-md);">
<div class="d-flex align-items-center mb-3">
<div class="icon-shape bg-warning-ghost text-warning rounded-circle me-3" style="width: 45px; height: 45px; display: flex; align-items: center; justify-content: center;">
<i class="fas fa-edit fs-5"></i>
</div>
<div>
<h4 id="titre-page" class="mb-0 fw-bold text-uppercase"><?= _("Modification des Seuils") ?></h4>
<p class="text-muted small mb-0"><?= _("Ajustez les taux et forfaits d'alerte par produit de santé") ?></p>
</div>
</div>
$codeGcAssureur = isset($_SESSION['codeGcAssureur_S']) ? $_SESSION['codeGcAssureur_S'] : ""; <div class="row g-2 align-items-end p-2 rounded-3 border" style="background-color: #fafafa;">
$codeProduit = isset($_SESSION['codeProduit_S']) ? $_SESSION['codeProduit_S'] : ""; <div class="col-md-5">
?> <label class="form-label small fw-bold text-muted ps-2 mb-1"><?= _("Garant") ?></label>
<select class="form-select selectpicker w-100" data-live-search="true" id="codeGcAssureur" name="codeGcAssureur" required onchange="javascript:filtreproduitgarant();">
<?php liste_options($garant, $codeGcAssureur); ?>
</select>
</div>
<script type="text/javascript"> <div class="col-md-5">
<label class="form-label small fw-bold text-muted ps-2 mb-1"><?= _("Produit Santé") ?></label>
<div id="div_produit">
<select class="form-select selectpicker w-100" data-live-search="true" id="codeProduit" name="codeProduit" required>
<?php liste_options($produits, $codeProduit); ?>
</select>
</div>
</div>
</script> <div class="col-md-2">
<button class="btn btn-warning w-100 fw-bold text-white shadow-sm" onclick="javascript:afficher_garantie_produit();">
<i class="fas fa-search me-2"></i><?= _("Actualiser") ?>
</button>
</div>
</div>
</div>
</div>
<legend> <?= _("Modification Seuil alerte consommation") ?> </legend> <div id="div_garantieproduit" class="mt-4">
<?php if($codeGcAssureur != "" && $codeProduit != ""): ?>
<script>window.addEventListener('load', function() { afficher_garantie_produit(); });</script>
<?php else: ?>
<div class="text-center p-5 bg-white shadow-sm rounded-3">
<div class="icon-shape bg-light text-muted rounded-circle mx-auto mb-3" style="width: 60px; height: 60px; display: flex; align-items: center; justify-content: center;">
<i class="fas fa-mouse-pointer fa-2x"></i>
</div>
<h6 class="text-muted"><?= _("Sélectionnez un couple Garant/Produit pour modifier les seuils") ?></h6>
</div>
<?php endif; ?>
</div>
</div>
<INPUT class="sr-only" TYPE="text" id="nomForm" NAME="nomForm" value="modifierseuilalerte" > <style>
.bg-warning-ghost { background-color: rgba(243, 156, 18, 0.1) !important; color: #e67e22 !important; }
<table class="table table-condensed table-responsive" style="font-size:10pt;" > .breadcrumb-item + .breadcrumb-item::before { content: ""; }
<tbody> .form-select.selectpicker + .btn { border: 2px solid #eee !important; border-radius: 8px; }
<tr> </style>
<td width="8%" class="required text-center"> <?= _("Garant") ?> </td>
<td width="40%">
<SELECT style="font-size:10pt; height:30px;" class="form-control selectpicker" data-live-search="true" id="codeGcAssureur" NAME="codeGcAssureur" required AUTOCOMPLETE="OFF" autofocus
onChange="javascript:filtreproduitgarant();" >
<?php liste_options($garant, $codeGcAssureur); ?>
</SELECT>
</td>
<td width="8%" class="required text-center"> <?= _("Produit") ?> </td>
<td width="32%">
<div id="div_produit">
<SELECT style="font-size:10pt; height:30px;" class="form-control selectpicker" data-live-search="true" id="codeProduit" NAME="codeProduit" required>
<?php liste_options($produits, $codeProduit); ?>
</SELECT>
</div>
</td>
<td width="2%"></td>
<td>
<td width="10%" align="center"> <input class = "form-control btn btn-primary" style="font-size:10pt;" type="button" value="<?= _("Actualiser") ?>" onClick="javascript:afficher_garantie_produit();"> </td>
</td>
</tr>
</tbody>
</table>
<div id="div_garantieproduit">
</div>