Affichage de la liste des contrat d'un employé
Some checks failed
Organisation/sirh/pipeline/head There was a failure building this commit
Organisation/sirh/pipeline/pr-main There was a failure building this commit

This commit is contained in:
2026-06-18 15:30:15 +00:00
parent 67c14cfc7e
commit 73e0fab052
6 changed files with 144 additions and 3 deletions

View File

@@ -260,4 +260,77 @@ const listeContratExpirant = new Tabulator("#listeContratExpirant", {
},
],
ajaxURL: $("boutonContratExpirants").dataset.urlexpirants,
})
})
let tabContrats = null;
document.getElementById("modalContratsEmploye")
.addEventListener("show.bs.modal", function () {
const employeId = document.getElementById("detail-id").value;
console.log("Employe ID :", employeId);
if (!employeId) {
alert("Aucun employé sélectionné");
return;
}
fetch(`/employé/employe/${employeId}/contrats/`)
.then(response => {
if (!response.ok) {
throw new Error("Erreur HTTP " + response.status);
}
return response.json();
})
.then(data => {
document.getElementById("nom-employe-contrat").innerText =
data.employe;
if (tabContrats) {
tabContrats.destroy();
}
tabContrats = new Tabulator(
"#table-contrats-tabulator",
{
data: data.contrats,
layout: "fitColumns",
placeholder: "Aucun contrat",
columns: [
{ title: "Numéro", field: "numero_contrat" },
{ title: "Type", field: "type_contrat" },
{ title: "Date début", field: "date_debut" },
{ title: "Date fin", field: "date_fin" },
{ title: "Salaire", field: "salaire_mensuel" },
{ title: "Statut", field: "statut" },
{
title: "Contrat",
field: "fichier",
formatter: function(cell) {
const url = cell.getValue();
if (!url) {
return "<span class='text-danger'>Aucun fichier</span>";
}
return `<a href="${url}" target="_blank" class="btn btn-sm btn-primary">
<i class="bi bi-file-earmark-pdf"></i> Ouvrir
</a>`;
}
}
]
}
);
})
.catch(error => {
console.error("Erreur :", error);
});
});