From e3951a76b91d7b9ba7ee13f34d77a5efe96e8623 Mon Sep 17 00:00:00 2001 From: cherif Date: Mon, 28 Aug 2023 21:16:48 +0200 Subject: [PATCH] 28/08/23 - 20h30 --- src/components/Employes.js | 254 +++++++++++++++++++++++-------------- 1 file changed, 160 insertions(+), 94 deletions(-) diff --git a/src/components/Employes.js b/src/components/Employes.js index d514b73..297eb92 100644 --- a/src/components/Employes.js +++ b/src/components/Employes.js @@ -326,10 +326,10 @@ const Employes = (props) => { const [selected_affectation_id, set_selected_affectation_id] = useState(); function handleClick_edit_affectation_From_Line(selected_row_id) { - - setSelectionModel_affectations([]); setdisplay_affectation("1"); - setAdd_new_affectation("") + setAdd_new_affectation(""); + clean_affectation_fields(); + clean_nouvelle_affectation_fields(); var line = JSON.parse(rows_affectations[selected_row_id]); @@ -809,13 +809,18 @@ const Employes = (props) => { setp_affect_date_au(mylocal_affectation.date_au); } - if (mylocal_affectation.related_target_collection_object) { - setp_affect_cible(mylocal_affectation.related_target_collection_object); + 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_nom) { - setp_affect_cible_nom(mylocal_affectation.related_target_collection_id_nom); + 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) { @@ -1563,6 +1568,10 @@ const Employes = (props) => { 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.") } @@ -1598,15 +1607,17 @@ const Employes = (props) => { 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(); @@ -1869,8 +1880,12 @@ const Employes = (props) => { const [p_affect_date_du, setp_affect_date_du] = useState(); const [p_affect_date_au, setp_affect_date_au] = useState(); 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(); @@ -1882,8 +1897,30 @@ const Employes = (props) => { setp_affect_date_du(); setp_affect_date_au(); 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 = ""; + + } @@ -1900,7 +1937,26 @@ const Employes = (props) => { setp_one_affect_date_au(); 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 = ""; } @@ -2135,7 +2191,7 @@ const Employes = (props) => { 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 { @@ -2152,7 +2208,7 @@ const Employes = (props) => { if (p_one_affect_date_au) - form.append("date_au", p_one_affect_date_au ); + form.append("date_au", p_one_affect_date_au); else form.append("date_au", ""); @@ -2255,7 +2311,8 @@ const Employes = (props) => { > Email   Nom   - + Lié a la Formation (code externe)   + Lié a la Session (code session)   @@ -2334,6 +2391,8 @@ const Employes = (props) => { > Email   Nom   + Lié a la Formation (code externe)   + Lié a la Session (code session)   @@ -2394,7 +2453,7 @@ const Employes = (props) => { } - {/* + {p_filtre3 &&
@@ -2412,8 +2471,8 @@ const Employes = (props) => { > Email   Nom   - Code Session    - Titre Formation   + Lié a la Formation (code externe)   + Lié a la Session (code session)   @@ -2472,6 +2531,7 @@ const Employes = (props) => {
} + {/* {p_filtre4 &&
@@ -3702,43 +3762,7 @@ const Employes = (props) => { 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 - }, }} > @@ -3748,6 +3772,7 @@ const Employes = (props) => { setSelectionModel_affectations(newSelectionModel); if (newSelectionModel.length === 1) handleClick_edit_affectation_From_Line(newSelectionModel); + if (newSelectionModel.length !== 1) { setedite_affectation_form(); setdisplay_affectation(); @@ -3781,43 +3806,43 @@ const Employes = (props) => { 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'; - } + /*//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'; - } + //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--inscrit'; + } - if (params.field === "status" && String(params.value) == "-1") { - return 'cell--statut--annule'; - } + if (params.field === "status" && String(params.value) == "-1") { + return 'cell--statut--annule'; + } - }} - getRowClassName={(params) => { + }} + 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'; - } - }} + 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'; + } + }}*/ /> @@ -3882,17 +3907,13 @@ const Employes = (props) => { }} disabled={false} className="disabled_style enable_style" - value={p_affect_cible} + value={p_affect_cible_label} />
} - {String(edite_affectation_form) === "1" &&
Cible edit
- - - p_affect_cible = {p_affect_cible}
- + {String(edite_affectation_form) === "1" &&
Cible
{ setp_affect_cible(e.target.value); setAffectation_data_changed("1"); }} - + > - Formation    - Session de formation   + Formation    + Session de formation   Aucun   @@ -3929,14 +3950,13 @@ const Employes = (props) => { }} disabled={false} className="disabled_style enable_style" - value={p_affect_cible_nom} + value={p_affect_cible_nom_label} />
} - {String(edite_affectation_form) === "1" &&
Cible Nom
- + {String(edite_affectation_form) === "1" &&
Cible Nom
{ />
} + +
Commentaire
+ { + setp_affect_comment(e.target.value); + + }} + + /> + +
+
 
@@ -4194,7 +4237,7 @@ const Employes = (props) => { 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') ); + setp_one_affect_date_au(format(date, 'dd/MM/yyyy')); } } showTimeSelect={false} @@ -4205,6 +4248,29 @@ const Employes = (props) => { />
+ +
Commentaire
+ { + setp_one_affect_comment(e.target.value); + + }} + + /> + +
+