import React, { useRef, useState, useEffect } from "react";
import TextField from '@mui/material/TextField';
import MenuItem from '@mui/material/MenuItem';
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 { Editor } from '@tinymce/tinymce-react';
import { FcViewDetails, FcDisapprove } from "react-icons/fc";
import 'react-tooltip/dist/react-tooltip.css'
import { Tooltip } from 'react-tooltip'
import Checkbox from '@mui/material/Checkbox';
import excel_icone from "../mysy_img/excel_icone.png";
import TextareaAutosize from '@mui/material/TextareaAutosize';
import fileDownload from 'js-file-download'
import { FcInfo } from "react-icons/fc";
import Popup from 'reactjs-popup';
import 'reactjs-popup/dist/index.css';
import parse from 'html-react-parser';
import { FcAcceptDatabase, } from "react-icons/fc";
import { format } from 'date-fns'
import InputAdornment from '@mui/material/InputAdornment';
import { AiFillCloseCircle, AiOutlineConsoleSql } from "react-icons/ai";
import Box from '@mui/material/Box';

import { CiTrash } from "react-icons/ci";
import { MdAddCircleOutline, MdRemoveCircleOutline } from "react-icons/md";
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif";
import { Fab } from "@material-ui/core";
import { IoMdAddCircle, IoIosRemoveCircleOutline } from "react-icons/io";
import { AiTwotoneSave } from "react-icons/ai";
import { FcEditImage } from "react-icons/fc";
import ToggleSwitch from "./ToggleSwitch";

import { FcSpeaker } from "react-icons/fc";
import Autocomplete from '@mui/material/Autocomplete';
import { FcOpenedFolder } from "react-icons/fc";
import Module_Absence from "./Module_Absence";
import { RiMoreFill } from "react-icons/ri";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import moment from "moment";
import 'moment/locale/fr';
import { IoAddCircleOutline, IoCloseCircleOutline } from "react-icons/io5";
import { gridClasses } from '@mui/x-data-grid';
import Link from '@mui/material/Link';
import { PiDotsThree } from "react-icons/pi";
import {
    GridToolbarContainer, GridToolbarExport, GridToolbarColumnsButton,
    GridToolbarFilterButton, GridToolbarDensitySelector, GridToolbarExportContainer, useGridApiContext,
    gridFilteredSortedRowIdsSelector,
    gridVisibleColumnFieldsSelector,
    GridValueGetterParams,
    GridPreferencePanelsValue,

} from '@mui/x-data-grid';
import * as XLSX from 'xlsx';
import Module_Alert_Confirmation from "./Module_Alert_Confirmation";
import { BiSolidGrid } from "react-icons/bi";
import { CiBoxList } from "react-icons/ci";
import Ent_Student_Affichage_Ftion_Grid from "./Ent_Student_Affichage_Ftion_Grid";

import CancelPresentationIcon from '@mui/icons-material/CancelPresentation';
import { makeStyles } from "@material-ui/core/styles";
import Paper from '@material-ui/core/Paper';
import Draggable from 'react-draggable';
import { IconButton } from '@material-ui/core';
import FullCalendar from "@fullcalendar/react";
import daygridPlugin from "@fullcalendar/daygrid";
import interactionPlugin from "@fullcalendar/interaction";
import timeGridPlugin from "@fullcalendar/timegrid";
import allLocales from '@fullcalendar/core/locales-all';

function PaperComponent(props) {
    return (
        <Draggable
            handle="#draggable-dialog-title"
            cancel={'[class*="MuiDialogContent-root"]'}
        >
            <Paper {...props} />
        </Draggable>
    );
}

const useStyles = makeStyles((theme) => ({

    dialog: {
        position: 'absolute',
        // left: 10,
        top: 400
    },

    paper: {
        overflowY: 'unset',
    },
    customizedButton: {
        position: 'absolute',
        left: '98%',
        top: '-3%',
        backgroundColor: 'lightgray',
        color: 'gray',
    },
}));

const Module_Ent_Mes_Formations = (props) => {

    const classes = useStyles();

    const history = useHistory();
    const [submenu, setsubmenu] = useState("");




    const filters = [
        { value: 'email', label: 'Email' },
        { value: 'nom', label: 'Nom' },
        { value: 'prenom', label: 'Prénom' }
    ]

    const [selectedfilt1, setselectedfilt1] = useState("");
    const [selectedfilt2, setselectedfilt2] = useState("");
    const [selectedfilt3, setselectedfilt3] = 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 : 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>
        );
    }



    function Display_Colunm_text({ value }) {

        return (
            <div style={{ paddingLeft: "5px", paddingRight: "10px", "display": "block", wordBreak: "break-all" }}>
                {value}&nbsp;

            </div>
        );
    }

    const [selectionModel, setSelectionModel] = React.useState([]);

    const columns_ent_mes_formations = [
        { field: 'id', headerName: 'id', hide: true, disableExport: true, },
        { field: '_id', headerName: '_id', hide: true, disableExport: true, },
        { field: 'associated_session_id', headerName: 'associated_session_id', hide: true, disableExport: true, },
        { field: 'associated_inscription_id', headerName: 'associated_inscription_id', hide: true, disableExport: true, },
        { field: 'external_code', headerName: 'external_code', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'title', headerName: 'title', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'session_code_session', headerName: 'Code Promo', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'session_date_debut', headerName: 'Du', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'session_date_fin', headerName: 'Au', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'description', headerName: 'description', hide: true, Width: 1 },
        { field: 'internal_url', headerName: 'internal_url', hide: true, Width: 1 },
        { field: 'objectif', headerName: 'objectif', hide: true, Width: 1 },
        { field: 'programme', headerName: 'programme', hide: true, Width: 1 },
        { field: 'prerequis', headerName: 'prerequis', hide: true, Width: 1 },

    ]


    const [selectionModel_notes, setselectionModel_notes] = React.useState([]);
    const [selectionModel_jury, setselectionModel_jury] = React.useState([]);


    const columns_notes = [
        { field: '_id', headerName: '_id', hide: true, editable: false, Width: 0 },
        { field: 'evaluation_id', headerName: 'evaluation_id', hide: true, editable: false, Width: 0 },
        { field: 'inscription_id', headerName: 'inscription_id', hide: true, editable: false, Width: 0 },
        { field: 'note_evaluation_id', headerName: 'session_id', hide: true, editable: false, Width: 0 },

        { field: 'id', headerName: 'id', hide: true, Width: 0 },
        { field: 'class_eu_id', headerName: 'class_eu_id', hide: true, Width: 0 },
        { field: 'type_eval_id', headerName: 'type_eval_id', hide: true, Width: 0 },


        { field: 'class_ue_code', headerName: 'Code UE', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'class_ue_titre', headerName: 'Titre UE', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'note_evaluation_code', headerName: 'Evaluation', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'eval_date_heure_debut', headerName: 'Debut Eval', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'eval_date_heure_fin', headerName: 'Fin Eval', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'note', headerName: 'Note', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },

    ]

    const columns_jury = [
        { field: '_id', headerName: '_id', hide: true, editable: false, Width: 0 },
        { field: 'jury_id', headerName: 'jury_id', hide: true, editable: false, Width: 0 },
        { field: 'jury_soutenance_id', headerName: 'jury_soutenance_id', hide: true, editable: false, Width: 0 },
        { field: 'agenda_id', headerName: 'agenda_id', hide: true, editable: false, Width: 0 },
        { field: 'inscription_id', headerName: 'inscription_id', hide: true, editable: false, Width: 0 },

        { field: 'id', headerName: 'id', hide: true, Width: 0 },
        { field: 'soutenance_agenda_event_start', headerName: 'Debut ', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'soutenance_agenda_event_end', headerName: 'Fin', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'soutenance_code', headerName: 'Matière', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'soutenance_sujet', headerName: 'Sujet', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'soutenance_note', headerName: 'Note', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'soutenance_observation', headerName: 'Observation', hide: false, minWidth: 200, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },

    ]



    const [isLoading, setLoading] = useState();

    const [p_filtre1, setp_filtre1] = useState("");
    const [p_filtre1_value, setp_filtre1_value] = useState("");

    const [p_filtre2, setp_filtre2] = useState("");
    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("");


    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("");
    }

    useEffect(() => {

        if (props.apprenant_id)
            Get_List_Ent_Formation();

        window.scrollTo({
            top: 0,
            behavior: "smooth",
        });

    }, [props.apprenant_id])


    const [New_Get_List_Ent_Formation_result, setNew_Get_List_Ent_Formation_result] = useState([]);

    const [Get_List_Ent_Formation_api, setGet_List_Ent_Formation_api] = useState();
    const [Get_List_Ent_Formation_message, setGet_List_Ent_Formation_message] = useState();
    const [Get_List_Ent_Formation_result, setGet_List_Ent_Formation_result] = useState();
    function Get_List_Ent_Formation(event) {

        var form = new FormData();
        const stored_cookie = getCookie('tokenmysych');

        form.append("token", stored_cookie);
        form.append("apprenant_id", props.apprenant_id);


        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_List_Class/";

        setLoading(true);
        axios.post(myurl, form).then(res => {
            //console.log(" In Get_List_Ent_Formation  res.data.status = " + res.data.status);
            //console.log(" In Get_List_Ent_Formation  res.data.message r_class = " + res.data.message);

            setLoading(false);

            if (String(res.data.status) === String("true")) {
                setGet_List_Ent_Formation_api("true");
                setGet_List_Ent_Formation_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 external_code = JSON.parse(x).external_code;
                    var title = JSON.parse(x).title;
                    var objectif = JSON.parse(x).objectif;
                    var programme = JSON.parse(x).programme;
                    var prerequis = JSON.parse(x).prerequis;
                    var description = JSON.parse(x).description;
                    var associated_session_id = JSON.parse(x).session_id;
                    var associated_inscription_id = JSON.parse(x).inscription_id;

                    var session_code_session = JSON.parse(x).session_code_session;
                    var session_date_debut = JSON.parse(x).session_date_debut;
                    var session_date_fin = JSON.parse(x).session_date_fin;


                    //---
                    var node = {
                        "_id": local_id,
                        "id": localid,
                        "label": external_code,
                        "external_code": external_code,
                        "title": title,
                        "objectif": objectif,
                        "programme": programme,
                        "prerequis": prerequis,
                        "description": description,
                        "associated_session_id": associated_session_id,
                        "associated_inscription_id": associated_inscription_id,
                        "session_code_session": session_code_session,
                        "session_date_debut": session_date_debut,
                        "session_date_fin": session_date_fin,

                    };
                    new_data2.push(node);
                });

                if (new_data2.length > 0)
                    setNew_Get_List_Ent_Formation_result(new_data2);
            }
            else if (String(res.data.status) === String("Err_Connexion")) {
                alert('Erreur: ' + res.data.message);
                history.push("/ent_student");
            }
            else {
                setGet_List_Ent_Formation_api("false");
                setGet_List_Ent_Formation_message(res.data.message);
                alert('Erreur: ' + res.data.message);
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( Get_List_Ent_Formation = ', error);
            setGet_List_Ent_Formation_api("false");
            alert('Erreur: Impossible de recuperer la liste des formation');
        })
    }

    const [Getall_Sequence_Of_Session_result_planning_view, setGetall_Sequence_Of_Session_result_planning_view] = useState([]);

    const [Getall_Sequence_Of_Session_api, setGetall_Sequence_Of_Session_api] = useState();
    const [Getall_Sequence_Of_Session_message, setGetall_Sequence_Of_Session_message] = useState();
    const [Getall_Sequence_Of_Session_result, setGetall_Sequence_Of_Session_result] = useState();
    function Getall_Sequence_Of_Session(local_session_id) {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysych');
        form.append("token", stored_cookie);
        form.append("session_id", local_session_id);
        form.append("apprenant_id", props.apprenant_id);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_Session_Sequence_List/";

        setLoading(true);
        axios.post(myurl, form).then(res => {
            //  console.log(" In Getall_Sequence_Of_Session  res.data.status = " + res.data.status);
            console.log(" In Getall_Sequence_Of_Session  res.data.message r_class = " + res.data.message);
            setLoading(false);
            if (String(res.data.status) === String("true")) {

                // console.log(" In Getall_Sequence_Of_Session  res.data.nb_sequence r_class = " + res.data.nb_sequence);
                setGetall_Sequence_Of_Session_api("true");
                setGetall_Sequence_Of_Session_result(res.data.message);

                // console.log(" ##NB_Sequence iii  = ", res.data.nb_sequence);


                var new_data2 = [];
                const new_data = res.data.message.map((x) => {

                    //---
                    var localid = JSON.parse(x)._id; // on donne volontairement a l'id la valeur de '_id'
                    var local_id = JSON.parse(x)._id;
                    var local_title = JSON.parse(x).sequence_title;
                    var local_start = new Date(moment(JSON.parse(x).sequence_start, "DD/MM/YYYY hh:mm"))
                    var local_end = new Date(moment(JSON.parse(x).sequence_end, "DD/MM/YYYY hh:mm"))


                    var local_agenda = JSON.parse(x).agenda;
                    var local_objectif = JSON.parse(x).objectif;
                    var local_session_id = JSON.parse(x).session_id;
                    var local_session_comment = JSON.parse(x).commentaire;
                    var local_mode_animation = JSON.parse(x).mode_animation;
                    var local_session_color = "#3788d8";


                    if (local_mode_animation === "1") {
                        // sequence en distantiel, on va mettre un code couleur
                        local_session_color = "#4ea860"
                    }


                    var local_type = JSON.parse(x).type;

                    //---
                    var node = {
                        "_id": localid,
                        "id": localid,
                        "title": local_title,
                        "start": local_start,
                        "end": local_end,
                        "local_mode_animation": local_mode_animation,
                        "local_agenda": local_agenda,
                        "local_objectif": local_objectif,
                        "local_comment": local_session_comment,
                        "color": local_session_color,
                        "type": local_type,
                    };
                    new_data2.push(node);


                });

                if (new_data2.length > 0) {
                    setGetall_Sequence_Of_Session_result_planning_view(new_data2);
                    //console.log(" ### new_data2 = ", new_data2);
                }


            }
            else {
                setGetall_Sequence_Of_Session_api("false");
                setGetall_Sequence_Of_Session_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_Sequence_Of_Session = ', error);
            setGetall_Sequence_Of_Session_api("false");
            alert("Impossible de récuperer la liste des séquences")
            //setmyApimyApiMessage("")
        })
    }


    const New_Option_mode_animation = [
        { "id": "1", "label": "Distanciel", "value": "1" },
        { "id": "2", "label": "Hybride", "value": "2" },
        { "id": "0", "label": "Présentiel", "value": "0" },
        { "id": "", "label": "", "value": "" },
    ]

    const [selected_id, setselected_id] = useState("");
    const [gridline_id, setgridline_id] = useState("");
    const [selected_session_id, setselected_session_id] = useState("");
    const [selected_inscription_id, setselected_inscription_id] = useState("");

    const [selected_class_external_code, setselected_class_external_code] = useState("");
    const [selected_code_session, setselected_code_session] = useState("");


    const [Get_Given_Class_Data_api, setGet_Given_Class_Data_api] = useState();
    const [Get_Given_Class_Data_message, setGet_Given_Class_Data_message] = useState();
    const [Get_Given_Class_Data_result, setGet_Given_Class_Data_result] = useState();
    function Get_Given_Class_Data(local_class_id) {

        var form = new FormData();
        const stored_cookie = getCookie('tokenmysych');
        form.append("class_id", local_class_id);
        var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_Ent_Student_Given_Class_From_Class_Id/";

        setLoading(true);
        axios.post(myurl, form).then(res => {
            //   console.log(" In Get_Given_Class_Data  res.data.status = " + res.data.status);
            //   console.log(" In Get_Given_Class_Data  res.data.message r_class = " + res.data.message);

            setLoading(false);

            if (String(res.data.status) === String("true")) {
                setGet_Given_Class_Data_api("true");
                setGet_Given_Class_Data_result(res.data.message);

                if (document.getElementById('myRef_detail')) {
                    var divh = document.getElementById('myRef_detail').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }

            }
            else if (String(res.data.status) === String("Err_Connexion")) {
                alert('Erreur: ' + res.data.message);
                history.push("/ent_student");
            }
            else {
                setGet_Given_Class_Data_api("false");
                setGet_Given_Class_Data_message(res.data.message);
                alert('Erreur: ' + res.data.message);
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( Get_Given_Class_Data = ', error);
            setGet_Given_Class_Data_api("false");
            alert('Erreur: Impossible les données de la formation');
        })
    }


    const myRef_detail = useRef(null)

    function submenu_planning() {
        setsubmenu("planning");
        submenu_color_management("planning");
    }

    function submenu_detail() {
        setsubmenu("detail");
        submenu_color_management("detail");
    }

    function submenu_notes() {
        setsubmenu("notes");
        submenu_color_management("notes");

        if (selected_id) {
            Get_Inscrit_List_Evaluation_Par_UE(selected_inscription_id);
            Get_Inscrit_List_UE(selected_inscription_id);
        }
    }

    function submenu_piece_jointe() {
        setsubmenu("piece_jointe");
        submenu_color_management("piece_jointe");

    }


    function submenu_color_management(current_menu) {
        const list_sous_menu = ['detail', 'planning', 'notes', 'piece_jointe']

        for (let i = 0; i < list_sous_menu.length; i++) {

            var sous_menu = list_sous_menu[i];
            if (String(sous_menu) !== current_menu) {
                if (document.getElementById(sous_menu)) {
                    document.getElementById(sous_menu).style.backgroundColor = "#d8edfc";
                    document.getElementById(sous_menu).style.color = "black";
                    document.getElementById(sous_menu).style.fontWeight = "normal";
                }
            }
        }

        if (document.getElementById(current_menu)) {
            document.getElementById(current_menu).style.backgroundColor = "#107758";
            document.getElementById(current_menu).style.color = "white";
            document.getElementById(current_menu).style.fontWeight = "bold";
        }
    }

    function handleClick_Class_Selected_From_Line(associated_session_id, associated_inscription_id) {

        // Recuperer le planning liée à cette formation
        Getall_Sequence_Of_Session(associated_session_id);
        Get_Inscrit_Notes_Of_Evaluations(associated_inscription_id, associated_session_id);
        Get_List_Of_All_PJ(associated_inscription_id);
    }


    const renderEventContent = (eventInfo) => {
        //console.log(eventInfo);
        return (
            <>
                <b>{eventInfo.timeText}</b><br />
                <i>{eventInfo.event.title}</i><br />
                {eventInfo.event.extendedProps.local_mode_animation && String(eventInfo.event.extendedProps.local_mode_animation) === "1" &&
                    <i><b>Distanciel</b></i>}
            </>
        )
    };


    const [p_detail_justified, setp_detail_justified] = useState(false);
    const [p_detail_event_type, setp_detail_event_type] = useState("");

    const [p_detail_event_id, setp_detail_event_id] = useState();
    const [p_detail_sequence_title, setp_detail_sequence_title] = useState();
    const [p_detail_sequence_comment, setp_detail_sequence_comment] = useState();
    const [p_detail_sequence_agenda, setp_detail_sequence_agenda] = useState();
    const [p_detail_sequence_objectif, setp_detail_sequence_objectif] = useState();
    const [sequence_startDate, setsequence_startDate] = useState(new Date());
    const [sequence_endDate, setsequence_endDate] = useState(new Date());


    const [selected_detail_sequence_title, setselected_detail_sequence_title] = useState();
    const [selected_detail_sequence_comment, setselected_detail_sequence_comment] = useState();
    const [selected_sequence_startDate, setselected_sequence_startDate] = useState(new Date());
    const [selected_sequence_endDate, setselected_sequence_endDate] = useState(new Date());


    const [mysy_events, setmysy_events] = useState();

    const [Partner_Debut_Journee, setPartner_Debut_Journee] = useState("7:00");
    const [Partner_Fin_Journee, setPartner_Fin_Journee] = useState("20:00");

    const [Dialog_DIALOG_AGENDA_message, setDialog_DIALOG_AGENDA_message] = React.useState(false);
    const [Dialog_DIALOG_AGENDA_open, setDialog_DIALOG_AGENDA_open] = React.useState(false);
    function Dialog_DIALOG_AGENDA_handle_change_participant_session(message) {
        setDialog_DIALOG_AGENDA_message(message);
        setDialog_DIALOG_AGENDA_open(true);
    }

    const Dialog_DIALOG_AGENDA_handleClose = () => {
        //alert(" Utiliser le bouton 'fermer' ");
        //setOpen(false);
    };

    const Dialog_DIALOG_AGENDA_handleClose_buton = () => {
        setDialog_DIALOG_AGENDA_open(false);
    };

    const New_Option_Type_Event = [
        { "id": "0", "label": "Absence", "value": "absence" },
        { "id": "1", "label": "Planning", "value": "planning" },
        { "id": "2", "label": "Autre", "value": "autre" },
        { "id": "", "label": "", "value": "" },
    ]

    const handleSelect = (info) => {
        return;
    };

    const handleEventClick = (arg) => {

        //console.log(" ## ARG = ", arg.event)
        // console.log(" ## arg.event.id = ", arg.event.id)

        setp_detail_sequence_title(arg.event.title)
        setsequence_startDate(arg.event.start)
        setsequence_endDate(arg.event.end)
        setp_detail_event_id(arg.event.id);

        if (arg.event.extendedProps.type) {
            setp_detail_event_type(arg.event.extendedProps.type);
        }
        else
            setp_detail_event_type("");


        if (arg.event.extendedProps.local_comment) {
            setp_detail_sequence_comment(arg.event.extendedProps.local_comment);
        }
        else
            setp_detail_sequence_comment("");


        if (arg.event.extendedProps.local_mode_animation) {
            if (String(arg.event.extendedProps.local_mode_animation) === "1")
                setp_detail_mode_animation_label("Distanciel");
            else if (String(arg.event.extendedProps.local_mode_animation) === "2")
                setp_detail_mode_animation_label("Hybride");
            else if (String(arg.event.extendedProps.local_mode_animation) === "0")
                setp_detail_mode_animation_label("Présentiel");
        }
        else
            setp_detail_mode_animation_label("");

        if (arg.event.extendedProps.local_objectif) {
            setp_detail_sequence_objectif(arg.event.extendedProps.local_objectif);
        }
        else
            setp_detail_sequence_objectif("");

        if (arg.event.extendedProps._id) {
            setp_detail_event_id(arg.event.extendedProps._id);

        }
        else
            setp_detail_event_id("");


        if (arg.event.extendedProps.local_agenda) {
            setp_detail_sequence_agenda(arg.event.extendedProps.local_agenda);

        }
        else
            setp_detail_sequence_agenda("");

        setDialog_DIALOG_AGENDA_open(true);
    }

    const [Get_Apprenant_Notes_Of_Evaluations_api, setGet_Apprenant_Notes_Of_Evaluations_api] = useState();
    const [Get_Apprenant_Notes_Of_Evaluations_message, setGet_Apprenant_Notes_Of_Evaluations_message] = useState();
    const [Get_Apprenant_Notes_Of_Evaluations_result, setGet_Apprenant_Notes_Of_Evaluations_result] = useState([]);
    function Get_Apprenant_Notes_Of_Evaluations(local_inscription, local_session_id) {

        var form = new FormData();

        const stored_cookie = getCookie('tokenmysych');

        var tab_my_inscription_ids = [];
        tab_my_inscription_ids.push(local_inscription);

        var tab_session_id = [];
        tab_session_id.push(local_session_id);

        form.append("token", stored_cookie);
        form.append("list_session_id", selected_session_id);
        form.append("list_apprenant_id", selected_inscription_id);


        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Apprenant_Notes_With_Filter/";

        axios.post(myurl, form).then(res => {
            //  console.log(" In Get_Apprenant_Notes_Of_Evaluations  res.data.status = " + res.data.status);
            // console.log(" In Get_Apprenant_Notes_Of_Evaluations  res.data.message r_class = " + res.data.message);
            if (String(res.data.status) === String("true")) {

                setGet_Apprenant_Notes_Of_Evaluations_api("true");
                setGet_Apprenant_Notes_Of_Evaluations_result(res.data.message);
            }
            else {
                setGet_Apprenant_Notes_Of_Evaluations_api("false");
                setGet_Apprenant_Notes_Of_Evaluations_message(res.data.message);
            }

        }).catch((error) => {
            console.warn('Not good man :( Get_Apprenant_Notes_Of_Evaluations = ', error);
            setGet_Apprenant_Notes_Of_Evaluations_api("false");
            //setmyApimyApiMessage("")
        })
    }

    const [inscription_list_ue, setinscription_list_ue] = useState([]);
    const [inscription_list_ue_eval, setinscription_list_ue_eval] = useState([]);

    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('tokenmysych');
        form.append("token", stored_cookie);
        form.append("inscription_id", local_inscription_id);
        form.append("apprenant_id", props.apprenant_id);


        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_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 [New_Get_Inscrit_List_Evaluation_Par_UE_result, setNew_Get_Inscrit_List_Evaluation_Par_UE_result] = useState([]);
    const [tab_inscrit_evaluation_ue_id, settab_inscrit_evaluation_ue_id] = useState([]);

    const [Get_Inscrit_List_Evaluation_Par_UE_api, setGet_Inscrit_List_Evaluation_Par_UE_api] = useState();
    const [Get_Inscrit_List_Evaluation_Par_UE_message, setGet_Inscrit_List_Evaluation_Par_UE_message] = useState();
    const [Get_Inscrit_List_Evaluation_Par_UE_result, setGet_Inscrit_List_Evaluation_Par_UE_result] = useState();
    function Get_Inscrit_List_Evaluation_Par_UE(local_inscription_id) {
        var form = new FormData();

        const stored_cookie = getCookie('tokenmysych');
        form.append("token", stored_cookie);
        form.append("inscription_id", local_inscription_id);
        form.append("apprenant_id", props.apprenant_id);


        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_Inscrit_List_EU_Type_Evaluation/";

        setLoading(true);

        axios.post(myurl, form).then(res => {

            setLoading(false);

            if (String(res.data.status) === String("true")) {
                //console.log(" In Get_Inscrit_List_Evaluation_Par_UE  res.data.status = " + res.data.status);
                //console.log(" In Get_Inscrit_List_Evaluation_Par_UE  res.data.message r_class = " + res.data.message);
                setGet_Inscrit_List_Evaluation_Par_UE_api("true");
                setGet_Inscrit_List_Evaluation_Par_UE_result(res.data.message);

                var new_data2 = [];

                var tab_tmp = []
                var tab_tmp_V2 = []
                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_class_eu_code = JSON.parse(x).class_eu_code;
                    var local_type_eval_id = JSON.parse(x).type_eval_id;
                    var local_type_eval_code = JSON.parse(x).type_eval_code;
                    var local_type_eval_nom = JSON.parse(x).type_eval_nom;

                    tab_tmp.push(local_type_eval_id);



                    //---
                    var node = {
                        "_id": local_id,
                        "id": localid,
                        "label": local_class_eu_code + " - " + local_type_eval_code,
                        "class_id": local_class_id,
                        "class_eu_id": local_class_eu_id,
                        "class_eu_code": local_class_eu_code,
                        "type_eval_id": local_type_eval_id,
                        "type_eval_code": local_type_eval_code,
                        "type_eval_nom": local_type_eval_nom,
                    };
                    new_data2.push(node);


                });

                //---
                var node = {
                    "_id": "",
                    "id": "",
                    "label": "",
                    "class_id": "",
                    "class_eu_id": "",
                    "class_eu_code": "",
                    "type_eval_id": "",
                    "type_eval_code": "",
                    "type_eval_nom": "",
                };
                new_data2.push(node);


                if (new_data2.length > 0) {
                    setNew_Get_Inscrit_List_Evaluation_Par_UE_result(new_data2);
                    settab_inscrit_evaluation_ue_id(tab_tmp);

                    //console.log(" ### settab_inscrit_evaluation_ue_id = ", tab_tmp);

                    if (New_Get_List_UE_From_Class_Id_result && New_Get_List_UE_From_Class_Id_result.length > 0) {

                        var local_defaultValue = New_Get_List_UE_From_Class_Id_result.filter((data) => {
                            if (tab_inscrit_ue_id.includes(String(data._id))) {

                                return data;
                            }
                        });

                        setinscription_list_ue(local_defaultValue);
                    }
                }
            }
            else {
                setGet_Inscrit_List_Evaluation_Par_UE_api("false");
                setGet_Inscrit_List_Evaluation_Par_UE_message(res.data.message);
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( Get_Inscrit_List_Evaluation_Par_UE = ', error);
            setGet_Inscrit_List_Evaluation_Par_UE_api("false");
            //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('tokenmysych');
        form.append("token", stored_cookie);
        form.append("class_id", local_class_id);
        form.append("apprenant_id", props.apprenant_id);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_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);
                });



                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_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('tokenmysych');
        form.append("token", stored_cookie);
        form.append("class_id", local_class_id);
        form.append("apprenant_id", props.apprenant_id);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_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);
                });



                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 [Get_Inscrit_Notes_Of_Evaluations_api, setGet_Inscrit_Notes_Of_Evaluations_api] = useState();
    const [Get_Inscrit_Notes_Of_Evaluations_message, setGet_Inscrit_Notes_Of_Evaluations_message] = useState();
    const [Get_Inscrit_Notes_Of_Evaluations_result, setGet_Inscrit_Notes_Of_Evaluations_result] = useState([]);
    function Get_Inscrit_Notes_Of_Evaluations(local_inscription, local_session_id) {

        var form = new FormData();

        const stored_cookie = getCookie('tokenmysych');

        var tab_my_inscription_ids = [];
        tab_my_inscription_ids.push(local_inscription);

        var tab_session_id = [];
        tab_session_id.push(local_session_id);

        form.append("token", stored_cookie);
        form.append("tab_session_id", tab_session_id);
        form.append("tab_inscription_id", tab_my_inscription_ids);
        form.append("apprenant_id", props.apprenant_id);


        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_Participant_Notes/";

        axios.post(myurl, form).then(res => {
            // console.log(" In Get_Inscrit_Notes_Of_Evaluations  res.data.status = " + res.data.status);
            //  console.log(" In Get_Inscrit_Notes_Of_Evaluations  res.data.message r_class = " + res.data.message);

            if (String(res.data.status) === String("true")) {

                setGet_Inscrit_Notes_Of_Evaluations_api("true");
                setGet_Inscrit_Notes_Of_Evaluations_result(res.data.message);
            }
            else {
                setGet_Inscrit_Notes_Of_Evaluations_api("false");
                setGet_Inscrit_Notes_Of_Evaluations_message(res.data.message);
            }

        }).catch((error) => {
            console.warn('Not good man :( Get_Inscrit_Notes_Of_Evaluations = ', error);
            setGet_Inscrit_Notes_Of_Evaluations_api("false");
            //setmyApimyApiMessage("")
        })
    }

    // -- Gestion pièces jointes 

    const [Download_one_attached_document_api, setDownload_one_attached_document_api] = useState();
    const [Download_one_attached_document_result, setDownload_one_attached_document_result] = useState();
    const [Download_one_attached_document_message, setDownload_one_attached_document_message] = useState();

    const Download_one_attached_document = (event) => {
        const stored_cookie = getCookie('tokenmysych');


        var nom_fiche_detaillee = "Fiche_Detaillee.pdf";
        var token = stored_cookie;
        var file_name = event.target.id;


        var url = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_Stored_Downloaded_File/" + token + "/" + file_name + "/" + props.apprenant_id;

        setLoading(true);
        axios.get(url, { responseType: 'blob', },)
            .then((res) => {
                setLoading(false);
                fileDownload(res.data, nom_fiche_detaillee);
                setDownload_one_attached_document_api("true");
            }).catch((error) => {
                setLoading(false);
                console.error('Error:', error);
                setDownload_one_attached_document_api("false");

            });
    }


    const [tab_convention_pieces_jointes_result, settab_convention_pieces_jointes_result] = useState([]);

    const [file_1_name, setfile_1_name] = useState();

    const [sessions_file_change_1_api, setsessions_file_change_1_api] = useState();
    const [sessions_file_change_1_result, setsessions_file_change_1_result] = useState();
    const [sessions_file_change_1_message, setsessions_file_change_1_message] = useState();
    const sessions_file_change_1 = event => {

        const fileUploaded = event.target.files[0];
        let file_size = event.target.files[0].size;
        let file_type = event.target.files[0].type;




        console.log("file_size 2 =  ", file_size, " file_type = ", file_type);
        if (file_size > 10000000) {

            setdisplay_alert_mysy("1");
            setalert_message("Le fichier ne doit pas depasser un 1 Méga octets");
            setalert_type("error");
            return;
        }

        setfile_1_name(event.target.files[0]);

        const formData = new FormData();
        formData.append('File', fileUploaded);
        //formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA');
        const stored_cookie = getCookie('tokenmysych');


        return;


    };



    const [sessions_file_change_1_convention_api, setsessions_file_change_1_convention_api] = useState();
    const [sessions_file_change_1_convention_result, setsessions_file_change_1_convention_result] = useState();
    const [sessions_file_change_1_convention_message, setsessions_file_change_1_convention_message] = useState();
    const sessions_file_change_1_convention = event => {


        const fileUploaded = event.target.files[0];
        let file_size = event.target.files[0].size;
        let file_type = event.target.files[0].type;


        if (file_type !== "application/pdf") {
            // alert("Le fichier n'est pas de type PDF");

            setdisplay_alert_mysy("1");
            setalert_message("Le fichier n'est pas de type PDF");
            setalert_type("error");

            return;
        }



        if (file_size > 10000000) {
            //  alert("Le fichier ne doit pas depasser un 1 Méga octets");
            // console.log("Le fichier ne doit pas depasser un 1 Méga octets");

            setdisplay_alert_mysy("1");
            setalert_message("Le fichier ne doit pas depasser un 1 Méga octets");
            setalert_type("error");
            return;
        }

        //var new_node = {'name':event.target.files[0].name, 'type':event.target.files[0].type}


        var new_tmp = [];

        if (tab_convention_pieces_jointes_result && tab_convention_pieces_jointes_result.length > 0) {

            tab_convention_pieces_jointes_result.map((x) => {
                new_tmp.push(x);

            });

        }

        new_tmp.push(event.target.files[0])

        settab_convention_pieces_jointes_result(new_tmp);


        return;


    };

    const [file_2_name, setfile_2_name] = useState();

    const [sessions_file_change_2_api, setsessions_file_change_2_api] = useState();
    const [sessions_file_change_2_result, setsessions_file_change_2_result] = useState();
    const [sessions_file_change_2_message, setsessions_file_change_2_message] = useState();
    const sessions_file_change_2 = event => {

        const fileUploaded = event.target.files[0];
        let file_size = event.target.files[0].size;
        let file_type = event.target.files[0].type;


        console.log("file_size 1 =  ", file_size, " file_type = ", file_type);
        if (file_size > 10000000) {
            //   alert("Le fichier ne doit pas depasser un 1 Méga octets");
            //  console.log("Le fichier ne doit pas depasser un 1 Méga octets");

            setdisplay_alert_mysy("1");
            setalert_message("Le fichier ne doit pas depasser un 1 Méga octets");
            setalert_type("error");

            return;
        }
        setfile_2_name(event.target.files[0]);

        const formData = new FormData();
        formData.append('File', fileUploaded);
        //formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA');
        const stored_cookie = getCookie('tokenmysych');



        return;


    };

    const [Record_All_PJ_api, setRecord_All_PJ_api] = useState();
    const [Record_All_PJ_result, setRecord_All_PJ_result] = useState();
    const [Record_All_PJ_message, setRecord_All_PJ_message] = useState();

    function Record_All_PJ() {

        if (!p_detail_one_file_to_download_type_name) {
            //  alert(" Vous devez donner un nom à la pièce jointe");

            setdisplay_alert_mysy("1");
            setalert_message(" Vous devez donner un nom à la pièce jointe");
            setalert_type("error");
            return;
        }

        if (file_1_name && file_1_name.name) {
            //console.log(" ### Traitement de  : ", file_1_name.name);

            const formData = new FormData();
            formData.append('File', file_1_name);
            //formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA');
            const stored_cookie = getCookie('tokenmysych');

            formData.append("token", stored_cookie);
            formData.append("file_business_object", p_detail_one_file_to_download_type_name);
            formData.append("file_name", file_1_name.name);
            formData.append("status", "0");
            formData.append("object_owner_collection", "inscription");
            formData.append("object_owner_id", selected_id);
            formData.append("type_document", "");

            //formData.append("class_internal_url", internal_url);
            //console.log("token = " + stored_cookie);

            setLoading(true);
            fetch(
                process.env.REACT_APP_API_URL + "myclass/api/Store_User_Downloaded_File/",
                {
                    method: 'POST',
                    body: formData,
                }
            )
                .then((response) => response.json())
                .then((result) => {

                    setLoading(false);
                    //console.log(" ## result['status'] = ", result['status'])
                    if (String(result['status']) === String("true")) {
                        //console.log('Success:', result['message']);
                        setRecord_All_PJ_result(result['message']);
                        setRecord_All_PJ_api("true");

                        Get_List_Of_All_PJ(selected_id);
                        setfile_1_name();
                        setp_detail_one_file_to_download_type_name();
                        //GetCurrentClass_trainingsession();
                        var text = " La pièce jointe " + file_1_name.name + " a été bien enregistrée";
                        setdisplay_alert_mysy("1");
                        setalert_message(text);
                        setalert_type("success");

                    }
                    else {
                        setRecord_All_PJ_message(result['message']);
                        setRecord_All_PJ_api("false");
                        // alert(result['message']);

                        setdisplay_alert_mysy("1");
                        setalert_message(result['message']);
                        setalert_type("error");
                    }

                })
                .catch((error) => {
                    setLoading(false);
                    console.error(' Record_All_PJ Error:', error);
                    setRecord_All_PJ_api("false");
                    alert(" Impossible d'ajouter la pièce jointe")
                });

        }


    }


    const [Delete_one_attached_document_api, setDelete_one_attached_document_api] = useState();
    const [Delete_one_attached_document_result, setDelete_one_attached_document_result] = useState();
    const [Delete_one_attached_document_message, setDelete_one_attached_document_message] = useState();

    const Delete_one_attached_document = (event) => {
        const stored_cookie = getCookie('tokenmysych');

        var formData = new FormData();
        var nom_fiche_detaillee = "Fiche_Detaillee.pdf";
        var file_name = event.target.id;


        formData.append("token", stored_cookie);
        formData.append("file_name", file_name);

        var url = process.env.REACT_APP_API_URL + "myclass/api/Delete_Stored_Downloaded_File/";

        setLoading(true);
        fetch(
            process.env.REACT_APP_API_URL + "myclass/api/Delete_Stored_Downloaded_File/",
            {
                method: 'POST',
                body: formData,
            }
        )
            .then((response) => response.json())
            .then((result) => {
                setLoading(false);
                //console.log(" ## result['status'] = ", result['status'])
                if (String(result['status']) === String("true")) {
                    //console.log('Success:', result['message']);
                    setDelete_one_attached_document_result(result['message']);
                    setDelete_one_attached_document_api("true");
                    Get_List_Of_All_PJ(selected_id);
                    //  alert(result['message'])
                    setdisplay_alert_mysy("1");
                    setalert_message(result['message']);
                    setalert_type("success");

                }
                else {
                    setDelete_one_attached_document_message(result['message']);
                    setDelete_one_attached_document_api("false");
                    // alert(result['message'])
                    setdisplay_alert_mysy("1");
                    setalert_message(result['message']);
                    setalert_type("error");
                }

            })
            .catch((error) => {
                setLoading(false);
                console.error(' Record_All_PJ Error:', error);
                setDelete_one_attached_document_api("false");
                // alert(" Impossible de supprimer le document")
                setdisplay_alert_mysy("1");
                setalert_message(" Impossible de supprimer le document");
                setalert_type("error");

            });


    }


    const Delete_one_attached_document_convention = (event) => {
        var file_name = event.target.id;

    }

    const [Get_List_Of_All_PJ_api, setGet_List_Of_All_PJ_api] = useState();
    const [Get_List_Of_All_PJ_result, setGet_List_Of_All_PJ_result] = useState();
    const [Get_List_Of_All_PJ_message, setGet_List_Of_All_PJ_message] = useState();

    function Get_List_Of_All_PJ(local_employee_id) {

        const formData = new FormData();

        //formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA');
        const stored_cookie = getCookie('tokenmysych');

        formData.append("token", stored_cookie);
        formData.append("object_owner_collection", "inscription");
        formData.append("object_owner_id", local_employee_id);
        formData.append("apprenant_id", props.apprenant_id);


        //formData.append("class_internal_url", internal_url);
        //console.log("token = " + stored_cookie);
        setLoading(true);

        fetch(
            process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_List_object_owner_collection_Stored_Files/",
            {
                method: 'POST',
                body: formData,
            }
        )
            .then((response) => response.json())
            .then((result) => {
                setLoading(false);

                //console.log(" ## result['status'] = ", result['status'])
                if (String(result['status']) === String("true")) {
                    //console.log('Message :', result['message']);
                    setGet_List_Of_All_PJ_result(result['message']);
                    setGet_List_Of_All_PJ_api("true");

                }
                else {
                    setGet_List_Of_All_PJ_message(result['message']);
                    setGet_List_Of_All_PJ_api("false");
                }

            })
            .catch((error) => {
                setLoading(false);
                console.error(' Get_List_Of_All_PJ Error:', error);
                setGet_List_Of_All_PJ_api("false");
            });

    }



    function Delete_file_1_name() {
        setfile_1_name();
    }

    function Delete_file_2_name() {
        setfile_2_name();
    }

    const [p_detail_one_file_to_download_type_name, setp_detail_one_file_to_download_type_name] = useState();

    // -- end gestion pièces jointes


    const [p_detail_mode_animation, setp_detail_mode_animation] = useState("");

    const [p_detail_mode_animation_label, setp_detail_mode_animation_label] = useState("");


    const [affichage_class, setaffichage_class] = useState("grid");


    function display_detail_from_grid(localid, local_id, local_session_id, local_inscription_id,
        local_class_id) {

        setselected_id(local_id);
        setgridline_id(localid);
        setselected_session_id(local_session_id);
        setselected_inscription_id(local_inscription_id);
        submenu_detail();

        Get_Given_Class_Data(local_id);
        Get_List_UE_From_Class_Id(local_class_id);
        Getall_Class_List_Evalution(local_class_id);
        handleClick_Class_Selected_From_Line(local_session_id, local_inscription_id);

        var line = New_Get_List_Ent_Formation_result[localid];
        setselected_class_external_code(line.external_code);
        setselected_code_session(line.session_code_session);
    }


    return (
        <div className="module_ent_mes_formations" >

            {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*/}


            {/**** Dialogue pour AGENDA */}

            <Dialog
                open={Dialog_DIALOG_AGENDA_open}
                // onClose={Dialog_DIALOG_AGENDA_handleClose}

                className="module_agenda"
                static
                onClose={() => null}

                PaperProps={{


                    className: classes.paper, // Apply the paper style
                    style: {
                        overflowY: 'unset',
                        position: 'absolute',
                        top: '7rem',
                        margin: "2px",
                    },
                }}
                hideBackdrop={true}
                disableScrollLock
                classes={{
                    paper: classes.dialog
                }}

                PaperComponent={PaperComponent}
                aria-labelledby="draggable-dialog-title"


            >

                <DialogTitle style={{ cursor: 'move', fontFamily: "DM Sans" }} id="draggable-dialog-title" >MySy Information</DialogTitle>
                <DialogContent className="DialogContent_width">
                    <DialogContentText>
                        {Dialog_DIALOG_AGENDA_message}
                    </DialogContentText>

                    <div className="session_caract_Dialog" >
                        <nav style={{ "float": "left", "width": "30%", "paddingTop": "15px" }}> Type </nav>

                        <nav style={{ "float": "right", "width": "65%" }}>
                            <TextField
                                sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}

                                name="event_dialog_event_type"
                                id="event_dialog_event_type"
                                fullWidth
                                value={p_detail_event_type}
                                disabled={true}
                            />

                        </nav>
                    </div>

                    <div className="session_caract_Dialog" >
                        <nav style={{ "float": "left", "width": "30%", "paddingTop": "15px" }}> Animation </nav>

                        <nav style={{ "float": "right", "width": "65%" }}>
                            <TextField
                                sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}

                                name="event_dialog_event_type"
                                id="event_dialog_event_type"
                                fullWidth
                                value={p_detail_mode_animation_label}
                                disabled={true}
                            />

                        </nav>
                    </div>



                    <div className="session_caract_Dialog" > Titre
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}

                            name="event_dialog_title"
                            id="event_dialog_title"
                            fullWidth
                            value={p_detail_sequence_title}
                            disabled={true}

                        />

                    </div>

                    <div className="session_caract_Dialog" > Debut
                        <DatePicker
                            name="event_dialog_start"
                            id="event_dialog_start"
                            selected={sequence_startDate}
                            className="disabled_style session_caract_Dialog_DatePicker"
                            style={{ width: "99%" }}
                            locale='fr-FR'
                            showTimeSelect
                            timeFormat="HH:mm"
                            timeIntervals={15}
                            dateFormat="dd/MM/yyyy HH:mm"
                            is24Hour
                            readOnly={true}


                        />

                    </div>

                    <div className="session_caract_Dialog" > Fin
                        <DatePicker
                            name="event_dialog_end"
                            id="event_dialog_end"
                            selected={sequence_endDate}
                            className="disabled_style session_caract_Dialog_DatePicker"
                            style={{ width: "99%" }}
                            locale='fr-FR'
                            showTimeSelect
                            timeFormat="HH:mm"
                            timeIntervals={15}
                            dateFormat="dd/MM/yyyy HH:mm"
                            is24Hour
                            readOnly={true}

                        />

                    </div>

                    <div className="session_caract_Dialog_comment_2_lines" > Agenda
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}

                            name="event_dialog_agenda"
                            id="event_dialog_agenda"
                            fullWidth

                            multiline
                            minRows={2}
                            maxRows={2}
                            rows={2}
                            disabled={true}

                        />

                    </div>

                    <div className="session_caract_Dialog_comment_2_lines" > Objectif
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}

                            name="event_dialog_objectif"
                            id="event_dialog_objectif"

                            fullWidth
                            value={p_detail_sequence_objectif}
                            multiline
                            minRows={2}
                            maxRows={2}
                            rows={2}
                            disabled={true}
                        />

                    </div>

                    <div className="session_caract_Dialog_comment_2_lines" > Commentaire
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}

                            name="event_dialog_comment"
                            id="event_dialog_comment"

                            fullWidth
                            value={p_detail_sequence_comment}
                            multiline
                            minRows={2}
                            maxRows={2}
                            rows={2}
                            disabled={true}
                        />
                    </div>
                </DialogContent>



                <DialogActions>
                    <IconButton
                        autoFocus
                        onClick={Dialog_DIALOG_AGENDA_handleClose_buton}
                        color="primary"
                        className={classes.customizedButton}
                    >
                        <CancelPresentationIcon />
                    </IconButton>

                    <div className="div_row">
                        <div className="div_row_gauche">
                            &nbsp;
                        </div>
                        <div className="div_row_droite" style={{ "textAlign": 'center' }}>
                            <Button onClick={Dialog_DIALOG_AGENDA_handleClose_buton} className="bton_annule_dialog" >Fermer</Button>
                        </div>
                    </div>

                </DialogActions>

            </Dialog>


            {/*** fin dialogue pr agenda */}




            {/*<div>
                <div className="titre1">  Utilisez les filtres !</div>
                <div className="div_row" style={{ "marginBottom": "5px" }}>
                    <div className="div_row_gauche texte_area_filter" >
                        <TextField
                            name="filtre1"
                            label="Choisir un champ"
                            select
                            sx={{ m: 1, width: '100%' }}
                            value={p_filtre1}
                            onChange={(e) => {
                                setp_filtre1(e.target.value)
                            }}
                        >

                            <MenuItem value="email" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Email &nbsp;&nbsp;</MenuItem>
                            <MenuItem value="nom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Nom &nbsp;</MenuItem>
                            <MenuItem value="prenom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Prénom &nbsp;</MenuItem>

                        </TextField>
                    </div>



                    <div className="div_row_droite texte_area_filter_value" >
                        {p_filtre1 &&
                            <TextField
                                sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                required
                                name="filtre1_value"
                                id="filtre1_value"

                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style"
                                value={p_filtre1_value}
                                onChange={(e) => { setp_filtre1_value(e.target.value); }}
                                InputProps={{
                                    endAdornment: (
                                        <InputAdornment position="end">
                                            <AiFillCloseCircle
                                                style={{ 'cursor': "pointer", "color": "orangered" }}
                                                onClick={(e) => {
                                                    setp_filtre1_value("");
                                                }} />
                                        </InputAdornment>
                                    ),
                                }}

                            />

                        }
                    </div>
                    {p_filtre1 && <div className='filter_bton_add'>
                        <Tooltip className="tooltip_css" id="my-tooltip01" style={{ "fontSize": "12px" }} />
                        <a data-tooltip-id="my-tooltip01" data-tooltip-html="Ajouter une nouvelle ligne de filtre">
                            &nbsp; <MdAddCircleOutline onClick={(e) => {
                                setp_filtre2("1");
                            }} />
                        </a>
                    </div>}
                    {p_filtre1 && <div className='filter_bton_add'>
                        <Tooltip className="tooltip_css" id="my-tooltip02" style={{ "fontSize": "12px" }} />
                        <a data-tooltip-id="my-tooltip02" data-tooltip-html="Supprimer cette ligne de filtre">
                            &nbsp; <MdRemoveCircleOutline onClick={(e) => {
                                setp_filtre1();
                                setp_filtre1_value();
                            }}
                            />
                        </a>
                    </div>}


                </div>

                {p_filtre2 &&
                    <div className="div_row" style={{ "marginBottom": "5px" }}>
                        <div className="div_row_gauche texte_area_filter">
                            <TextField
                                name="filtre2"
                                label="Choisir un champ"
                                select
                                sx={{ m: 1, width: '100%' }}
                                options={filters}
                                value={p_filtre2}
                                onChange={(e) => {
                                    setp_filtre2(e.target.value)
                                }}
                            >

                                <MenuItem value="email" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Email &nbsp;&nbsp;</MenuItem>
                                <MenuItem value="nom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Nom &nbsp;</MenuItem>
                                <MenuItem value="prenom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Prénom &nbsp;</MenuItem>

                            </TextField>
                        </div>
                        <div className="div_row_droite texte_area_filter" >
                            {String(p_filtre2).length > 3 &&
                                <TextField
                                    sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                    required
                                    name="filtre2_value"
                                    id="filtre2_value"

                                    InputLabelProps={{
                                        shrink: true,
                                    }}
                                    disabled={false}
                                    className="disabled_style"
                                    value={p_filtre2_value}
                                    onChange={(e) => setp_filtre2_value(e.target.value)}
                                    InputProps={{
                                        endAdornment: (
                                            <InputAdornment position="end">
                                                <AiFillCloseCircle
                                                    style={{ 'cursor': "pointer", "color": "orangered" }}
                                                    onClick={(e) => {
                                                        setp_filtre2_value("");
                                                    }} />
                                            </InputAdornment>
                                        ),
                                    }}

                                />}
                        </div>


                        {String(p_filtre2).length > 3 && <div className='filter_bton_add'>
                            <Tooltip className="tooltip_css" id="my-tooltip04" style={{ "fontSize": "12px" }} />
                            <a data-tooltip-id="my-tooltip04" data-tooltip-html="Supprimer cette ligne de filtre">
                                &nbsp; <MdRemoveCircleOutline
                                    onClick={(e) => {
                                        setp_filtre2();
                                        setp_filtre2_value();
                                    }}
                                />
                            </a>
                        </div>}
                    </div>
                }


                {<div className="div_row" 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_All_Apprenant"}>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>}

            </div>
            <br />*/}

            <div className="div_row">
                <nav style={{ width: '80%', float: 'right', textAlign: "right", marginTop: "10px", paddingRight:'10px' }}>
                    <nav className="mode_affichage" onClick={(event) => {
                        setaffichage_class("grid")
                    }}> <BiSolidGrid /> </nav>


                    <nav className="mode_affichage" onClick={(event) => {
                        setaffichage_class("list")
                    }}> <CiBoxList /> </nav>

                </nav>

            </div>


            {
                affichage_class && String(affichage_class) === "list" && <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',
                                        fontFamily: "Plus Jakarta Sans, sans-serif", color: '#EEF1F6',

                                        // Gestion des cellule a distance ou presentiel
                                        '& .cell--distantiel': {
                                            backgroundColor: '#AFE1AF',
                                            color: 'black',
                                        },

                                        '& .cell--presentiel': {
                                            backgroundColor: '#AFE1AF',
                                            color: 'black',
                                        },


                                        // gestion couleur des lignes avec le statut d'inscription
                                        '& .line--statut--annule': {
                                            backgroundColor: '#D8D8D8',
                                            color: 'white',
                                        },

                                        '& .line--statut--inscrit': {
                                            backgroundColor: '#CEF6D8',
                                            color: 'black',
                                        },
                                        '& .line--statut--preinscrit': {
                                            backgroundColor: '#F7F2E0',
                                            color: 'black',
                                        },


                                        /*"& .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(newSelectionModel);
                                            /*if (newSelectionModel.length === 1)
                                                handleClick_edit_employee_From_Line(newSelectionModel);*/
                                            if (newSelectionModel.length !== 1) {
                                                //    setsubmenu();

                                            }
                                        }}
                                        selectionModel={selectionModel}

                                        localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
                                        rows={New_Get_List_Ent_Formation_result.map((item, index) => (
                                            {
                                                id: index,
                                                _id: (item)._id,
                                                title: (item).title,
                                                external_code: (item).external_code,
                                                objectif: (item).objectif,
                                                programme: (item).programme,
                                                prerequis: (item).prerequis,
                                                description: (item).description,

                                                associated_session_id: (item).associated_session_id,
                                                associated_inscription_id: (item).associated_inscription_id,
                                                session_code_session: (item).session_code_session,
                                                session_date_debut: (item).session_date_debut,
                                                session_date_fin: (item).session_date_fin,
                                            }
                                        ))}

                                        columns={columns_ent_mes_formations}
                                        pageSize={10}
                                        className="datagridclass"

                                        onRowDoubleClick={(newSelectionModel) => {
                                            setselected_id(newSelectionModel.row._id);
                                            setgridline_id(newSelectionModel.row.id);
                                            setselected_session_id(newSelectionModel.row.associated_session_id);
                                            setselected_inscription_id(newSelectionModel.row.associated_inscription_id);

                                            setselected_class_external_code(newSelectionModel.row.external_code);
                                            setselected_code_session(newSelectionModel.row.session_code_session);


                                            submenu_detail();

                                            Get_Given_Class_Data(newSelectionModel.row._id);
                                            Get_List_UE_From_Class_Id(newSelectionModel.row.class_id);
                                            Getall_Class_List_Evalution(newSelectionModel.row.class_id);
                                            handleClick_Class_Selected_From_Line(newSelectionModel.row.associated_session_id, newSelectionModel.row.associated_inscription_id);
                                        }}

                                        rowsPerPageOptions={[10]}
                                        disableSelectionOnClick
                                        components={{
                                            Toolbar: GridToolbar,
                                        }}
                                        //sx={datagridSx}
                                        getCellClassName={(params) => {

                                            if (params.field === 'distantiel' && String(params.value) === "1") {
                                                return 'cell--distantiel';
                                            }
                                            if (params.field === "presentiel" && String(params.value) == "1") {
                                                return 'cell--presentiel';
                                            }


                                            //field === "statut"
                                            if (params.field === "status" && String(params.value) == "0") {
                                                return 'cell--statut--preinscrit';
                                            }

                                            if (params.field === "status" && String(params.value) == "1") {
                                                return 'cell--statut--inscrit';
                                            }

                                            if (params.field === "status" && String(params.value) == "-1") {
                                                return 'cell--statut--annule';
                                            }

                                        }}
                                        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';
                                            }

                                            if (String(params.row.status) === "-1") {
                                                return 'line--statut--annule';
                                            }
                                            if (String(params.row.status) === "0") {
                                                return 'line--statut--preinscrit';
                                            }
                                            if (String(params.row.status) === "1") {
                                                return 'line--statut--inscrit';
                                            }
                                        }}
                                        getEstimatedRowHeight={() => 200}
                                        getRowHeight={() => "auto"}
                                        sx={{
                                            "& .MuiDataGrid-cellContent": {
                                                minHeight: 50,

                                            }
                                        }}
                                    />
                                </Box>
                                <br />

                            </div>

                        </div>

                    </div>

                </div>
            }

            {
                affichage_class && String(affichage_class) === "grid" && <div className="div_row" style={{ paddingRight: '10px' }}>

                    <div style={{ width: '100%', float: 'left', }}>
                        <div className="block_display_flex_formation">

                            {New_Get_List_Ent_Formation_result && New_Get_List_Ent_Formation_result.map((formation) => (
                                <div className="block_formation" >
                                    <Ent_Student_Affichage_Ftion_Grid formation={(formation)} key={(formation).title}
                                        session_id={formation.associated_session_id}
                                        inscription_id={formation.associated_inscription_id}
                                        formation_id={formation._id}
                                        formationid={formation.id}
                                        class_id={formation.class_id}
                                        display_detail_from_grid={display_detail_from_grid}

                                    />
                                </div>
                            ))}


                        </div>
                    </div>

                </div>
            }
            <div className="div_row" ref={myRef_detail} id="myRef_detail"> &nbsp;</div>
            {
                selected_id && String(selected_id).length > "5" && <div className="div_row">
                    <Button variant="outlined" onClick={submenu_detail} className="detail_class_submenu" id='detail' name='detail'>Détail</Button>
                    <Button variant="outlined" onClick={submenu_planning} className="detail_class_submenu" id='planning' name='planning'>Planning </Button>
                    <Button variant="outlined" onClick={submenu_notes} className="detail_class_submenu" id='notes' name='notes'>Notes </Button>
                    <Button variant="outlined" onClick={submenu_piece_jointe} className="detail_class_submenu" id='piece_jointe' name='contrat'>Pièces Jointes  </Button>
                </div>
            }
            {selected_id && String(selected_id).length > 0 && <div className="div_row">
                <nav style={{ textAlign: 'center', padding: '10px', fontFamily: 'DM Sans' }}> Formation &nbsp; &nbsp; :  <b>{selected_class_external_code} - {selected_code_session} </b> &nbsp; </nav>
            </div>}


            {
                String(submenu) === "detail" && Get_Given_Class_Data_result && Get_Given_Class_Data_result.length > 0 && <div className="div_row" >
                    <div className="block_central" >
                        <div className="block_central_gauche">

                            <br />
                            <div className="block_info_page_pave_title_desc">
                                <div className="block_info_page_pave_title_desc_title">  Description

                                </div>
                                {JSON.parse(Get_Given_Class_Data_result).description && <div className="block_info_page_pave_title_desc description_block">
                                    {parse(String(JSON.parse(Get_Given_Class_Data_result).description))}

                                </div>
                                }
                            </div>
                            <br />

                            <br />
                            <div className="block_info_page_pave_title_desc">
                                <div className="block_info_page_pave_title_desc_title">  Objectif
                                </div>
                                {JSON.parse(Get_Given_Class_Data_result).objectif && <div className="block_info_page_pave_title_desc description_block">
                                    {parse(String(JSON.parse(Get_Given_Class_Data_result).objectif))}

                                </div>}

                            </div>
                            <br />


                            <div className="block_info_page_pave_title_desc_long_text" >
                                <div className="block_info_page_pave_title_desc_title">
                                    Programme
                                </div>
                                {JSON.parse(Get_Given_Class_Data_result).programme && <div className="block_info_page_pave_title_desc description_block">
                                    {parse(String(JSON.parse(Get_Given_Class_Data_result).programme))}

                                </div>
                                }
                            </div>

                        </div>
                    </div>


                </div>
            }

            {
                String(submenu) === "planning" && Get_Given_Class_Data_result && Get_Given_Class_Data_result.length > 0 && <div className="div_row">
                    <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Planning </nav>
                    <div className="div_row" style={{ "border": "None" }}></div>
                    &nbsp;

                    <div style={{ "width": "98%", "marginLeft": "5px", }}>
                        <FullCalendar
                            height={550}
                            locales={allLocales}
                            locale={'fr'}
                            editable
                            selectable
                            //events={events}
                            events={Getall_Sequence_Of_Session_result_planning_view}

                            select={handleSelect}
                            headerToolbar={{
                                start: "today prev next",
                                center: "title",
                                end: "dayGridMonth,timeGridWeek,timeGridDay",
                            }}
                            //eventContent={(info) => <EventItem info={info} />}
                            //plugins={[timeGridPlugin]}
                            plugins={[timeGridPlugin, daygridPlugin, interactionPlugin]}
                            views={["dayGridMonth", "dayGridWeek", "dayGridDay"]}
                            slotMinTime={Partner_Debut_Journee}
                            slotMaxTime={Partner_Fin_Journee}
                            scrollTime='08:00'
                            displayEventEnd={true}
                            eventContent={renderEventContent}
                            eventClick={handleEventClick}


                        />
                    </div>

                </div>
            }

            {
                String(submenu) === "notes" && Get_Given_Class_Data_result && Get_Given_Class_Data_result.length > 0 && <div className="div_row" >
                    <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Notes </nav>
                    <div className="div_row" style={{ "border": "None" }}></div>
                    &nbsp;
                    {<div className="div_row" style={{ "border": "None", "background": '#F8F9F9', "padding": '5px' }}>


                        <nav style={{ "border": "None", "fontSize": "20px", "paddingTop": "5px", "paddingLeft": "5px", fontFamily: 'DM Sans' }}> Les notes </nav>


                        <div className="div_row" style={{ "textAlign": "right", "marginTop": "0.5rem" }}>
                            <Button className="bton_emarge" onClick={(event) => {
                                //  Export_Inscrit_Notes();
                            }}>Exporter (excel)</Button>
                        </div>

                        <div className="session_data">
                            <div style={{ "border": "None", paddingRight: '10px' }}>

                                <div style={{ height: 550, width: '100%', paddingRight: '5px' }}>
                                    &nbsp;
                                    <Box
                                        sx={{
                                            height: 500,
                                            width: '100%',
                                            paddingRight: '1px',



                                            "& .MuiDataGrid-columnHeaders": {
                                                backgroundColor: "#c8cfd5",
                                                color: "black",
                                                fontSize: 14
                                            },


                                            '& .line--statut--pair': {
                                                backgroundColor: 'rgba(235, 235, 235, .7)',
                                                color: 'black',
                                            },
                                            '& .line--statut--impair': {
                                                backgroundColor: '#FFFFFF',
                                                color: 'black',
                                            },
                                            '& .line--statut--selected': {
                                                backgroundColor: '#FBF2EF',
                                                color: 'black',
                                            },

                                        }}
                                    >
                                        <DataGrid
                                            checkboxSelection

                                            onSelectionModelChange={(newSelectionModel) => {
                                                setselectionModel_notes(newSelectionModel);
                                                /*if (newSelectionModel.length === 1)
                                                    handleClick_edit_session_From_Line(newSelectionModel);*/
                                                if (newSelectionModel.length !== 1) {

                                                }
                                            }}
                                            selectionModel={selectionModel_notes}

                                            localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
                                            rows={Get_Inscrit_Notes_Of_Evaluations_result.map((item, index) => (
                                                {
                                                    id: index,
                                                    _id: JSON.parse(item)._id,
                                                    evaluation_id: JSON.parse(item).evaluation_id,
                                                    inscription_id: JSON.parse(item).inscription_id,
                                                    note_evaluation_id: JSON.parse(item).note_evaluation_id,
                                                    class_eu_id: JSON.parse(item).class_eu_id,
                                                    type_eval_id: JSON.parse(item).type_eval_id,
                                                    class_ue_code: JSON.parse(item).class_ue_code,
                                                    class_ue_titre: JSON.parse(item).class_ue_titre,
                                                    note_evaluation_code: JSON.parse(item).note_evaluation_code,
                                                    eval_date_heure_debut: JSON.parse(item).eval_date_heure_debut,
                                                    eval_date_heure_fin: JSON.parse(item).eval_date_heure_fin,
                                                    note: JSON.parse(item).note,

                                                }
                                            ))}

                                            columns={columns_notes}
                                            pageSize={10}
                                            className="datagridclass"

                                            onRowDoubleClick={(newSelectionModel) => {

                                            }}

                                            rowsPerPageOptions={[10]}
                                            disableSelectionOnClick
                                            components={{
                                                Toolbar: GridToolbar,
                                            }}
                                            //sx={datagridSx}
                                            getCellClassName={(params) => {
                                                //field === 'distantiel'
                                                if (params.field === 'distantiel' && String(params.value) === "1") {
                                                    return 'cell--distantiel';
                                                }
                                                if (params.field === "presentiel" && String(params.value) == "1") {
                                                    return 'cell--presentiel';
                                                }


                                                //field === "statut"
                                                if (params.field === "status" && String(params.value) == "0") {
                                                    return 'cell--statut--preinscrit';
                                                }

                                                if (params.field === "status" && String(params.value) == "1") {
                                                    return 'cell--statut--inscrit';
                                                }

                                                if (params.field === "status" && String(params.value) == "-1") {
                                                    return 'cell--statut--annule';
                                                }

                                            }}
                                            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"}

                                        />
                                    </Box>
                                    <br />

                                </div>


                            </div>

                        </div>


                    </div>}


                </div>
            }

            {String(submenu) === "piece_jointe" && Get_Given_Class_Data_result && Get_Given_Class_Data_result.length > 0 && <div className="div_row" style={{ "border": "None", "background": '#F8F9F9', "padding": '5px' }}>

                <div>
                    <div className="div_row" style={{ "border": "None" }}>
                        <hr className="hr_break" />
                    </div>

                    <div className="div_row" style={{ "border": "None", "fontSize": "22px", "fontWeight": "600", "padding": "5px" }}>
                        Pièces jointes

                    </div>

                    {/* <div className="div_row" style={{ "padding": "5px" }}>

                        <div style={{ "fontSize": "12px" }}>
                            <label htmlFor="upload-photo">
                                <input
                                    style={{ display: "none" }}
                                    id="upload-photo"
                                    name="upload-photo"
                                    type="file"
                                    onChange={sessions_file_change_1}
                                />

                                <Fab
                                    color="secondary"
                                    size="small"
                                    component="span"
                                    aria-label="add"
                                    variant="extended"
                                >
                                    <IoMdAddCircle /> <nav style={{ "fontSize": "12px" }}> Ajouter un fichier </nav>
                                </Fab>

                            </label>
                        </div>
                        {file_1_name && file_1_name.name &&
                            <nav style={{ "fontSize": "12px" }}>
                                <div className="session_caract">Nom du fichier <br />
                                    <TextField
                                        name="file_to_download_type_name"
                                        id="file_to_download_type_name"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}

                                        disabled={false}
                                        className="disabled_style enable_style"
                                        value={p_detail_one_file_to_download_type_name}
                                        onChange={(e) => {
                                            setp_detail_one_file_to_download_type_name(e.target.value);

                                        }}
                                    />

                                </div>
                                <br />
                                <br />
                                Fichier : {file_1_name.name} <br /> <font style={{ "cursor": "pointer" }}
                                    onClick={Delete_file_1_name}>  Supprimer <IoIosRemoveCircleOutline />  </font>
                            </nav>}

                        {Record_All_PJ_api && String(Record_All_PJ_api) === "true" && <div className="okUpdateData"> Pièce jointe enregistrée </div>}

                        {Record_All_PJ_api && String(Record_All_PJ_api) === "false" && <div className="koUpdateData"> {Record_All_PJ_message} </div>}


                    </div>*/}


                    {/*file_1_name && file_1_name.name && <div className="div_row">

                        <div className="div_row_gauche">
                            <Button variant="contained" onClick={Record_All_PJ}
                                startIcon={<AiTwotoneSave />} className="bton_enreg">ENREGISTRER LA PIECE</Button>
                        </div>


                    </div>*/}

                    {Get_List_Of_All_PJ_result && <div className="div_row" style={{ "padding": "5px" }}>
                        <div className="div_row">
                            Liste des pièces jointes <br />
                            <div className="div_row">
                                {Get_List_Of_All_PJ_result && Get_List_Of_All_PJ_result.map((val) => (
                                    <div className="div_row_list_pj" style={{ fontFamily: "DM Sans", fontSize: '14px' }}>
                                        <nav style={{ "color": "green", "cursor": "pointer" }} onClick={Download_one_attached_document} name={(JSON.parse(val).file_name)} id={(JSON.parse(val).file_name)}> Télécharger &nbsp;<i> {(JSON.parse(val).file_business_object)}</i> </nav> <br />
                                        {/*<Popup
                                            trigger={
                                                <nav style={{ "color": "red", "cursor": "pointer" }}  > Supprimer</nav>


                                            }
                                            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, la pièce jointe sera <i><font color="red"> définitivement supprimée</font></i>. <br />


                                                    </div>
                                                    <div className="gest_actions">
                                                        <div style={{ "width": "45%", "float": "left" }}>
                                                            <button className="gest_bton_popup" onClick={(event) => {

                                                                Delete_one_attached_document(event);
                                                                close();
                                                            }}
                                                                name={(JSON.parse(val).file_name)} id={(JSON.parse(val).file_name)}
                                                            > 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>*/}

                                    </div>
                                ))}
                            </div>
                        </div>
                    </div>}


                </div>
            </div>}


        </div >
    );
}

export default Module_Ent_Mes_Formations;