Merge branch 'main' of https://jenkins.cerfig.org/CERFIG/sirh
This commit is contained in:
@@ -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));
|
||||
});
|
||||
Reference in New Issue
Block a user