diff --git a/src/components/GestionAdministrative.js b/src/components/GestionAdministrative.js index a2c59a7..4dde7e0 100644 --- a/src/components/GestionAdministrative.js +++ b/src/components/GestionAdministrative.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useRef} from "react"; +import React, { useState, useEffect, useRef } from "react"; import { useForm } from "react-hook-form"; import { getCookie, setCookie } from 'react-use-cookie'; import Box from '@mui/material/Box'; @@ -1316,6 +1316,24 @@ function GestionAdministrative(props) { }) } + + function DownloadAttendeeAttestation(event) { + + const stored_cookie = getCookie('tokenmysypart'); + + var nom_fiche_detaillee = "Attestation.pdf"; + + var url = process.env.REACT_APP_API_URL + "myclass/api/PrintAttendeeCertification/" + stored_cookie + "/" + mysession + "/" + selectedattendeeemail; + + + + axios.get(url, { responseType: 'blob', },) + .then((res) => { + fileDownload(res.data, nom_fiche_detaillee) + }) + } + + useEffect(() => { desableSessionFields(); setCreateListEmargement_api(); @@ -1628,7 +1646,7 @@ function GestionAdministrative(props) { if (res.data.status != "false") { //console.log(" In GetAttendee res.data.status = " + res.data.status); - //console.log(" In GetAttendee res.data.message r_class = " + res.data.message); + console.log(" In GetAttendee res.data.message r_class = " + res.data.message); setGetAttendee_api("true"); setGetAttendee_result(res.data.message); var mylocalattendee = JSON.parse(res.data.message); @@ -1701,15 +1719,25 @@ function GestionAdministrative(props) { setdetailuser_date_evaluation(date_eval); } + document.getElementsByName("date_evaluation")[0].value = ""; + if (mylocalattendee.certification_send_date) { + alert(" certification_send_date = ", mylocalattendee.certification_send_date); + + var date_eval = new Date(moment(mylocalattendee.certification_send_date, "DD/MM/YYYY")); + setdetailuser_date_certification(date_eval); + } + + + document.getElementsByName("note_eval")[0].value = ""; if (mylocalattendee.eval_note) { document.getElementsByName("note_eval")[0].value = mylocalattendee.eval_note; } - + if (mylocalattendee.eval_eval) { setfield_evaluation(mylocalattendee.eval_eval); - + } @@ -1818,8 +1846,79 @@ function GestionAdministrative(props) { const editorRef_evaluation = useRef(null); const [field_evaluation, setfield_evaluation] = useState(""); function editor_keyup() { - - } + + } + + + + const [SendEvaluationEmail_api, setSendEvaluationEmail_api] = useState(); + const [SendEvaluationEmail_message, setSendEvaluationEmail_message] = useState(); + const [SendEvaluationEmail_result, setSendEvaluationEmail_result] = useState(); + function SendEvaluationEmail() { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("session_id", mysession); + form.append("attendee_email", selectedattendeeemail); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/SendTrainingEvaluationEmail/"; + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) == "true") { + console.log(" In SendEvaluationEmail res.data.status = " + res.data.status); + console.log(" In SendEvaluationEmail res.data.message r_class = " + res.data.message); + setSendEvaluationEmail_api("true"); + setSendEvaluationEmail_result(res.data.message); + + } + else { + setSendEvaluationEmail_api("false"); + setSendEvaluationEmail_message(res.data.message); + } + + }).catch((error) => { + console.warn('Not good man :( SendEvaluationEmail = ', error); + setSendEvaluationEmail_api("false"); + + }) + } + + const [SendAttendeeAttestation_api, setSendAttendeeAttestation_api] = useState(); + const [SendAttendeeAttestation_message, setSendAttendeeAttestation_message] = useState(); + const [SendAttendeeAttestation_result, setSendAttendeeAttestation_result] = useState(); + function SendAttendeeAttestation() { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("session_id", mysession); + form.append("attendee_email", selectedattendeeemail); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/SendAttendeeCertification/"; + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) == "true") { + console.log(" In SendAttendeeAttestation res.data.status = " + res.data.status); + console.log(" In SendAttendeeAttestation res.data.message r_class = " + res.data.message); + setSendAttendeeAttestation_api("true"); + setSendAttendeeAttestation_result(res.data.message); + + } + else { + setSendAttendeeAttestation_api("false"); + setSendAttendeeAttestation_message(res.data.message); + } + + }).catch((error) => { + console.warn('Not good man :( SendAttendeeAttestation = ', error); + setSendAttendeeAttestation_api("false"); + + }) + + } return (