diff --git a/src/components/DisplayPartnerSession.js b/src/components/DisplayPartnerSession.js index 0432a15..226676c 100644 --- a/src/components/DisplayPartnerSession.js +++ b/src/components/DisplayPartnerSession.js @@ -569,8 +569,6 @@ const DisplayPartnerSession = (props) => { var form = new FormData(); - - const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); diff --git a/src/components/DisplayPartnerStagiaires.js b/src/components/DisplayPartnerStagiaires.js index 01b405b..aa9b66d 100644 --- a/src/components/DisplayPartnerStagiaires.js +++ b/src/components/DisplayPartnerStagiaires.js @@ -81,7 +81,7 @@ const DisplayPartnerStagiaires = (props) => { else if (String(params.value) === "-1") return "Annulé"; else - return "?"; + return "???"; }, }, { field: 'session_id', headerName: 'Code session', hideable: true, }, @@ -294,6 +294,9 @@ const DisplayPartnerStagiaires = (props) => { GetAttendee_Data(participant_email, code_session, internal_url); + // Recuperation de l'image de profiel + getStagiaireImages(internal_url, code_session, participant_email); + /* GetCurrentSession(line.code_session, line.class_internal_url); @@ -492,6 +495,55 @@ const DisplayPartnerStagiaires = (props) => { } + function Disable_DetailAttendeFields() { + + setparticipant_data_edit_mode("0"); + + if (document.getElementsByName("detail_nom") && document.getElementsByName("detail_nom")[0]) + document.getElementsByName("detail_nom")[0].value = ""; + + if (document.getElementsByName("detail_prenom") && document.getElementsByName("detail_prenom")[0]) + document.getElementsByName("detail_prenom")[0].value = ""; + + if (document.getElementsByName("detail_mail") && document.getElementsByName("detail_mail")[0]) + document.getElementsByName("detail_mail")[0].value = ""; + + if (document.getElementsByName("detail_tel") && document.getElementsByName("detail_tel")[0]) + document.getElementsByName("detail_tel")[0].value = ""; + + if (document.getElementsByName("detail_adresse") && document.getElementsByName("detail_adresse")[0]) + document.getElementsByName("detail_adresse")[0].value = ""; + + if (document.getElementsByName("detail_code_postal") && document.getElementsByName("detail_code_postal")[0]) + document.getElementsByName("detail_code_postal")[0].value = ""; + + if (document.getElementsByName("detail_ville") && document.getElementsByName("detail_ville")[0]) + document.getElementsByName("detail_ville")[0].value = ""; + + if (document.getElementsByName("detail_incr_date") && document.getElementsByName("detail_incr_date")[0]) + document.getElementsByName("detail_incr_date")[0].value = ""; + + if (document.getElementsByName("detail_cout") && document.getElementsByName("detail_cout")[0]) + document.getElementsByName("detail_cout")[0].value = ""; + + if (document.getElementsByName("detail_mode_fin") && document.getElementsByName("detail_mode_fin")[0]) + document.getElementsByName("detail_mode_fin")[0].value = ""; + + if (document.getElementsByName("detail_employeur") && document.getElementsByName("detail_employeur")[0]) + document.getElementsByName("detail_employeur")[0].value = ""; + + if (document.getElementsByName("date_evaluation") && document.getElementsByName("date_evaluation")[0]) + document.getElementsByName("date_evaluation")[0].value = ""; + + if (document.getElementsByName("note_eval") && document.getElementsByName("note_eval")[0]) + document.getElementsByName("note_eval")[0].value = ""; + + if (document.getElementsByName("certif_date") && document.getElementsByName("certif_date")[0]) + document.getElementsByName("certif_date")[0].value = ""; + + + } + const [Resend_LMS_Credentials_api, setResend_LMS_Credentials_api] = useState(); const [Resend_LMS_Credentials_result, setResend_LMS_Credentials_result] = useState(); const [Resend_LMS_Credentials_message, setResend_LMS_Credentials_message] = useState(); @@ -751,8 +803,73 @@ const DisplayPartnerStagiaires = (props) => { const [isimgclassSaved, setisimgclassSaved] = useState(""); const [isimgclassSaved_message, setisimgclassSaved_message] = useState(""); + function AnnuleAttendeeDetailFields() { + + GetAttendee_Data(selected_participant_email, selected_code_session, selected_internal_url); + disableAttendeeDetailFields(); + setparticipant_data_changed(); + setparticipant_data_edit_mode(); + } + + function disableAttendeeDetailFields() { + setparticipant_data_edit_mode("0"); + + + document.getElementsByName("detail_session_class")[0].disabled = true; + document.getElementsByName("detail_session_class")[0].style.backgroundColor = "#ECEFF1"; + + + document.getElementsByName("detail_nom")[0].disabled = true; + document.getElementsByName("detail_nom")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("detail_status_inscript")[0].disabled = true; + document.getElementsByName("detail_status_inscript")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("detail_opco")[0].disabled = true; + document.getElementsByName("detail_opco")[0].style.backgroundColor = "#ECEFF1"; + + + document.getElementsByName("detail_prenom")[0].disabled = true; + document.getElementsByName("detail_prenom")[0].style.backgroundColor = "#ECEFF1"; + + + document.getElementsByName("detail_mail")[0].disabled = true; + document.getElementsByName("detail_mail")[0].style.backgroundColor = "#ECEFF1"; + + + document.getElementsByName("detail_tel")[0].disabled = true; + document.getElementsByName("detail_tel")[0].style.backgroundColor = "#ECEFF1"; + + + document.getElementsByName("detail_adresse")[0].disabled = true; + document.getElementsByName("detail_adresse")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("detail_code_postal")[0].disabled = true; + document.getElementsByName("detail_code_postal")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("detail_ville")[0].disabled = true; + document.getElementsByName("detail_ville")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("detail_cout")[0].disabled = true; + document.getElementsByName("detail_cout")[0].style.backgroundColor = "#ECEFF1"; + + + document.getElementsByName("detail_mode_fin")[0].disabled = true; + document.getElementsByName("detail_mode_fin")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("detail_employeur")[0].disabled = true; + document.getElementsByName("detail_employeur")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("date_evaluation")[0].disabled = true; + document.getElementsByName("date_evaluation")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("certif_date")[0].disabled = true; + document.getElementsByName("certif_date")[0].style.backgroundColor = "#ECEFF1"; + + document.getElementsByName("note_eval")[0].disabled = true; + document.getElementsByName("note_eval")[0].style.backgroundColor = "#ECEFF1"; + - function desableAttendeeDetailFields() { document.getElementsByName("date_evaluation")[0].disabled = true; document.getElementsByName("date_evaluation")[0].style.backgroundColor = "#ECEFF1"; @@ -766,6 +883,82 @@ const DisplayPartnerStagiaires = (props) => { } + + + function EnableAttendeeDetailFields() { + setparticipant_data_edit_mode("1"); + + document.getElementsByName("detail_session_class")[0].disabled = false; + document.getElementsByName("detail_session_class")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("detail_nom")[0].disabled = false; + document.getElementsByName("detail_nom")[0].style.backgroundColor = "#FFFFFF"; + + + + document.getElementsByName("detail_status_inscript")[0].disabled = false; + document.getElementsByName("detail_status_inscript")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("detail_opco")[0].disabled = false; + document.getElementsByName("detail_opco")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("detail_prenom")[0].disabled = false; + document.getElementsByName("detail_prenom")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("detail_mail")[0].disabled = false; + document.getElementsByName("detail_mail")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("detail_tel")[0].disabled = false; + document.getElementsByName("detail_tel")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("detail_adresse")[0].disabled = false; + document.getElementsByName("detail_adresse")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("detail_code_postal")[0].disabled = false; + document.getElementsByName("detail_code_postal")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("detail_ville")[0].disabled = false; + document.getElementsByName("detail_ville")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("detail_cout")[0].disabled = false; + document.getElementsByName("detail_cout")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("detail_mode_fin")[0].disabled = false; + document.getElementsByName("detail_mode_fin")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("detail_employeur")[0].disabled = false; + document.getElementsByName("detail_employeur")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("date_evaluation")[0].disabled = false; + document.getElementsByName("date_evaluation")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("certif_date")[0].disabled = false; + document.getElementsByName("certif_date")[0].style.backgroundColor = "#FFFFFF"; + + document.getElementsByName("note_eval")[0].disabled = false; + document.getElementsByName("note_eval")[0].style.backgroundColor = "#FFFFFF"; + + + + + document.getElementsByName("date_evaluation")[0].disabled = false; + document.getElementsByName("date_evaluation")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("detail_incr_date")[0].disabled = false; + document.getElementsByName("detail_incr_date")[0].style.backgroundColor = "#FFFFFF"; + + + document.getElementsByName("certif_date")[0].disabled = false; + document.getElementsByName("certif_date")[0].style.backgroundColor = "#FFFFFF"; + } + + const [detailuser_date_inscription, setdetailuser_date_inscription] = useState(); const [detailuser_date_evaluation, setdetailuser_date_evaluation] = useState(); const [detailuser_date_certification, setdetailuser_date_certification] = useState(); @@ -785,7 +978,7 @@ const DisplayPartnerStagiaires = (props) => { } if (document.getElementById("detail_session")) { - document.getElementById("detail_session").style.backgroundColor = "#d8edfc"; + document.getElementById("detail_session").style.backgroundColor = "red"; document.getElementById("detail_session").style.color = "black"; } @@ -886,7 +1079,7 @@ const DisplayPartnerStagiaires = (props) => { formData.append("token", stored_cookie); formData.append("class_internal_url", selected_internal_url); formData.append("session_id", selected_code_session); - formData.append("email", selectedattendeeemail); + formData.append("email", selected_participant_email); console.log(" ### userimgclassprofilchanged =", userimgclassprofilchanged) @@ -962,7 +1155,7 @@ const DisplayPartnerStagiaires = (props) => { setisimgclassSelected_recid(""); setisimgclassSelectedfile(""); setuserimgclassprofil(""); - //getStagiaireImages(); + getStagiaireImages(); } else if (String(result['status']) === String("Err_Connexion")) { @@ -1079,68 +1272,39 @@ const DisplayPartnerStagiaires = (props) => { } + + const [Getall_TrainingSession_api, setGetall_TrainingSession_api] = useState(); const [Getall_TrainingSession_message, setGetall_TrainingSession_message] = useState(); const [Getall_TrainingSession_result, setGetall_TrainingSession_result] = useState(); function Getall_TrainingSession(event) { + var form = new FormData(); - /* var form = new FormData(); - - - // Recuperation des parametres - var filtre1 = p_filtre1; - var filtre2 = p_filtre2; - - - var filtre1_value = ""; - var filtre2_value = ""; - var filtre3_value = ""; - // Recuperation des valeurs de filtres - - if (p_filtre1_value) { - filtre1_value = p_filtre1_value; - form.append(filtre1, filtre1_value); - } - - if (p_filtre2_value) { - filtre2_value = p_filtre2_value; - form.append(filtre2, filtre2_value); - } - - - const stored_cookie = getCookie('tokenmysypart'); - form.append("token", stored_cookie); - - var myurl = process.env.REACT_APP_API_URL + "myclass/api/GetAllValideSessionPartner_List/"; - - - // Verification s'il faut faire une recherche avec une option like. - //console.log(" p_filtre1 = ", p_filtre1, " filtre1_value = ", filtre1_value); - - if (p_filtre1_value || p_filtre2_value) { - myurl = process.env.REACT_APP_API_URL + "myclass/api/GetAllValideSessionPartner_List_filter_like/"; - } - - - axios.post(myurl, form).then(res => { - - if (String(res.data.status) === String("true")) { - //console.log(" In Getall_TrainingSession res.data.status = " + res.data.status); - //console.log(" In Getall_TrainingSession res.data.message r_class = " + res.data.message); - setGetall_TrainingSession_api("true"); - setGetall_TrainingSession_result(res.data.message); - setRows(res.data.message); - } - else { - setGetall_TrainingSession_api("false"); - setGetall_TrainingSession_message(res.data.message); - } - - }).catch((error) => { - console.warn('Not good man :( Getall_TrainingSession = ', error); - setGetall_TrainingSession_api("false"); - //setmyApimyApiMessage("") - })*/ + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/GetAllValideSessionPartner_List/"; + + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_TrainingSession res.data.status = " + res.data.status); + //console.log(" In Getall_TrainingSession res.data.message r_class = " + res.data.message); + setGetall_TrainingSession_api("true"); + setGetall_TrainingSession_result(res.data.message); + + } + else { + setGetall_TrainingSession_api("false"); + setGetall_TrainingSession_message(res.data.message); + } + + }).catch((error) => { + console.warn('Not good man :( Getall_TrainingSession = ', error); + setGetall_TrainingSession_api("false"); + //setmyApimyApiMessage("") + }) } const [nb_stagiaire_Inscrit, setnb_stagiaire_Inscrit] = useState("0"); @@ -1155,6 +1319,7 @@ const DisplayPartnerStagiaires = (props) => { useEffect(() => { Getall_TrainingParticipant(); + Getall_TrainingSession(); let windowWidth = window.innerWidth; if (windowWidth < 1001) { @@ -1189,6 +1354,11 @@ const DisplayPartnerStagiaires = (props) => { const [p_detail_employeur, setp_detail_employeur] = useState(); const [p_date_evaluation, setp_date_evaluation] = useState(); const [p_note_eval, setp_note_eval] = useState(); + const [p_detail_session_class, setp_detail_session_class] = useState(); + const [p_detail_status_inscrit, setp_detail_status_inscrit] = useState(); + const [p_detail_status_inscrit_label, setp_detail_status_inscrit_label] = useState(); + const [p_detail_opco, setp_detail_opco] = useState(); + // Cette fonction remplit la zone detail de la personne inscrite @@ -1196,6 +1366,8 @@ const DisplayPartnerStagiaires = (props) => { const [GetAttendee_message, setGetAttendee_message] = useState(); const [GetAttendee_result, setGetAttendee_result] = useState(); function GetAttendee_Data(attendee_email, session_id, internal_url) { + setparticipant_data_changed(); + setparticipant_data_edit_mode(); clean_old_messages(); var form = new FormData(); @@ -1223,6 +1395,26 @@ const DisplayPartnerStagiaires = (props) => { } + document.getElementsByName("detail_session")[0].value = ""; + if (mylocalattendee.session_id) + setp_detail_session_class(mylocalattendee.session_id); + + document.getElementsByName("detail_status_inscript")[0].value = ""; + if (mylocalattendee.status) { + setp_detail_status_inscrit(mylocalattendee.status); + if (String(mylocalattendee.status) === "1") + setp_detail_status_inscrit_label("Inscrit"); + else if (String(mylocalattendee.status) === "0") + setp_detail_status_inscrit_label("Preinsc."); + else if (String(mylocalattendee.status) === "-1") + setp_detail_status_inscrit_label("Annulé"); + } + + document.getElementsByName("detail_opco")[0].value = ""; + if (mylocalattendee.opco) + setp_detail_opco(mylocalattendee.opco); + + document.getElementsByName("detail_nom")[0].value = ""; if (mylocalattendee.nom) @@ -1309,7 +1501,7 @@ const DisplayPartnerStagiaires = (props) => { setattendee_lms_pwd("xxxxxx"); } - desableAttendeeDetailFields(); + var myelement; if (document.getElementById('ajout_participant')) { @@ -1320,6 +1512,10 @@ const DisplayPartnerStagiaires = (props) => { myelement.scrollIntoView({ behavior: 'smooth' }); } + disableAttendeeDetailFields(); + + + } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); @@ -1348,11 +1544,13 @@ const DisplayPartnerStagiaires = (props) => { + const [is_lms_class_code, setis_lms_class_code] = useState(); const [display_detail_insc, setdisplay_detail_insc] = React.useState(); const [selectedattendeeemail, setselectedattendeeemail] = useState([]) + function Display_Detail_Inscription(event, cellValues) { clearDetailAttendeFields(); setdisplay_detail_insc("1") @@ -1362,6 +1560,8 @@ const DisplayPartnerStagiaires = (props) => { setselectedattendeeemail(email); var prenom = cellValues.row.prenom; GetAttendee_Data(email, selected_code_session); + + getStagiaireImages(selected_internal_url, selected_code_session, email,); } @@ -1414,6 +1614,180 @@ const DisplayPartnerStagiaires = (props) => { } + let [fields1desabled, setfields1desabled] = useState(true); + + const [One_Create_Participant_api, setOne_Create_Participant_api] = useState(); + const [One_Create_Participant_message, setOne_Create_Participant_message] = useState(); + const [One_Create_Participant_result, setOne_Create_Participant_result] = useState(); + function One_Create_Participant() { + /* clean_old_messages(); + var form = new FormData(); + var nb_participant = "0"; + var prix_session; + + + var one_nom_part = "" + if (document.getElementById("one_nom_part") && document.getElementById("one_nom_part").value != "") { + one_nom_part = document.getElementById("one_nom_part").value; + } + if (one_nom_part.trim() == "") { + alert(" Vous devez saisir le nom du participant"); + return; + } + + var one_prenom_part = "" + if (document.getElementById("one_prenom_part") && document.getElementById("one_prenom_part").value != "") { + one_prenom_part = document.getElementById("one_prenom_part").value; + } + if (one_prenom_part.trim() == "") { + alert(" Vous devez saisir le prenom du participant"); + return; + } + + var one_email_part = "" + if (document.getElementById("one_email_part") && document.getElementById("one_email_part").value != "") { + one_email_part = document.getElementById("one_email_part").value; + } + if (one_email_part.trim() == "") { + alert(" Vous devez saisir l'email du participant"); + return; + } + + + var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; + if (!one_email_part.match(validRegex)) { + alert("L'adresse email est invalide."); + return; + } + + + var one_phone_part = "" + if (document.getElementById("one_phone_part") && document.getElementById("one_phone_part").value != "") { + one_phone_part = document.getElementById("one_phone_part").value; + } + if (one_phone_part.trim() == "") { + alert(" Vous devez saisir le téléphone du participant"); + return; + } + + + var code_session = ""; + if (document.getElementById("code_session") && document.getElementById("code_session").value != "") + code_session = document.getElementById("code_session").value; + + if (code_session.trim() == "") { + alert(" La session est invalide"); + return; + } + + + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("class_internal_url", internal_url); + form.append("session_id", code_session); + form.append("nom", one_nom_part); + form.append("prenom", one_prenom_part); + form.append("email", one_email_part); + form.append("telephone", one_phone_part); + form.append("status", myinscript_status); + form.append("modefinancement", ""); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/AddStagiairetoClass/"; + + + + axios.post(myurl, form).then(res => { + //console.log(" In One_Create_Participant res.data.status = " + res.data.status); + //console.log(" In One_Create_Participant res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setOne_Create_Participant_api("true"); + setOne_Create_Participant_result(res.data.message); + alert(" Le participant a été correctement ajouté"); + setaddOneParticipant("0"); + setreduction_session("1"); + GetListePreinscrit(mysession); + GetListeInscrit(mysession); + GetListeEmargement(mysession); + GetListeEvaluation(mysession); + submenu_inscrit(); + + } else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + else { + setOne_Create_Participant_api("false"); + setOne_Create_Participant_message(res.data.message); + } + + }).catch((error) => { + + console.warn('One_Create_Participant : Not good man :( = ' + error); + setOne_Create_Participant_api("false"); + + })*/ + } + + const [UpdateStagiaireData_api, setUpdateStagiaireData_api] = useState(); + const [UpdateStagiaireData_message, setUpdateStagiaireData_message] = useState(); + const [UpdateStagiaireData_result, setUpdateStagiaireData_result] = useState(); + function Update_One_StagiaireData() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + if (p_detail_session_class.length <= 0) { + alert(" Vous devez choisir une session"); + return; + } + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("class_internal_url", selected_internal_url); + form.append("session_id", p_detail_session_class); + form.append("nom", p_detail_nom); + form.append("prenom", p_detail_prenom); + form.append("email", p_detail_mail); + form.append("employeur", p_detail_employeur); + form.append("status", p_detail_status_inscrit); + form.append("price", p_detail_cout); + form.append("modefinancement", p_detail_mode_fin); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/UpdateStagiairetoClass/"; + + axios.post(myurl, form).then(res => { + console.log(" In UpdateStagiaireData res.data.status = " + res.data.status); + console.log(" In UpdateStagiaireData res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setUpdateStagiaireData_api("true"); + setUpdateStagiaireData_result(res.data.message); + setparticipant_data_changed(); + Getall_TrainingParticipant(); + disableAttendeeDetailFields(); + setparticipant_data_changed(); + setparticipant_data_edit_mode(); + GetAttendee_Data(p_detail_mail, p_detail_session_class, selected_internal_url); + alert(" La mise à jour été correctement faite."); + } + else { + setUpdateStagiaireData_api("false"); + setUpdateStagiaireData_message(res.data.message); + alert(res.data.message); + } + + }).catch((error) => { + + console.warn('UpdateStagiaireData : Not good man :( mysearchtext = ' + error); + setUpdateStagiaireData_api("false"); + alert(" Impossible de mettre à jour le participant"); + + }) + } + + return (