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 CheckOut from "./CheckOut";
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 parse from 'html-react-parser';
import { FcViewDetails, FcDisapprove } from "react-icons/fc";
import 'react-tooltip/dist/react-tooltip.css'
import { Tooltip } from 'react-tooltip'
import add_plus from "../mysy_img/plus.png";
import excel_icone from "../mysy_img/excel_icone.png";
import participants from "../mysy_img/participants.png";
import fileDownload from 'js-file-download'
import Popup from 'reactjs-popup';
import 'reactjs-popup/dist/index.css';
import { FcCancel, FcApproval, FcAcceptDatabase, FcPrint } from "react-icons/fc";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { format } from 'date-fns'
import moment from "moment";
import InputAdornment from '@mui/material/InputAdornment';
import { AiFillCloseCircle } from "react-icons/ai";
import Box from '@mui/material/Box';
import { Typography, LinearProgress } from '@mui/material';
import styled from 'styled-components';
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 { TransitionProps } from '@mui/material/transitions';

const Employes = (props) => {
    const history = useHistory();
    const [submenu, setsubmenu] = useState("");
    const [rowss, setRows] = useState([]);
    const [selectionModel, setSelectionModel] = React.useState([]);

    const [rows_affectations, setrows_affectations] = useState([]);
    const [selectionModel_affectations, setSelectionModel_affectations] = React.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 columns = [
        { field: '_id', headerName: '_id', hide: true },
        { field: 'id', headerName: 'id', hide: true },
        { field: 'email', headerName: 'email', width: 150, hideable: false, },
        { field: 'nom', headerName: 'nom', width: 150, hide: false, editable: true },
        { field: 'prenom', headerName: 'prenom', width: 150, hide: false, editable: true },
        {
            field: 'ismanager', headerName: 'Manager', width: 150, hide: false, editable: true,
            valueFormatter: (params) => {
                if (String(params.value) === "0")
                    return "Non";
                else if (String(params.value) === "1")
                    return "Oui";

                else
                    return String(params.value);
            },
        },
        { field: 'telephone_mobile', headerName: 'Mobile', width: 150, hide: false, editable: true },
        {
            field: 'civilite', headerName: 'Civilité', width: 150, hide: false, editable: true,
            valueFormatter: (params) => {
                if (String(params.value) === "0")
                    return "Mme";
                else if (String(params.value) === "1")
                    return "M";
                else if (String(params.value) === "-1")
                    return " ";
                else
                    return String(params.value);
            },
        },
        { field: 'profil', headerName: 'profil', width: 150, hide: false, editable: true },
        { field: 'fonction', headerName: 'Fonction', width: 150, hide: false, editable: true },

        /* {
             field: "Detail", headerName: 'Voir detail',
             renderCell: (cellValues) => {
                 return (
 
                     <Button
 
                         onClick={(event) => {
                             Display_Detail_Employe(event, cellValues);
                         }}
                     >
                         <FcViewDetails />
 
                     </Button>
 
                 );
             }
         },*/
        {
            field: "delete", headerName: 'Supprimer',
            renderCell: (cellValues) => {
                return (

                    <Popup
                        trigger={<Button

                            onClick={(event) => {
                                // handleClick_delete(event, cellValues);
                            }}
                        >
                            <CiTrash />

                        </Button>}
                        modal
                        nested
                        position="center center"
                    >
                        {close => (
                            <div>
                                <button className="gest_close" onClick={close}>
                                    &times;
                                </button>
                                <div className="gest_header"> MySy Information </div>
                                <div className="gest_content">
                                    {' '}

                                    En confirmant cette opération, l'employé sera <i><font color="red"> définitivement supprimé</font></i>. <br />

                                </div>
                                <div className="gest_actions">
                                    <div style={{ "width": "45%", "float": "left" }}>
                                        <button className="gest_bton_popup" onClick={(event) => {
                                            handleClick_delete(event, cellValues);
                                            //console.log('modal closed ');
                                            close();
                                        }}> Valider </button>

                                    </div>
                                    <div style={{ "width": "45%", "float": "right" }}>
                                        <button
                                            className="gest_bton_popup"
                                            onClick={() => {
                                                //console.log('modal closed ');
                                                close();
                                            }}
                                        >
                                            Annuler
                                        </button>
                                    </div>
                                </div>
                            </div>
                        )}
                    </Popup>


                );
            }
        }

    ]

    const columns_employee_affectation = [
        { field: '_id', headerName: '_id', hide: true },
        { field: 'id', headerName: 'id', hide: true },
        { field: 'poste', headerName: 'Poste', width: 150, hideable: false, },
        { field: 'date_du', headerName: 'Du', width: 150, hide: false, editable: true },
        { field: 'date_au', headerName: 'Au', width: 150, hide: false, editable: true },
        { field: 'related_target_collection_object', headerName: 'Cible', width: 150, hide: false, editable: true },
        { field: 'related_target_collection_id_nom', headerName: 'Cible Nom', width: 150, hide: false, editable: true },
        { field: 'target_related_collection', headerName: 'Type', hide: true },
        { field: 'target_related_collection_id', headerName: 'Type ID', hide: true },
        {
            field: "delete", headerName: 'Supprimer',
            renderCell: (cellValues) => {
                return (

                    <Popup
                        trigger={<Button

                            onClick={(event) => {
                                //handleClick_delete(event, cellValues);
                            }}
                        >
                            <CiTrash />

                        </Button>}
                        modal
                        nested
                        position="center center"
                    >
                        {close => (
                            <div>
                                <button className="gest_close" onClick={close}>
                                    &times;
                                </button>
                                <div className="gest_header"> MySy Information </div>
                                <div className="gest_content">
                                    {' '}

                                    En confirmant cette opération, la fonction 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) => {
                                            handleClick_delete_affection(event, cellValues);
                                            //console.log('modal closed ');
                                            close();
                                        }}> Valider </button>

                                    </div>
                                    <div style={{ "width": "45%", "float": "right" }}>
                                        <button
                                            className="gest_bton_popup"
                                            onClick={() => {
                                                //console.log('modal closed ');
                                                close();
                                            }}
                                        >
                                            Annuler
                                        </button>
                                    </div>
                                </div>
                            </div>
                        )}
                    </Popup>


                );
            }
        }


    ]
    function clean_all_filters() {
        setp_filtre1();
        setp_filtre1_value();

        setp_filtre2();
        setp_filtre2_value();

        setp_filtre3();
        setp_filtre3_value();

        setp_filtre4();
        setp_filtre4_value();

        setdisplay_affectation("");
        setAdd_new_affectation("");
        clean_affectation_fields();
        clean_nouvelle_affectation_fields();
        setSelectionModel_affectations([]);
        setSelectionModel([]);
        setsubmenu("");

        Getall_Training_Employee_No_Filter();
    }

    const myRef = useRef(null)

    const [Dialog_1_message, setDialog_1_message] = React.useState(false);
    const [Dialog_1_open, setDialog_1_open] = React.useState(false);
    function Dialog_1_handle_change_participant_session(message) {
        setDialog_1_message(message);
        setDialog_1_open(true);
    }

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

    const Dialog_1_handleClose_buton = () => {
        setDialog_1_open(false);
    };


    useEffect(() => {
        Getall_Training_Employee_No_Filter();
        Get_List_Managers();
        Get_List_RH_Profils();
        Get_Employee_Related_Target_Collection_Data();

    }, [])


    const [display_detail_employe, setdisplay_detail_employe] = React.useState();

    const [selected_id, setselected_id] = useState("");
    const [selected_employe_email, setselected_employe_email] = useState("");
    function handleClick_edit_employee_From_Line(selected_row_id) {

        submenu_detail_employe();

        var line = JSON.parse(rowss[selected_row_id]);

        //console.log("### line = ", line);
        var employe_id = line._id;
        setselected_id(employe_id);

        var employe_email = line.email;
        setselected_employe_email(employe_email);

        //console.log(" ### employe_id  = ", employe_id);
        Display_Detail_Employe(employe_id);

        if (myRef.current) {
            myRef.current.scrollIntoView({ behavior: "smooth" });
        }

        Getall_Employee_Affectation(employe_id);
    }


    const [Add_new_affectation, setAdd_new_affectation] = useState();

    const [selected_affectation_id, set_selected_affectation_id] = useState();
    function handleClick_edit_affectation_From_Line(selected_row_id) {
        setdisplay_affectation("1");
        setAdd_new_affectation("");
        clean_affectation_fields();
        clean_nouvelle_affectation_fields();
        setsubmenu("");

        var line = JSON.parse(rows_affectations[selected_row_id]);

        //console.log("### line = ", line);
        var affectation_id = line._id;
        set_selected_affectation_id(affectation_id);


        if (myRef_affectation.current) {
            myRef_affectation.current.scrollIntoView({ behavior: "smooth" });
        }

        Get_Given_Employee_Affectation(affectation_id);

    }


    function Display_Detail_Employe(employee_id) {
        //clearDetailAttendeFields();
        setadd_One_Employee();
        setdisplay_detail_employe("1");

        Get_Employee_Data(employee_id);
        get_Employee_Images(employee_id);
    }


    function handleClick_delete(event, cellValues) {

        var local_rh_id = cellValues.row._id;

        Delete_Employee(local_rh_id);
    }


    function handleClick_delete_affection(event, cellValues) {

        var local_affectation_id = cellValues.row._id;

        Delete_affection(selected_id, local_affectation_id);
    }



    const [p_detail_nom, setp_detail_nom] = useState();
    const [p_detail_prenom, setp_detail_prenom] = useState();
    const [p_detail_mail, setp_detail_mail] = useState();
    const [p_detail_tel, setp_detail_tel] = useState();
    const [p_detail_adresse, setp_detail_adresse] = useState();
    const [p_detail_code_postal, setp_detail_code_postal] = useState();
    const [p_detail_ville, setp_detail_ville] = useState();
    const [p_detail_resp_hierarchie_id, setp_detail_resp_hierarchie_id] = useState();
    const [p_detail_civilite, setp_detail_civilite] = useState();
    const [p_detail_civilite_label, setp_detail_civilite_label] = useState();
    const [p_detail_fonction, setp_detail_fonction] = useState();
    const [p_detail_profil, setp_detail_profil] = useState();
    const [p_detail_pays, setp_detail_pays] = useState();
    const [p_detail_tel_mobile, setp_detail_tel_mobile] = useState();
    const [p_detail_linkedIn, setp_detail_linkedIn] = useState();
    const [p_detail_facebook, setp_detail_facebook] = useState();
    const [p_detail_twitter, setp_detail_twitter] = useState();
    const [p_detail_ismanager, setp_detail_ismanager] = useState();
    const [p_detail_ismanager_label, setp_detail_ismanager_label] = useState();
    const [p_detail_resp_hierarchie_nom, setp_detail_resp_hierarchie_nom] = useState();
    const [p_detail_resp_hierarchie_prenom, setp_detail_resp_hierarchie_prenom] = useState();


    const [p_one_detail_nom, setp_one_detail_nom] = useState();
    const [p_one_detail_prenom, setp_one_detail_prenom] = useState();
    const [p_one_detail_mail, setp_one_detail_mail] = useState();
    const [p_one_detail_tel, setp_one_detail_tel] = useState();
    const [p_one_detail_adresse, setp_one_detail_adresse] = useState();
    const [p_one_detail_code_postal, setp_one_detail_code_postal] = useState();
    const [p_one_detail_ville, setp_one_detail_ville] = useState();
    const [p_one_detail_resp_hierarchie_id, setp_one_detail_resp_hierarchie_id] = useState();
    const [p_one_detail_civilite, setp_one_detail_civilite] = useState();
    const [p_one_detail_fonction, setp_one_detail_fonction] = useState();
    const [p_one_detail_profil, setp_one_detail_profil] = useState();
    const [p_one_detail_profil_label, setp_one_detail_profil_label] = useState();
    const [p_one_detail_pays, setp_one_detail_pays] = useState();
    const [p_one_detail_tel_mobile, setp_one_detail_tel_mobile] = useState();
    const [p_one_detail_linkedIn, setp_one_detail_linkedIn] = useState();
    const [p_one_detail_facebook, setp_one_detail_facebook] = useState();
    const [p_one_detail_twitter, setp_one_detail_twitter] = useState();
    const [p_one_detail_ismanager, setp_one_detail_ismanager] = useState();
    const [p_one_detail_ismanager_label, setp_one_detail_ismanager_label] = useState();
    const [p_one_detail_resp_hierarchie_nom, setp_one_detail_resp_hierarchie_nom] = useState();
    const [p_one_detail_resp_hierarchie_prenom, setp_one_detail_resp_hierarchie_prenom] = useState();


    const [employee_data_changed, setemployee_data_changed] = useState("");
    const [employee_data_edit_mode, setemployee_data_edit_mode] = useState("");

    const [GetAttendee_api, setGetAttendee_api] = useState();
    const [GetAttendee_message, setGetAttendee_message] = useState();
    const [GetAttendee_result, setGetAttendee_result] = useState();
    function Get_Employee_Data(employe_id) {
        setemployee_data_changed("");
        setemployee_data_edit_mode("");
        setisimgclassSelected();
        setuserimgclassprofil();
        setisimgclassSelected_recid();

        var form = new FormData();

        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("_id", employe_id);


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

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

            if (String(res.data.status) === "true") {
                //console.log(" In Get_Employee_Data  res.data.status = " + res.data.status);
                //console.log(" In Get_Employee_Data  res.data.message r_class = " + res.data.message);
                setGetAttendee_api("true");
                setGetAttendee_result(res.data.message);

                if (res.data.message.length > 0) {
                    var mylocal_employe = JSON.parse(res.data.message);



                    document.getElementsByName("detail_nom")[0].value = "";
                    if (mylocal_employe.nom)
                        setp_detail_nom(mylocal_employe.nom);

                    document.getElementsByName("detail_prenom")[0].value = "";
                    if (mylocal_employe.prenom)
                        setp_detail_prenom(mylocal_employe.prenom);

                    document.getElementsByName("detail_mail")[0].value = "";
                    if (mylocal_employe.email) {
                        setp_detail_mail(mylocal_employe.email);
                    }

                    document.getElementsByName("detail_tel_mobile")[0].value = "";
                    if (mylocal_employe.telephone_mobile) {
                        setp_detail_tel_mobile(mylocal_employe.telephone_mobile);
                    }

                    document.getElementsByName("detail_civilite")[0].value = "";
                    if (mylocal_employe.civilite) {
                        setp_detail_civilite(mylocal_employe.civilite);

                        if (String(mylocal_employe.civilite) === "1")
                            setp_detail_civilite_label("M.");
                        else if (String(mylocal_employe.civilite) === "0")
                            setp_detail_civilite_label("Mme.");
                        else if (String(mylocal_employe.civilite) === "-1")
                            setp_detail_civilite_label("Neutre");
                        else
                            setp_detail_civilite_label("?");


                    }


                    document.getElementsByName("detail_tel")[0].value = "";
                    if (mylocal_employe.telephone) {
                        setp_detail_tel(mylocal_employe.telephone);
                    }

                    document.getElementsByName("detail_adresse")[0].value = "";
                    if (mylocal_employe.adr_adresse) {
                        setp_detail_adresse(mylocal_employe.adr_adresse);
                    }

                    document.getElementsByName("detail_code_postal")[0].value = "";
                    if (mylocal_employe.adr_code_postal) {
                        setp_detail_code_postal(mylocal_employe.adr_code_postal);
                    }

                    document.getElementsByName("detail_ville")[0].value = "";
                    if (mylocal_employe.adr_ville) {
                        setp_detail_ville(mylocal_employe.adr_ville);
                    }


                    document.getElementsByName("detail_pays")[0].value = "";
                    if (mylocal_employe.adr_pays) {
                        setp_detail_pays(mylocal_employe.adr_pays);
                    }

                    document.getElementsByName("detail_linkedin")[0].value = "";
                    if (mylocal_employe.linkedin) {
                        setp_detail_linkedIn(mylocal_employe.linkedin);
                    }

                    document.getElementsByName("detail_facebook")[0].value = "";
                    if (mylocal_employe.facebook) {
                        setp_detail_facebook(mylocal_employe.facebook);
                    }

                    document.getElementsByName("detail_twitter")[0].value = "";
                    if (mylocal_employe.twitter) {
                        setp_detail_twitter(mylocal_employe.twitter);
                    }

                    document.getElementsByName("detail_profil")[0].value = "";
                    if (mylocal_employe.ville) {
                        setp_detail_profil(mylocal_employe.profil);
                    }

                    document.getElementsByName("detail_fonction")[0].value = "";
                    if (mylocal_employe.fonction) {
                        setp_detail_fonction(mylocal_employe.fonction);
                    }


                    document.getElementsByName("detail_ismanager")[0].value = "";
                    if (mylocal_employe.ismanager) {
                        setp_detail_ismanager(mylocal_employe.ismanager);
                        if (String(mylocal_employe.ismanager) === "1")
                            setp_detail_ismanager_label("Oui");
                        else
                            setp_detail_ismanager_label("Non");
                    }

                    document.getElementsByName("detail_resp_hierarchie_id")[0].value = "";
                    if (mylocal_employe.superieur_hierarchie_id) {
                        setp_detail_resp_hierarchie_id(mylocal_employe.superieur_hierarchie_id);
                        setp_detail_resp_hierarchie_nom(mylocal_employe.superieur_hierarchie_nom);
                        setp_detail_resp_hierarchie_prenom(mylocal_employe.superieur_hierarchie_prenom);
                    }




                    disable_Employee_DetailFields();
                } else {
                    alert(" Aucun employé recuperé");
                }


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

            else {
                setGetAttendee_api("false");
                setGetAttendee_message(res.data.message);
                alert(res.data.message);
            }

        }).catch((error) => {
            console.warn('Not good man :( Get_Employee_Data = ', error);
            setGetAttendee_api("false");
            alert(" Impossible de recuperer les données de l'employé");
            //setmyApimyApiMessage("")
        })
    }



    const [Getall_Training_Employee_api, setGetall_Training_Employee_api] = useState();
    const [Getall_Training_Employee_message, setGetall_Training_Employee_message] = useState();
    const [Getall_Training_Employee_result, setGetall_Training_Employee_result] = useState();
    function Getall_Training_Employee(event) {

        var form = new FormData();


        // Recuperation des parametres
        var filtre1 = p_filtre1;
        var filtre2 = p_filtre2;
        var filtre3 = p_filtre3;
        var filtre4 = p_filtre4;

        var filtre1_value = "";
        var filtre2_value = "";
        var filtre3_value = "";
        var filtre4_value = "";
        // Recuperation des valeurs de filtres

        if (p_filtre1_value) {
            filtre1_value = p_filtre1_value;
            form.append(filtre1, filtre1_value);
        }

        if (p_filtre2_value) {
            filtre2_value = p_filtre2_value;
            form.append(filtre2, filtre2_value);
        }

        if (p_filtre3_value) {
            filtre3_value = p_filtre3_value;
            form.append(filtre3, p_filtre3_value);
        }

        if (p_filtre4_value) {
            filtre4_value = p_filtre4_value;
            form.append(filtre4, p_filtre4_value);
        }


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);

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

        
        setdisplay_affectation("");
        setAdd_new_affectation("");
        clean_affectation_fields();
        clean_nouvelle_affectation_fields();
        setSelectionModel_affectations([]);
        setSelectionModel([]);
        setsubmenu("");
        setSelectionModel([]);

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

            if (String(res.data.status) === String("true")) {
                //console.log(" In Getall_Training_Employee  res.data.status = " + res.data.status);
                //console.log(" In Getall_Training_Employee  res.data.message r_class = " + res.data.message);
                setGetall_Training_Employee_api("true");
                setGetall_Training_Employee_result(res.data.message);
                setRows(res.data.message);
            }
            else {
                setGetall_Training_Employee_api("false");
                setGetall_Training_Employee_message(res.data.message);
            }

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


    const [Getall_Training_Employee_No_Filter_api, setGetall_Training_Employee_No_Filter_api] = useState();
    const [Getall_Training_Employee_No_Filter_message, setGetall_Training_Employee_No_Filter_message] = useState();
    const [Getall_Training_Employee_No_Filter_result, setGetall_Training_Employee_No_Filter_result] = useState();
    function Getall_Training_Employee_No_Filter(event) {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);

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



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

            if (String(res.data.status) === String("true")) {
                //console.log(" In Getall_Training_Employee_No_Filter  res.data.status = " + res.data.status);
                //console.log(" In Getall_Training_Employee_No_Filter  res.data.message r_class = " + res.data.message);
                setGetall_Training_Employee_No_Filter_api("true");
                setGetall_Training_Employee_No_Filter_result(res.data.message);
                setRows(res.data.message);
            }
            else {
                setGetall_Training_Employee_No_Filter_api("false");
                setGetall_Training_Employee_No_Filter_message(res.data.message);
                alert(res.data.message);
            }

        }).catch((error) => {
            console.warn('Not good man :( Getall_Training_Employee_No_Filter = ', error);
            setGetall_Training_Employee_No_Filter_api("false");
            alert(" Impossible de recuperer la liste des employés");
            //setmyApimyApiMessage("")
        })
    }

    const [session_file_name, setsession_file_name] = useState();

    const [liste_sessions_file_change_api, setliste_sessions_file_change_api] = useState();
    const [liste_sessions_file_change_result, setliste_sessions_file_change_result] = useState();
    const [liste_sessions_file_change_message, setliste_sessions_file_change_message] = useState();
    const liste_sessions_file_change = 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 =  ",file_size," file_type = ",file_type);
        if (file_size > 1000000) {
            alert("Le fichier ne doit pas depasser un 1 Méga octets");
            return;
        }

        setsession_file_name(event.target.files[0].name);

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

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

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

                //console.log(" ## result['status'] = ", result['status'])
                if (String(result['status']) === String("Err_Connexion")) {
                    alert('Erreur: ' + result['message']);
                    history.push("/Connexion");
                }

                else if (String(result['status']) === String("true")) {
                    //console.log('Success:', result['message']);
                    setliste_sessions_file_change_result(result['message']);
                    setliste_sessions_file_change_api("true");

                    Getall_Training_Employee();
                    alert(" Les employés ont été correctement importés");

                }

                else {
                    setliste_sessions_file_change_message(result['message']);
                    setliste_sessions_file_change_api("false");
                    alert('Erreur: ' + result['message']);

                }


            })
            .catch((error) => {
                console.error('Error:', error);
                setliste_sessions_file_change_api("false");
                alert(" Impossible d'importer les employés ");
            });
    }


    const [Get_Given_Employee_Affectation_api, setGet_Given_Employee_Affectation_api] = useState();
    const [Get_Given_Employee_Affectation_message, setGet_Given_Employee_Affectation_message] = useState();
    const [Get_Given_Employee_Affectation_result, setGet_Given_Employee_Affectation_result] = useState();
    function Get_Given_Employee_Affectation(local_affectation_id) {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("affectation_id", local_affectation_id);

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



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

            if (String(res.data.status) === String("true")) {
                console.log(" In Get_Given_Employee_Affectation  res.data.status = " + res.data.status);
                console.log(" In Get_Given_Employee_Affectation  res.data.message r_class = " + res.data.message);
                setGet_Given_Employee_Affectation_api("true");



                if (String(res.data.message).length > 0) {
                    setGet_Given_Employee_Affectation_result(res.data.message);
                    var mylocal_affectation = JSON.parse(res.data.message);

                    if (mylocal_affectation.poste) {
                        setp_affect_poste(mylocal_affectation.poste);
                    }

                    if (mylocal_affectation.date_du) {
                        setp_affect_date_du(mylocal_affectation.date_du);

                    }

                    if (mylocal_affectation.date_au) {
                        setp_affect_date_au(mylocal_affectation.date_au);
                    }

                    if (mylocal_affectation.related_target_collection) {
                        setp_affect_cible(mylocal_affectation.related_target_collection);
                        if (String(mylocal_affectation.related_target_collection) === "myclass")
                            setp_affect_cible_label("Formation");
                        else if (String(mylocal_affectation.related_target_collection) === "session_formation")
                            setp_affect_cible_label("Session formation");
                    }


                    if (mylocal_affectation.related_target_collection_id) {
                        setp_affect_cible_nom(mylocal_affectation.related_target_collection_id);
                        setp_affect_cible_nom_label(mylocal_affectation.related_target_collection_id_nom);
                    }

                    if (mylocal_affectation.comment) {
                        setp_affect_comment(mylocal_affectation.comment);
                    }


                } else {
                    alert(" Aucune donnée recuperée");
                }

                Disable_Detail_Affectation_Fields();
            }
            else {
                setGet_Given_Employee_Affectation_api("false");
                setGet_Given_Employee_Affectation_message(res.data.message);
                alert(res.data.message)
            }

        }).catch((error) => {
            console.warn('Not good man :( Get_Given_Employee_Affectation = ', error);
            setGet_Given_Employee_Affectation_api("false");
            alert(" Impossible de recuperer l'affectation de l'employé");
            //setmyApimyApiMessage("")
        })
    }


    const [Getall_Employee_Affectation_api, setGetall_Employee_Affectation_api] = useState();
    const [Getall_Employee_Affectation_message, setGetall_Employee_Affectation_message] = useState();
    const [Getall_Employee_Affectation_result, setGetall_Employee_Affectation_result] = useState();
    function Getall_Employee_Affectation(local_employe_id) {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("rh_id", local_employe_id);

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



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

            if (String(res.data.status) === String("true")) {
                //console.log(" In Getall_Employee_Affectation  res.data.status = " + res.data.status);
                //console.log(" In Getall_Employee_Affectation  res.data.message r_class = " + res.data.message);
                setGetall_Employee_Affectation_api("true");
                setGetall_Employee_Affectation_result(res.data.message);
                setrows_affectations(res.data.message);
            }
            else {
                setGetall_Employee_Affectation_api("false");
                setGetall_Employee_Affectation_message(res.data.message);
                alert(res.data.message)
            }

        }).catch((error) => {
            console.warn('Not good man :( Getall_Employee_Affectation = ', error);
            setGetall_Employee_Affectation_api("false");
            alert(" Impossible de recuperer les affectations de l'employé");
            //setmyApimyApiMessage("")
        })
    }


    const [Get_Employee_Related_Target_Collection_Data_api, setGet_Employee_Related_Target_Collection_Data_api] = useState();
    const [Get_Employee_Related_Target_Collection_Data_message, setGet_Employee_Related_Target_Collection_Data_message] = useState();
    const [Get_Employee_Related_Target_Collection_Data_result, setGet_Employee_Related_Target_Collection_Data_result] = useState();
    function Get_Employee_Related_Target_Collection_Data() {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);


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



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

            if (String(res.data.status) === String("true")) {
                //console.log(" In Get_Employee_Related_Target_Collection_Data  res.data.status = " + res.data.status);
                //console.log(" In Get_Employee_Related_Target_Collection_Data  res.data.message r_class = " + res.data.message);
                setGet_Employee_Related_Target_Collection_Data_api("true");
                setGet_Employee_Related_Target_Collection_Data_result(res.data.message);

            }
            else {
                setGet_Employee_Related_Target_Collection_Data_api("false");
                setGet_Employee_Related_Target_Collection_Data_message(res.data.message);
                alert(res.data.message)
            }

        }).catch((error) => {
            console.warn('Not good man :( Get_Employee_Related_Target_Collection_Data = ', error);
            setGet_Employee_Related_Target_Collection_Data_api("false");
            alert(" Impossible de recuperer les cibles d'affectation");
            //setmyApimyApiMessage("")
        })
    }

    function disable_Employee_DetailFields() {
        setemployee_data_edit_mode("0");

        if (document.getElementsByName("detail_nom")[0]) {
            document.getElementsByName("detail_nom")[0].disabled = true;
            document.getElementsByName("detail_nom")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("detail_prenom")[0]) {
            document.getElementsByName("detail_prenom")[0].disabled = true;
            document.getElementsByName("detail_prenom")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_mail")[0]) {
            document.getElementsByName("detail_mail")[0].disabled = true;
            document.getElementsByName("detail_mail")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("detail_tel")[0]) {
            document.getElementsByName("detail_tel")[0].disabled = true;
            document.getElementsByName("detail_tel")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("detail_adresse")[0]) {
            document.getElementsByName("detail_adresse")[0].disabled = true;
            document.getElementsByName("detail_adresse")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("detail_code_postal")[0]) {
            document.getElementsByName("detail_code_postal")[0].disabled = true;
            document.getElementsByName("detail_code_postal")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_ville")[0]) {
            document.getElementsByName("detail_ville")[0].disabled = true;
            document.getElementsByName("detail_ville")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_civilite")[0]) {
            document.getElementsByName("detail_civilite")[0].disabled = true;
            document.getElementsByName("detail_civilite")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_tel_mobile")[0]) {
            document.getElementsByName("detail_tel_mobile")[0].disabled = true;
            document.getElementsByName("detail_tel_mobile")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_pays")[0]) {
            document.getElementsByName("detail_pays")[0].disabled = true;
            document.getElementsByName("detail_pays")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_linkedin")[0]) {
            document.getElementsByName("detail_linkedin")[0].disabled = true;
            document.getElementsByName("detail_linkedin")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_facebook")[0]) {
            document.getElementsByName("detail_facebook")[0].disabled = true;
            document.getElementsByName("detail_facebook")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_twitter")[0]) {
            document.getElementsByName("detail_twitter")[0].disabled = true;
            document.getElementsByName("detail_twitter")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_profil")[0]) {
            document.getElementsByName("detail_profil")[0].disabled = true;
            document.getElementsByName("detail_profil")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_fonction")[0]) {
            document.getElementsByName("detail_fonction")[0].disabled = true;
            document.getElementsByName("detail_fonction")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_ismanager")[0]) {
            document.getElementsByName("detail_ismanager")[0].disabled = true;
            document.getElementsByName("detail_ismanager")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_resp_hierarchie_id")[0]) {
            document.getElementsByName("detail_resp_hierarchie_id")[0].disabled = true;
            document.getElementsByName("detail_resp_hierarchie_id")[0].style.backgroundColor = "#ECEFF1";
        }

    }

    function Enable_Employee_DetailFields() {
        setemployee_data_edit_mode("1");


        document.getElementsByName("detail_nom")[0].disabled = false;
        document.getElementsByName("detail_nom")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_prenom")[0].disabled = false;
        document.getElementsByName("detail_prenom")[0].style.backgroundColor = "#FFFFFF";


        document.getElementsByName("detail_mail")[0].disabled = false;
        document.getElementsByName("detail_mail")[0].style.backgroundColor = "#FFFFFF";


        document.getElementsByName("detail_tel")[0].disabled = false;
        document.getElementsByName("detail_tel")[0].style.backgroundColor = "#FFFFFF";


        document.getElementsByName("detail_adresse")[0].disabled = false;
        document.getElementsByName("detail_adresse")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_code_postal")[0].disabled = false;
        document.getElementsByName("detail_code_postal")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_ville")[0].disabled = false;
        document.getElementsByName("detail_ville")[0].style.backgroundColor = "#FFFFFF";


        document.getElementsByName("detail_civilite")[0].disabled = false;
        document.getElementsByName("detail_civilite")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_tel_mobile")[0].disabled = false;
        document.getElementsByName("detail_tel_mobile")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_pays")[0].disabled = false;
        document.getElementsByName("detail_pays")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_linkedin")[0].disabled = false;
        document.getElementsByName("detail_linkedin")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_facebook")[0].disabled = false;
        document.getElementsByName("detail_facebook")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_twitter")[0].disabled = false;
        document.getElementsByName("detail_twitter")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_profil")[0].disabled = false;
        document.getElementsByName("detail_profil")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_fonction")[0].disabled = false;
        document.getElementsByName("detail_fonction")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_ismanager")[0].disabled = false;
        document.getElementsByName("detail_ismanager")[0].style.backgroundColor = "#FFFFFF";

        document.getElementsByName("detail_resp_hierarchie_id")[0].disabled = false;
        document.getElementsByName("detail_resp_hierarchie_id")[0].style.backgroundColor = "#FFFFFF";



    }


    function Annule_Employee_DetailFields() {

        setisimgclassSelected();
        setuserimgclassprofil();
        setisimgclassSelected_recid();

        Get_Employee_Data(selected_id);
        get_Employee_Images(selected_id);

        setemployee_data_changed("");
        setemployee_data_edit_mode("");

    }


    const [Update_One_Employee_Data_api, setUpdate_One_Employee_Data_api] = useState();
    const [Update_One_Employee_Data_message, setUpdate_One_Employee_Data_message] = useState();
    const [Update_One_Employee_Data_result, setUpdate_One_Employee_Data_result] = useState();
    function Update_One_Employee_Data() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("nom", p_detail_nom);
        form.append("email", p_detail_mail);

        if (p_detail_prenom)
            form.append("prenom", p_detail_prenom);
        else
            form.append("prenom", "");


        if (p_detail_tel)
            form.append("telephone", p_detail_tel);
        else
            form.append("telephone", "");


        if (p_detail_tel_mobile)
            form.append("telephone_mobile", p_detail_tel_mobile);
        else
            form.append("telephone_mobile", "");

        if (p_detail_adresse)
            form.append("adr_adresse", p_detail_adresse);
        else
            form.append("adr_adresse", "");


        if (p_detail_code_postal)
            form.append("adr_code_postal", p_detail_code_postal);
        else
            form.append("adr_code_postal", "");

        if (p_detail_ville)
            form.append("adr_ville", p_detail_ville);
        else
            form.append("adr_ville", "");

        if (p_detail_pays)
            form.append("adr_pays", p_detail_pays);
        else
            form.append("adr_pays", "");

        if (p_detail_profil)
            form.append("profil", p_detail_profil);
        else
            form.append("profil", "");


        if (p_detail_fonction)
            form.append("fonction", p_detail_fonction);
        else
            form.append("fonction", "");


        if (p_detail_civilite)
            form.append("civilite", p_detail_civilite);
        else
            form.append("civilite", "");


        if (p_detail_resp_hierarchie_id)
            form.append("superieur_hierarchie_id", p_detail_resp_hierarchie_id);
        else
            form.append("superieur_hierarchie_id", "");


        if (p_detail_linkedIn)
            form.append("linkedin", p_detail_linkedIn);
        else
            form.append("linkedin", "");

        if (p_detail_facebook)
            form.append("facebook", p_detail_facebook);
        else
            form.append("facebook", "");


        if (p_detail_twitter)
            form.append("twitter", p_detail_twitter);
        else
            form.append("twitter", "");

        if (p_detail_ismanager)
            form.append("ismanager", p_detail_ismanager);
        else
            form.append("ismanager", "0");

        form.append("_id", selected_id);

        //console.log(" form == ", form);

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

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

            if (String(res.data.status) === String("true")) {
                setUpdate_One_Employee_Data_api("true");
                setUpdate_One_Employee_Data_result(res.data.message);

                Getall_Training_Employee();

                disable_Employee_DetailFields();
                setemployee_data_changed("");
                setemployee_data_edit_mode("");
                Get_Employee_Data(selected_id);
                alert(" La mise à jour été correctement faite.");

                myRef_head.current.scrollIntoView({ behavior: "smooth" });

            }
            else {
                setUpdate_One_Employee_Data_api("false");
                setUpdate_One_Employee_Data_message(res.data.message);
                alert(res.data.message);
            }

        }).catch((error) => {

            console.warn('UpdateStagiaireData : Not good man :( Update_One_Employee_Data = ' + error);
            setUpdate_One_Employee_Data_api("false");
            alert(" Impossible de mettre à jour l'employé");

        })
    }


    const [record_employee_Image_api, setrecord_employee_Image_api] = useState();
    const [record_employee_Image_message, setrecord_employee_Image_message] = useState();
    const [record_employee_Image_result, setrecord_employee_Image_result] = useState();
    function record_employee_Image(l) {

        const formData = new FormData();
        const url = process.env.REACT_APP_API_URL + "myclass/api/Update_Ressource_Humaine_Image/";

        const stored_cookie = getCookie('tokenmysypart');
        formData.append("token", stored_cookie);
        formData.append("rh_id", selected_id);

        formData.append('file_img', isimgclassSelected);
        formData.append('file_img_recid', isimgclassSelected_recid);


        //console.log(" ### formData = ", formData);
        fetch(
            url,
            {
                method: 'POST',
                body: formData,
            }
        )
            .then((response) => response.json())
            .then((result) => {
                console.log('Success:', result['message'], "result['status'] = ", result['status']);

                if (String(result['status']) === String("true")) {
                    setrecord_employee_Image_api("true");
                    setuserimgclassprofilchanged("");
                    alert(" L'image à jour a été mise enregistrée ");

                } else if (String(result['status']) === String("Err_Connexion")) {
                    alert('Erreur: ' + result['message']);
                    history.push("/Connexion");
                } else {
                    setrecord_employee_Image_api("false");
                    alert(" Erreur : " + result['message']);
                }

            })
            .catch((error) => {
                console.error('Error:', error);
                setrecord_employee_Image_api("false");
                alert(" Erreur : Impossible d'enregistrer l'image ");

            });


    };


    const [get_Employee_Images_api, setget_Employee_Images_api] = useState();
    const [get_Employee_Images_message, setget_Employee_Images_message] = useState();
    const [get_Employee_Images_result, setget_Employee_Images_result] = useState();
    function get_Employee_Images(employee_id) {

        setisimgclassSelected();
        setuserimgclassprofil();
        setisimgclassSelected_recid();

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

        var form = new FormData();
        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("rh_id", employee_id);


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

            //console.log(" get_Employee_Images : In test  res.data.status = " + res.data.status);
            // console.log(" get_Employee_Images: res.data.message.img = " + res.data.message);

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

                if (JSON.parse(res.data.message).logo_img) {
                    var partner_logo_img = "data:image/png;base64," + JSON.parse(res.data.message).logo_img;
                    setisimgclassSelected(partner_logo_img);
                    setuserimgclassprofil(partner_logo_img);
                    setisimgclassSelected_recid(JSON.parse(res.data.message).logo_img_recid);
                }


            }
            else if (String(res.data.status) === String("Err_Connexion")) {
                alert('Erreur: ' + res.data.message);
                history.push("/Connexion");
                return;
            }
            else {
                setget_Employee_Images_api("false");
                get_Employee_Images_message(res.data.message)
                alert(res.data.message);

            }
        }).catch((error) => {
            console.warn('get_Employee_Images ee: Not good man :(  = ', error);
            setget_Employee_Images_api("false");
            get_Employee_Images_message(" Impossible de recuperer l'image de l'employé")
        })

    }


    function removeRecodedLogoImage() {
        if (!isimgclassSelected_recid || String(isimgclassSelected_recid).length < 3) {
            alert(" Image incorrecte. Impossible de la supprimer ");
            return;
        }

        var form = new FormData();

        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("image_recid", isimgclassSelected_recid);

        fetch(
            process.env.REACT_APP_API_URL + "myclass/api/DeleteImage_Stagiaire_v2/",
            {
                method: 'POST',
                body: form,
            }
        ).then((response) => response.json())
            .then((result) => {

                console.log(' removeRecodedClassImage : status:', result['status']);
                console.log('removeRecodedClassImage : Success:', result['message']);


                if (String(result['status']) === String("true")) {
                    setisimgclassSelected("");
                    setisimgclassSelected_recid("");
                    setisimgclassSelectedfile("");
                    setuserimgclassprofil("");
                    get_Employee_Images();

                }
                else if (String(result['status']) === String("Err_Connexion")) {
                    alert('Erreur: ' + result['message']);
                    history.push("/Connexion");
                    return;
                }

                else {
                    alert(result['message']);
                }

            })
            .catch((error) => {
                console.error('Error:', error);
                alert(" Impossible de supprimer l'image ");
            });

    }


    const imglogoclasschangeHandler = (event) => {


        let file_size = event.target.files[0].size;

        //or if you like to have name and type
        //console.log(event.target.files);

        let file_name = event.target.files[0].name;
        let file_type = event.target.files[0].type;



        //alert("file_size =  "+file_size+" file_type = "+file_type+" a = "+a);
        if (file_size > 1000000) {
            alert("L'image ne doit pas depasser un 1 Méga octets");
            return;
        }
        setisimgclassSelected(event.target.files[0]);
        setisimgclassSelectedfile(true);

        setuserimgclassprofil(URL.createObjectURL(event.target.files[0]));
        setuserimgclassprofilchanged("1");

    };


    const [Get_List_Managers_api, setGet_List_Managers_api] = useState();
    const [Get_List_Managers_message, setGet_List_Managers_message] = useState();
    const [Get_List_Managers_result, setGet_List_Managers_result] = useState();
    function Get_List_Managers(event) {

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

        form.append("token", stored_cookie);


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

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

            if (String(res.data.status) === String("true")) {
                setGet_List_Managers_api("true");
                setGet_List_Managers_result(res.data.message);
            }
            else if (String(res.data.status) === String("Err_Connexion")) {
                alert('Erreur: ' + res.data.message);
                history.push("/Connexion");
            }
            else {
                setGet_List_Managers_api("false");
                setGet_List_Managers_message(res.data.message);
            }

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

    const [isimgclassSelected, setisimgclassSelected] = useState(false);
    const [isimgclassSelected_recid, setisimgclassSelected_recid] = useState("");
    const [isimgclassSelectedfile, setisimgclassSelectedfile] = useState(false);


    const [Get_List_RH_Profils_api, setGet_List_RH_Profils_api] = useState();
    const [Get_List_RH_Profils_message, setGet_List_RH_Profils_message] = useState();
    const [Get_List_RH_Profils_result, setGet_List_RH_Profils_result] = useState();
    function Get_List_RH_Profils(event) {

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

        form.append("token", stored_cookie);


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

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

            if (String(res.data.status) === String("true")) {
                setGet_List_RH_Profils_api("true");
                setGet_List_RH_Profils_result(res.data.message);
            }
            else if (String(res.data.status) === String("Err_Connexion")) {
                alert('Erreur: ' + res.data.message);
                history.push("/Connexion");
            }
            else {
                setGet_List_RH_Profils_api("false");
                setGet_List_RH_Profils_message(res.data.message);
            }

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


    const [Delete_Employee_api, setDelete_Employee_api] = useState();
    const [Delete_Employee_message, setDelete_Employee_message] = useState();
    const [Delete_Employee_result, setDelete_Employee_result] = useState();
    function Delete_Employee(local_rh_id) {

        var form = new FormData();

        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("_id", local_rh_id);



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

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

            if (String(res.data.status) === String("true")) {
                setDelete_Employee_api("true");
                setDelete_Employee_result(res.data.message);
                clean_all_filters();
                alert(" L'employé a été correctement supprimé.")
            }
            else {
                setDelete_Employee_api("false");
                setDelete_Employee_message(res.data.message);
                alert(res.data.message);

            }

        }).catch((error) => {

            console.log('Delete_Employee : Not good man :( Delete_Employee = ' + error);
            setDelete_Employee_api("false");
            alert(" Impossible de supprimer l'employee");
        })
    }


    const [Delete_affection_api, setDelete_affection_api] = useState();
    const [Delete_affection_message, setDelete_affection_message] = useState();
    const [Delete_affection_result, setDelete_affection_result] = useState();
    function Delete_affection(local_rh_id, local_affectation_id) {

        var form = new FormData();

        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("rh_id", local_rh_id);
        form.append("_id", local_affectation_id);



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

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

            if (String(res.data.status) === String("true")) {
                setDelete_affection_api("true");
                setDelete_affection_result(res.data.message);
                clean_affectation_fields();
                setAffectation_data_changed();
                setedite_affectation_form();
                setdisplay_affectation();
                Getall_Employee_Affectation(local_rh_id);
                alert(" La fonction a été correctement supprimée.")
            }
            else {
                setDelete_affection_api("false");
                setDelete_affection_message(res.data.message);
                alert(res.data.message);

            }

        }).catch((error) => {

            console.log('Delete_affection : Not good man :( Delete_affection = ' + error);
            setDelete_affection_api("false");
            alert(" Impossible de supprimer la fonction");
        })
    }


    const [isimgclassdeleted, setisimgclassdeleted] = useState("");
    const [isimgclassdeleted_message, setisimgclassdeleted_message] = useState("");
    const [isimgclassSaved, setisimgclassSaved] = useState("");
    const [isimgclassSaved_message, setisimgclassSaved_message] = useState("");

    const [userimgclassprofil, setuserimgclassprofil] = useState();
    const [userimgclassprofilchanged, setuserimgclassprofilchanged] = useState("");

    const myRef_head = useRef(null);
    const myRef_affectation = useRef(null);
    const myRef_new_affectation = useRef(null);
    const hiddenFileInput_session = React.useRef(null);
    const [Employee_data_changed, setEmployee_data_changed] = useState();

    const [add_One_Employee, setadd_One_Employee] = useState();
    function submenu_add_one_employee() {
        setdisplay_detail_employe();
        setadd_One_Employee("1");
        setsubmenu("detail_employe");

    }

    function Annule_add_one_Employee() {
        setdisplay_detail_employe();
        setadd_One_Employee();
        setsubmenu("");
        setSelectionModel([]);
    }
    const [Add_One_Employee_Data_api, setAdd_One_Employee_Data_api] = useState();
    const [Add_One_Employee_Data_message, setAdd_One_Employee_Data_message] = useState();
    const [Add_One_Employee_Data_result, setAdd_One_Employee_Data_result] = useState();
    function Add_One_Employee_Data() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");

        // Controle sur les champs

        if (p_one_detail_nom.trim() == "") {
            alert(" Vous devez saisir le nom de l'employé");
            return;
        }


        if (p_one_detail_prenom.trim() == "") {
            alert(" Vous devez saisir le prenom de l'employé");
            return;
        }


        if (p_one_detail_mail.trim() == "") {
            alert(" Vous devez saisir l'email de l'employé");
            return;
        }


        var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
        if (!p_one_detail_mail.match(validRegex)) {
            alert("L'adresse email est invalide.");
            return;
        }



        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("nom", p_one_detail_nom);
        form.append("email", p_one_detail_mail);
        form.append("prenom", p_one_detail_prenom);



        if (p_one_detail_tel)
            form.append("telephone", p_one_detail_tel);
        else
            form.append("telephone", "");


        if (p_one_detail_tel_mobile)
            form.append("telephone_mobile", p_one_detail_tel_mobile);
        else
            form.append("telephone_mobile", "");

        if (p_one_detail_adresse)
            form.append("adr_adresse", p_one_detail_adresse);
        else
            form.append("adr_adresse", "");


        if (p_one_detail_code_postal)
            form.append("adr_code_postal", p_one_detail_code_postal);
        else
            form.append("adr_code_postal", "");

        if (p_one_detail_ville)
            form.append("adr_ville", p_one_detail_ville);
        else
            form.append("adr_ville", "");

        if (p_one_detail_pays)
            form.append("adr_pays", p_one_detail_pays);
        else
            form.append("adr_pays", "");

        if (p_one_detail_profil)
            form.append("profil", p_one_detail_profil);
        else
            form.append("profil", "");


        if (p_one_detail_fonction)
            form.append("fonction", p_one_detail_fonction);
        else
            form.append("fonction", "");


        if (p_one_detail_civilite)
            form.append("civilite", p_one_detail_civilite);
        else
            form.append("civilite", "");


        if (p_one_detail_resp_hierarchie_id)
            form.append("superieur_hierarchie_id", p_one_detail_resp_hierarchie_id);
        else
            form.append("superieur_hierarchie_id", "");


        if (p_one_detail_linkedIn)
            form.append("linkedin", p_one_detail_linkedIn);
        else
            form.append("linkedin", "");

        if (p_one_detail_facebook)
            form.append("facebook", p_one_detail_facebook);
        else
            form.append("facebook", "");


        if (p_one_detail_twitter)
            form.append("twitter", p_one_detail_twitter);
        else
            form.append("twitter", "");

        if (p_one_detail_ismanager)
            form.append("ismanager", p_one_detail_ismanager);
        else
            form.append("ismanager", "0");


        console.log(" form == ", form);

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

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

            if (String(res.data.status) === String("true")) {
                setAdd_One_Employee_Data_api("true");
                setAdd_One_Employee_Data_result(res.data.message);

                Getall_Training_Employee();


                setemployee_data_changed("");
                setemployee_data_edit_mode("");

                alert(res.data.message);

                myRef_head.current.scrollIntoView({ behavior: "smooth" });

            }
            else {
                setAdd_One_Employee_Data_api("false");
                setAdd_One_Employee_Data_message(res.data.message);
                alert(res.data.message);
            }

        }).catch((error) => {

            console.warn('UpdateStagiaireData : Not good man :( Add_One_Employee_Data = ' + error);
            setAdd_One_Employee_Data_api("false");
            alert(" Impossible d'ajouter l'employé");

        })
    }


    function submenu_import_employee() {
        setsession_file_name();
        setliste_sessions_file_change_api();
        hiddenFileInput_session.current.click();
    }


    const sleep = (milliseconds) => {
        return new Promise(resolve => setTimeout(resolve, milliseconds))
    }

    async function submenu_detail_employe() {
        setsubmenu("detail_employe");

        await sleep(5);
        /*if (!edit_session_form) {
            desableSessionFields();
        }*/

        if (document.getElementById("detail_employe")) {
            document.getElementById("detail_employe").style.backgroundColor = "#104277";
            document.getElementById("detail_employe").style.color = "white";
        }

        if (document.getElementById("droit_acces")) {
            document.getElementById("droit_acces").style.backgroundColor = "#d8edfc";
            document.getElementById("droit_acces").style.color = "black";
        }

        if (document.getElementById("affectation")) {
            document.getElementById("affectation").style.backgroundColor = "#d8edfc";
            document.getElementById("affectation").style.color = "black";
        }

        //console.log(" ### employee_data_edit_mode = ", employee_data_edit_mode);
        if (String(employee_data_edit_mode) !== "1")
            disable_Employee_DetailFields();

    }


    async function submenu_affectation() {
        setsubmenu("affectation");

        await sleep(5);
        /*if (!edit_session_form) {
            desableSessionFields();
        }*/

        if (document.getElementById("affectation")) {
            document.getElementById("affectation").style.backgroundColor = "#104277";
            document.getElementById("affectation").style.color = "white";
        }

        if (document.getElementById("detail_employe")) {
            document.getElementById("detail_employe").style.backgroundColor = "#d8edfc";
            document.getElementById("detail_employe").style.color = "black";
        }

        if (document.getElementById("droit_acces")) {
            document.getElementById("droit_acces").style.backgroundColor = "#d8edfc";
            document.getElementById("droit_acces").style.color = "black";
        }


    }



    async function submenu_droit_acces() {
        setsubmenu("droit_acces");

        await sleep(5);
        /*if (!edit_session_form) {
            desableSessionFields();
        }*/

        if (document.getElementById("droit_acces")) {
            document.getElementById("droit_acces").style.backgroundColor = "#104277";
            document.getElementById("droit_acces").style.color = "white";
        }

        if (document.getElementById("detail_employe")) {
            document.getElementById("detail_employe").style.backgroundColor = "#d8edfc";
            document.getElementById("detail_employe").style.color = "black";
        }

        if (document.getElementById("affectation")) {
            document.getElementById("affectation").style.backgroundColor = "#d8edfc";
            document.getElementById("affectation").style.color = "black";
        }


    }


    const [display_affectation, setdisplay_affectation] = useState();
    const [p_affect_poste, setp_affect_poste] = useState();
    const [p_affect_date_du, setp_affect_date_du] = useState(new Date().toLocaleDateString('fr-FR'));
    const [p_affect_date_au, setp_affect_date_au] = useState(new Date().toLocaleDateString('fr-FR'));
    const [p_affect_cible, setp_affect_cible] = useState();
    const [p_affect_cible_label, setp_affect_cible_label] = useState();

    const [p_affect_cible_nom, setp_affect_cible_nom] = useState();
    const [p_affect_cible_nom_label, setp_affect_cible_nom_label] = useState();


    const [edite_affectation_form, setedite_affectation_form] = useState();
    const [p_affect_comment, setp_affect_comment] = useState();
    const [p_related_target_collection, setp_related_target_collection] = useState();
    const [p_related_target_collection_id, setp_related_target_collection_id] = useState();


    function clean_affectation_fields() {
        setp_affect_poste();
        setp_affect_date_du(new Date().toLocaleDateString('fr-FR'));
        setp_affect_date_au(new Date().toLocaleDateString('fr-FR'));
        setp_affect_cible();
        setp_affect_cible_label();
        setp_affect_cible_nom();
        setp_affect_cible_nom_label();
        setp_affect_comment();

        if (document.getElementsByName("affect_poste")[0])
            document.getElementsByName("affect_poste")[0].value = "";

        if (document.getElementsByName("affect_cible")[0])
            document.getElementsByName("affect_cible")[0].value = "";

        if (document.getElementsByName("affect_cible_nom")[0])
            document.getElementsByName("affect_cible_nom")[0].value = "";

        if (document.getElementsByName("affect_date_du")[0])
            document.getElementsByName("affect_date_du")[0].value = "";

        if (document.getElementsByName("affect_date_au")[0])
            document.getElementsByName("affect_date_au")[0].value = "";

        if (document.getElementsByName("affect_comment")[0])
            document.getElementsByName("affect_comment")[0].value = "";


    }


    const [p_one_affect_poste, setp_one_affect_poste] = useState();
    const [p_one_affect_date_du, setp_one_affect_date_du] = useState(new Date().toLocaleDateString('fr-FR'));
    const [p_one_affect_date_au, setp_one_affect_date_au] = useState(new Date().toLocaleDateString('fr-FR'));
    const [p_one_affect_cible, setp_one_affect_cible] = useState();
    const [p_one_affect_cible_nom, setp_one_affect_cible_nom] = useState();
    const [p_one_affect_comment, setp_one_affect_comment] = useState();

    function clean_nouvelle_affectation_fields() {
        setp_one_affect_poste();
        setp_one_affect_date_du(new Date().toLocaleDateString('fr-FR'));
        setp_one_affect_date_au(new Date().toLocaleDateString('fr-FR'));
        setp_one_affect_cible();
        setp_one_affect_cible_nom();

        setp_one_affect_comment();

        if (document.getElementsByName("one_affect_poste")[0])
            document.getElementsByName("one_affect_poste")[0].value = "";

        if (document.getElementsByName("one_affect_cible")[0])
            document.getElementsByName("one_affect_cible")[0].value = "";

        if (document.getElementsByName("one_affect_cible_nom")[0])
            document.getElementsByName("one_affect_cible_nom")[0].value = "";

        if (document.getElementsByName("one_affect_date_du")[0])
            document.getElementsByName("one_affect_date_du")[0].value = "";

        if (document.getElementsByName("one_affect_date_au")[0])
            document.getElementsByName("one_affect_date_au")[0].value = "";

        if (document.getElementsByName("one_affect_comment")[0])
            document.getElementsByName("one_affect_comment")[0].value = "";
    }


    const [Affectation_data_changed, setAffectation_data_changed] = useState();



    function Disable_Detail_Affectation_Fields() {
        setedite_affectation_form("0");

        if (document.getElementsByName("affect_poste")[0]) {
            document.getElementsByName("affect_poste")[0].disabled = true;
            document.getElementsByName("affect_poste")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("affect_cible")[0]) {
            document.getElementsByName("affect_cible")[0].disabled = true;
            document.getElementsByName("affect_cible")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("affect_cible_nom")[0]) {
            document.getElementsByName("affect_cible_nom")[0].disabled = true;
            document.getElementsByName("affect_cible_nom")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("affect_date_du")[0]) {
            document.getElementsByName("affect_date_du")[0].disabled = true;
            document.getElementsByName("affect_date_du")[0].style.backgroundColor = "#ECEFF1";
        }


        if (document.getElementsByName("affect_date_au")[0]) {
            document.getElementsByName("affect_date_au")[0].disabled = true;
            document.getElementsByName("affect_date_au")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("affect_comment")[0]) {
            document.getElementsByName("affect_comment")[0].disabled = true;
            document.getElementsByName("affect_comment")[0].style.backgroundColor = "#ECEFF1";
        }

    }


    function Enable_Detail_Affectation_Fields() {

        setedite_affectation_form("1");

        if (document.getElementsByName("affect_poste")[0]) {
            document.getElementsByName("affect_poste")[0].disabled = false;
            document.getElementsByName("affect_poste")[0].style.backgroundColor = "#FFFFFF";
        }


        if (document.getElementsByName("affect_cible")[0]) {
            document.getElementsByName("affect_cible")[0].disabled = false;
            document.getElementsByName("affect_cible")[0].style.backgroundColor = "#FFFFFF";
        }


        if (document.getElementsByName("affect_cible_nom")[0]) {
            document.getElementsByName("affect_cible_nom")[0].disabled = false;
            document.getElementsByName("affect_cible_nom")[0].style.backgroundColor = "#FFFFFF";
        }


        if (document.getElementsByName("affect_date_du")[0]) {
            document.getElementsByName("affect_date_du")[0].disabled = false;
            document.getElementsByName("affect_date_du")[0].style.backgroundColor = "#FFFFFF";
        }


        if (document.getElementsByName("affect_date_au")[0]) {
            document.getElementsByName("affect_date_au")[0].disabled = false;
            document.getElementsByName("affect_date_au")[0].style.backgroundColor = "#FFFFFF";
        }

        if (document.getElementsByName("affect_comment")[0]) {
            document.getElementsByName("affect_comment")[0].disabled = false;
            document.getElementsByName("affect_comment")[0].style.backgroundColor = "#FFFFFF";
        }
    }


    function Annule_Affectation_DetailFields() {
        clean_affectation_fields();
        Get_Given_Employee_Affectation(selected_affectation_id);
        setAffectation_data_changed("");
        setedite_affectation_form("");

    }


    function Fermer_Affectation_Fields() {
        clean_affectation_fields();
        setedite_affectation_form();
        setdisplay_affectation();
        setSelectionModel_affectations([]);
    }

    function Fermer_nouvelle_Affectation_Fields() {
        clean_nouvelle_affectation_fields();
        setedite_affectation_form();
        setdisplay_affectation();
        setAdd_new_affectation();
        setSelectionModel_affectations([]);
    }




    const [Update_One_Affectation_Data_api, setUpdate_One_Affectation_Data_api] = useState();
    const [Update_One_Affectation_Data_message, setUpdate_One_Affectation_Data_message] = useState();
    const [Update_One_Affectation_Data_result, setUpdate_One_Affectation_Data_result] = useState();
    function Update_One_Affectation_Data() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("_id", selected_affectation_id);
        form.append("rh_id", selected_id);

        if (p_affect_poste)
            form.append("poste", p_affect_poste);
        else {
            alert(" Vous devez definir une poste pour cette affectation");
            return;
        }

        if (p_affect_date_du)
            form.append("date_du", p_affect_date_du);
        else {
            alert(" Vous devez definir une date de debut pour cette affectation");
            return;
        }

        if (p_affect_date_au)
            form.append("date_au", p_affect_date_au);
        else
            form.append("date_au", "");


        if (p_affect_comment)
            form.append("comment", p_affect_comment);
        else
            form.append("comment", "");


        if (p_affect_cible)
            form.append("related_target_collection", p_affect_cible);
        else
            form.append("related_target_collection", "");

        if (p_affect_cible_nom)
            form.append("related_target_collection_id", p_affect_cible_nom);
        else
            form.append("related_target_collection_id", "");



        //console.log(" affectation form == ", form);

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

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

            if (String(res.data.status) === String("true")) {
                setUpdate_One_Affectation_Data_api("true");
                setUpdate_One_Affectation_Data_result(res.data.message);

                Disable_Detail_Affectation_Fields();
                setAffectation_data_changed("");
                setedite_affectation_form("");
                Getall_Employee_Affectation(selected_id);
                setSelectionModel_affectations([]);

                alert(" La mise à jour été correctement faite.");

                if (myRef_affectation)
                    myRef_affectation.current.scrollIntoView({ behavior: "smooth" });

            }
            else {
                setUpdate_One_Affectation_Data_api("false");
                setUpdate_One_Affectation_Data_message(res.data.message);
                alert(res.data.message);
            }

        }).catch((error) => {

            console.log('UpdateStagiaireData : Not good man :( Update_One_Affectation_Data = ' + error);
            setUpdate_One_Affectation_Data_api("false");
            alert(" Impossible de mettre à jour l'affectation");

        })
    }


    const filterPassedTime_start = (time) => {
        const currentDate = new Date();
        const selectedDate = new Date(time);

        return currentDate.getTime() < selectedDate.getTime();
    };


    function add_one_affectation_block() {  

        setdisplay_affectation("");
        
        setAdd_new_affectation("1");
        
        if (myRef_new_affectation.current) {
            myRef_new_affectation.current.scrollIntoView({ behavior: "smooth" });
        }
        
        clean_affectation_fields();
        
    }


    const [Add_one_affectation_api, setAdd_one_affectation_api] = useState();
    const [Add_one_affectation_message, setAdd_one_affectation_message] = useState();
    const [Add_one_affectation_result, setAdd_one_affectation_result] = useState();
    function Add_one_affectation() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("rh_id", selected_id);

        if (p_one_affect_poste)
            form.append("poste", p_one_affect_poste);
        else {
            alert(" Vous devez definir une poste pour cette affectation");
            return;
        }

        if (p_one_affect_date_du)
            form.append("date_du", p_one_affect_date_du);
        else {
            alert(" Vous devez definir une date de debut pour cette affectation");
            return;
        }


        if (p_one_affect_date_au)
            form.append("date_au", p_one_affect_date_au);
        else
            form.append("date_au", "");


        if (p_one_affect_comment)
            form.append("comment", p_one_affect_comment);
        else
            form.append("comment", "");


        if (p_one_affect_cible)
            form.append("related_target_collection", p_one_affect_cible);
        else
            form.append("related_target_collection", "");

        if (p_one_affect_cible_nom)
            form.append("related_target_collection_id", p_one_affect_cible_nom);
        else
            form.append("related_target_collection_id", "");


        console.log(" Add_one_affectation affectation form == ", form);


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

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

            if (String(res.data.status) === String("true")) {
                setAdd_one_affectation_api("true");
                setAdd_one_affectation_result(res.data.message);

                Disable_Detail_Affectation_Fields();
                setAffectation_data_changed("");
                setedite_affectation_form("");
                setAdd_new_affectation("");
                Getall_Employee_Affectation(selected_id);
                setSelectionModel_affectations([]);
                alert(" L'affectation a été ajoutée.");

                if (myRef_affectation)
                    myRef_affectation.current.scrollIntoView({ behavior: "smooth" });

            }
            else {
                setAdd_one_affectation_api("false");
                setAdd_one_affectation_message(res.data.message);
                alert(res.data.message);
            }

        }).catch((error) => {

            console.log('UpdateStagiaireData : Not good man :( Add_one_affectation = ' + error);
            setAdd_one_affectation_api("false");
            alert(" Impossible d'ajouter l'affectation");

        })
    }


    return (
        <div className="employes">
            <Dialog
                open={Dialog_1_open}
                onClose={Dialog_1_handleClose}

            >

                <DialogTitle>MySy Information</DialogTitle>
                <DialogContent>
                    <DialogContentText>
                        {Dialog_1_message}
                    </DialogContentText>

                </DialogContent>

                <DialogActions>
                    <Button onClick={Dialog_1_handleClose_buton}>OK</Button>

                </DialogActions>
            </Dialog>

            <h3> Vos employés </h3>
            <div className="div_row">
                <div className="titre1">  Utilisez les filtres !</div>
                <div className="div_row" style={{ "marginBottom": "5px" }}>
                    <div className="div_row_gauche texte_area_filter" >
                        <TextField
                            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;</MenuItem>
                            <MenuItem value="nom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Nom  &nbsp;</MenuItem>
                            <MenuItem value="formation" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Lié a la Formation (code externe) &nbsp;</MenuItem>
                            <MenuItem value="session" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Lié a la Session (code session) &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 id="my-tooltip01" style={{ "fontSize": "12px" }} />
                        <a data-tooltip-id="my-tooltip01" data-tooltip-content="Ajouter une nouvelle ligne de filtre">
                            &nbsp; <MdAddCircleOutline onClick={(e) => {
                                setp_filtre2("1");
                                setp_filtre2_value("");
                            }} />
                        </a>
                    </div>}
                    {p_filtre1 && <div className='filter_bton_add'>
                        <Tooltip id="my-tooltip02" style={{ "fontSize": "12px" }} />
                        <a data-tooltip-id="my-tooltip02" data-tooltip-content="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%' }}

                                value={p_filtre2}
                                onChange={(e) => {
                                    setp_filtre2(e.target.value);

                                }}
                            >
                                <MenuItem value="email" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Email &nbsp;</MenuItem>
                                <MenuItem value="nom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Nom  &nbsp;</MenuItem>
                                <MenuItem value="formation" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Lié a la Formation (code externe) &nbsp;</MenuItem>
                                <MenuItem value="session" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Lié a la Session (code session) &nbsp;</MenuItem>


                            </TextField>
                        </div>
                        <div className="div_row_droite texte_area_filter_value" style={{ "marginTop": "0.5rem" }}>
                            {String(p_filtre2).length > 2 &&
                                <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 > 2 && <div className='filter_bton_add' >
                            <Tooltip id="my-tooltip03" style={{ "fontSize": "12px" }} />
                            <a data-tooltip-id="my-tooltip03" data-tooltip-content="Ajouter une nouvelle ligne de filtre">
                                &nbsp; <MdAddCircleOutline
                                    onClick={(e) => {
                                        setp_filtre3("1");
                                        setp_filtre3_value("");
                                    }}
                                />
                            </a>
                        </div>}

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

                    </div>
                }


                {p_filtre3 &&
                    <div className="div_row" style={{ "marginBottom": "5px" }}>
                        <div className="div_row_gauche texte_area_filter">
                            <TextField
                                name="filtre3"
                                label="Choisir un champ"
                                select
                                sx={{ m: 1, width: '100%' }}

                                value={p_filtre3}
                                onChange={(e) => {
                                    setp_filtre3(e.target.value)
                                }}
                            >
                                <MenuItem value="email" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Email &nbsp;</MenuItem>
                                <MenuItem value="nom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Nom  &nbsp;</MenuItem>
                                <MenuItem value="formation" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Lié a la Formation (code externe) &nbsp;</MenuItem>
                                <MenuItem value="session" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Lié a la Session (code session) &nbsp;</MenuItem>


                            </TextField>
                        </div>
                        <div className="div_row_droite texte_area_filter_value" style={{ "marginTop": "0.5rem" }}>
                            {String(p_filtre3).length > 2 &&
                                <TextField
                                    sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                    required
                                    name="filtre3_value"
                                    id="filtre3_value"

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

                                />}
                        </div>

                        {String(p_filtre2).length > 2 && <div className='filter_bton_add' >
                            <Tooltip id="my-tooltip03" style={{ "fontSize": "12px" }} />
                            <a data-tooltip-id="my-tooltip03" data-tooltip-content="Ajouter une nouvelle ligne de filtre">
                                &nbsp; <MdAddCircleOutline
                                    onClick={(e) => {
                                        setp_filtre4("1");
                                        setp_filtre4_value("");
                                    }}
                                />
                            </a>
                        </div>}

                        {String(p_filtre3).length > 2 && <div className='filter_bton_add'>
                            <Tooltip id="my-tooltip05" style={{ "fontSize": "12px" }} />
                            <a data-tooltip-id="my-tooltip05" data-tooltip-content="Supprimer cette ligne de filtre">
                                &nbsp; <MdRemoveCircleOutline onClick={(e) => {
                                    setp_filtre3();
                                    setp_filtre3_value();
                                }} />
                            </a>
                        </div>}
                    </div>
                }

                {/*
                {p_filtre4 &&
                    <div className="div_row" style={{ "marginBottom": "5px" }}>
                        <div className="div_row_gauche texte_area_filter">
                            <TextField
                                name="filtre4"
                                label="Choisir un champ"
                                select
                                sx={{ m: 1, width: '100%' }}

                                value={p_filtre4}
                                onChange={(e) => {
                                    setp_filtre4(e.target.value)
                                }}
                            >
                                <MenuItem value="email" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Email &nbsp;</MenuItem>
                                <MenuItem value="nom" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Nom  &nbsp;</MenuItem>
                                <MenuItem value="code_session" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Code Session &nbsp;&nbsp;</MenuItem>
                                <MenuItem value="class_title" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Titre Formation &nbsp;</MenuItem>


                            </TextField>
                        </div>
                        <div className="div_row_droite texte_area_filter_value" style={{ "marginTop": "0.5rem" }}>
                            {String(p_filtre4).length > 2 &&
                                <TextField
                                    sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                    required
                                    name="filtre4_value"
                                    id="filtre4_value"

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

                                />}
                        </div>



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

                    </div>
                }
                */}
                <div className="div_row" ref={myRef_head} style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                    <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>
                        <Button variant="contained" className="bton_enreg" onClick={Getall_Training_Employee}>Rechercher
                        </Button>
                    </div>

                    <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }}>
                        <Button variant="contained" className="bton_annule" onClick={clean_all_filters}>Annuler
                        </Button>

                    </div>

                </div>

                <br />
            </div>

            <div className="div_row">
                <div className="session_data">
                    <div style={{ "border": "None" }}>

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

                                    // 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
                                    },

                                }}
                            >
                                <DataGrid
                                    checkboxSelection
                                    onSelectionModelChange={(newSelectionModel) => {
                                        setSelectionModel(newSelectionModel);
                                        if (newSelectionModel.length === 1)
                                            handleClick_edit_employee_From_Line(newSelectionModel);
                                        if (newSelectionModel.length !== 1) {
                                            setsubmenu();
                                            setdisplay_detail_employe();
                                            setadd_One_Employee();
                                        }
                                    }}
                                    selectionModel={selectionModel}

                                    localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
                                    rows={rowss.map((item, index) => (
                                        {
                                            id: index,
                                            _id: JSON.parse(item)._id,
                                            email: JSON.parse(item).email,
                                            nom: JSON.parse(item).nom,
                                            prenom: JSON.parse(item).prenom,
                                            telephone_mobile: JSON.parse(item).telephone_mobile,
                                            civilite: JSON.parse(item).civilite,
                                            profil: JSON.parse(item).profil,
                                            fonction: JSON.parse(item).fonction,
                                            ismanager: JSON.parse(item).ismanager,

                                        }
                                    ))}

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

                                    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) => {

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


                                />
                            </Box>
                            <br />

                        </div>

                    </div>

                </div>

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

                    <div className="div_row_gauche div_row_gauche_etendu" style={{ "textAlign": "left", "paddingLeft": "5px" }}>

                        <Button variant="outlined" onClick={submenu_import_employee} className="detail_class_submenu bton_import_excel"
                            id='menu_import_participant' name='menu_import_participant'>Importer des employes Excel &nbsp;
                            <img src={excel_icone} alt="ajout csv" className="icon_excel" />
                        </Button>


                        <Button variant="outlined" onClick={submenu_add_one_employee}
                            className="detail_class_submenu bton_add_session"
                            id='menu_import_participant' name='menu_import_participant'>Ajout 1 employé &nbsp;
                            <img src={add_plus} alt="ajout session" className="icon_plus" />
                        </Button>

                        <br />
                        {session_file_name && <nav><i>{session_file_name}</i></nav>}
                        {String(liste_sessions_file_change_api) === String("true") && <nav className="okUpdateData"> Les employés ont été correctement importés</nav>}
                        {String(liste_sessions_file_change_api) === String("false") && <nav className="koUpdateData"> {liste_sessions_file_change_message} </nav>}

                        <input type="file"
                            accept=".csv"
                            ref={hiddenFileInput_session}
                            style={{ display: 'none' }}
                            name="liste_sessions_file"
                            onChange={liste_sessions_file_change}
                        />

                        <a href='/sample/template_import_employes.csv' download>Télécharger un fichier modèle</a>
                    </div>
                </div>
                <div className="div_row"> &nbsp;</div>
                <div className="div_row">
                    <Button variant="outlined" ref={myRef} onClick={submenu_detail_employe} className="detail_class_submenu" id='detail_employe' name='detail_employe'>Détail employé</Button>
                    <Button variant="outlined" onClick={submenu_droit_acces} className="detail_class_submenu" id='droit_acces' name='droit_acces'>Droits d'acces  </Button>
                    <Button variant="outlined" onClick={submenu_affectation} className="detail_class_submenu" id='affectation' name='affectation'>Affectation  </Button>


                </div>

            </div>



            {String(submenu) === "detail_employe" && String(add_One_Employee) !== "1" && <div className="div_row">
                <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Détail Employé </nav>
                <div className="div_row" style={{ "border": "None" }}>
                    <div className="div_row_gauche">

                        <div className="div_row_bis" style={{ "marginBottom": "10px", "marginTop": "1rem" }} >
                            <div className="div_row_gauche_image">
                                <img class="img_class_logo" src={userimgclassprofil} /><br />

                            </div>
                            <div className="div_row_droite_image">
                                <input type="file" id="files_img_class" accept="image/*" onChange={imglogoclasschangeHandler} style={{ opacity: "0", zIndex: "-1", maxWidth: "5px", maxHeight: "0px" }} /><br />
                                {<nav>

                                    <label for="files_img_class" className="bton_image_class">Charger une photo</label><br />

                                    {String(userimgclassprofilchanged) === "1" &&
                                        <nav className="bton_image_class" onClick={record_employee_Image}>Enregistrer la photo<br />  </nav>
                                    }

                                    {String(isimgclassSelected_recid) && String(isimgclassSelected_recid).length > 3 &&
                                        <nav className="bton_supprime_image_class" onClick={removeRecodedLogoImage}>Supprimer la photo<br />  </nav>
                                    }
                                    {String(userimgclassprofilchanged) === "1" &&
                                        <div className="koUpdateData" style={{ "color": "orange", "textAlign": "center" }}> /!\ Pensez à enregistrer la photo
                                        </div>}


                                </nav>}

                                {/*isimgclassSelected && <Button variant="outlined" onClick={sendClassImage} className="bton_image_class">Enregistrer image</Button>*/}
                                {isimgclassdeleted && String(isimgclassdeleted) === "1" && <nav className="koUpdateData"> {isimgclassdeleted_message}</nav>}
                                {isimgclassdeleted && String(isimgclassdeleted) === "0" && <nav className="okUpdateData"> {isimgclassdeleted_message}</nav>}
                                {isimgclassSelected && String(isimgclassSaved) === "0" && <nav className="koUpdateData"> {isimgclassSaved_message}</nav>}
                            </div>

                        </div>
                        <div className="div_row_bis tips_img_class">
                            <li>
                                L'image doit etre carrée.
                            </li>
                            <li>
                                Les formats autorisés sont : <i>['jpg', 'jpeg', 'png', 'jpe', 'webp']</i>
                            </li>
                            <li>
                                Les dimensions recommandées: 128pixels X 128pixels --   144pixels X 144pixels --  168pixels X 168pixels<br />
                                Les dimensions maximales sont de 256pixels X 256pixels
                            </li>
                            <li>
                                La taille de l'image ne doit pas depasser 1 mega octet
                            </li>
                        </div>

                    </div>
                </div>

                <div className="session_data" >

                    <div className="session_caract"> Nom<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_nom"
                            id="detail_nom"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_nom}
                            onChange={(e) => {
                                setp_detail_nom(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }

                        />
                    </div>

                    <div className="session_caract"> Prenom<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_prenom"
                            id="detail_prenom"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_prenom}
                            onChange={(e) => {
                                setp_detail_prenom(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    {String(employee_data_edit_mode) !== "1" && <div className="session_caract"> Civilité<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_civilite"
                            id="detail_civilite"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_civilite_label}

                        />
                    </div>}
                    {String(employee_data_edit_mode) === "1" && <div className="session_caract"> Civilité <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_civilite"
                            id="detail_civilite"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_civilite}
                            onChange={(e) => {
                                setp_detail_civilite(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            <MenuItem value="1" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>M. &nbsp;&nbsp;</MenuItem>
                            <MenuItem value="0" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Mme. &nbsp;</MenuItem>
                            <MenuItem value="-1" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Neutre &nbsp;</MenuItem>

                        </TextField>
                    </div>}

                    <div className="session_caract"> Email<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_mail"
                            id="detail_mail"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_mail}
                            onChange={(e) => {
                                setp_detail_mail(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }

                        />
                    </div>

                    <div className="session_caract"> Téléphone Mobile<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_tel_mobile"
                            id="detail_tel_mobile"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_tel_mobile}
                            onChange={(e) => {
                                setp_detail_tel_mobile(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }
                        />
                    </div>

                    <div className="session_caract"> Téléphone <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_tel"
                            id="detail_tel"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_tel}
                            onChange={(e) => {
                                setp_detail_tel(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }
                        />
                    </div>

                    <div className="session_caract"> Adresse<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_adresse"
                            id="detail_adresse"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_adresse}
                            onChange={(e) => {
                                setp_detail_adresse(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>
                    <div className="session_caract"> Code postal<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_code_postal"
                            id="detail_code_postal"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_code_postal}
                            onChange={(e) => {
                                setp_detail_code_postal(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>
                    <div className="session_caract"> Ville<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_ville"
                            id="detail_ville"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_ville}
                            onChange={(e) => {
                                setp_detail_ville(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Pays<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_pays"
                            id="detail_pays"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_pays}
                            onChange={(e) => {
                                setp_detail_pays(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Linkedin<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_linkedin"
                            id="detail_linkedin"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_linkedIn}
                            onChange={(e) => {
                                setp_detail_linkedIn(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Facebook<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_facebook"
                            id="detail_facebook"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_facebook}
                            onChange={(e) => {
                                setp_detail_facebook(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Twitter<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_twitter"
                            id="detail_twitter"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_twitter}
                            onChange={(e) => {
                                setp_detail_twitter(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    {String(employee_data_edit_mode) !== "1" && <div className="session_caract"> Profil<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_profil"
                            id="detail_profil"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_profil}

                        />
                    </div>}

                    {String(employee_data_edit_mode) === "1" && <div className="session_caract"> Profil<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_profil"
                            id="detail_profil"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_profil}
                            onChange={(e) => {
                                setp_detail_profil(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            {Get_List_RH_Profils_result &&
                                Get_List_RH_Profils_result.map((myprofil) => (
                                    <MenuItem key={JSON.parse(myprofil).profil_nom} value={JSON.parse(myprofil).profil_nom}
                                        style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%", "fontSize": "12px" }}>
                                        {JSON.parse(myprofil).profil_nom}&nbsp;&nbsp;

                                    </MenuItem>
                                ))}
                        </TextField>
                    </div>}

                    <div className="session_caract"> Fonction <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_fonction"
                            id="detail_fonction"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_fonction}
                            onChange={(e) => {
                                setp_detail_fonction(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>


                    {String(employee_data_edit_mode) !== "1" && <div className="session_caract"> Manager<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_ismanager"
                            id="detail_ismanager"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_ismanager_label}

                        />
                    </div>}

                    {String(employee_data_edit_mode) === "1" && <div className="session_caract"> Manager<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_ismanager"
                            id="detail_ismanager"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_ismanager}
                            onChange={(e) => {
                                setp_detail_ismanager(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            <MenuItem value="1" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Oui &nbsp;&nbsp;</MenuItem>
                            <MenuItem value="0" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Non &nbsp;</MenuItem>

                        </TextField>
                    </div>}

                    {String(employee_data_edit_mode) !== "1" && <div className="session_caract"> Responsable (n+1) <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_resp_hierarchie_id"
                            id="detail_resp_hierarchie_id"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_resp_hierarchie_nom + " " + p_detail_resp_hierarchie_prenom}

                        />
                    </div>}
                    {String(employee_data_edit_mode) === "1" && <div className="session_caract"> Responsable (n+1) <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="detail_resp_hierarchie_id"
                            id="detail_resp_hierarchie_id"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_detail_resp_hierarchie_id}
                            onChange={(e) => {
                                setp_detail_resp_hierarchie_id(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            {Get_List_Managers_result &&
                                Get_List_Managers_result.filter((local_mymanager) => JSON.parse(local_mymanager)._id !== selected_id).map((mymanager) => (
                                    <MenuItem key={JSON.parse(mymanager)._id} value={JSON.parse(mymanager)._id}
                                        style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%", "fontSize": "12px" }}>
                                        {JSON.parse(mymanager).nom}&nbsp;&nbsp;{JSON.parse(mymanager).prenom}

                                    </MenuItem>
                                ))}

                        </TextField>
                    </div>}


                    <div className="div_row" style={{ "border": "None" }}>
                        &nbsp;
                    </div>
                    {String(Employee_data_changed) === "1" && String(employee_data_edit_mode) === "1" && <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>
                        /!\ Pensez à enregistrer les modifications
                    </div>}


                    <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                        {String(Employee_data_changed) === "1" && String(employee_data_edit_mode) === "1" && <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                            <Button variant="contained" className="bton_enreg" onClick={Update_One_Employee_Data}>Enregistrer les modifications
                            </Button>

                        </div>}

                        {String(employee_data_edit_mode) === "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                            <Button variant="contained" className="bton_annule" onClick={Annule_Employee_DetailFields}>Annuler
                            </Button>
                        </div>}
                    </div>


                    {String(employee_data_edit_mode) !== "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }}>

                        <Button variant="contained" className="bton_edit" onClick={Enable_Employee_DetailFields}>Editer
                        </Button>

                    </div>}
                    <div className="div_row" style={{ "border": "None" }}>
                        &nbsp;
                    </div>
                </div>
            </div>}



            {String(submenu) === "detail_employe" && String(add_One_Employee) === "1" && <div className="div_row">
                <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Ajouter un  Employé </nav>

                <div className="session_data" >

                    <div className="session_caract"> Nom<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_nom"
                            id="one_detail_nom"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_nom}
                            onChange={(e) => {
                                setp_one_detail_nom(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }

                        />
                    </div>

                    <div className="session_caract"> Prenom<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_prenom"
                            id="one_detail_prenom"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_prenom}
                            onChange={(e) => {
                                setp_one_detail_prenom(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Civilité <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_civilite"
                            id="one_detail_civilite"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_civilite}
                            onChange={(e) => {
                                setp_one_detail_civilite(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            <MenuItem value="1" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>M. &nbsp;&nbsp;</MenuItem>
                            <MenuItem value="0" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Mme. &nbsp;</MenuItem>
                            <MenuItem value="-1" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Neutre &nbsp;</MenuItem>

                        </TextField>
                    </div>

                    <div className="session_caract"> Email<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_mail"
                            id="one_detail_mail"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_mail}
                            onChange={(e) => {
                                setp_one_detail_mail(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }

                        />
                    </div>

                    <div className="session_caract"> Téléphone Mobile<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_tel_mobile"
                            id="one_detail_tel_mobile"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_tel_mobile}
                            onChange={(e) => {
                                setp_one_detail_tel_mobile(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }
                        />
                    </div>

                    <div className="session_caract"> Téléphone <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_tel"
                            id="one_detail_tel"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_tel}
                            onChange={(e) => {
                                setp_one_detail_tel(e.target.value);
                                setEmployee_data_changed("1");
                            }
                            }
                        />
                    </div>

                    <div className="session_caract"> Adresse<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_adresse"
                            id="one_detail_adresse"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_adresse}
                            onChange={(e) => {
                                setp_one_detail_adresse(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>
                    <div className="session_caract"> Code postal<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_code_postal"
                            id="one_detail_code_postal"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_code_postal}
                            onChange={(e) => {
                                setp_one_detail_code_postal(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>
                    <div className="session_caract"> Ville<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_ville"
                            id="one_detail_ville"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_ville}
                            onChange={(e) => {
                                setp_one_detail_ville(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Pays<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_pays"
                            id="one_detail_pays"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_pays}
                            onChange={(e) => {
                                setp_one_detail_pays(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Linkedin<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_linkedin"
                            id="one_detail_linkedin"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_linkedIn}
                            onChange={(e) => {
                                setp_one_detail_linkedIn(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Facebook<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_facebook"
                            id="one_detail_facebook"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_facebook}
                            onChange={(e) => {
                                setp_one_detail_facebook(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Twitter<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_twitter"
                            id="one_detail_twitter"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_twitter}
                            onChange={(e) => {
                                setp_one_detail_twitter(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>

                    <div className="session_caract"> Profil<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_profil"
                            id="one_detail_profil"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_profil}
                            onChange={(e) => {
                                setp_one_detail_profil(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            {Get_List_RH_Profils_result &&
                                Get_List_RH_Profils_result.map((myprofil) => (
                                    <MenuItem key={JSON.parse(myprofil).profil_nom} value={JSON.parse(myprofil).profil_nom}
                                        style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%", "fontSize": "12px" }}>
                                        {JSON.parse(myprofil).profil_nom}&nbsp;&nbsp;

                                    </MenuItem>
                                ))}
                        </TextField>
                    </div>

                    <div className="session_caract"> Fonction <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_fonction"
                            id="one_detail_fonction"

                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_fonction}
                            onChange={(e) => {
                                setp_one_detail_fonction(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        />
                    </div>


                    <div className="session_caract"> Manager<br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_ismanager"
                            id="one_detail_ismanager"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_ismanager}
                            onChange={(e) => {
                                setp_one_detail_ismanager(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            <MenuItem value="1" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Oui &nbsp;&nbsp;</MenuItem>
                            <MenuItem value="0" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Non &nbsp;</MenuItem>

                        </TextField>
                    </div>

                    <div className="session_caract"> Responsable (n+1) <br />
                        <TextField
                            sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                            required
                            name="one_detail_resp_hierarchie_id"
                            id="one_detail_resp_hierarchie_id"
                            select
                            InputLabelProps={{
                                shrink: true,
                            }}
                            disabled={false}
                            className="disabled_style"
                            value={p_one_detail_resp_hierarchie_id}
                            onChange={(e) => {
                                setp_one_detail_resp_hierarchie_id(e.target.value);
                                setEmployee_data_changed("1");
                            }}
                        >
                            {Get_List_Managers_result &&
                                Get_List_Managers_result.filter((local_mymanager) => JSON.parse(local_mymanager)._id !== selected_id).map((mymanager) => (
                                    <MenuItem key={JSON.parse(mymanager)._id} value={JSON.parse(mymanager)._id}
                                        style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%", "fontSize": "12px" }}>
                                        {JSON.parse(mymanager).nom}&nbsp;&nbsp;{JSON.parse(mymanager).prenom}

                                    </MenuItem>
                                ))}

                        </TextField>
                    </div>


                    <div className="div_row" style={{ "border": "None" }}>
                        &nbsp;
                    </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={Add_One_Employee_Data}>Enregistrer
                        </Button>

                    </div>}

                    {<div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                        <Button variant="contained" className="bton_annule" onClick={Annule_add_one_Employee}>Annuler
                        </Button>
                    </div>}
                </div>



                <div className="div_row" style={{ "border": "None" }}>
                    &nbsp;
                </div>
            </div>}



            {String(submenu) === "affectation" && <div className="div_row">
                <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Affectation </nav>
                <div className="session_data">
                    <div style={{ "border": "None" }}>

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



                                }}
                            >
                                <DataGrid
                                    checkboxSelection
                                    onSelectionModelChange={(newSelectionModel) => {
                                        setSelectionModel_affectations(newSelectionModel);
                                        if (newSelectionModel.length === 1)
                                            handleClick_edit_affectation_From_Line(newSelectionModel);

                                        if (newSelectionModel.length !== 1) {
                                            setedite_affectation_form();
                                            setdisplay_affectation();
                                        }
                                    }}
                                    selectionModel={selectionModel_affectations}

                                    localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
                                    rows={rows_affectations.map((item, index) => (
                                        {
                                            id: index,
                                            _id: JSON.parse(item)._id,
                                            poste: JSON.parse(item).poste,
                                            date_du: JSON.parse(item).date_du,
                                            date_au: JSON.parse(item).date_au,
                                            target_related_collection: JSON.parse(item).target_related_collection,
                                            target_related_collection_id: JSON.parse(item).target_related_collection_id,
                                            related_target_collection_id_nom: JSON.parse(item).related_target_collection_id_nom,
                                            related_target_collection_object: JSON.parse(item).related_target_collection_object,


                                        }
                                    ))}

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

                                    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) => {

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


                                />
                            </Box>
                            <br />

                        </div>

                    </div>

                </div>

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

                    <div className="div_row_gauche div_row_gauche_etendu" style={{ "textAlign": "left", "paddingLeft": "5px" }}>

                        <Button variant="outlined" onClick={add_one_affectation_block}
                            className="detail_class_submenu bton_add_session"
                            id='menu_add_participant' name='menu_add_participant'>Ajout 1 affectation &nbsp;
                            <img src={add_plus} alt="ajout affectation" className="icon_plus" />
                        </Button>

                        <br />

                    </div>
                </div>


                <nav ref={myRef_affectation}> &nbsp; </nav>
                {String(display_affectation) === "1" && <div className="div_row" style={{ "border": "None", "background": '#F8F9F9', "padding": '5px' }}>
                    <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Détail Affectation </nav>

                    <div className="session_data" >
                        <div className="session_caract">Poste Occupé <br />
                            <TextField
                                name="affect_poste"
                                id="affect_poste"
                                text
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_poste}
                                onChange={(e) => {
                                    setp_affect_poste(e.target.value);
                                    setAffectation_data_changed("1");
                                }}

                            />

                        </div>


                        {String(edite_affectation_form) !== "1" && <div className="session_caract">Cible <br />
                            <TextField
                                name="affect_cible"
                                id="affect_cible"
                                text
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_cible_label}

                            />

                        </div>}

                        {String(edite_affectation_form) === "1" && <div className="session_caract">Cible <br />
                            <TextField
                                name="affect_cible"
                                id="affect_cible"
                                select
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_cible}
                                onChange={(e) => {
                                    setp_affect_cible(e.target.value);
                                    setAffectation_data_changed("1");
                                }}


                            >
                                <MenuItem value="myclass" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Formation &nbsp;&nbsp;</MenuItem>
                                <MenuItem value="session_formation" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Session de formation &nbsp;</MenuItem>
                                <MenuItem value="" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Aucun &nbsp;</MenuItem>

                            </TextField>

                        </div>}


                        {String(edite_affectation_form) !== "1" && <div className="session_caract">Cible Nom <br />
                            <TextField
                                name="affect_cible_nom"
                                id="affect_cible_nom"
                                text
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_cible_nom_label}

                            />

                        </div>}

                        {String(edite_affectation_form) === "1" && <div className="session_caract">Cible Nom <br />
                            <TextField
                                name="affect_cible_nom"
                                id="affect_cible_nom"
                                select
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_cible_nom}
                                onChange={(e) => {
                                    setp_affect_cible_nom(e.target.value);
                                    setAffectation_data_changed("1");
                                }}
                            >

                                {Get_Employee_Related_Target_Collection_Data_result &&
                                    Get_Employee_Related_Target_Collection_Data_result.filter((local_mymanager) => JSON.parse(local_mymanager).related_target_collection === p_affect_cible).map((mymanager) => (
                                        <MenuItem key={JSON.parse(mymanager).related_target_collection_id} value={JSON.parse(mymanager).related_target_collection_id}
                                            style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%", "fontSize": "12px" }}>
                                            {JSON.parse(mymanager).related_target_collection_id_nom}&nbsp;&nbsp;

                                        </MenuItem>
                                    ))}


                            </TextField>

                        </div>}



                        {String(edite_affectation_form) !== "1" && <div className="session_caract">Date du <br />
                            <TextField
                                name="affect_date_du"
                                id="affect_date_du"
                                text
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_date_du}

                            />

                        </div>}

                        {String(edite_affectation_form) === "1" && <div className="session_caract">Date du <br />

                            <DatePicker
                                name="affect_date_du"
                                id="affect_date_du"
                                selected={new Date(moment(p_affect_date_du, "DD/MM/YYYY HH:mm:ss"))}
                                onChange={(date) => {
                                    setp_affect_date_du(format(date, 'dd/MM/yyyy'));
                                    setAffectation_data_changed("1");
                                }
                                }
                                showTimeSelect={false}
                                //filterTime={filterPassedTime_start}
                                dateFormat="dd/MM/yyyy"
                                className="disabled_style enable_style"
                                locale='fr-FR'
                            />

                        </div>}


                        {String(edite_affectation_form) !== "1" && <div className="session_caract">Date au <br />
                            <TextField
                                name="affect_date_au"
                                id="affect_date_au"
                                text
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_date_au}

                            />

                        </div>}

                        {String(edite_affectation_form) === "1" && <div className="session_caract">Date au <br />
                            <DatePicker
                                name="affect_date_au"
                                id="affect_date_au"
                                selected={new Date(moment(p_affect_date_au, "DD/MM/YYYY HH:mm:ss"))}
                                onChange={(date) => {
                                    setp_affect_date_au(format(date, 'dd/MM/yyyy'));
                                    setAffectation_data_changed("1");
                                }
                                }
                                showTimeSelect={false}
                                //filterTime={filterPassedTime_start}
                                dateFormat="dd/MM/yyyy"
                                className="disabled_style enable_style"
                                locale='fr-FR'
                            />

                        </div>}

                        <div className="session_caract">Commentaire <br />
                            <TextField
                                name="affect_comment"
                                id="affect_comment"
                                text
                                InputLabelProps={{
                                    shrink: true,
                                }}
                                minRows={3}
                                maxRows={3}
                                disabled={false}
                                className="disabled_style enable_style"
                                value={p_affect_comment}
                                onChange={(e) => {
                                    setp_affect_comment(e.target.value);

                                }}

                            />

                        </div>

                        <div className="div_row" style={{ "border": "None" }}>
                            &nbsp;
                        </div>
                        {String(Affectation_data_changed) === "1" && String(edite_affectation_form) === "1" && <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>
                            /!\ Pensez à enregistrer les modifications
                        </div>}


                        <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                            {String(Affectation_data_changed) === "1" && String(edite_affectation_form) === "1" && <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                                <Button variant="contained" className="bton_enreg" onClick={Update_One_Affectation_Data}>Enregistrer les modifications
                                </Button>

                            </div>}

                            {String(edite_affectation_form) === "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                                <Button variant="contained" className="bton_annule" onClick={Annule_Affectation_DetailFields}>Annuler
                                </Button>
                            </div>}
                        </div>
                        <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                            {String(edite_affectation_form) !== "1" && <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                                <Button variant="contained" className="bton_annule" onClick={Fermer_Affectation_Fields}>Fermer
                                </Button>

                            </div>}


                            {String(edite_affectation_form) !== "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }}>

                                <Button variant="contained" className="bton_edit" onClick={Enable_Detail_Affectation_Fields}>Editer
                                </Button>

                            </div>}
                        </div>
                        <div className="div_row" style={{ "border": "None" }}>
                            &nbsp;
                        </div>

                    </div>
                </div>}

                <nav ref={myRef_new_affectation}> &nbsp; </nav>
                {String(Add_new_affectation) === "1" && <div className="div_row" style={{ "border": "None", "background": '#F8F9F9', "padding": '5px' }}>

                    <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Nouvelle affectation </nav>
                    <div className="session_data" >
                        <div>
                            <div className="session_caract">Poste Occupé <br />
                                <TextField
                                    name="one_affect_poste"
                                    id="one_affect_poste"
                                    text
                                    InputLabelProps={{
                                        shrink: true,
                                    }}
                                    disabled={false}
                                    className="disabled_style enable_style"
                                    value={p_one_affect_poste}
                                    onChange={(e) => {
                                        setp_one_affect_poste(e.target.value);

                                    }}

                                />

                            </div>

                            <div className="session_caract">Cible <br />
                                <TextField
                                    name="one_affect_cible"
                                    id="one_affect_cible"
                                    select
                                    InputLabelProps={{
                                        shrink: true,
                                    }}
                                    disabled={false}
                                    className="disabled_style enable_style"
                                    value={p_one_affect_cible}
                                    onChange={(e) => {
                                        setp_one_affect_cible(e.target.value);
                                    }}

                                >
                                    <MenuItem value="myclass" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }}>Formation &nbsp;&nbsp;</MenuItem>
                                    <MenuItem value="session_formation" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Session de formation &nbsp;</MenuItem>
                                    <MenuItem value="" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Aucun &nbsp;</MenuItem>

                                </TextField>

                            </div>

                            <div className="session_caract">Cible Nom  <br />
                                <TextField
                                    name="one_affect_cible_nom"
                                    id="one_affect_cible_nom"
                                    select
                                    InputLabelProps={{
                                        shrink: true,
                                    }}
                                    disabled={false}
                                    className="disabled_style enable_style"
                                    value={p_one_affect_cible_nom}
                                    onChange={(e) => {
                                        setp_one_affect_cible_nom(e.target.value);
                                    }}
                                >

                                    {Get_Employee_Related_Target_Collection_Data_result &&
                                        Get_Employee_Related_Target_Collection_Data_result.filter((local_mymanager) => JSON.parse(local_mymanager).related_target_collection === p_one_affect_cible).map((mymanager) => (
                                            <MenuItem key={JSON.parse(mymanager).related_target_collection_id} value={JSON.parse(mymanager).related_target_collection_id}
                                                style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%", "fontSize": "12px" }}>
                                                {JSON.parse(mymanager).related_target_collection_id_nom}&nbsp;&nbsp;

                                            </MenuItem>
                                        ))}


                                </TextField>

                            </div>



                            <div className="session_caract">Date du <br />
                                <DatePicker
                                    name="one_affect_date_du"
                                    id="one_affect_date_du"
                                    selected={new Date(moment(p_one_affect_date_du, "DD/MM/YYYY HH:mm:ss"))}
                                    onChange={(date) => {
                                        setp_one_affect_date_du(format(date, 'dd/MM/yyyy'));
                                    }
                                    }
                                    showTimeSelect={false}
                                    //filterTime={filterPassedTime_start}
                                    dateFormat="dd/MM/yyyy"
                                    className="disabled_style enable_style"
                                    locale='fr-FR'
                                />

                            </div>


                            <div className="session_caract">Date au <br />
                                <DatePicker
                                    name="one_affect_date_au"
                                    id="one_affect_date_au"
                                    selected={new Date(moment(p_one_affect_date_au, "DD/MM/YYYY HH:mm:ss"))}
                                    onChange={(date) => {
                                        setp_one_affect_date_au(format(date, 'dd/MM/yyyy'));
                                    }
                                    }
                                    showTimeSelect={false}
                                    //filterTime={filterPassedTime_start}
                                    dateFormat="dd/MM/yyyy"
                                    className="disabled_style enable_style"
                                    locale='fr-FR'
                                />

                            </div>

                            <div className="session_caract">Commentaire <br />
                                <TextField
                                    name="one_affect_comment"
                                    id="one_affect_comment"
                                    text
                                    InputLabelProps={{
                                        shrink: true,
                                    }}
                                    minRows={3}
                                    maxRows={3}
                                    disabled={false}
                                    className="disabled_style enable_style"
                                    value={p_one_affect_comment}
                                    onChange={(e) => {
                                        setp_one_affect_comment(e.target.value);

                                    }}

                                />

                            </div>

                        </div>
                        <div className="div_row" style={{ "border": "None" }}>
                            &nbsp;
                        </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={Add_one_affectation}>Enregistrer
                                </Button>

                            </div>

                            <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                                <Button variant="contained" className="bton_annule" onClick={Fermer_nouvelle_Affectation_Fields}>Annuler
                                </Button>
                            </div>
                        </div>

                        <div className="div_row" style={{ "border": "None" }}>
                            &nbsp;
                        </div>
                    </div>

                </div>}

            </div>}

            {String(submenu) === "droit_acces" && <div className="div_row">
                <nav style={{ "border": "None", "fontSize": "22px", "fontWeight": "600" }}> Droit Acces </nav>
            </div>}


        </div >
    );
}

export default Employes;

