From 42e262b1c6b9a399f441961459166466aaad0001 Mon Sep 17 00:00:00 2001 From: Cherif Date: Sat, 7 Jun 2025 21:40:00 +0200 Subject: [PATCH] 07/06/2025 - 21h30 --- src/components/DisplayPartnerStagiaires.js | 581 +++++++++++++++++--- src/components/Module_Email_Management.js | 10 +- src/components/Module_Ent_Mes_Formations.js | 4 +- 3 files changed, 516 insertions(+), 79 deletions(-) diff --git a/src/components/DisplayPartnerStagiaires.js b/src/components/DisplayPartnerStagiaires.js index 34bacd7..44dd5cf 100644 --- a/src/components/DisplayPartnerStagiaires.js +++ b/src/components/DisplayPartnerStagiaires.js @@ -5,11 +5,11 @@ 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 AttachFileIcon from '@mui/icons-material/AttachFile'; 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 { IoShareSocialOutline } from "react-icons/io5"; import 'react-tooltip/dist/react-tooltip.css' import { Tooltip } from 'react-tooltip' import add_plus from "../mysy_img/plus.png"; @@ -140,7 +140,7 @@ const DisplayPartnerStagiaires = (props) => { const [p_filtre4_value, setp_filtre4_value] = useState(""); const filters = [ - { value: 'code_session', label: 'Code Session' }, + { value: 'code_session', label: 'Code Promo' }, { value: 'class_title', label: 'Titre Formation' }, { value: 'certif', label: 'Certification' } ] @@ -248,7 +248,7 @@ const DisplayPartnerStagiaires = (props) => { return "???"; }, }, - { field: 'code_session', headerName: 'Code session', hideable: true, editable: false, minWidth: 150, flex: 1 }, + { field: 'code_session', headerName: 'Code Promo', hideable: true, editable: false, minWidth: 150, flex: 1 }, { field: 'title', headerName: 'Formation', minWidth: datagrid_columns_size_model1, align: "center", hideable: true, editable: false, hide: true }, { field: 'distantiel', headerName: 'Distantiel', width: datagrid_columns_size_model2, @@ -5223,7 +5223,6 @@ const DisplayPartnerStagiaires = (props) => { tab_convention_pieces_jointes_result.map((x) => { new_tmp.push(x); - }); } @@ -5535,12 +5534,7 @@ const DisplayPartnerStagiaires = (props) => { setliste_selected_inscription_id(liste_session); setselectedtraining_emails(liste_session); - // console.log(" liste_session = ", liste_session); - // console.log(" actionmass_ftion_val = ", actionmass_ftion_val); - - - //console.log(" actionmass_ftion_val = ", actionmass_ftion_val); if (String(actionmass_ftion_val) === String("valide_inscr")) { Accept_List_Inscritpion(liste_session); @@ -5571,8 +5565,16 @@ const DisplayPartnerStagiaires = (props) => { // console.log(" #### selectedtraining_emails_liste = ", selectedtraining_emails_liste); setDialog_SEND_EMAIL_open(true); } + + else if (String(actionmass_ftion_val) === String("pushdocument")) { + // console.log(" #### selectedtraining_emails_liste = ", selectedtraining_emails_liste); + settab_email_pieces_jointes_result([]); + setDialog_PUSH_DOCUMENT_TO_ENT_open(true); + } } + + function Export_Inscriptions(tab_class) { const stored_cookie = getCookie('tokenmysypart'); @@ -6583,6 +6585,7 @@ const DisplayPartnerStagiaires = (props) => { { "id": "2", "label": "Exporter", "value": "exporter" }, { "id": "3", "label": "Desactiver Recyclage", "value": "recyclage_disable" }, { "id": "4", "label": "Contacter par Email", "value": "sendemail" }, + { "id": "5", "label": "Partager Document", "value": "pushdocument" }, ] @@ -6614,7 +6617,7 @@ const DisplayPartnerStagiaires = (props) => { const New_Option_Filter = [ { "id": "email", "label": "Email ", "value": "email" }, { "id": "nom", "label": "Nom ", "value": "nom" }, - { "id": "code_session", "label": "Code Session", "value": "code_session" }, + { "id": "code_session", "label": "Code Promo", "value": "code_session" }, { "id": "class_title", "label": "Titre Formation", "value": "class_title" }, { "id": "client_nom", "label": "Lié au Client (nom client) ", "value": "client_nom" }, { "id": "", "label": "", "value": "" }, @@ -6775,7 +6778,6 @@ const DisplayPartnerStagiaires = (props) => { const [Dialog_SEND_EMAIL_open, setDialog_SEND_EMAIL_open] = React.useState(false); - const Dialog_SEND_EMAIL_handleClose = () => { setDialog_SEND_EMAIL_open(false); } @@ -6913,6 +6915,198 @@ const DisplayPartnerStagiaires = (props) => { function clear_display_alert_mysy() { setdisplay_alert_mysy(""); } + + const [Dialog_PUSH_DOCUMENT_TO_ENT_open, setDialog_PUSH_DOCUMENT_TO_ENT_open] = React.useState(false); + + const Dialog_PUSH_DOCUMENT_TO_ENT_handleClose = () => { + setDialog_PUSH_DOCUMENT_TO_ENT_open(false); + settab_email_pieces_jointes_result([]); + } + + const [tab_email_pieces_jointes_result, settab_email_pieces_jointes_result] = useState([]); + const sessions_file_change_1_piece_jointe = event => { + + + const fileUploaded = event.target.files[0]; + let file_size = event.target.files[0].size; + let file_type = event.target.files[0].type; + + + if (file_type !== "application/pdf") { + // alert("Le fichier n'est pas de type PDF"); + + setdisplay_alert_mysy("1"); + setalert_message("Le fichier n'est pas de type PDF"); + setalert_type("error"); + return; + } + + + + if (file_size > 10000000) { + // alert("Le fichier ne doit pas depasser un 1 Méga octets"); + // console.log("Le fichier ne doit pas depasser un 1 Méga octets"); + + setdisplay_alert_mysy("1"); + setalert_message("Le fichier ne doit pas depasser un 1 Méga octets"); + setalert_type("error"); + return; + } + + //var new_node = {'name':event.target.files[0].name, 'type':event.target.files[0].type} + + + var new_tmp = []; + + if (tab_email_pieces_jointes_result && tab_email_pieces_jointes_result.length > 0) { + + tab_email_pieces_jointes_result.map((x) => { + new_tmp.push(x); + + }); + + } + + new_tmp.push(event.target.files[0]) + + settab_email_pieces_jointes_result(new_tmp); + + //console.log(" tab_convention_pieces_jointes_result = ", tab_convention_pieces_jointes_result) + return; + }; + + function Delete_Email_Attached_Doc(event) { + + var doc_to_del_name = event.target.id; + const myArray = tab_email_pieces_jointes_result; + + + console.log(" Suppression du fichier : ", doc_to_del_name) + let new_myArray = myArray.filter(file => file.name !== String(doc_to_del_name)); + + //console.log(" new_myArray = ", new_myArray); + + + var new_tab = [] + for (let i = 0; i < new_myArray.length; i++) { + new_tab.push(new_myArray[i]); + } + + settab_email_pieces_jointes_result(new_tab); + } + + const [include_client, setinclude_client] = useState(false); + const [include_tuteur, setinclude_tuteur] = useState(false); + + const [store_file_in_ent, setstore_file_in_ent] = useState(false); + + const handleChange_file_to_ent = (event) => { + if (event.currentTarget.checked) { + setstore_file_in_ent(true); + } + else { + setstore_file_in_ent(false); + } + } + + + const [Share_Document_To_Ent_api, setShare_Document_To_Ent_api] = useState(); + const [Share_Document_To_Ent_message, setShare_Document_To_Ent_message] = useState(); + const [Share_Document_To_Ent_result, setShare_Document_To_Ent_result] = useState(); + function Share_Document_To_Ent() { + + const tab_destinataire = selectedtraining_emails_liste.split(','); + if (tab_destinataire.length > 50) { + // alert(" Vous ne pouvez pas envoyer plus de 50 emails (destinataires) à la fois."); + + setdisplay_alert_mysy("1"); + setalert_message(" Vous ne pouvez pas envoyer plus de 50 emails (destinataires) à la fois."); + setalert_type("error"); + return; + } + + + + if (tab_email_pieces_jointes_result.length > 5) { + // alert("Vous ne pouvez pas envoyer plus de 5 pièces jointes à la fois."); + + setdisplay_alert_mysy("1"); + setalert_message("Vous ne pouvez pas envoyer plus de 5 pièces jointes à la fois."); + setalert_type("error"); + return; + } + + + if (tab_email_pieces_jointes_result.length <= 0) { + // alert("Vous ne pouvez pas envoyer plus de 5 pièces jointes à la fois."); + + setdisplay_alert_mysy("1"); + setalert_message("Aucun fichier à publier"); + setalert_type("error"); + return; + } + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("related_collection", "inscription"); + form.append("list_email_dest", selectedtraining_emails_liste); + + // pièce jointe + + + for (let i = 0; i < tab_email_pieces_jointes_result.length; i++) { + form.append('File', tab_email_pieces_jointes_result[i]); + } + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Push_Document_To_ENT_For_Inscrit/"; + form.append("list_inscription_id", selected_list_inscription_id); + + + + // return; + + setLoading(true); + + + axios.post(myurl, form).then(res => { + //console.log(" In Share_Document_To_Ent res.data.status = " + res.data.status); + //console.log(" In Share_Document_To_Ent res.data.message r_class = " + res.data.message); + setLoading(false); + if (String(res.data.status) === String("true")) { + + + setShare_Document_To_Ent_api("true"); + setShare_Document_To_Ent_result(res.data.message); + Dialog_PUSH_DOCUMENT_TO_ENT_handleClose(); + + //alert(res.data.message); + + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + + } + else { + setShare_Document_To_Ent_api("false"); + setShare_Document_To_Ent_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Share_Document_To_Ent = ', error); + setShare_Document_To_Ent_api("false"); + alert("Impossible de publier les documents dans l'espace ENT"); + //setmyApimyApiMessage("") + }) + } + return (
{isLoading &&
@@ -6929,6 +7123,249 @@ const DisplayPartnerStagiaires = (props) => { } {/*** FIN Affichage des messages d'alerte*/} + { /********* Dialog Partage fichier dans l'ENT */} + null} + + PaperProps={{ + + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '7rem', + margin: "2px", + maxWidth: '800px' + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + > + +   + + + + + + +
+
+ +
+ +
+ + +
+ + + {tab_email_pieces_jointes_result && tab_email_pieces_jointes_result.length > 0 &&
+ +
+ Liste des pièces jointes
+ + + {tab_email_pieces_jointes_result &&
+
+ +
+ {tab_email_pieces_jointes_result && tab_email_pieces_jointes_result.map((val) => ( +
+ + + + Supprimer + + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + Confirmer la suppression de la pièce jointe.
+ + +
+
+
+ + +
+
+ +
+
+
+ )} +
+ +
+ ))} +
+
+
} + + + +
+
} + + + +
+ +
+ + + +
+
+ { + }} className="bton_enreg_dialog">Publier + + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + Publier les document dans l'ENT ?
+ + +
+
+
+ + +
+
+ +
+
+
+ )} +
+
+
+ +
+
+ + + + + +
+ + +
+ { /********* FIN Dialog Partage fichier dans l'ENT */} + + + { /********* Dialog redaction email */} {
- Code Session + Code Promo
{selected_row_data_json.code_session &&
@@ -8899,7 +9336,8 @@ const DisplayPartnerStagiaires = (props) => { || String(value.value) === "convention" || String(value.value) === "exporter" || String(value.value) === "valide_inscr" || String(value.value) === "recyclage_disable" - || String(value.value) === "sendemail") { + || String(value.value) === "sendemail" + || String(value.value) === "pushdocument") { setactionmass_ftion_val(value.value); } else { @@ -8918,81 +9356,82 @@ const DisplayPartnerStagiaires = (props) => { /> - {actionmass_ftion_val && String(actionmass_ftion_val) !== "sendemail" && } - {actionmass_ftion_val && String(actionmass_ftion_val) === "sendemail" &&
- -
diff --git a/src/components/Module_Ent_Mes_Formations.js b/src/components/Module_Ent_Mes_Formations.js index 2fd35a5..f44ef12 100644 --- a/src/components/Module_Ent_Mes_Formations.js +++ b/src/components/Module_Ent_Mes_Formations.js @@ -2534,7 +2534,7 @@ const Module_Ent_Mes_Formations = (props) => { {Get_List_Of_All_PJ_result && Get_List_Of_All_PJ_result.map((val) => (

- Supprimer @@ -2582,7 +2582,7 @@ const Module_Ent_Mes_Formations = (props) => {
)} - + */}
))}