radiantrh/Vue/Gedadherent/index.php
2026-03-24 12:12:41 +00:00

170 lines
8.9 KiB
PHP

<?php $this->titre = "INTER-SANTE - GED Famille"; ?>
<div id="div_adherent" class="container-fluid py-1 animate__animated animate__fadeIn">
<h1 class="text-primary"><i class="bi bi-file-earmark-person me-2"></i><?= _('G E D Adhérent') ?></h1>
<div class="card-header d-flex justify-content-between align-items-center py-1 mb-2">
<h5 class="mb-0 fw-bold">
<?= _("POLICE") ?> : <span class="text-secondary"><?= $this->nettoyer($_SESSION['numeroPolice_C']) ?></span>
<span class="ms-3 badge bg-primary text-light small fw-normal">ID: <?= $this->nettoyer($_SESSION['idPolice_C']) ?></span>
</h5>
</div>
<div class="alert alert-warning border-0 shadow-sm d-flex align-items-center mb-4">
<i class="fas fa-exclamation-circle fs-4 me-3"></i>
<div>
<strong><?= _("Information :") ?></strong>
<?= _("Affichage limité aux 50 derniers documents. Utilisez les filtres pour affiner votre recherche.") ?>
</div>
</div>
<div class="row g-4">
<div class="col-xl-12">
<div class="card border-0 shadow-sm">
<div class="card-body">
<form id="form_ged_adherent" enctype="multipart/form-data" action="Gedadherent" method="post">
<div class="row g-3">
<div class="col-md-3">
<label class="form-label fw-bold small text-muted text-uppercase">
<?= _("Type Document") ?><span class="text-danger">*</span>
</label>
<select class="form-select form-select-sm border-primary-subtle" id="codeNaturePiece" name="codeNaturePiece" required>
<?php liste_options($naturepiece, ""); ?>
</select>
</div>
<div class="col-md-3" id="div_autre_type" style="display: none;">
<label class="form-label fw-bold small text-muted text-uppercase">
<?= _("Préciser si autre type") ?><span class="text-danger">*</span>
</label>
<input type="text" class="form-control form-control-sm border-warning" id="libelleAutre" name="libelleAutre" placeholder="<?= _("Saisissez le type...") ?>">
</div>
<div class="col-md-9">
<label class="form-label small fw-bold text-muted text-uppercase"><?= _("Nouveau Document") ?></label>
<input class="form-control form-control-sm border-info" name="fichier_upload" type="file" id="fichier_upload">
</div>
<div class="col-md-3 d-flex align-items-end gap-2">
<button type="button" class="btn btn-primary btn-sm flex-fill fw-bold shadow-sm" onclick="lister_ged_adherent();">
<i class="fas fa-sync-alt me-1"></i> <?= _("Filtrer") ?>
</button>
<button type="submit" id="btn_submit_ged" name="submit" class="btn btn-success btn-sm flex-fill fw-bold shadow-sm">
<i class="fas fa-upload me-1"></i> <?= _("Envoyer") ?>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-xl-12">
<div id="div_ged" class="card border-0 shadow-sm">
<?php if((isset($msgErreur)) && ($msgErreur > " ")) : ?>
<div class="alert alert-danger m-3 border-0 shadow-xs"><?= $msgErreur ?></div>
<?php endif; ?>
<div class="table-responsive">
<table id="table_ged_famille" class="table table-hover align-middle mb-0" style="font-size:8.5pt; width:100%;">
<thead class="table-dark text-nowrap">
<tr>
<th class="text-center">Date</th>
<th class="text-center">Src</th>
<th><?= _("Souscripteur / Police") ?></th>
<th><?= _("Prestataire") ?></th>
<th><?= _("Bénéficiaire (Adhérent)") ?></th>
<th><?= _("Nom du Document") ?></th>
<th class="text-center no-export"><?= _("Action") ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($geds as $ged):
$idGed = $this->nettoyer($ged['idGed']);
$cheminFichier = $this->nettoyer($ged['cheminFichier']);
?>
<tr class="text-nowrap">
<td class="text-center small text-muted"><?= dateheureLang($this->nettoyer($ged['dateSysteme'])) ?></td>
<td class="text-center"><span class="badge bg-light text-dark border small fw-normal"><?= $this->nettoyer($ged['source']) ?></span></td>
<td>
<div class="fw-bold"><?= $this->nettoyer($ged['souscripteur']) ?></div>
<div class="small text-primary">N° <?= $this->nettoyer($ged['numeroPolice']) ?></div>
</td>
<td class="small"><?= $this->nettoyer($ged['prestataire']) ?></td>
<td>
<div class="fw-bold"><?= $this->nettoyer($ged['beneficiaire']) ?></div>
<div class="small text-muted italic"><?= $this->nettoyer($ged['adherent']) ?></div>
</td>
<td class="small text-truncate" style="max-width: 200px;" title="<?= $this->nettoyer($ged['nomOrigine']) ?>">
<i class="far fa-file-alt me-1 text-secondary"></i> <?= $this->nettoyer($ged['nomOrigine']) ?>
</td>
<td class="text-center">
<a class="btn btn-xs btn-outline-danger shadow-sm fw-bold px-3" href="<?= $cheminFichier ?>" target="_blank">
<i class="fas fa-download me-1"></i> <?= _("Télécharger") ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const selectNature = document.getElementById('codeNaturePiece');
const divAutre = document.getElementById('div_autre_type');
const inputAutre = document.getElementById('libelleAutre');
const form = document.getElementById('form_ged_adherent');
// 1. Gérer l'affichage dynamique du champ "Autre"
selectNature.addEventListener('change', function() {
if (this.value === 'AUT') {
divAutre.style.display = 'block';
inputAutre.setAttribute('required', 'required');
inputAutre.focus();
} else {
divAutre.style.display = 'none';
inputAutre.removeAttribute('required');
inputAutre.value = '';
}
});
// 2. Contrôle du formulaire au Submit avec alerte Ebene
form.addEventListener('submit', async function(e) {
const valNature = selectNature.value;
const fileInput = document.getElementById('fichier_upload');
// Cas : Type de document non sélectionné
if (valNature === "") {
e.preventDefault(); // On bloque l'envoi immédiatement
await alert_ebene(
"Veuillez sélectionner un Type de Document avant l'envoi.",
"Please select a Document Type before sending."
);
selectNature.classList.add('is-invalid');
selectNature.focus();
return false;
}
// Cas : Type "Autre" sélectionné mais libellé vide
if (valNature === 'AUT' && inputAutre.value.trim() === "") {
e.preventDefault();
await alert_ebene(
"Veuillez préciser le type de document dans le champ orange.",
"Please specify the document type in the orange field."
);
inputAutre.classList.add('is-invalid');
inputAutre.focus();
return false;
}
});
});
</script>