From d28bf85556743f8b5b2ed71238f0c16eda9b495e Mon Sep 17 00:00:00 2001 From: Fatimac2804 Date: Wed, 2 Sep 2026 14:33:51 +0200 Subject: [PATCH] Affichage de la liste des departements pour la modification 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, 21 insertions(+), 92 deletions(-) diff --git a/gestion_employe/forms.py b/gestion_employe/forms.py index 087f699..55fab64 100644 --- a/gestion_employe/forms.py +++ b/gestion_employe/forms.py @@ -1,12 +1,11 @@ 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', @@ -14,18 +13,7 @@ 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 260ed02..ba451c1 100644 --- a/gestion_employe/static/gestion_employe/js/index.js +++ b/gestion_employe/static/gestion_employe/js/index.js @@ -12,6 +12,7 @@ const tableau_liste_employe = new Tabulator("#tableau_liste_employe", { // ajaxURL: url_liste_employe, pagination: true, paginationSize: 10, + responsiveLayout : "hide" }) fetch(url_liste_employe) @@ -28,8 +29,6 @@ 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; @@ -212,41 +211,23 @@ $("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(payload) + body: JSON.stringify({ + "id": id_, + "fonction": fonction, + "date_embauche": dateEmbauche, + "matricule": matricule + }) }) .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 1684de6..187ef49 100644 --- a/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html +++ b/gestion_employe/templates/gestion_employe/parts/modalDetailEmploye.html @@ -8,7 +8,7 @@ -