Merge branch 'main' of https://jenkins.cerfig.org/CERFIG/sirh
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -8,6 +8,8 @@ class EmployeForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Employe
|
||||
fields = (
|
||||
'departement',
|
||||
'fonction',
|
||||
'adresse',
|
||||
'telephone',
|
||||
'CV',
|
||||
@@ -15,7 +17,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:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Generated by Django 5.2.13 on 2026-09-01 10:51
|
||||
# Generated by Django 5.2.13 on 2026-09-03 14:33
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
|
||||
@@ -29,6 +29,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 +213,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();
|
||||
})
|
||||
|
||||
@@ -18,37 +18,31 @@ const tableau_certificat = new Tabulator("#tableau-certificat", {
|
||||
})
|
||||
const enregistrerProfil = $("enregistrerProfil");
|
||||
|
||||
// enregistrerProfil.addEventListener("click", (e) => {
|
||||
enregistrerProfil.addEventListener("click", (e) => {
|
||||
const url = $("information-personnelles").dataset.url;
|
||||
const csrftoken = document.querySelector("[name='csrfmiddlewaretoken']").value;
|
||||
|
||||
// const url = $("information-personnelles").dataset.url;
|
||||
// const csrftoken = document.querySelector("[name='csrfmiddlewaretoken']").value;
|
||||
const formData = new FormData();
|
||||
formData.append("nom", $("nom").value);
|
||||
formData.append("prenom", $("prenom").value);
|
||||
formData.append("email", $("email").value);
|
||||
formData.append("telephone", $("telephone").value);
|
||||
formData.append("adresse", $("adresse").value);
|
||||
formData.append("sexe", $("sexe").value);
|
||||
formData.append("date_naissance", $("date_naissance").value);
|
||||
const photoInput = $("photo");
|
||||
if (photoInput.files.length > 0) {
|
||||
formData.append("photo", photoInput.files[0]);
|
||||
}
|
||||
|
||||
// const formData = new FormData();
|
||||
// formData.append("nom", $("nom").value);
|
||||
// formData.append("prenom", $("prenom").value);
|
||||
// formData.append("email", $("email").value);
|
||||
// formData.append("telephone", $("telephone").value);
|
||||
// formData.append("adresse", $("adresse").value);
|
||||
// formData.append("sexe", $("sexe").value);
|
||||
// formData.append("date_naissance", $("date_naissance").value);
|
||||
// const photoInput = $("photo");
|
||||
// if (photoInput.files.length > 0) {
|
||||
// formData.append("photo", photoInput.files[0]);
|
||||
// }
|
||||
|
||||
|
||||
// console.log("---------------------------------------------")
|
||||
// console.log("Données du formulaire:", url);
|
||||
// console.log("Données du formulaire:", formData);
|
||||
|
||||
// fetch(url, {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// "X-CSRFToken": csrftoken
|
||||
// },
|
||||
// body: formData
|
||||
// })
|
||||
// .then(response => response.json())
|
||||
// .then(data => alert(data.message))
|
||||
// .catch(error => console.error("Erreur:", error));
|
||||
// });
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-CSRFToken": csrftoken
|
||||
},
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => alert(data.message))
|
||||
.catch(error => console.error("Erreur:", error));
|
||||
});
|
||||
@@ -8,7 +8,7 @@
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="modalDetailEmployeBody" data-url="{% url 'gestion_employe:enregistrer-detail-employe' %}">
|
||||
<div class="modal-body" id="modalDetailEmployeBody" data-url="{% url 'gestion_employe:enregistrer-detail-employe' %}" data-url-departements="{% url 'gestion_employe:liste-departements' %}">
|
||||
<div class="row g-3">
|
||||
<input type="hidden" id="detail-id">
|
||||
<div class="col-md-6">
|
||||
@@ -23,7 +23,12 @@
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label>Département :</label>
|
||||
<input type="text" class="form-control" id="detail-departement">
|
||||
<select class="form-select" id="detail-departement">
|
||||
<option value="">-- Sélectionner --</option>
|
||||
{% for dept in departements %}
|
||||
<option value="{{ dept.id }}">{{ dept.nom }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label>Sexe :</label>
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.utils import timezone
|
||||
from fonction_utilitaire import fonctions_utilitaire
|
||||
|
||||
from .forms import AffectationForm, ContratForm, FormationForm
|
||||
from .models import Affectation, Contrat, Employe, Formation
|
||||
from .models import Affectation, Contrat, Departement, Employe, Formation
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -42,7 +42,8 @@ def index(request):
|
||||
'nombre_stage': nombre_stage,
|
||||
'nombre_expirants': nombre_expirants,
|
||||
'affectation_form': AffectationForm(),
|
||||
'contrat_form': ContratForm()
|
||||
'contrat_form': ContratForm(),
|
||||
'departements': Departement.objects.all()
|
||||
})
|
||||
|
||||
@login_required
|
||||
@@ -285,7 +286,7 @@ def creation_contrat(request):
|
||||
|
||||
contrat_actif = Contrat.objects.filter(
|
||||
employe=employe,
|
||||
date_fin__gte=datetime.date.today()
|
||||
date_fin__gte=timezone.now().date()
|
||||
).exists()
|
||||
|
||||
if request.method == "POST":
|
||||
@@ -360,10 +361,30 @@ def enregistrer_detail_employe(request):
|
||||
except Employe.DoesNotExist:
|
||||
return JsonResponse({"error": "Employé non trouvé."}, status=404)
|
||||
|
||||
employe.fonction = data['fonction']
|
||||
employe.date_embauche = data['date_embauche']
|
||||
employe.matricule = data['matricule']
|
||||
employe.fonction = data.get('fonction')
|
||||
employe.date_embauche = data.get('date_embauche')
|
||||
employe.matricule = data.get('matricule')
|
||||
|
||||
# Traiter le département
|
||||
dept_value = data.get('departement')
|
||||
print(f"[DEBUG] Département brut: {dept_value!r}")
|
||||
print(f"[DEBUG] Type département: {type(dept_value).__name__}")
|
||||
print(f"[DEBUG] Est vide: {not dept_value}")
|
||||
|
||||
if dept_value and str(dept_value).strip():
|
||||
try:
|
||||
dept_id = int(dept_value)
|
||||
departement = Departement.objects.get(id=dept_id)
|
||||
employe.departement = departement
|
||||
except Departement.DoesNotExist:
|
||||
employe.departement = None
|
||||
except (ValueError, TypeError) as e:
|
||||
employe.departement = None
|
||||
else:
|
||||
employe.departement = None
|
||||
|
||||
employe.save()
|
||||
|
||||
return JsonResponse({"message": "Détails de l'employé mis à jour avec succès."})
|
||||
else:
|
||||
return JsonResponse({"message": "Méthode non autorisée."}, status=405)
|
||||
@@ -426,7 +447,7 @@ def liste_employe(request):
|
||||
"affectations": affectations,
|
||||
"projet": projets,
|
||||
"contrats": contrats,
|
||||
"departement": employe.departement.nom if employe.departement else "",
|
||||
"departement": employe.departement.id if employe.departement else "",
|
||||
"fonction": employe.fonction,
|
||||
"date_embauche": employe.date_embauche,
|
||||
"adresse": employe.adresse,
|
||||
|
||||
Reference in New Issue
Block a user