This commit is contained in:
KONE SOREL 2026-03-18 10:45:33 +00:00
parent 7b1ab6bd2f
commit d3ed6ddd1d
7 changed files with 261 additions and 162 deletions

View File

@ -70,13 +70,33 @@ class ControleurAjaxprestatairesreseau extends Controleurrequete
$this->executerAction("index");
}
public function rechercher() {
$query = $this->requete->getParametreFormulaire("query");
public function rechercherdispos()
{
// Récupération sécurisée du paramètre de recherche
$query = $this->requete->getParametreFormulaire("query");
$codeReseau = $_SESSION['codeReseau'];
// Appel au modèle mis à jour
$resultats = $this->reseausoins->rechercherPrestatairesDisponibles($codeReseau, $query);
// On génère la vue Ajax partielle (contenant uniquement les <tr>)
$this->genererVueAjax(array(
'prestatairesdispo' => $resultats,
'isSearch' => true // Flag utile pour la vue si besoin
));
}
public function rechercheraffectes() {
$query = $this->requete->getParametreFormulaire("query");
$codeReseau = $_SESSION['codeReseau'];
$codeSociete = $_SESSION['codeSociete'];
$resultats = $this->reseau->rechercherPrestatairesDispo($codeReseau, $query);
// Nouvelle méthode dans le modèle pour chercher UNIQUEMENT dans ce qui est déjà affecté
$resultats = $this->reseausoins->rechercherPrestatairesAffectes($codeReseau, $query);
// On génère une vue partielle qui ne contient que les <tr>
$this->genererVueAjax(array('resultats' => $resultats));
$this->genererVueAjax(array(
'prestatairesreseau' => $resultats,
'isSearch' => true // Flag utile pour la vue si besoin
));
}
}

View File

@ -92359,3 +92359,44 @@ function actualiser_garantie_produit() {
});
}
let timerDispo, timerAffect;
/**
* Recherche Serveur Multi-critères
* @param {string} target - 'dispo' ou 'affect'
*/
function rechercheServeur(target) {
// 1. Récupération des critères selon la colonne
let nom = $("#search_nom_" + target).val();
let ville = $("#search_ville_" + target).val();
let type = $("#search_type_" + target).val();
let query = (nom + " " + ville + " " + type).trim();
// 2. Sécurité : On ne lance rien si c'est trop court (sauf si vide pour réinitialiser)
if (query.length > 0 && query.length < 3) return;
// 3. Gestion du Timer (Debounce)
let timer = (target === 'dispo') ? timerDispo : timerAffect;
clearTimeout(timer);
let currentTimer = setTimeout(function() {
let action = (target === 'dispo') ? 'rechercherdispos' : 'rechercheraffectes';
$.ajax({
url: $("#racineWeb").val() + "Ajaxprestatairesreseau/" + action + "/",
type: 'post',
data: { query: query },
beforeSend: function() {
$("#count_" + target).html('<i class="fas fa-spinner fa-spin"></i>');
},
success: function(data) {
$("#tab_" + target + " tbody").html(data);
$("#count_" + target).text($("#tab_" + target + " tbody tr").length);
}
});
}, 400);
// Mise à jour de la référence du timer
if (target === 'dispo') timerDispo = currentTimer;
else timerAffect = currentTimer;
}

View File

@ -374,16 +374,33 @@ class Reseausoins extends Modele
}
/**
* Recherche les prestataires non affectés avec un filtre textuel (Serveur-side)
* Recherche les prestataires disponibles via procédure stockée
*/
public function rechercherPrestatairesDispo($codeReseau, $query) {
$query = contruireParamLike($query);
public function rechercherPrestatairesDisponibles($codeReseau, $query) {
// Utilisation de la fonction helper pour formater le LIKE (%query%)
$queryParam = contruireParamLike($query);
$codeSociete = $_SESSION['codeSociete'];
$sql = "CALL sp_rechercher_prestataires_dispo(?, ?, ?)"; // Sécurité pour ne pas saturer le DOM
// Appel de la procédure stockée optimisée
$sql = "CALL sp_rechercher_prestataires_dispo(?, ?, ?)";
$resultat = $this->executerRequete($sql, array($codeSociete, $codeReseau, $query));
$resultat = $this->executerRequete($sql, array($codeSociete, $codeReseau, $queryParam));
return $resultat->fetchAll(PDO::FETCH_ASSOC);
}
/**
* Recherche les prestataires affectés via procédure stockée
*/
public function rechercherPrestatairesAffectes($codeReseau, $query) {
// Utilisation de la fonction helper pour formater le LIKE (%query%)
$queryParam = contruireParamLike($query);
$codeSociete = $_SESSION['codeSociete'];
// Appel de la procédure stockée optimisée
$sql = "CALL sp_rechercher_prestataires_affectes(?, ?, ?)";
$resultat = $this->executerRequete($sql, array($codeSociete, $codeReseau, $queryParam));
return $resultat->fetchAll(PDO::FETCH_ASSOC);
}

View File

@ -4,117 +4,139 @@
$nomReseau = $this->nettoyer($reseau['libelle']);
?>
<input class="sr-only" type="text" id="codeReseau" name="codeReseau" value="<?= $codeReseau ?>">
<input class="sr-only" type="text" id="idReseau" name="idReseau" value="<?= $idReseau ?>">
<div id="div_prestataires_reseau" class="row g-4">
<div class="col-lg-5">
<div class="card border-0 shadow-sm h-100">
<div class="card-header bg-white py-3 border-bottom">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="mb-0 fw-bold text-muted text-uppercase small">
<i class="fas fa-list-ul me-2"></i><?= _("Disponibles") ?>
</h6>
<span class="badge bg-light text-primary border rounded-pill" id="count_dispo">
<?= count($prestatairesdispo) ?>
</span>
</div>
<input class="sr-only" type="text" id="codeReseau" name="codeReseau" value="<?= $codeReseau ?>" >
<input class="sr-only" type="text" id="idReseau" name="idReseau" value="<?= $idReseau ?>" >
<div id="div_prestataires_reseau" class="col-lg-20">
<div id="div_prestataire_1" class="table-responsive">
<table id="tab_ent_prestataire_1" class="table table-condensed table-responsive">
<tbody>
<tr valign="top">
<td align='center' colspan="2">
<button type="button" style="font-size:10pt;" class="form-control btn btn-primary"
onclick="javascript:afficher_prestataires_reseau();" > <?= _("Actualiser...") ?>
</button>
</td>
</tr>
<tr>
<td align='center' style="font-size:18pt; font-weight:bold; vertical-align: middle;"><?= _("Prestataires disponibles") ?></td>
<td>
<input class="form-control" style="text-align: center; font-size:10pt;" type="text" id="nbligne1" name="nbligne1" value="Nbre Lignes :<?= format_N(count($prestatairesdispo));?>" readonly>
</td>
</tr>
</tbody>
</table>
<table id="tab_prestataire_1" class="table table-striped table-bordered table-hover table-condensed table-responsive tabliste compact" style="font-size:8pt;">
<thead>
<tr>
<th style='text-align:center'> <?= _("Nom") ?> </th>
<th style='text-align:center'> <?= _("Type") ?> </th>
<th style='text-align:center'> <?= _("Ville") ?> </th>
<th style='text-align:center'> => </th>
</tr>
<tr>
<td colspan="4">
<button type="button" style="font-size:10pt; width:100%;" class="form-control btn btn-primary"
onclick="javascript:ajouter_tous_prestataires_reseau();" >
<?= "============================ "._("Ajouter Tous")." ============================>" ?>
</button>
</td>
</tr>
</thead>
<div class="bg-primary-ghost-light p-2 rounded mb-2 border border-primary-subtle">
<div class="row g-1">
<div class="col-12 mb-1">
<input type="text" id="search_nom_dispo" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Nom du prestataire...") ?>" onkeyup="rechercheServeur('dispo')">
</div>
<div class="col-6">
<input type="text" id="search_ville_dispo" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Ville...") ?>" onkeyup="rechercheServeur('dispo')">
</div>
<div class="col-6">
<select id="search_type_dispo" class="form-select form-select-sm border-2 shadow-none" onchange="rechercheServeur('dispo')">
<option value=""><?= _("Tous les types") ?></option>
<?php foreach($typesDispo as $t): ?> <option value="<?= $t ?>"><?= $t ?></option> <?php endforeach; ?>
</select>
</div>
</div>
</div>
<tbody>
<?php foreach ($prestatairesdispo as $v):
$idPrestataire = $v['id'];
$codePrestataire = $v['codePrestataire'];
?>
<tr ondblclick="javascript:prestatairereseausoins_id(<?= $idPrestataire ?>);" valign="top">
<td><?= $this->nettoyer($v['libelle']) ?></td>
<td><?= $this->nettoyer($v['typeprestataire']) ?></td>
<td><?= $this->nettoyer($v['localite']) ?></td>
<td align='center'>
<input type="button" value="=>" onClick="javascript:ajouter_un_prestataire_reseau('<?=$codePrestataire?>');"
style="font-size:10pt; width:30px;" >
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button class="btn btn-primary-ghost btn-sm w-100 rounded-pill fw-bold" onclick="ajouter_tous_prestataires_reseau();">
<?= _("Tout ajouter") ?> <i class="fas fa-angle-double-right ms-1"></i>
</button>
</div>
<div class="card-body p-0">
<div class="table-responsive" style="max-height: 500px; overflow-y: auto;">
<table class="table table-hover align-middle mb-0" id="tab_dispo" style="font-size: 8.5pt;">
<thead class="bg-light sticky-top">
<tr>
<th class="ps-3 py-2"><?= _("Nom & Détails") ?></th>
<th class="text-center py-2" width="50px"></th>
</tr>
</thead>
<tbody>
<?php foreach ($prestatairesdispo as $v): $codePres = $v['codePrestataire']; ?>
<tr>
<td class="ps-3">
<div class="fw-bold text-dark search-target"><?= $this->nettoyer($v['libelle']) ?></div>
<div class="text-muted smaller">
<span class="search-target"><?= $this->nettoyer($v['localite']) ?></span> |
<span class="text-primary search-target"><?= $this->nettoyer($v['typeprestataire']) ?></span>
</div>
</td>
<td class="text-center pe-3">
<button class="btn btn-sm btn-primary-ghost rounded-circle action-icon" onclick="ajouter_un_prestataire_reseau('<?=$codePres?>');">
<i class="fas fa-chevron-right"></i>
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="div_prestataire_2" class="table-responsive">
<table class="table table-condensed table-responsive">
<tbody>
<tr>
<td align='center' colspan="2"><INPUT style="font-size:12pt;" class="form-control text-center" TYPE="text" value="Réseau: <?= $nomReseau ?> " disabled ></td>
</tr>
<tr>
<td align='center' style="font-size:18pt; font-weight:bold; vertical-align: middle;">
<?= _("Prestataires ajoutés") ?>
</td>
<td >
<input class="form-control" style="text-align: center; font-size:10pt;" type="text" id="nbligne2" name="nbligne2"
value="Nbre Lignes : <?= Format_N(count($prestatairesreseau))?>" readonly>
</td>
</tr>
</tbody>
</table>
<table class="table table-striped table-bordered table-hover table-condensed table-responsive tabliste compact" style="font-size:8pt;">
<thead>
<tr>
<th style='text-align:center'> <= </th>
<th style='text-align:center'> <?= _("Nom") ?> </th>
<th style='text-align:center'> <?= _("Ville") ?> </th>
</tr>
<tr>
<td colspan="4">
<button type="button" style="font-size:10pt; width:100%;" class="form-control btn btn-danger" onclick="javascript:retirer_tous_prestataires_du_site();" >
<?= "<================== " . _("Retirer Tous")." ==================" ?>
</button>
</td>
</tr>
</thead>
<tbody>
<?php foreach ($prestatairesreseau as $v):
$idPrestataire = $v['id'];
$codePrestataire = $v['codePrestataire'];
?>
<tr valign="top">
<td align='center'>
<input type="button" value="<=" onclick="javascript:retirer_un_prestataire_reseau('<?=$codePrestataire?>');"
style="font-size:10pt; width:30px;">
</td>
<td><?= $this->nettoyer($v['libelle']) ?></td>
<td><?= $this->nettoyer($v['localite']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="col-lg-7">
<div class="card border-0 shadow-sm h-100 border-start border-success border-4">
<div class="card-header bg-white py-3 border-bottom">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="mb-0 fw-bold text-success text-uppercase small">
<i class="fas fa-check-double me-2"></i><?= _("Affectés au réseau") ?>
</h6>
<span class="badge bg-success-light text-success rounded-pill px-3" id="count_affect">
<?= count($prestatairesreseau) ?>
</span>
</div>
<div class="bg-success-ghost p-2 rounded mb-2 border border-success-subtle">
<div class="row g-1">
<div class="col-12 mb-1">
<input type="text" id="search_nom_affect" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Rechercher dans la liste...") ?>" onkeyup="rechercheServeur('affect');">
</div>
<div class="col-6">
<input type="text" id="search_ville_affect" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Filtrer par ville...") ?>" onkeyup="rechercheServeur('affect');">
</div>
<div class="col-6">
<select id="search_type_affect" class="form-select form-select-sm border-2 shadow-none" onchange="rechercheServeur('affect');">
<option value=""><?= _("Tous les types") ?></option>
<?php foreach($typesAffect as $t): ?> <option value="<?= $t ?>"><?= $t ?></option> <?php endforeach; ?>
</select>
</div>
</div>
</div>
<button class="btn btn-danger-light btn-sm w-100 rounded-pill fw-bold" onclick="retirer_tous_prestataires_du_site();">
<i class="fas fa-angle-double-left me-1"></i> <?= _("Retirer tous les prestataires") ?>
</button>
</div>
<div class="card-body p-0">
<div class="table-responsive" style="max-height: 500px; overflow-y: auto;">
<table class="table table-hover align-middle mb-0" id="tab_affect" style="font-size: 8.5pt;">
<thead class="bg-success-light text-success sticky-top">
<tr>
<th class="ps-3 py-2" width="50px"></th>
<th class="py-2"><?= _("Nom du Prestataire") ?></th>
<th class="py-2 pe-3"><?= _("Ville & Type") ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($prestatairesreseau as $v): $codePres = $v['codePrestataire']; ?>
<tr>
<td class="ps-3 text-center">
<button class="btn btn-sm btn-danger-light rounded-circle action-icon" onclick="retirer_un_prestataire_reseau('<?=$codePres?>');">
<i class="fas fa-chevron-left"></i>
</button>
</td>
<td class="fw-bold text-dark text-uppercase search-target"><?= $this->nettoyer($v['libelle']) ?></td>
<td class="pe-3 search-target">
<span class="text-muted"><i class="fas fa-map-marker-alt me-1"></i><?= $this->nettoyer($v['localite']) ?></span>
<span class="badge bg-light text-muted fw-normal ms-2 search-target"><?= $this->nettoyer($v['typeprestataire']) ?></span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,13 @@
<?php if (isset($prestatairesreseau)): ?>
<?php foreach ($prestatairesreseau as $v): $code = $v['codePrestataire']; ?>
<tr>
<td class="ps-3 text-center">
<button class="btn btn-sm btn-danger-light rounded-circle action-icon" onclick="retirer_un_prestataire_reseau('<?=$code?>');">
<i class="fas fa-chevron-left"></i>
</button>
</td>
<td class="fw-bold text-dark text-uppercase"><?= $this->nettoyer($v['libelle']) ?></td>
<td class="pe-3 small text-muted"><?= $this->nettoyer($v['localite']) ?> <span class="badge bg-light text-muted ms-1"><?= $this->nettoyer($v['typeprestataire']) ?></span></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -0,0 +1,15 @@
<?php if (isset($prestatairesdispo)): ?>
<?php foreach ($prestatairesdispo as $v): $code = $v['codePrestataire']; ?>
<tr>
<td class="ps-3">
<div class="fw-bold text-dark"><?= $this->nettoyer($v['libelle']) ?></div>
<div class="text-muted small"><?= $this->nettoyer($v['localite']) ?> | <?= $this->nettoyer($v['typeprestataire']) ?></div>
</td>
<td class="text-center">
<button class="btn btn-sm btn-primary-ghost rounded-circle action-icon" onclick="ajouter_un_prestataire_reseau('<?=$code?>');">
<i class="fas fa-chevron-right"></i>
</button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -1,18 +1,22 @@
<?php
$this->titre = "INTER SANTE - Affectation Prestataires";
$codeReseau = $this->nettoyer($reseau['codeReseau']);
$idReseau = $this->nettoyer($reseau['id']);
$nomReseau = $this->nettoyer($reseau['libelle']);
// Extraction unique des types pour les selects (Optionnel)
$typesDispo = array_unique(array_column($prestatairesdispo, 'typeprestataire'));
$typesDispo = est_anglophone()
? array_unique(array_column($prestatairesdispo, 'typeprestataireEng'))
: array_unique(array_column($prestatairesdispo, 'typeprestataire'));
sort($typesDispo);
$typesAffect = array_unique(array_column($prestatairesreseau, 'typeprestataire'));
$typesAffect = est_anglophone()
? array_unique(array_column($prestatairesreseau, 'typeprestataireEng'))
: array_unique(array_column($prestatairesreseau, 'typeprestataire'));
sort($typesAffect);
?>
<div class="page-content animate__animated animate__fadeIn">
<div class="header-section mb-4">
<div class="header-section mb-1">
<div class="d-flex align-items-center justify-content-between bg-white p-3 shadow-sm border-start border-primary border-4" style="border-radius: var(--radius-md);">
<div class="d-flex align-items-center">
<div class="icon-shape bg-primary-ghost text-primary rounded-circle me-3" style="width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;">
@ -54,13 +58,13 @@
<div class="bg-primary-ghost-light p-2 rounded mb-2 border border-primary-subtle">
<div class="row g-1">
<div class="col-12 mb-1">
<input type="text" id="search_nom_dispo" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Nom du prestataire...") ?>" onkeyup="multiFilter('tab_dispo', 'count_dispo')">
<input type="text" id="search_nom_dispo" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Nom du prestataire...") ?>" onkeyup="rechercheServeur('dispo')">
</div>
<div class="col-6">
<input type="text" id="search_ville_dispo" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Ville...") ?>" onkeyup="multiFilter('tab_dispo', 'count_dispo')">
<input type="text" id="search_ville_dispo" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Ville...") ?>" onkeyup="rechercheServeur('dispo')">
</div>
<div class="col-6">
<select id="search_type_dispo" class="form-select form-select-sm border-2 shadow-none" onchange="multiFilter('tab_dispo', 'count_dispo')">
<select id="search_type_dispo" class="form-select form-select-sm border-2 shadow-none" onchange="rechercheServeur('dispo')">
<option value=""><?= _("Tous les types") ?></option>
<?php foreach($typesDispo as $t): ?> <option value="<?= $t ?>"><?= $t ?></option> <?php endforeach; ?>
</select>
@ -121,13 +125,13 @@
<div class="bg-success-ghost p-2 rounded mb-2 border border-success-subtle">
<div class="row g-1">
<div class="col-12 mb-1">
<input type="text" id="search_nom_affect" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Rechercher dans la liste...") ?>" onkeyup="multiFilter('tab_affect', 'count_affect')">
<input type="text" id="search_nom_affect" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Rechercher dans la liste...") ?>" onkeyup="rechercheServeur('affect');">
</div>
<div class="col-6">
<input type="text" id="search_ville_affect" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Filtrer par ville...") ?>" onkeyup="multiFilter('tab_affect', 'count_affect')">
<input type="text" id="search_ville_affect" class="form-control form-control-sm border-2 shadow-none" placeholder="<?= _("Filtrer par ville...") ?>" onkeyup="rechercheServeur('affect');">
</div>
<div class="col-6">
<select id="search_type_affect" class="form-select form-select-sm border-2 shadow-none" onchange="multiFilter('tab_affect', 'count_affect')">
<select id="search_type_affect" class="form-select form-select-sm border-2 shadow-none" onchange="rechercheServeur('affect');">
<option value=""><?= _("Tous les types") ?></option>
<?php foreach($typesAffect as $t): ?> <option value="<?= $t ?>"><?= $t ?></option> <?php endforeach; ?>
</select>
@ -174,39 +178,6 @@
</div>
</div>
<script>
/**
* Filtrage multicritères universel pour INTER-SANTE
*/
function multiFilter(tableId, counterId) {
const suffix = tableId === 'tab_dispo' ? '_dispo' : '_affect';
const valNom = document.getElementById('search_nom' + suffix).value.toLowerCase();
const valVille = document.getElementById('search_ville' + suffix).value.toLowerCase();
const valType = document.getElementById('search_type' + suffix).value.toLowerCase();
const rows = document.querySelectorAll(`#${tableId} tbody tr`);
let visibleCount = 0;
rows.forEach(row => {
// On récupère le texte complet de la ligne pour le filtrage
const rowText = row.innerText.toLowerCase();
const matchNom = rowText.includes(valNom);
const matchVille = rowText.includes(valVille);
const matchType = valType === "" || rowText.includes(valType);
if (matchNom && matchVille && matchType) {
row.style.display = "";
visibleCount++;
} else {
row.style.display = "none";
}
});
document.getElementById(counterId).innerText = visibleCount;
}
</script>
<style>
.bg-primary-ghost { background-color: rgba(33, 46, 83, 0.08) !important; }