Ajout de la liste des affectations d'un employé #74
@@ -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;
|
||||
|
||||
@@ -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' %}
|
||||
<script type="text/javascript" src="{% static 'gestion_employe/js/index.js' %}"></script>
|
||||
|
||||
@@ -112,12 +112,17 @@
|
||||
<div class="row d-flex g-3">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h5><i class="bi bi-pin-angle me-2"></i> Affectations</h5>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="button" class="btn btn-outline-primary" id="btnAfficherToutesAffectations">
|
||||
<i class="bi bi-list-ul"></i> Voir toutes les affectations
|
||||
</button>
|
||||
{% if user|has_group:"ressource_humaine" %}
|
||||
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#modalAffectation" onclick="setEmployeId()">
|
||||
<i class="bi bi-file-earmark-text"></i> Affecter
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div id="affectations-list"></div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<div class="modal fade" id="modalListeAffectations" tabindex="-1" aria-labelledby="modalListeAffectationsLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modalListeAffectationsLabel">
|
||||
Toutes les affectations de <span id="liste-affectations-nom-employe"></span>
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="tableauToutesAffectations"></div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light">
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
||||
<i class="bi bi-x-circle"></i> Fermer
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -418,6 +418,16 @@ def liste_employe(request):
|
||||
date_fin_daffectation__gte=timezone.now().date()
|
||||
)
|
||||
]
|
||||
toutes_affectations = [
|
||||
{
|
||||
"projet": affectation.projet.nom_projet,
|
||||
"role": dict(Affectation.ROLE_CHOICES).get(affectation.role, affectation.role),
|
||||
"pourcentage_temps_affectation": affectation.pourcentage_temps_affectation,
|
||||
"date_affectation": affectation.date_affectation,
|
||||
"date_fin_daffectation": affectation.date_fin_daffectation,
|
||||
}
|
||||
for affectation in Affectation.objects.filter(employe=employe).select_related("projet")
|
||||
]
|
||||
|
||||
data.append(
|
||||
{
|
||||
@@ -427,6 +437,7 @@ def liste_employe(request):
|
||||
"email": employe.user.email,
|
||||
"formations": formations,
|
||||
"affectations": affectations,
|
||||
"toutes_affectations": toutes_affectations,
|
||||
"projet": projets,
|
||||
"contrats": contrats,
|
||||
"departement": employe.departement.id if employe.departement else "",
|
||||
|
||||
Reference in New Issue
Block a user