diff --git a/gestion_employe/static/gestion_employe/js/index.js b/gestion_employe/static/gestion_employe/js/index.js index 95eb1d8..950142e 100644 --- a/gestion_employe/static/gestion_employe/js/index.js +++ b/gestion_employe/static/gestion_employe/js/index.js @@ -260,4 +260,77 @@ const listeContratExpirant = new Tabulator("#listeContratExpirant", { }, ], ajaxURL: $("boutonContratExpirants").dataset.urlexpirants, -}) \ No newline at end of file +}) + + + +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 "Aucun fichier"; + } + + return ` + Ouvrir + `; + } + } + ] + } + ); + }) + .catch(error => { + console.error("Erreur :", error); + }); +}); + + diff --git a/gestion_employe/templates/gestion_employe/index.html b/gestion_employe/templates/gestion_employe/index.html index 825dec9..2330546 100644 --- a/gestion_employe/templates/gestion_employe/index.html +++ b/gestion_employe/templates/gestion_employe/index.html @@ -58,6 +58,7 @@ {% block 'modal' %} {% include "gestion_employe/parts/modalDetailEmploye.html" %} {% include "gestion_employe/parts/modalCreationContrat.html" %} + {% include "gestion_employe/parts/modalContratsEmploye.html" %} {% include "gestion_employe/parts/modalAffectationProjet.html" %} {% include "gestion_employe/parts/modalDocument.html" %} {% include "gestion_employe/parts/modalListeContratExpirants.html" %} diff --git a/gestion_employe/templates/gestion_employe/parts/modalContratsEmploye.html b/gestion_employe/templates/gestion_employe/parts/modalContratsEmploye.html new file mode 100644 index 0000000..c26a2e1 --- /dev/null +++ b/gestion_employe/templates/gestion_employe/parts/modalContratsEmploye.html @@ -0,0 +1,21 @@ +