diff --git a/gestion_employe/static/gestion_employe/js/index.js b/gestion_employe/static/gestion_employe/js/index.js index 9c31f13..bd4fed2 100644 --- a/gestion_employe/static/gestion_employe/js/index.js +++ b/gestion_employe/static/gestion_employe/js/index.js @@ -14,6 +14,20 @@ const tableau_liste_employe = new Tabulator("#tableau_liste_employe", { responsiveLayout : "hide" }) +const tableauToutesAffectations = new Tabulator("#tableauToutesAffectations", { + layout: "fitColumns", + pagination: "local", + paginationSize: 10, + placeholder: "Aucune affectation enregistrée pour cet employé.", + columns: [ + {title: "Projet", field: "projet"}, + {title: "Rôle", field: "role"}, + {title: "Pourcentage", field: "pourcentage_temps_affectation", formatter: cell => `${cell.getValue()} %`}, + {title: "Date de début", field: "date_affectation"}, + {title: "Date de fin", field: "date_fin_daffectation", formatter: cell => cell.getValue() || "Non définie"}, + ], +}) + fetch(url_liste_employe) .then(response => response.json()) .then(data => { @@ -149,6 +163,9 @@ tableau_liste_employe.on("rowClick", function (row, rowData) { document.getElementById("affectation-nom-employe").textContent = data.employe || "Employé inconnu"; document.getElementById("affecter_employe_id").value = data.id; + $("liste-affectations-nom-employe").textContent = data.employe || "Employé inconnu"; + tableauToutesAffectations.setData(data.toutes_affectations); + document.getElementById("affectations-list").innerHTML = ""; for (const affectation of data.affectations) { document.getElementById("affectations-list").innerHTML += ` @@ -205,6 +222,23 @@ tableau_liste_employe.on("rowClick", function (row, rowData) { modal.show(); }) +$("btnAfficherToutesAffectations").addEventListener("click", function() { + const modalDetail = $("modalDetailEmploye"); + const modalAffectations = $("modalListeAffectations"); + + modalDetail.addEventListener("hidden.bs.modal", function ouvrirListe() { + modalDetail.removeEventListener("hidden.bs.modal", ouvrirListe); + bootstrap.Modal.getOrCreateInstance(modalAffectations).show(); + }, {once: true}); + + modalAffectations.addEventListener("hidden.bs.modal", function revenirAuDetail() { + modalAffectations.removeEventListener("hidden.bs.modal", revenirAuDetail); + bootstrap.Modal.getOrCreateInstance(modalDetail).show(); + }, {once: true}); + + bootstrap.Modal.getOrCreateInstance(modalDetail).hide(); +}) + $("enregistrerDetail").addEventListener("click", function() { const id_ = document.getElementById('detail-id').value; const fonction = document.getElementById('detail-fonction').value; diff --git a/gestion_employe/templates/gestion_employe/index.html b/gestion_employe/templates/gestion_employe/index.html index 7e37c58..40688b9 100644 --- a/gestion_employe/templates/gestion_employe/index.html +++ b/gestion_employe/templates/gestion_employe/index.html @@ -61,6 +61,7 @@ {% include "gestion_employe/parts/modalAffectationProjet.html" %} {% include "gestion_employe/parts/modalDocument.html" %} {% include "gestion_employe/parts/modalListeContratExpirants.html" %} + {% include "gestion_employe/parts/modalListeAffectations.html" %} {% endblock %} {% block 'js' %} diff --git a/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html b/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html index 1c7693c..da29daf 100644 --- a/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html +++ b/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html @@ -112,11 +112,16 @@