From e3f0befff64c1d0b095f8c16b1b2722e0a3fa5fe Mon Sep 17 00:00:00 2001 From: Fatimac2804 Date: Wed, 2 Sep 2026 12:48:35 +0200 Subject: [PATCH] Correction sur l'afficha de la liste de departement pour la modification des informations de l'employer --- gestion_employe/forms.py | 16 +++++- .../static/gestion_employe/js/index.js | 33 +++++++++--- .../parts/modalDetailEmploye.html | 9 +++- gestion_employe/urls.py | 5 ++ gestion_employe/views.py | 50 +++++++++++++++---- 5 files changed, 92 insertions(+), 21 deletions(-) diff --git a/gestion_employe/forms.py b/gestion_employe/forms.py index 55fab64..087f699 100644 --- a/gestion_employe/forms.py +++ b/gestion_employe/forms.py @@ -1,11 +1,12 @@ from django import forms from .models import Contrat, Departement, Employe,Affectation,Formation - class EmployeForm(forms.ModelForm): """Formulaire pour modifier les informations de profil d'un employé""" class Meta: model = Employe fields = ( + 'departement', + 'fonction', 'adresse', 'telephone', 'CV', @@ -13,7 +14,18 @@ class EmployeForm(forms.ModelForm): 'rib', 'photo', 'casier_judiciaire' - ) + ) + widgets = { + 'departement': forms.Select(attrs={'class': 'form-select'}), + 'fonction': forms.Select(attrs={'class': 'form-select'}), + 'adresse': forms.TextInput(attrs={'class': 'form-control'}), + 'telephone': forms.TextInput(attrs={'class': 'form-control'}), + 'CV': forms.FileInput(attrs={'class': 'form-control'}), + 'diplome': forms.FileInput(attrs={'class': 'form-control'}), + 'rib': forms.FileInput(attrs={'class': 'form-control'}), + 'photo': forms.FileInput(attrs={'class': 'form-control'}), + 'casier_judiciaire': forms.FileInput(attrs={'class': 'form-control'}), + } class AffectationForm(forms.ModelForm): class Meta: diff --git a/gestion_employe/static/gestion_employe/js/index.js b/gestion_employe/static/gestion_employe/js/index.js index ba451c1..260ed02 100644 --- a/gestion_employe/static/gestion_employe/js/index.js +++ b/gestion_employe/static/gestion_employe/js/index.js @@ -12,7 +12,6 @@ const tableau_liste_employe = new Tabulator("#tableau_liste_employe", { // ajaxURL: url_liste_employe, pagination: true, paginationSize: 10, - responsiveLayout : "hide" }) fetch(url_liste_employe) @@ -29,6 +28,8 @@ fetch(url_liste_employe) tableau_liste_employe.on("rowClick", function (row, rowData) { const data = rowData.getData(); + console.log('Employé cliqué:', data); + document.getElementById('detail-id').value = data.id; document.getElementById('detail-matricule').value = data.matricule; document.getElementById('detail-employe').value = data.employe; @@ -211,23 +212,41 @@ $("enregistrerDetail").addEventListener("click", function() { const fonction = document.getElementById('detail-fonction').value; const dateEmbauche = document.getElementById('detail-dateEmbauche').value; const matricule = document.getElementById('detail-matricule').value; + const departement = document.getElementById('detail-departement').value; + + console.log('=== ENREGISTREMENT DÉTAILS ==='); + console.log('ID:', id_); + console.log('Fonction:', fonction); + console.log('Date embauche:', dateEmbauche); + console.log('Matricule:', matricule); + console.log('Département (valeur brute):', departement); + console.log('Département (type):', typeof departement); + console.log('Département est vide:', !departement); const url_enregistrer_detail = $("modalDetailEmployeBody").dataset.url; + + const payload = { + "id": id_, + "fonction": fonction, + "date_embauche": dateEmbauche, + "matricule": matricule, + "departement": departement + }; + + console.log('Payload JSON:', payload); + console.log('Payload stringifié:', JSON.stringify(payload)); + fetch(url_enregistrer_detail, { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": document.querySelector('[name=csrfmiddlewaretoken]').value }, - body: JSON.stringify({ - "id": id_, - "fonction": fonction, - "date_embauche": dateEmbauche, - "matricule": matricule - }) + body: JSON.stringify(payload) }) .then(response => response.json()) .then(data => { + console.log('Réponse du serveur:', data); alert(data.message); location.reload(); }) diff --git a/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html b/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html index 187ef49..1684de6 100644 --- a/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html +++ b/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html @@ -8,7 +8,7 @@ -