Ela_Front/src/components/Module_Selection_Evaluation...

1616 lines
66 KiB
JavaScript

import React, { useRef, useState, useEffect } from "react";
import TextField from '@mui/material/TextField';
import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css
import Button from '@mui/material/Button';
import axios from "axios";
import { getCookie, setCookie } from 'react-use-cookie';
import { useHistory } from "react-router-dom";
import { DataGrid, GridToolbar, frFR } from '@mui/x-data-grid';
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
import { FcViewDetails, } from "react-icons/fc";
import 'react-tooltip/dist/react-tooltip.css'
import Popup from 'reactjs-popup';
import 'reactjs-popup/dist/index.css';
import "react-datepicker/dist/react-datepicker.css";
import 'moment/locale/fr';
import Box from '@mui/material/Box';
import { CiTrash } from "react-icons/ci";
import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif";
import Autocomplete from '@mui/material/Autocomplete';
import { gridClasses } from '@mui/x-data-grid';
import Link from '@mui/material/Link';
import { PiDotsThree } from "react-icons/pi";
import { FcCancel, FcApproval, FcAcceptDatabase, FcPrint, FcPlanner } from "react-icons/fc";
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
import CheckBoxIcon from '@mui/icons-material/CheckBox';
import Checkbox from '@mui/material/Checkbox';
import Module_Alert_Confirmation from "./Module_Alert_Confirmation";
const Module_Selection_Evaluation_Apprenants = (props) => {
const history = useHistory();
const [submenu, setsubmenu] = useState("");
const [rowss, setRows] = useState([]);
var date_today_90j = new Date();
date_today_90j.setDate(date_today_90j.getDate() + 90);
const [p_filtre1, setp_filtre1] = useState("Inscrit ");
const [p_filtre1_value, setp_filtre1_value] = useState("");
const [p_filtre2, setp_filtre2] = useState("Type de groupe");
const [p_filtre2_value, setp_filtre2_value] = useState("");
const [p_filtre3, setp_filtre3] = useState("");
const [p_filtre3_value, setp_filtre3_value] = useState("");
const [p_filtre4, setp_filtre4] = useState("");
const [p_filtre4_value, setp_filtre4_value] = useState("");
function ExpandableCell_50({ value }) {
const [expanded, setExpanded] = React.useState(false);
return (
<nav>
{value && <div style={{ paddingLeft: "5px", paddingRight: "15px", "display": "block", wordBreak: "break-all" }}>
{expanded ? value : String(value).slice(0, 50)}&nbsp;
{value.length > 50 && (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
<Link
type="button"
component="button"
sx={{ fontSize: 'inherit' }}
onClick={() => setExpanded(!expanded)}
>
{expanded ? <nav> <PiDotsThree />Réduire</nav> : <nav> <PiDotsThree />Voir</nav>}
</Link>
)}
</div>}
{!value && <div style={{ paddingLeft: "5px", paddingRight: "15px", "display": "block", wordBreak: "break-all" }}>
&nbsp;
</div>
}
</nav>
);
}
const columns_participants = [
{ field: '_id', headerName: '_id', hide: true, Width: 0 },
{ field: 'id', headerName: 'id', hide: true, Width: 0 },
{ field: 'email', headerName: 'email', flex: 1, hide: false, minWidth: 180, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'nom', headerName: 'nom', flex: 1, hide: false, minWidth: 180, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'prenom', headerName: 'prenom', flex: 1, hide: false, minWidth: 180, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{ field: 'groupe', headerName: 'groupe', flex: 1, hide: false, minWidth: 180, renderCell: (params) => <ExpandableCell_50 {...params} />, },
{
field: "Detail", headerName: 'Voir detail',
renderCell: (cellValues) => {
return (
<Button
onClick={(event) => {
//handleClick_edit_evaluation_From_Line(cellValues.row.id);
}}
>
<FcViewDetails />
</Button>
);
}
},
{
field: "delete", headerName: 'Supprimer',
renderCell: (cellValues) => {
return (
<Popup
trigger={<Button
onClick={(event) => {
// handleClick_delete(event, cellValues);
}}
>
<CiTrash />
</Button>}
modal
nested
position="center center"
>
{close => (
<div>
<button className="gest_close" onClick={close}>
&times;
</button>
<div className="gest_header"> MySy Information </div>
<div className="gest_content">
{' '}
En confirmant cette opération, l'employé sera <i><font color="red"> définitivement supprimé</font></i>. <br />
</div>
<div className="gest_actions">
<div style={{ "width": "45%", "float": "left" }}>
<button className="gest_bton_popup" onClick={(event) => {
//handleClick_delete(event, cellValues);
//console.log('modal closed ');
close();
}}> Valider </button>
</div>
<div style={{ "width": "45%", "float": "right" }}>
<button
className="gest_bton_popup"
onClick={() => {
//console.log('modal closed ');
close();
}}
>
Annuler
</button>
</div>
</div>
</div>
)}
</Popup>
);
}
}
]
const [selectionModel_participants, setselectionModel_participants] = React.useState([]);
const [selected_id, setselected_id] = React.useState("");
function Display_Colunm_text({ value }) {
return (
<div style={{ paddingLeft: "5px", paddingRight: "10px", "display": "block", wordBreak: "break-all" }}>
{value}&nbsp;
</div>
);
}
const [isLoading, setLoading] = useState();
const New_Option_Filter = [
{ "id": "user", "label": "Lié a la Formation (code externe) ", "value": "class_external_code" },
{ "id": "user_group", "label": "Lié a la Classe (code Classe) ", "value": "code_session" },
{ "id": "ty", "label": "Lié a l'UE (code UE) ", "value": "code_ue" },
{ "id": "", "label": "", "value": "" },
{ "id": "1", "label": "", "value": "1" }, // Cette ligne pour couvrir l'ajout d'une ligne de filter. C'est fait expres.
]
const New_Option_type_user = [
{ "id": "user", "label": "Personnes Inscrites", "value": "user" },
{ "id": "user_group", "label": "Groupe ", "value": "user_group" },
{ "id": "", "label": "", "value": "" },
]
const New_Option_type_goupe = [
{ "id": "td", "label": "Groupe TD", "value": "td" },
{ "id": "tp", "label": "Groupe TP", "value": "tp" },
{ "id": "", "label": "", "value": "" },
]
const [New_Getall_Groupe_Membres_result, setNew_Getall_Groupe_Membres_result] = useState([]);
const [Getall_Groupe_Membres_api, setGetall_Groupe_Membres_api] = useState();
const [Getall_Groupe_Membres_message, setGetall_Groupe_Membres_message] = useState();
const [Getall_Groupe_Membres_result, setGetall_Groupe_Membres_result] = useState([]);
function Getall_Groupe_Membres(local_groupe_id) {
var evalutaion_id = "";
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("_id", local_groupe_id);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Groupe_Membres/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
//console.log(" In Getall_Groupe_Membres res.data.status = " + res.data.status);
//console.log(" In Getall_Groupe_Membres res.data.message r_class = " + res.data.message);
setGetall_Groupe_Membres_api("true");
setGetall_Groupe_Membres_result(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
// /!\ : ici on met l'inscription dans le '_id' exceptionnellement.
// Ca permet de rester cohérent avec la recherche venant de la collection 'inscription', pas de recherche depuis un groupe de TD ou TP...
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x).inscription_id;
var local_nom = JSON.parse(x).nom;
var local_prenom = JSON.parse(x).prenom;
var local_email = JSON.parse(x).email;
var local_inscription_id = JSON.parse(x).inscription_id;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_nom,
"nom": local_nom,
"prenom": local_prenom,
"email": local_email,
"groupe": "",
"inscription_id": local_inscription_id,
};
new_data2.push(node);
});
if (new_data2) {
setNew_Getall_Groupe_Membres_result(new_data2);
setNew_GetListePreinscrit_insc_result(new_data2);
}
}
else {
setGetall_Groupe_Membres_api("false");
setGetall_Groupe_Membres_message(res.data.message);
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
console.warn('Not good man :( Getall_Groupe_Membres = ', error);
setGetall_Groupe_Membres_api("false");
alert(" Impossible de recuperer la liste des membres du groupe");
//setmyApimyApiMessage("")
})
}
const [New_GetListePreinscrit_insc_result, setNew_GetListePreinscrit_insc_result] = useState([]);
const [GetListePreinscrit_insc_api, setGetListePreinscrit_insc_api] = useState();
const [GetListePreinscrit_insc_meassage, setGetListePreinscrit_insc_meassage] = useState();
const [GetListePreinscrit_insc_result, setGetListePreinscrit_insc_result] = useState([])
function GetListeInscrit() {
var form = new FormData();
//form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("session_id", props.session_id);
setLoading(true);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Accepted_Insription_From_Session_id_Reduice_Fields/";
fetch(myurl,
{
method: 'POST',
body: form,
})
.then((data) => data.json())
.then((data) => {
setLoading(false);
//console.log(' GetListeInscrit : Success:', data['message'], "data['status'] = ", data['status']);
setGetListePreinscrit_insc_result(data['message']);
if (String(data['status']) === String("true")) {
//console.log("erreur rrrr:" + data['status'])
setGetListePreinscrit_insc_api("true");
var new_data2 = [];
const new_data = data['message'].map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_nom = JSON.parse(x).apprenant_nom;
var local_prenom = JSON.parse(x).apprenant_prenom;
var local_email = JSON.parse(x).apprenant_email;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_nom + " " + local_prenom,
"nom": local_nom,
"prenom": local_prenom,
"email": local_email,
"groupe": "",
};
new_data2.push(node);
});
if (new_data2) {
setNew_GetListePreinscrit_insc_result(new_data2);
}
} else if (String(data['status']) === String("Err_Connexion")) {
alert('Erreur: ' + data['message']);
history.push("/Connexion");
}
else {
setGetListePreinscrit_insc_api("false");
}
}).catch((error) => {
setLoading(false);
console.error('Error:', error);
setGetListePreinscrit_insc_api("false");
});
}
const myRef_head = useRef(null);
function get_attendee_list_data() {
if (String(p_filtre1_value) === "user") {
GetListeInscrit();
}
if (String(p_filtre1_value) === "user_group") {
Getall_Groupe_Membres(p_filtre2_value);
}
}
const [gridline_id, setgridline_id] = useState("");
const New_Option_PreInscription = [
{ "id": "inscr", "label": "Inscrire", "value": "inscr" },
]
const [actionmass_preinsc_val, setactionmass_preinsc_val] = useState();
function GetSelectedRows_PreInsc_Ids() {
var tab_tmp = []
for (var i = 0; i < selectionModel_participants.length; i++) {
//console.log(" ### selectionModel_insc[i] = ", selectionModel_insc[i]);
var myid = parseInt(String(selectionModel_participants[i]));
//var line = JSON.parse(rowss[myid]);
tab_tmp.push(myid);
}
return tab_tmp;
}
async function actionmass_preinsc_Traitemet() {
var liste_preinscr_id = GetSelectedRows_PreInsc_Ids();
var tab_mongo_preins_ids = [];
for (var i = 0; i < liste_preinscr_id.length; i++) {
var line = New_GetListePreinscrit_insc_result[liste_preinscr_id[i]]
var line_json = line;
console.log(" line_json = ", line_json);
//console.log(" line_json['_id'] = ", line_json['_id']);
tab_mongo_preins_ids.push(line_json._id)
}
if (String(actionmass_preinsc_val) === String("inscr")) {
Record_Inscrit_To_Evaluation(tab_mongo_preins_ids);
}
}
const [Record_Inscrit_To_Evaluation_api, setRecord_Inscrit_To_Evaluation_api] = useState();
const [Record_Inscrit_To_Evaluation_message, setRecord_Inscrit_To_Evaluation_message] = useState();
const [Record_Inscrit_To_Evaluation_result, setRecord_Inscrit_To_Evaluation_result] = useState();
function Record_Inscrit_To_Evaluation(list_inscription_id) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("evaluation_id", props.evaluation_selected_id);
form.append("tab_inscription_id", list_inscription_id);
form.append("tab_group_inscription_id", "");
setLoading(true);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Record_Participant_To_Evaluation/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
setLoading(false);
//console.log(" In UpdateStagiaireData res.data.status = " + res.data.status);
//console.log(" In UpdateStagiaireData res.data.message r_class = " + res.data.message);
setRecord_Inscrit_To_Evaluation_api("true");
setRecord_Inscrit_To_Evaluation_result(res.data.message);
setselectionModel_participants([]);
setactionmass_preinsc_val("");
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("success");
} else if (String(res.data.status) === String("Err_Connexion")) {
setLoading(false);
alert('Erreur: ' + res.data.message);
history.push("/Connexion");
}
else {
setLoading(false);
setRecord_Inscrit_To_Evaluation_api("false");
setRecord_Inscrit_To_Evaluation_message(res.data.message);
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
setLoading(false);
console.warn('Record_Inscrit_To_Evaluation : Not good man :( mysearchtext = ' + error);
setRecord_Inscrit_To_Evaluation_api("false");
alert(" Impossible de faire les inscriptions ");
})
}
const [New_Get_List_UE_From_Class_Id_result, setNew_Get_List_UE_From_Class_Id_result] = useState([]);
const [Get_List_UE_From_Class_Id_api, setGet_List_UE_From_Class_Id_api] = useState();
const [Get_List_UE_From_Class_Id_message, setGet_List_UE_From_Class_Id_message] = useState();
const [Get_List_UE_From_Class_Id_result, setGet_List_UE_From_Class_Id_result] = useState();
function Get_List_UE_From_Class_Id(local_class_id) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("class_id", local_class_id);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Unite_Enseignement_Of_Given_Class/";
setLoading(true);
axios.post(myurl, form).then(res => {
setLoading(false);
if (String(res.data.status) === String("true")) {
//console.log(" In Get_List_UE_From_Class_Id res.data.status = " + res.data.status);
//console.log(" In Get_List_UE_From_Class_Id res.data.message r_class = " + res.data.message);
setGet_List_UE_From_Class_Id_api("true");
setGet_List_UE_From_Class_Id_result(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_code = JSON.parse(x).code;
var local_titre = JSON.parse(x).titre;
var local_class_id = JSON.parse(x).class_id;
var local_internal_url = JSON.parse(x).internal_url;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_code,
"code": local_code,
"titre": local_titre,
"class_id": local_class_id,
"internal_url": local_internal_url,
};
new_data2.push(node);
});
//---
/* var node = {
"_id": "",
"id": "",
"label": "",
"code": "",
"titre": "",
"class_id": "",
"internal_url": "",
};
new_data2.push(node);*/
if (new_data2.length > 0) {
setNew_Get_List_UE_From_Class_Id_result(new_data2);
// console.log("### setNew_Get_List_UE_From_Class_Id_result = ", new_data2);
}
}
else {
setGet_List_UE_From_Class_Id_api("false");
setGet_List_UE_From_Class_Id_message(res.data.message);
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
setLoading(false);
console.warn('Not good man :( Get_List_UE_From_Class_Id = ', error);
setGet_List_UE_From_Class_Id_api("false");
alert(" Impossible de recuperer la liste des UE de la formation");
//setmyApimyApiMessage("")
})
}
const [New_Getall_Class_List_Evalution_result, setNew_Getall_Class_List_Evalution_result] = useState([]);
const [Getall_Class_List_Evalution_api, setGetall_Class_List_Evalution_api] = useState();
const [Getall_Class_List_Evalution_message, setGetall_Class_List_Evalution_message] = useState();
const [Getall_Class_List_Evalution_result, setGetall_Class_List_Evalution_result] = useState([]);
function Getall_Class_List_Evalution(local_class_id) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("class_id", local_class_id);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Class_Evaluation/";
setLoading(true);
axios.post(myurl, form).then(res => {
setLoading(false);
if (String(res.data.status) === String("true")) {
//console.log(" In Getall_Class_List_Evalution res.data.status = " + res.data.status);
//console.log(" In Getall_Class_List_Evalution res.data.message r_class = " + res.data.message);
setGetall_Class_List_Evalution_api("true");
setGetall_Class_List_Evalution_result(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_class_id = JSON.parse(x).class_id;
var local_class_ue_id = JSON.parse(x).class_ue_id;
var local_class_ue_code = JSON.parse(x).class_ue_code;
var local_type_evaluation_id = JSON.parse(x).type_evaluation_id;
var local_type_evaluation_code = JSON.parse(x).type_evaluation_code;
var local_max_note = JSON.parse(x).max_note;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_type_evaluation_code + "-" + local_class_ue_code,
"class_id": local_class_id,
"class_ue_id": local_class_ue_id,
"class_ue_code": local_class_ue_code,
"type_evaluation_id": local_type_evaluation_id,
"type_evaluation_code": local_type_evaluation_code,
"max_note": local_max_note,
};
new_data2.push(node);
});
//---
/* var node = {
"_id": "",
"id": "",
"label": "",
"class_id": "",
"class_ue_id": "",
"class_ue_code": "",
"type_evaluation_id": "",
"type_evaluation_code": "",
"max_note": "",
};
new_data2.push(node);*/
if (new_data2.length > 0) {
setNew_Getall_Class_List_Evalution_result(new_data2);
//console.log(" setNew_Getall_Class_List_Evalution_result = ", new_data2);
}
}
else {
setGetall_Class_List_Evalution_api("false");
setGetall_Class_List_Evalution_message(res.data.message);
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
setLoading(false);
console.warn('Not good man :( Getall_Class_List_Evalution = ', error);
setGetall_Class_List_Evalution_api("false");
alert(" Impossible de recuperer la liste des évaluations de la formatio");
//setmyApimyApiMessage("")
})
}
const [New_Get_Inscrit_List_UE_result, setNew_Get_Inscrit_List_UE_result] = useState([]);
const [tab_inscrit_ue_id, settab_inscrit_ue_id] = useState([]);
const [Get_Inscrit_List_UE_api, setGet_Inscrit_List_UE_api] = useState();
const [Get_Inscrit_List_UE_message, setGet_Inscrit_List_UE_message] = useState();
const [Get_Inscrit_List_UE_result, setGet_Inscrit_List_UE_result] = useState();
function Get_Inscrit_List_UE(local_inscription_id) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("inscription_id", local_inscription_id);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Inscrit_List_EU/";
setLoading(true);
axios.post(myurl, form).then(res => {
setLoading(false);
if (String(res.data.status) === String("true")) {
//console.log(" In Get_Inscrit_List_UE res.data.status = " + res.data.status);
// console.log(" In Get_Inscrit_List_UE res.data.message r_class = " + res.data.message);
setGet_Inscrit_List_UE_api("true");
setGet_Inscrit_List_UE_result(res.data.message);
var new_data2 = [];
var tab_tmp = []
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_class_id = JSON.parse(x).class_id;
var local_class_eu_id = JSON.parse(x).class_eu_id;
var local_ue_code = JSON.parse(x).code;
var local_ue_titre = JSON.parse(x).titre;
tab_tmp.push(local_class_eu_id);
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_ue_code,
"class_id": local_class_id,
"class_eu_id": local_class_eu_id,
"ue_code": local_ue_code,
"ue_titre": local_ue_titre,
};
new_data2.push(node);
// return {"_id": " + str(local_id) + ", "label": " + local_courrier_template_ref_interne + '" , "courrier_template_ref_interne": "' + local_courrier_template_ref_interne + '", "nom_champ_technique": "' + local_nom_champ_technique + '", "nom_champ_fonctionel": "' + local_nom_champ_fonctionel + '","valide": "1" };
});
//---
var node = {
"_id": "",
"id": "",
"label": "",
"class_id": "",
"class_eu_id": "",
"ue_code": "",
"ue_titre": "",
};
new_data2.push(node);
if (new_data2.length > 0) {
setNew_Get_Inscrit_List_UE_result(new_data2);
settab_inscrit_ue_id(tab_tmp);
if (New_Getall_Class_List_Evalution_result && New_Getall_Class_List_Evalution_result.length > 0) {
var local_defaultValue = New_Getall_Class_List_Evalution_result.filter((data) => {
if (tab_inscrit_evaluation_ue_id.includes(String(data.type_evaluation_id))) {
return data;
}
});
setinscription_list_ue_eval(local_defaultValue);
}
}
}
else {
setGet_Inscrit_List_UE_api("false");
setGet_Inscrit_List_UE_message(res.data.message);
}
}).catch((error) => {
setLoading(false);
console.warn('Not good man :( Get_Inscrit_List_UE = ', error);
setGet_Inscrit_List_UE_api("false");
//setmyApimyApiMessage("")
})
}
const [tab_inscrit_evaluation_ue_id, settab_inscrit_evaluation_ue_id] = useState([]);
const [inscription_list_ue, setinscription_list_ue] = useState([]);
const [inscription_list_ue_eval, setinscription_list_ue_eval] = useState([]);
const [New_Getall_Partner_Session_Reduice_Fields_result, setNew_Getall_Partner_Session_Reduice_Fields_result] = useState([]);
const [Getall_Partner_Session_Reduice_Fields_api, setGetall_Partner_Session_Reduice_Fields_api] = useState();
const [Getall_Partner_Session_Reduice_Fields_message, setGetall_Partner_Session_Reduice_Fields_message] = useState();
const [Getall_Partner_Session_Reduice_Fields_result, setGetall_Partner_Session_Reduice_Fields_result] = useState();
function Getall_Partner_Session_Reduice_Fields(event) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Partner_Session_Ftion_Reduice_Fields/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
//console.log(" In Getall_Partner_Session_Reduice_Fields res.data.status = " + res.data.status);
//console.log(" In Getall_Partner_Session_Reduice_Fields res.data.message r_class = " + res.data.message);
setGetall_Partner_Session_Reduice_Fields_api("true");
setGetall_Partner_Session_Reduice_Fields_result(res.data.message);
setRows(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_code_session = JSON.parse(x).code_session;
var local_titre = JSON.parse(x).titre;
var local_class_internal_url = JSON.parse(x).class_internal_url;
var local_date_debut = JSON.parse(x).date_debut;
var local_date_fin = JSON.parse(x).date_fin;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_code_session,
"code_session": local_code_session,
"titre": local_titre,
"class_internal_url": local_class_internal_url,
"date_debut": local_date_debut,
"date_fin": local_date_fin,
};
new_data2.push(node);
});
//---
var node = {
"_id": "",
"id": "",
"label": "",
"code_session": "",
"titre": "",
"class_internal_url": "",
"date_debut": "",
"date_fin": "",
};
new_data2.push(node);
if (new_data2.length > 0)
setNew_Getall_Partner_Session_Reduice_Fields_result(new_data2);
}
else {
setGetall_Partner_Session_Reduice_Fields_api("false");
setGetall_Partner_Session_Reduice_Fields_message(res.data.message);
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
console.warn('Not good man :( Getall_Partner_Session_Reduice_Fields = ', error);
setGetall_Partner_Session_Reduice_Fields_api("false");
alert(" Impossible de recuperer la liste des sessions de formation (classe)");
//setmyApimyApiMessage("")
})
}
const [New_Getall_Partner_Class_Reduice_Fields_result, setNew_Getall_Partner_Class_Reduice_Fields_result] = useState([]);
const [Getall_Partner_Class_Reduice_Fields_api, setGetall_Partner_Class_Reduice_Fields_api] = useState();
const [Getall_Partner_Class_Reduice_Fields_message, setGetall_Partner_Class_Reduice_Fields_message] = useState();
const [Getall_Partner_Class_Reduice_Fields_result, setGetall_Partner_Class_Reduice_Fields_result] = useState();
function Getall_Partner_Class_Reduice_Fields(event) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Partner_All_Class_Few_Fields/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
//console.log(" In Getall_Partner_Class_Reduice_Fields res.data.status = " + res.data.status);
//console.log(" In Getall_Partner_Class_Reduice_Fields res.data.message r_class = " + res.data.message);
setGetall_Partner_Class_Reduice_Fields_api("true");
setGetall_Partner_Class_Reduice_Fields_result(res.data.message);
setRows(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_external_code = JSON.parse(x).external_code;
var local_internal_code = JSON.parse(x).internal_code;
var local_internal_url = JSON.parse(x).internal_url;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_external_code,
"external_code": local_external_code,
"internal_code": local_internal_code,
"internal_url": local_internal_url
};
new_data2.push(node);
});
//---
var node = {
"_id": "",
"id": "",
"label": "",
"external_code": "",
"internal_code": "",
"internal_url": ""
};
new_data2.push(node);
if (new_data2.length > 0)
setNew_Getall_Partner_Class_Reduice_Fields_result(new_data2);
}
else {
setGetall_Partner_Class_Reduice_Fields_api("false");
setGetall_Partner_Class_Reduice_Fields_message(res.data.message);
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
console.warn('Not good man :( Getall_Partner_Class_Reduice_Fields = ', error);
setGetall_Partner_Class_Reduice_Fields_api("false");
alert(" Impossible de recuperer la liste des formations");
//setmyApimyApiMessage("")
})
}
const [New_Getall_Partner_Groupe_Inscrit_result, setNew_Getall_Partner_Groupe_Inscrit_result] = useState([]);
const [Getall_Partner_Groupe_Inscrit_api, setGetall_Partner_Groupe_Inscrit_api] = useState();
const [Getall_Partner_Groupe_Inscrit_message, setGetall_Partner_Groupe_Inscrit_message] = useState();
const [Getall_Partner_Groupe_Inscrit_result, setGetall_Partner_Groupe_Inscrit_result] = useState([]);
function Getall_Partner_Groupe_Inscrit(event) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("session_id", props.session_id);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Groupe_Inscrit_With_Filter/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
//console.log(" In Getall_Partner_Groupe_Inscrit res.data.status = " + res.data.status);
//console.log(" In Getall_Partner_Groupe_Inscrit res.data.message r_class = " + res.data.message);
setGetall_Partner_Groupe_Inscrit_api("true");
setGetall_Partner_Groupe_Inscrit_result(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_code = JSON.parse(x).code;
var local_nom = JSON.parse(x).nom;
var local_type_groupe_code = JSON.parse(x).type_groupe_code;
var local_class_id = JSON.parse(x).class_id;
var local_session_id = JSON.parse(x).session_id;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_code,
"code": local_code,
"nom": local_nom,
"type_groupe_code": local_type_groupe_code,
"class_id": local_class_id,
"session_id": local_session_id,
};
new_data2.push(node);
});
//---
var node = {
"_id": "",
"id": "",
"label": "",
"code": "",
"nom": "",
"type_groupe_code": "",
"class_id": "",
"session_id": "",
};
new_data2.push(node);
if (new_data2.length > 0)
setNew_Getall_Partner_Groupe_Inscrit_result(new_data2);
}
else {
setGetall_Partner_Groupe_Inscrit_api("false");
setGetall_Partner_Groupe_Inscrit_message(res.data.message);
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
console.warn('Not good man :( Getall_Partner_Groupe_Inscrit = ', error);
setGetall_Partner_Groupe_Inscrit_api("false");
alert(" Impossible de recuperer la liste des groupes d'inscrits");
//setmyApimyApiMessage("")
})
}
useEffect(() => {
Get_List_UE_From_Class_Id(props.class_id);
Getall_Class_List_Evalution(props.class_id);
Getall_Partner_Class_Reduice_Fields();
Getall_Partner_Session_Reduice_Fields();
Getall_Groupe_Apprenant_Type();
Getall_Partner_Groupe_Inscrit();
}, []);
const [New_Getall_Groupe_Apprenant_Type_result, setNew_Getall_Groupe_Apprenant_Type_result] = useState([]);
const [Getall_Groupe_Apprenant_Type_api, setGetall_Groupe_Apprenant_Type_api] = useState();
const [Getall_Groupe_Apprenant_Type_message, setGetall_Groupe_Apprenant_Type_message] = useState();
const [Getall_Groupe_Apprenant_Type_result, setGetall_Groupe_Apprenant_Type_result] = useState();
function Getall_Groupe_Apprenant_Type(event) {
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Type_Groupe_Apprenant/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
//console.log(" In Getall_Groupe_Apprenant_Type res.data.status = " + res.data.status);
//console.log(" In Getall_Groupe_Apprenant_Type res.data.message r_class = " + res.data.message);
setGetall_Groupe_Apprenant_Type_api("true");
setGetall_Groupe_Apprenant_Type_result(res.data.message);
setRows(res.data.message);
var new_data2 = [];
const new_data = res.data.message.map((x) => {
//---
var localid = JSON.parse(x).id;
var local_id = JSON.parse(x)._id;
var local_code = JSON.parse(x).code;
var local_description = JSON.parse(x).description;
//---
var node = {
"_id": local_id,
"id": localid,
"label": local_code + " - " + local_description,
"code": local_code,
"description": local_description,
};
new_data2.push(node);
});
//---
var node = {
"_id": "",
"id": "",
"label": "",
"code": "",
"description": "",
};
new_data2.push(node);
if (new_data2.length > 0)
setNew_Getall_Groupe_Apprenant_Type_result(new_data2);
}
else {
setGetall_Groupe_Apprenant_Type_api("false");
setGetall_Groupe_Apprenant_Type_message(res.data.message);
// alert(res.data.message)
setdisplay_alert_mysy("1");
setalert_message(res.data.message);
setalert_type("error");
}
}).catch((error) => {
console.warn('Not good man :( Getall_Groupe_Apprenant_Type = ', error);
setGetall_Groupe_Apprenant_Type_api("false");
alert(" Impossible de recuperer la liste des type de groupe d'apprenants");
//setmyApimyApiMessage("")
})
}
const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
const checkedIcon = <CheckBoxIcon fontSize="small" />;
const [ueChanged, setueChanged] = useState("");
const [display_alert_mysy, setdisplay_alert_mysy] = useState("");
const [alert_message, setalert_message] = useState("");
const [alert_type, setalert_type] = useState("");
function clear_alert_message() {
setalert_message("");
}
function clear_alert_type() {
setalert_type("");
}
function clear_display_alert_mysy() {
setdisplay_alert_mysy("");
}
return (
<div className="moduleselectionevaluationapprenants">
{isLoading && <div className="loader-container">
<div className="mysy_spinner"> <img src={img_loading_spin} /> </div>
</div>}
{/*** Affichage des messages d'alerte*/}
{display_alert_mysy && String(display_alert_mysy) === "1" &&
<Module_Alert_Confirmation alert_message={alert_message}
alert_type={alert_type}
clear_alert_message={clear_alert_message}
clear_alert_type={clear_alert_type}
clear_display_alert_mysy={clear_display_alert_mysy}
/>
}
{/*** FIN Affichage des messages d'alerte*/}
<nav style={{ "border": "None", "fontSize": "20px", "paddingTop": "10px", "paddingLeft": "5px" }}> Selection des Apprenants & Groupe d'apprenants </nav>
<div className="div_row">
<div className="titre1"> Utilisez les filtres !</div>
<div className="div_row" style={{ "marginBottom": "5px" }}>
<div className="div_row_gauche texte_area_filter" >
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="filtre1"
id="filtre1"
InputLabelProps={{
shrink: true,
}}
disabled={false}
className="disabled_style"
value={p_filtre1}
/>
</div>
<div className="div_row_droite texte_area_filter_value" >
{p_filtre1 && New_Option_type_user && New_Option_type_user.length > 0 &&
<Autocomplete
disablePortal
name="filtre1_value"
id="filtre1_value"
className="disabled_style"
value={New_Option_type_user.filter((data) => (data).value === String(p_filtre1_value))[0].label}
options={New_Option_type_user}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre1_value(value.value);
} else {
setp_filtre1_value("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>
}
</div>
</div>
{p_filtre1_value && String(p_filtre1_value) === "user_group" &&
<div className="div_row" style={{ "marginBottom": "5px" }}>
<div className="div_row_gauche texte_area_filter">
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="filtre2"
id="filtre2"
InputLabelProps={{
shrink: true,
}}
disabled={false}
className="disabled_style"
value={p_filtre2}
/>
</div>
<div className="div_row_droite texte_area_filter_value" style={{ "marginTop": "0.5rem" }}>
{p_filtre1_value && String(p_filtre1_value) === "user_group" &&
New_Getall_Partner_Groupe_Inscrit_result && New_Getall_Partner_Groupe_Inscrit_result.length > 0 &&
<Autocomplete
disablePortal
name="filtre2_value"
id="filtre2_value"
className="disabled_style"
value={New_Getall_Partner_Groupe_Inscrit_result.filter((data) => (data)._id === String(p_filtre2_value))[0].label}
options={New_Getall_Partner_Groupe_Inscrit_result}
onChange={(event, value) => {
if (value && value._id) {
setp_filtre2_value(value._id);
} else {
setp_filtre2_value("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>
}
</div>
</div>
}
{/*
<div className="div_row">
<div className="session_caract"> <b>Unite D'enseignement </b> <br />
{New_Get_List_UE_From_Class_Id_result && New_Get_List_UE_From_Class_Id_result.length > 0 &&
<Autocomplete
multiple
name="detail_ue"
id="detail_ue"
//className="disabled_style"
disablePortal
disableCloseOnSelect
getOptionLabel={(option) => option.label}
options={New_Get_List_UE_From_Class_Id_result}
defaultValue={New_Get_List_UE_From_Class_Id_result.filter((data) => {
if (tab_inscrit_ue_id.includes(String(data._id))) {
return data;
}
})}
renderOption={(props, option, { selected }) => (
<li {...props}>
<Checkbox
icon={icon}
checkedIcon={checkedIcon}
style={{ marginRight: 8 }}
checked={selected}
/>
{option.label}
</li>
)}
// style={{ width: 500 }}
onChange={(event, value) => {
setinscription_list_ue(value)
setueChanged("1");
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une UE "
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>
}
</div>
</div>
*/}
<div className="div_row" ref={myRef_head} id="myRef_head" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>
<div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>
<Button variant="contained" className="bton_enreg" onClick={get_attendee_list_data}>Rechercher
</Button>
</div>
<div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }}>
<Button variant="contained" className="bton_annule" onClick={"clean_all_filters"}>Annuler
</Button>
</div>
</div>
<br />
</div>
<div style={{ height: 550, width: '100%', paddingRight: '5px' }}>
<div className="div_row" style={{ paddingRight: '10px' }}>
<div className="session_data">
<div style={{ "border": "None" }}>
<div style={{ height: 550, width: '100%', paddingRight: '5px' }}>
&nbsp;
<Box
sx={{
height: 500,
width: '100%',
paddingRight: '1px',
/*"& .MuiDataGrid-virtualScrollerRenderZone": {
"& .MuiDataGrid-row": {
"&:nth-child(2n)": { backgroundColor: "rgba(235, 235, 235, .7)" }
}
},*/
"& .MuiDataGrid-columnHeaders": {
backgroundColor: "#c8cfd5",
color: "black",
fontSize: 14
},
'& .line--statut--selected': {
backgroundColor: '#FBF2EF',
color: 'black',
},
'& .line--statut--pair': {
backgroundColor: 'rgba(235, 235, 235, .7)',
color: 'black',
},
'& .line--statut--impair': {
backgroundColor: '#FFFFFF',
color: 'black',
},
[`& .${gridClasses.cell}`]: {
py: 1,
},
}}
>
<DataGrid
checkboxSelection
onSelectionModelChange={(newSelectionModel) => {
setselectionModel_participants(newSelectionModel);
/*if (newSelectionModel.length === 1)
handleClick_edit_employee_From_Line(newSelectionModel);*/
if (newSelectionModel.length !== 1) {
/* setsubmenu();
setdisplay_detail_employe();
setadd_One_Employee();*/
}
}}
selectionModel={selectionModel_participants}
localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
rows={New_GetListePreinscrit_insc_result.map((item, index) => (
{
id: index,
_id: (item)._id,
code: (item).code,
email: (item).email,
nom: (item).nom,
prenom: (item).prenom,
groupe: (item).groupe,
}
))}
columns={columns_participants}
pageSize={10}
className="datagridclass"
onRowDoubleClick={(newSelectionModel) => {
setselected_id(newSelectionModel.row._id);
setgridline_id(newSelectionModel.row.id);
//handleClick_edit_evaluation_From_Line(newSelectionModel.row.id);
}}
rowsPerPageOptions={[10]}
disableSelectionOnClick
components={{
Toolbar: GridToolbar,
}}
//sx={datagridSx}
getCellClassName={(params) => {
}}
getRowClassName={(params) => {
// Pour la gestion de la couleur de zone double cliquée
if (String(params.row.id) === String(gridline_id)) {
return 'line--statut--selected';
}
else if (parseInt(String(params.row.id)) % 2 === 0) {
return 'line--statut--pair';
}
else if (parseInt(String(params.row.id)) % 2 !== 0) {
return 'line--statut--impair';
}
}}
getEstimatedRowHeight={() => 200}
getRowHeight={() => "auto"}
sx={{
"& .MuiDataGrid-cellContent": {
minHeight: 50,
}
}}
/>
</Box>
{selectionModel_participants && selectionModel_participants.length >= 1 &&
<div className="div_row" style={{ "border": "none", "marginLeft": "10px" }}>
<div className="block_en_mass">
<nav className='traitement_mass'>Traitement en masse</nav>
&nbsp;
<Autocomplete
disablePortal
id="combo-box-demo"
className="block_en_mass_select"
fullWidth
options={New_Option_PreInscription}
onChange={(event, value) => {
if (value && value.value) {
if (String(value.value) === "inscr") {
setactionmass_preinsc_val(value.value);
}
else {
setactionmass_preinsc_val("");
}
}
else {
setactionmass_preinsc_val("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>
&nbsp;
{actionmass_preinsc_val && String(actionmass_preinsc_val).length > 1 && <nav className='block_en_mass_bton_action'>
<Popup
trigger={<Button className="bton_enreg" style={{ "width": "90%" }}>
<FcAcceptDatabase /> Traiter
</Button>}
modal
nested
position="center center"
>
{close => (
<div>
<button className="gest_close" onClick={close}>
&times;
</button>
<div className="gest_header"> MySy Information </div>
<div className="gest_content">
{' '}
{String(actionmass_preinsc_val) === "inscr" &&
<font> Confirmer la <b> validation des inscriptions </b> en masse pour {selectionModel_participants.length} lignes.
</font>}
</div>
<div className="gest_actions">
<div style={{ "width": "45%", "float": "left" }}>
<button className="gest_bton_popup" onClick={(event) => {
actionmass_preinsc_Traitemet();
close();
}}> Valider </button>
</div>
<div style={{ "width": "45%", "float": "right" }}>
<button
className="gest_bton_popup"
onClick={() => {
//console.log('modal closed ');
close();
}}
>
Annuler
</button>
</div>
</div>
</div>
)}
</Popup>
</nav>
}
<br />
</div>
</div>}
<br />
</div>
</div>
</div>
<div className="div_row" style={{ "border": "None" }}>
</div>
</div>
</div>
</div >
);
}
export default Module_Selection_Evaluation_Apprenants;