Ela_Front/src/components/Modules_Mes_Documents.js

1392 lines
59 KiB
JavaScript

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 { useParams } from 'react-router-dom';
import { getCookie, setCookie } from 'react-use-cookie';
import { useHistory } from "react-router-dom";
import CheckOut from "./CheckOut";
import {
DataGrid, frFR, GridToolbar,
} from '@mui/x-data-grid';
import * as XLSX from 'xlsx';
import { Fab } from "@material-ui/core";
import { IoMdAddCircle, IoIosRemoveCircleOutline } from "react-icons/io";
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
import { Editor } from '@tinymce/tinymce-react';
import parse from 'html-react-parser';
import { FcViewDetails, FcDisapprove, FcInfo } 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, sliderClasses } from '@mui/material';
import styled from 'styled-components';
import { CiTrash } from "react-icons/ci";
import { MdAddCircleOutline, MdRemoveCircleOutline } from "react-icons/md";
import Autocomplete from '@mui/material/Autocomplete';
import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif";
import { IoAddCircleOutline, IoCloseCircleOutline } from "react-icons/io5";
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 Link from '@mui/material/Link';
import { PiDotsThree } from "react-icons/pi";
import { gridClasses } from '@mui/x-data-grid';
import {
GridToolbarContainer, GridToolbarExport, GridToolbarColumnsButton,
GridToolbarFilterButton, GridToolbarDensitySelector, GridToolbarExportContainer, useGridApiContext,
gridFilteredSortedRowIdsSelector,
gridVisibleColumnFieldsSelector,
GridValueGetterParams,
GridPreferencePanelsValue,
} from '@mui/x-data-grid';
import AttachFileIcon from '@mui/icons-material/AttachFile';
//import { utils, writeFileXLSX } from "xlsx";
import { IconButton } from '@material-ui/core';
import MoreVertIcon from '@mui/icons-material/MoreVert';
import Menu from '@mui/material/Menu';
const Modules_Mes_Documents = (props) => {
const { action, orderid } = useParams();
const history = useHistory();
const [submenu, setsubmenu] = useState("");
const [rowss, setRows] = useState([]);
const [rowss_total_data, setRows_total_data] = useState([]);
const [selectionModel, setSelectionModel] = React.useState([]);
const [myprops_type_document, setmyprops_type_document] = React.useState("");
const [rows_invoice_lines, setrows_invoice_lines] = useState([]);
const [selectionModel_invoice_lines, setselectionModel_invoice_lines] = React.useState([]);
const [gridline_id, setgridline_id] = useState("");
var date_today_90j = new Date();
date_today_90j.setDate(date_today_90j.getDate() + 90);
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();
function ExpandableCell_50({ value }) {
const [expanded, setExpanded] = React.useState(false);
return (
<nav>
{value && <div style={{ paddingLeft: "5px", paddingRight: "15px", "display": "block", wordBreak: "break-all" }}>
{expanded ? value : String(value).slice(0, 50)}&nbsp;
{value.length > 50 && (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
<Link
type="button"
component="button"
sx={{ fontSize: 'inherit' }}
onClick={() => setExpanded(!expanded)}
>
{expanded ? <nav> <PiDotsThree />Réduire</nav> : <nav> <PiDotsThree />Voir</nav>}
</Link>
)}
</div>}
{!value && <div style={{ paddingLeft: "5px", paddingRight: "15px", "display": "block", wordBreak: "break-all" }}>
&nbsp;
</div>
}
</nav>
);
}
const options_menu_vertical = [
'',
'Télécharger',
];
const ITEM_HEIGHT = 48;
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick_option_button_vertical = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose_option_button_vertical = (event, value) => {
setAnchorEl(null);
};
const columns = [
{ field: '_id', headerName: '_id', hide: true, editable: false },
{ field: 'id', headerName: 'id', hide: true, editable: false },
{ field: 'file_extention', hide: true, editable: false },
{ field: 'file_name', headerName: 'file_name', hide: true, disableExport: true },
{
field: 'created_date', headerName: 'Date Creation', Width: 100, flex: 1, hide: false, editable: false,
renderCell: (cellValues) => {
return (
<nav style={{ width: '100%', 'textAlign': 'left' }}>
{String(cellValues.row.created_date).substring(0, 10)}
</nav>)
},
},
{ field: 'file_business_object', headerName: 'file_business_object', minWidth: 200, flex: 1, hide: false, editable: false, },
{ field: 'object_owner_collection', headerName: 'object_owner_collection', minWidth: 200, flex: 1, hide: false, editable: false },
{ field: 'client_raison_sociale', headerName: 'client_raison_sociale', minWidth: 200, flex: 1, hide: false, editable: false },
{ field: 'client_nom', headerName: 'client_nom', minWidth: 150, flex: 1, hide: false, editable: false },
{
field: 'type_document', headerName: 'type_document', minWidth: 100, flex: 1, hide: false, editable: false,
renderCell: (cellValues) => {
return (
<nav style={{ width: '100%', 'textAlign': 'left' }}>
{String(cellValues.row.type_document).charAt(0).toUpperCase() + String(cellValues.row.type_document).slice(1)}
</nav>)
},
},
{
field: 'bton_vertif', headerName: 'Gestion', minWidth: 50, flex: 1, maxWidth: 100, hideable: true, hide: false, editable: false, align: "center",
renderCell: (cellValues,) => {
return (
<nav style={{ width: '100%', 'textAlign': 'center' }}>
<IconButton
aria-label="more"
id="long-button"
aria-controls={open ? 'long-menu' : undefined}
aria-expanded={open ? 'true' : undefined}
aria-haspopup="true"
onClick={(e) => {
handleClick_option_button_vertical(e);
setprint_doc_id(cellValues.row._id);
setprint_file_extention(cellValues.row.file_extention);
setprint_file_business_object(cellValues.row.file_business_object);
}}
>
<MoreVertIcon />
</IconButton>
<Menu
id="long-menu"
MenuListProps={{
'aria-labelledby': 'long-button',
}}
anchorEl={anchorEl}
open={open}
onClose={handleClose_option_button_vertical}
onClick={(e) => {
}}
slotProps={{
paper: {
style: {
maxHeight: ITEM_HEIGHT * 4.5,
width: '20ch',
boxShadow: "-3px 4px 0px -30px #000000",
borderRadius: '0px !important',
lineHeight: '3rem'
},
},
}}
>
{options_menu_vertical.map((option) => (
<MenuItem key={option}
onClick={(e) => {
if (option && String(option) === "Télécharger") {
setselected_id(cellValues.row._id);
print_document_pdf(print_doc_id, print_file_extention, print_file_business_object);
}
setAnchorEl(null);
}}
>
{option}
</MenuItem>
))}
</Menu>
</nav>
);
},
},
]
const [print_doc_id, setprint_doc_id] = useState("");
const [print_file_extention, setprint_file_extention] = useState("");
const [print_file_business_object, setprint_file_business_object] = useState("");
function print_document_pdf(doc_id, file_extention, file_business_object) {
const stored_cookie = getCookie('tokenmysych');
var nom_fichier_cmd = String(file_business_object) + "." + String(file_extention);
console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- doc_id = ", doc_id);
var url = process.env.REACT_APP_API_URL + "myclass/api/Get_Stored_Downloaded_File_From_Id/" + stored_cookie + "/" + doc_id;
//console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id, " --- url =", url);
axios.get(url, { responseType: 'blob', },)
.then((res) => {
fileDownload(res.data, nom_fichier_cmd)
}).catch((error) => {
console.error('Error:', error);
});
}
const [isLoading, setLoading] = useState();
const [p_detail_header_client_nom_id, setp_detail_header_client_nom_id] = useState();
const myRef = useRef(null);
const [history_securite_read, sethistory_securite_read] = useState("");
const autorized_type_document = ['devis', 'convention', 'convocation', 'attestation'];
useEffect(() => {
console.log(" ### props.type_document = ", props.type_document)
if (props.type_document && autorized_type_document.includes(String(props.type_document))) {
console.log(" ### iciiii ")
setmyprops_type_document(props.type_document);
setp_filtre1("filter_type_document");
setp_filtre1_value(props.type_document);
Get_All_Documents_With_Filter();
} else {
Get_List_Of_All_PJ();
}
}, [])
const [display_detail_invoice, setdisplay_detail_invoice] = React.useState();
const myRef_head = useRef(null);
const [selected_id, setselected_id] = useState("");
const [selected_order_line_id, setselected_order_line_id] = useState("");
const [selected_order_header_type, setselected_order_header_type] = useState();
const [order_internal_ref, setorder_internal_ref] = useState("");
const [invoice_internal_ref, setinvoice_internal_ref] = useState("");
function submenu_color_management(current_menu) {
const list_sous_menu = ["order_header_facturation", "order_header_detail", "order_header_main", "order_header_detail", "paiement"]
for (let i = 0; i < list_sous_menu.length; i++) {
var sous_menu = list_sous_menu[i];
if (String(sous_menu) !== current_menu) {
if (document.getElementById(sous_menu)) {
document.getElementById(sous_menu).style.backgroundColor = "#d8edfc";
document.getElementById(sous_menu).style.color = "black";
document.getElementById(sous_menu).style.fontWeight = "normal";
}
}
}
if (document.getElementById(current_menu)) {
document.getElementById(current_menu).style.backgroundColor = "#104277";
document.getElementById(current_menu).style.color = "white";
document.getElementById(current_menu).style.fontWeight = "bold";
}
}
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
function print_invoice_pdf() {
const stored_cookie = getCookie('tokenmysych');
var nom_fichier_cmd = "Facture_" + invoice_internal_ref + ".pdf";
// console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id);
var url = process.env.REACT_APP_API_URL + "myclass/api/GerneratePDF_Partner_Invoice/" + stored_cookie + "/" + selected_id;
//console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id, " --- url =", url);
axios.get(url, { responseType: 'blob', },)
.then((res) => {
fileDownload(res.data, nom_fichier_cmd)
}).catch((error) => {
console.error('Error:', error);
});
}
function clean_all_filters() {
setp_filtre1("");
setp_filtre1_value();
setp_filtre2("");
setp_filtre2_value();
setp_filtre3("");
setp_filtre3_value();
setp_filtre4("");
setp_filtre4_value();
clean_order_detail_fields();
setsubmenu();
setSelectionModel([]);
setgridline_id("");
Get_List_Of_All_PJ();
}
function clean_order_detail_fields() {
}
const [Dialog_Detail_Article_open, setDialog_Detail_Article_open] = React.useState(false);
const Close_Dialog_Detail_Article_open = () => {
setDialog_Detail_Article_open(false);
};
const Dialog_1_handleClose = () => {
//alert(" Utiliser le bouton 'fermer' ");
//setOpen(false);
};
const Dialog_1_handleClose_buton = () => {
setDialog_1_open(false);
};
const [Dialog_1_open, setDialog_1_open] = React.useState(false);
const [Dialog_annotation_1_message, setDialog_annotation_1_message] = React.useState(false);
const [Dialog_annotation_1_open, setDialog_annotation_1_open] = React.useState(false);
function Dialog_1_handle_change_annotation(message) {
setDialog_annotation_1_message(message);
setDialog_annotation_1_open(true);
}
const Dialog_annotation_1_handleClose = () => {
//alert(" Utiliser le bouton 'fermer' ");
//setOpen(false);
};
const Dialog_annotation_1_handleClose_buton = () => {
setDialog_annotation_1_open(false);
/* if (document.getElementById('myRef')) {
var divh = document.getElementById('myRef').offsetTop;
window.scrollTo({
top: divh,
behavior: "smooth",
});
}*/
};
const New_Option_Filter = [
{ "id": "filter_file_business_object", "label": "Nom Document", "value": "filter_file_business_object" },
{ "id": "filter_type_document", "label": "Type Document", "value": "filter_type_document" },
{ "id": "filter_nom_client", "label": "Nom Client", "value": "filter_nom_client" },
{ "id": "date_create_start_date", "label": "Crée après (jj/mm/aaaa) ", "value": "date_create_start_date" },
{ "id": "date_create_end_date", "label": "Crée avant (jj/mm/aaaa)", "value": "date_create_end_date" },
{ "id": "filter_formation_external_code", "label": "Lié a la Formation (code externe)", "value": "filter_formation_external_code" },
{ "id": "filter_session_code", "label": "Lié a la session (code session)", "value": "filter_session_code" },
{ "id": "", "label": "", "value": "" },
{ "id": "1", "label": "", "value": "1" }, // Cette ligne pour couvrir l'ajout d'une ligne de filter. C'est fait expres.
]
const Option_Type_Document = [
{ "id": "devis", "label": "Devis", "value": "devis" },
{ "id": "convention", "label": "Convention", "value": "convention" },
{ "id": "convocation", "label": "Convocation", "value": "convocation" },
{ "id": "attestation", "label": "Attestation", "value": "attestation" },
{ "id": "autre", "label": "Autre", "value": "autre" },
{ "id": "", "label": "", "value": "" },
{ "id": "1", "label": "", "value": "1" }, // Cette ligne pour couvrir l'ajout d'une ligne de filter. C'est fait expres.
]
function handleClick_menu_droite_facture(e) {
console.log(" III ");
}
const New_type_apprenant = [
{ "id": "0", "label": "Autre", "value": "0" },
{ "id": "1", "label": "Salariés", "value": "1" },
{ "id": "2", "label": "Apprentis", "value": "2" },
{ "id": "3", "label": "Particuliers", "value": "3" },
{ "id": "4", "label": "Rech. Emploi", "value": "4" },
{ "id": "", "label": "", "value": "" },
]
// DEBUT EXPORT EXCEL DATAGRID
function CustomToolbar(props) {
return (
<GridToolbarContainer {...props}>
<GridToolbarColumnsButton />
<GridToolbarFilterButton />
<GridToolbarDensitySelector
slotProps={{ tooltip: { title: 'Change density' } }}
/>
<Box sx={{ flexGrow: 1 }} />
<ExportButton data_colums={props.data_colums} />
</GridToolbarContainer>
);
}
function getExcelData(apiRef) {
// Select rows and columns
const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
const visibleColumnsField = gridVisibleColumnFieldsSelector(apiRef);
// Format the data. Here we only keep the value
const data = filteredSortedRowIds.map((id) => {
const row = {};
visibleColumnsField.forEach((field) => {
row[field] = apiRef.current.getCellParams(id, field).value;
});
return row;
});
return data;
}
function ExportButton(props) {
return (
<GridToolbarExportContainer {...props}>
<ExportMenuItem data_colums={props.data_colums} />
</GridToolbarExportContainer>
);
}
function handleExport(apiRef, data_colums) {
const data = getExcelData(apiRef);
const visibleColumnsField = gridVisibleColumnFieldsSelector(apiRef);
const local_config = {
keys: visibleColumnsField,
columnNames: data_colums.filter((mydata) => (mydata).disableExport !== true).map(function (mydata) {
if (mydata.headerName && visibleColumnsField.includes(mydata.field)) {
if (mydata.headerName) {
return mydata.headerName;
}
}
}),
fileName: 'data_' + String(new Date().toJSON().slice(0, 10)).replaceAll("-", "_") + '.xlsx',
sheetName: 'Export_' + String(new Date().toJSON().slice(0, 10)).replaceAll("-", "_"),
};
local_config.columnNames = local_config.columnNames.filter(function (element) {
return element !== undefined;
});
const rows = data.map((row) => {
const mRow = {};
for (const key of local_config.keys) {
mRow[key] = row[key];
}
return mRow;
});
const worksheet = XLSX.utils.json_to_sheet(rows);
XLSX.utils.sheet_add_aoa(worksheet, [[...local_config.columnNames]], {
origin: 'A1',
});
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, local_config.sheetName);
XLSX.writeFile(workbook, local_config.fileName, { compression: true });
}
function ExportMenuItem(props) {
const apiRef = useGridApiContext();
const { hideMenu } = props;
return (
<MenuItem
onClick={() => {
handleExport(apiRef, props.data_colums);
// Hide the export menu after the export
hideMenu?.();
}}
>
Export Excel
</MenuItem>
);
}
// FIN EXPORT EXCEL DATAGRID
const [Dialog_send_invoice_with_PJ_message, setDialog_send_invoice_with_PJ_message] = React.useState(false);
const [Dialog_send_invoice_with_PJ_open, setDialog_send_invoice_with_PJ_open] = React.useState(false);
function Dialog_send_invoice_with_PJ_handle_change_participant_session(message) {
setDialog_send_invoice_with_PJ_message(message);
setDialog_send_invoice_with_PJ_open(true);
}
const [tab_invoice_mail_pieces_jointes_result, settab_invoice_mail_pieces_jointes_result] = useState([]);
const [Dialog_invoice_history_message, setDialog_invoice_history_message] = React.useState(false);
const [Dialog_invoice_history_open, setDialog_invoice_history_open] = React.useState(false);
function Dialog_invoice_history_handle_change_participant_session(message) {
setDialog_invoice_history_message(message);
setDialog_invoice_history_open(true);
}
const Dialog_invoice_history_handleClose = () => {
//alert(" Utiliser le bouton 'fermer' ");
//setOpen(false);
};
const Dialog_invoice_history_handleClose_buton = () => {
setDialog_invoice_history_open(false);
settab_invoice_mail_pieces_jointes_result([]);
if (document.getElementsByName("invoice_history_bton") && document.getElementsByName("invoice_history_bton")[0]) {
document.getElementsByName("invoice_history_bton")[0].style.backgroundColor = "#d8edfc";
document.getElementsByName("invoice_history_bton")[0].style.color = "#3b3e40";
}
};
const [Get_List_Of_All_PJ_api, setGet_List_Of_All_PJ_api] = useState();
const [Get_List_Of_All_PJ_result, setGet_List_Of_All_PJ_result] = useState();
const [Get_List_Of_All_PJ_message, setGet_List_Of_All_PJ_message] = useState();
function Get_List_Of_All_PJ() {
const formData = new FormData();
//formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA');
const stored_cookie = getCookie('tokenmysych');
formData.append("token", stored_cookie);
formData.append("object_owner_id", props.partner_client_id);
//formData.append("class_internal_url", internal_url);
//console.log("token = " + stored_cookie);
setLoading(true);
fetch(
process.env.REACT_APP_API_URL + "myclass/api/Get_List_object_owner_collection_Stored_Files/",
{
method: 'POST',
body: formData,
}
)
.then((response) => response.json())
.then((result) => {
setLoading(false);
//console.log(" ## result['status'] = ", result['status'])
if (String(result['status']) === String("true")) {
// console.log('Message :', result['message']);
setGet_List_Of_All_PJ_result(result['message']);
setGet_List_Of_All_PJ_api("true");
setRows(result['message']);
}
else {
setGet_List_Of_All_PJ_message(result['message']);
setGet_List_Of_All_PJ_api("false");
}
})
.catch((error) => {
setLoading(false);
console.error(' Get_List_Of_All_PJ Error:', error);
setGet_List_Of_All_PJ_api("false");
});
}
// -- Gestion pièces jointes
const [Download_one_attached_document_api, setDownload_one_attached_document_api] = useState();
const [Download_one_attached_document_result, setDownload_one_attached_document_result] = useState();
const [Download_one_attached_document_message, setDownload_one_attached_document_message] = useState();
const Download_one_attached_document = (event) => {
const stored_cookie = getCookie('tokenmysych');
var nom_fiche_detaillee = "Fiche_Detaillee.pdf";
var token = stored_cookie;
var file_name = event.target.id;
var url = process.env.REACT_APP_API_URL + "myclass/api/Get_Stored_Downloaded_File/" + token + "/" + file_name;
setLoading(true);
axios.get(url, { responseType: 'blob', },)
.then((res) => {
setLoading(false);
fileDownload(res.data, nom_fiche_detaillee);
setDownload_one_attached_document_api("true");
}).catch((error) => {
setLoading(false);
console.error('Error:', error);
setDownload_one_attached_document_api("false");
});
}
const [Get_All_Documents_With_Filter_api, setGet_All_Documents_With_Filter_api] = useState();
const [Get_All_Documents_With_Filter_message, setGet_All_Documents_With_Filter_message] = useState();
const [Get_All_Documents_With_Filter_result, setGet_All_Documents_With_Filter_result] = useState();
function Get_All_Documents_With_Filter() {
setgridline_id("");
var form = new FormData();
const stored_cookie = getCookie('tokenmysych');
form.append("token", stored_cookie);
// Recuperation des parametres
var filtre1 = p_filtre1;
var filtre2 = p_filtre2;
var filtre3 = p_filtre3;
var filtre1_value = "";
var filtre2_value = "";
var filtre3_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, filtre3_value);
}
/*** Si le formulaire est appelé avec un type de document;
* on va forcer dans les argument un champ avec filter_type_document
*/
if (props.type_document && autorized_type_document.includes(String(props.type_document))) {
form.delete("filter_type_document");
form.append("filter_type_document", props.type_document);
}
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_object_owner_collection_Stored_Files_With_Filter/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === String("true")) {
//console.log(" In Get_All_Documents_With_Filter res.data.status = " + res.data.status);
// console.log(" In Get_All_Documents_With_Filter res.data.message r_class = " + res.data.message);
setGet_All_Documents_With_Filter_api("true");
setGet_All_Documents_With_Filter_result(res.data.message);
setRows(res.data.message);
//setRows_total_data(JSON.parse(res.data.total_data));
}
else {
setGet_All_Documents_With_Filter_api("false");
setGet_All_Documents_With_Filter_message(res.data.message);
alert(res.data.message);
}
}).catch((error) => {
console.warn('Not good man :( Get_All_Documents_With_Filter = ', error);
setGet_All_Documents_With_Filter_api("false");
alert(" Impossible de recuperer la liste des factures");
//setm yApimyApiMessage("")
})
}
/***
* IMPORTANT
* Ce module permet d'afficher et telecharger tous les documents qui sont dans la collection 'download_files', c'est à dire :
* 1 - Les documents importés manuellement sur l'espace du client
* 2 - Les devis signés electroniquement (en effet ils sont automatiquement importés dans l'espace du client)
* 3 - Les Convention signés electroniquement (en effet ils sont automatiquement importés dans l'espace du client)
* 4 - A ajouter : les convocations adressées à ses apprenants
* 5 - A ajouter : les attestations adressées à ses apprenants
*
* /!\ /!\ /!\ /!\ /!\ /!\ /!\ Les factures sont bien dans la collection, mais pour recuperer il faut passer par la collection 'partner_invoice_header'
* /!\ /!\ /!\ /!\ /!\ /!\ /!\ raison pour laquel, on va mettre les documents d'un coté et les facture de l'autre.
*/
return (
<div className="modules_mes_documents">
{isLoading && <div className="loader-container">
<div className="mysy_spinner"> <img src={img_loading_spin} /> </div>
</div>}
{props.my_title && <h3> {props.my_title} </h3>}
{!props.my_title && <h3> Tous vos documents </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" >
{New_Option_Filter && New_Option_Filter.length > 0 && <Autocomplete
disablePortal
name="filtre1"
id="filtre1"
className="disabled_style"
value={New_Option_Filter.filter((data) => (data).value === String(p_filtre1))[0].label}
options={New_Option_Filter}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre1(value.value);
} else {
setp_filtre1("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>}
</div>
<div className="div_row_droite texte_area_filter_value" >
{p_filtre1 && String(p_filtre1) !== "filter_type_document" &&
<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>
),
}}
/>
}
{p_filtre1 && String(p_filtre1) === "filter_type_document" &&
<Autocomplete
disablePortal
name="filtre1_value"
id="filtre1_value"
className="disabled_style autocomplete_float_right"
options={Option_Type_Document}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre1_value(value.value);
} else {
setp_filtre1_value("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>
}
</div>
{p_filtre1 && <div className='filter_bton_add'>
<Tooltip className="tooltip_css" id="my-tooltip01" style={{ "fontSize": "12px" }} />
<a data-tooltip-id="my-tooltip01" data-tooltip-html="Ajouter une nouvelle ligne de filtre">
&nbsp; <MdAddCircleOutline onClick={(e) => {
setp_filtre2("1");
setp_filtre2_value("");
}} />
</a>
</div>}
{p_filtre1 && <div className='filter_bton_add'>
<Tooltip className="tooltip_css" id="my-tooltip02" style={{ "fontSize": "12px" }} />
<a data-tooltip-id="my-tooltip02" data-tooltip-html="Supprimer cette ligne de filtre">
&nbsp; <MdRemoveCircleOutline onClick={(e) => {
setp_filtre1("");
setp_filtre1_value();
}}
/>
</a>
</div>}
</div>
{p_filtre2 &&
<div className="div_row" style={{ "marginBottom": "5px" }}>
<div className="div_row_gauche texte_area_filter">
{New_Option_Filter && New_Option_Filter.length > 0 && <Autocomplete
disablePortal
name="filtre2"
id="filtre2"
className="disabled_style"
value={New_Option_Filter.filter((data) => (data).value === String(p_filtre2))[0].label}
options={New_Option_Filter}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre2(value.value);
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>}
</div>
<div className="div_row_droite texte_area_filter_value" style={{ "marginTop": "0.5rem" }} >
{String(p_filtre2).length > 2 && String(p_filtre2) !== "filter_type_document" &&
<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>
),
}}
/>}
{String(p_filtre2).length > 2 && String(p_filtre2) === "filter_type_document" &&
<Autocomplete
disablePortal
name="filtre2_value"
id="filtre2_value"
className="disabled_style autocomplete_float_right"
options={Option_Type_Document}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre2_value(value.value);
} else {
setp_filtre2_value("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>}
</div>
{String(p_filtre2).length > 2 && <div className='filter_bton_add' >
<Tooltip className="tooltip_css" id="my-tooltip03" style={{ "fontSize": "12px" }} />
<a data-tooltip-id="my-tooltip03" data-tooltip-html="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 className="tooltip_css" id="my-tooltip04" style={{ "fontSize": "12px" }} />
<a data-tooltip-id="my-tooltip04" data-tooltip-html="Supprimer cette ligne de filtre">
&nbsp; <MdRemoveCircleOutline
onClick={(e) => {
setp_filtre2("");
setp_filtre2_value();
}}
/>
</a>
</div>}
</div>
}
{p_filtre3 &&
<div className="div_row" style={{ "marginBottom": "5px" }}>
<div className="div_row_gauche texte_area_filter">
{New_Option_Filter && New_Option_Filter.length > 0 && <Autocomplete
disablePortal
name="filtre3"
id="filtre3"
className="disabled_style"
value={New_Option_Filter.filter((data) => (data).value === String(p_filtre3))[0].label}
options={New_Option_Filter}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre3(value.value);
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>}
</div>
<div className="div_row_droite texte_area_filter_value" style={{ "marginTop": "0.5rem" }}>
{String(p_filtre3).length > 2 && String(p_filtre3) !== "filter_type_document" &&
<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>
),
}}
/>}
{String(p_filtre3).length > 2 && String(p_filtre3) === "filter_type_document" &&
<Autocomplete
disablePortal
name="filtre3_value"
id="filtre3_value"
className="disabled_style autocomplete_float_right"
options={Option_Type_Document}
onChange={(event, value) => {
if (value && value.value) {
setp_filtre3_value(value.value);
} else {
setp_filtre3_value("");
}
}}
renderInput={(params) => <TextField {...params} label="" placeholder="Choisir une option"
inputProps={{ ...params.inputProps, style: { fontSize: 12, height: "1.4rem" } }}
/>
}
/>}
</div>
{String(p_filtre2).length > 2 && <div className='filter_bton_add' >
<Tooltip className="tooltip_css" id="my-tooltip03" style={{ "fontSize": "12px" }} />
<a data-tooltip-id="my-tooltip03" data-tooltip-html="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 className="tooltip_css" id="my-tooltip05" style={{ "fontSize": "12px" }} />
<a data-tooltip-id="my-tooltip05" data-tooltip-html="Supprimer cette ligne de filtre">
&nbsp; <MdRemoveCircleOutline onClick={(e) => {
setp_filtre3("");
setp_filtre3_value();
}} />
</a>
</div>}
</div>
}
<div className="div_row" ref={myRef_head} id="myRef_head" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>
<div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>
<Button variant="contained" className="bton_enreg" onClick={Get_All_Documents_With_Filter}>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" style={{ "border": "None", paddingRight: '10px' }}>
<div className="session_data">
<div style={{ "border": "None" }}>
<div style={{ height: 550, width: '100%', paddingRight: '5px' }}>
&nbsp;
<Box
sx={{
height: 500,
width: '100%',
paddingRight: '1px',
// Gestion des cellule "statut"
'& .cell--status--encours': {
backgroundColor: '#E6F7C8',
color: '#1a3e72',
fontWeight: 'light',
},
'& .cell--status--traite': {
backgroundColor: '#E6CEAA',
color: '#F9E79F',
fontWeight: 'light',
},
/*"& .MuiDataGrid-virtualScrollerRenderZone": {
"& .MuiDataGrid-row": {
"&:nth-child(2n)": { backgroundColor: "rgba(235, 235, 235, .7)" }
}
},*/
"& .MuiDataGrid-columnHeaders": {
backgroundColor: "#c8cfd5",
color: "black",
fontSize: 14
},
'& .line--statut--selected': {
backgroundColor: '#FBF2EF',
color: 'black',
},
'& .line--statut--pair': {
backgroundColor: 'rgba(235, 235, 235, .7)',
color: 'black',
},
'& .line--statut--impair': {
backgroundColor: '#FFFFFF',
color: 'black',
},
'& .line--statut--payed': {
backgroundColor: '#EAFAF1',
color: '#239B56',
fontWeight: '700'
},
}}
>
<DataGrid
components={{
Toolbar: CustomToolbar
}}
componentsProps={{ toolbar: { data_colums: columns } }}
// checkboxSelection
disableSelectionOnClick
onSelectionModelChange={(newSelectionModel) => {
setSelectionModel(newSelectionModel);
/*if (newSelectionModel.length === 1)
handleClick_edit_invoice_From_Line(newSelectionModel);*/
if (newSelectionModel.length !== 1) {
//clean_order_detail_fields();
//setsubmenu();
setdisplay_detail_invoice();
}
}}
onRowDoubleClick={(newSelectionModel) => {
setgridline_id(newSelectionModel.row.id);
// setp_detail_header_client_nom_id(newSelectionModel.row.order_header_client_id);
// handleClick_edit_invoice_From_Line(newSelectionModel.row.id);
}
}
selectionModel={selectionModel}
localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
rows={rowss.map((item, index) => (
{
id: index,
_id: JSON.parse(item)._id,
file_name: JSON.parse(item).file_name,
file_business_object: JSON.parse(item).file_business_object,
object_owner_collection: JSON.parse(item).object_owner_collection,
type_document: JSON.parse(item).type_document,
file_extention: JSON.parse(item).file_extention,
client_raison_sociale: JSON.parse(item).client_raison_sociale,
client_nom: JSON.parse(item).client_nom,
created_date: JSON.parse(item).created_date,
}
))}
columns={columns}
pageSize={10}
className="datagridclass"
rowsPerPageOptions={[10]}
//disableSelectionOnClick
/* components={{
Toolbar: GridToolbar,
}}*/
//sx={datagridSx}
getCellClassName={(params) => {
}}
getRowClassName={(params) => {
// Pour la gestion de la couleur de zone double cliquée
if (String(params.row.id) === String(gridline_id)) {
return 'line--statut--selected';
}
else if (parseInt(String(params.row.id)) % 2 === 0) {
return 'line--statut--pair';
}
else if (parseInt(String(params.row.id)) % 2 !== 0) {
return 'line--statut--impair';
}
}}
/>
</Box>
<br />
</div>
</div>
</div>
</div>
<div className="div_row" > &nbsp;</div>
{/* <div className="div_row" style={{ "border": "None", paddingRight: '10px' }}>
{Get_List_Of_All_PJ_result && <div className="div_row" style={{ "padding": "5px" }}>
<div className="div_row">
<b> Liste des pièces jointes </b> <br />
<div className="div_row">
{Get_List_Of_All_PJ_result && Get_List_Of_All_PJ_result.map((val) => (
<div className="div_row_list_pj" >
<nav name={(JSON.parse(val).file_name)}
id={(JSON.parse(val).file_name)}> <i> <AttachFileIcon />{(JSON.parse(val).file_business_object)} </i> <br /><font style={{ "color": "green", "cursor": "pointer" }}
name={(JSON.parse(val).file_name)}
id={(JSON.parse(val).file_name)} onClick={Download_one_attached_document}> Télécharger &nbsp;</font></nav>
<Popup
trigger={
<nav style={{ "color": "red", "cursor": "pointer" }} > Supprimer</nav>
}
modal
nested
position="center center"
>
{close => (
<div>
<button className="gest_close" onClick={close}>
&times;
</button>
<div className="gest_header"> MySy Information </div>
<div className="gest_content">
{' '}
En confirmant cette opération, la pièce jointe sera <i><font color="red"> définitivement supprimée</font></i>. <br />
</div>
<div className="gest_actions">
<div style={{ "width": "45%", "float": "left" }}>
<button className="gest_bton_popup" onClick={(event) => {
// Delete_one_attached_document(event);
close();
}}
name={(JSON.parse(val).file_name)} id={(JSON.parse(val).file_name)}
> Valider </button>
</div>
<div style={{ "width": "45%", "float": "right" }}>
<button
className="gest_bton_popup"
onClick={() => {
//console.log('modal closed ');
close();
}}
>
Annuler
</button>
</div>
</div>
</div>
)}
</Popup>
</div>
))}
</div>
</div>
</div>}
</div>*/}
<div className="div_row" ref={myRef} id="myRef" > &nbsp;</div>
</div >
)
}
export default Modules_Mes_Documents;