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 DeleteIcon from '@mui/icons-material/Delete'; import { getCookie, setCookie } from 'react-use-cookie'; import { AiTwotoneEdit, AiTwotoneSave } from "react-icons/ai"; import { useHistory } from "react-router-dom"; import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css"; import { GrUserAdmin, GrOrderedList } from "react-icons/gr"; import 'react-tooltip/dist/react-tooltip.css' import { Tooltip } from 'react-tooltip' import { CiEdit, CiTrash } from "react-icons/ci"; import { IoAddCircleOutline, IoCloseCircleOutline } from "react-icons/io5"; import { AiOutlineUserAdd } from "react-icons/ai"; import PartnerClientActivite from "./PartnerClient_Activite"; import Popup from 'reactjs-popup'; import 'reactjs-popup/dist/index.css'; import ToggleSwitch from "./ToggleSwitch"; import { FcSpeaker } from "react-icons/fc"; import Autocomplete from '@mui/material/Autocomplete'; import { gridClasses } from '@mui/x-data-grid'; import Link from '@mui/material/Link'; import { PiDotsThree } from "react-icons/pi"; const AddParnerClient = (props) => { const history = useHistory(); const [submenu, setsubmenu] = useState(""); const [current_contact_recid, setcurrent_contact_recid] = useState(""); const [datamodification, setdatamodification] = useState("0"); const [formedit_mode, setformedit_mode] = useState("0"); const [datamodification_invoice, setdatamodification_invoice] = useState("0"); const [formedit_mode_invoice, setformedit_mode_invoice] = useState("0"); const [datamodification_contact, setdatamodification_contact] = useState("0"); const [formedit_mode_contact, setformedit_mode_contact] = useState("0"); const [p_client_email, setclient_email] = useState(""); const [p_client_nom, setclient_nom] = useState(""); const [p_client_type_id, setp_client_type_id] = useState(""); const [p_client_type_label, setp_client_type_label] = useState(""); const [p_client_raison_sociale, setclient_raison_sociale] = useState(""); const [p_client_siret, setclient_siret] = useState(""); const [p_client_tva, setclient_tva] = useState(""); const [p_client_adresse, setclient_adresse] = useState(""); const [p_client_ville, setclient_ville] = useState(""); const [p_client_code_postal, setclient_code_postal] = useState(""); const [p_client_pays, setclient_pays] = useState(""); const [p_client_telephone, setclient_telephone] = useState(""); const [p_client_website, setclient_website] = useState(""); // Données de facturation const [p_client_invoice_email, setclient_invoice_email] = useState(""); const [p_client_invoice_nom, setclient_invoice_nom] = useState(""); const [p_client_invoice_siret, setclient_invoice_siret] = useState(""); const [p_client_invoice_tva, setclient_invoice_tva] = useState(""); const [p_client_invoice_adresse, setclient_invoice_adresse] = useState(""); const [p_client_invoice_ville, setclient_invoice_ville] = useState(""); const [p_client_invoice_code_postal, setclient_invoice_code_postal] = useState(""); const [p_client_invoice_pays, setclient_invoice_pays] = useState(""); // Données contact const [p_contact_email, setp_contact_email] = useState(""); const [p_contact_nom, setp_contact_nom] = useState(""); const [p_contact_prenom, setp_contact_prenom] = useState(""); const [p_contact_siret, setcontact_siret] = useState(""); const [p_contact_tva, setcontact_tva] = useState(""); const [p_contact_adresse, setcontact_adresse] = useState(""); const [p_contact_ville, setcontact_ville] = useState(""); const [p_contact_code_postal, setcontact_code_postal] = useState(""); const [p_contact_pays, setcontact_pays] = useState(""); const [p_contact_telephone, setcontact_telephone] = useState(""); const [p_contact_telephone_mobile, setp_contact_telephone_mobile] = useState(""); const [p_contact_fonction, setp_contact_fonction] = useState(""); const [p_contact_civilite, setp_contact_civilite] = useState(""); const [selected_contact_id, setelected_contact_id] = useState(""); function ExpandableCell_50({ value }) { const [expanded, setExpanded] = React.useState(false); return ( ); } function Display_Colunm_text({ value }) { return (
{value} 
); } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } const [importmessage, setimportmessage] = useState(""); async function submenu_donnee_client() { setsubmenu("submenu_donnee_client"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); if (String(formedit_mode) !== "1") { Disable_fields(); } else { Enable_fields(); } /* document.getElementById("submenu_factures").style.background = "#d8edfc"; document.getElementById("submenu_factures").style.color = "#3b3e40"; document.getElementById("submenu_stagiaires").style.background = "#d8edfc"; document.getElementById("submenu_stagiaires").style.color = "#3b3e40"; document.getElementById("submenu_devis").style.background = "#d8edfc"; document.getElementById("submenu_devis").style.color = "#3b3e40"; document.getElementById("submenu_cmd").style.background = "#d8edfc"; document.getElementById("submenu_cmd").style.color = "#3b3e40"; */ document.getElementById("submenu_contact").style.background = "#d8edfc"; document.getElementById("submenu_contact").style.color = "#3b3e40"; document.getElementById("submenu_activite").style.background = "#d8edfc"; document.getElementById("submenu_activite").style.color = "#3b3e40"; document.getElementById("submenu_donnee_client").style.background = "#d8edfc"; document.getElementById("submenu_donnee_client").style.color = "#3b3e40"; document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; document.getElementById("submenu_donnee_client").style.background = "#104277"; document.getElementById("submenu_donnee_client").style.color = "white"; } async function submenu_donnee_facturation() { setsubmenu("submenu_donnees_facturation"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); if (String(formedit_mode_invoice) !== "1") { Disable_invoice_fields(); } else { Enable_invoice_fields(); } /*document.getElementById("submenu_factures").style.background = "#d8edfc"; document.getElementById("submenu_factures").style.color = "#3b3e40"; document.getElementById("submenu_stagiaires").style.background = "#d8edfc"; document.getElementById("submenu_stagiaires").style.color = "#3b3e40"; document.getElementById("submenu_devis").style.background = "#d8edfc"; document.getElementById("submenu_devis").style.color = "#3b3e40"; document.getElementById("submenu_cmd").style.background = "#d8edfc"; document.getElementById("submenu_cmd").style.color = "#3b3e40"; */ document.getElementById("submenu_contact").style.background = "#d8edfc"; document.getElementById("submenu_contact").style.color = "#3b3e40"; document.getElementById("submenu_activite").style.background = "#d8edfc"; document.getElementById("submenu_activite").style.color = "#3b3e40"; document.getElementById("submenu_donnee_client").style.background = "#d8edfc"; document.getElementById("submenu_donnee_client").style.color = "#3b3e40"; document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; document.getElementById("submenu_donnee_facturation").style.background = "#104277"; document.getElementById("submenu_donnee_facturation").style.color = "white"; } async function submenu_contact() { setsubmenu("submenu_contact"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); /*if (String(formedit_mode_invoice) !== "1") { Disable_invoice_fields(); } else { Enable_invoice_fields(); }*/ /* document.getElementById("submenu_factures").style.background = "#d8edfc"; document.getElementById("submenu_factures").style.color = "#3b3e40"; document.getElementById("submenu_stagiaires").style.background = "#d8edfc"; document.getElementById("submenu_stagiaires").style.color = "#3b3e40"; document.getElementById("submenu_devis").style.background = "#d8edfc"; document.getElementById("submenu_devis").style.color = "#3b3e40"; document.getElementById("submenu_cmd").style.background = "#d8edfc"; document.getElementById("submenu_cmd").style.color = "#3b3e40"; */ document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; document.getElementById("submenu_activite").style.background = "#d8edfc"; document.getElementById("submenu_activite").style.color = "#3b3e40"; document.getElementById("submenu_donnee_client").style.background = "#d8edfc"; document.getElementById("submenu_donnee_client").style.color = "#3b3e40"; document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; document.getElementById("submenu_contact").style.background = "#104277"; document.getElementById("submenu_contact").style.color = "white"; } async function submenu_activite() { setsubmenu("submenu_activite"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); if (String(formedit_mode_invoice) !== "1") { //Disable_invoice_fields(); } else { //Enable_invoice_fields(); } /* document.getElementById("submenu_factures").style.background = "#d8edfc"; document.getElementById("submenu_factures").style.color = "#3b3e40"; document.getElementById("submenu_stagiaires").style.background = "#d8edfc"; document.getElementById("submenu_stagiaires").style.color = "#3b3e40"; document.getElementById("submenu_devis").style.background = "#d8edfc"; document.getElementById("submenu_devis").style.color = "#3b3e40"; document.getElementById("submenu_cmd").style.background = "#d8edfc"; document.getElementById("submenu_cmd").style.color = "#3b3e40"; */ document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; document.getElementById("submenu_donnee_client").style.background = "#d8edfc"; document.getElementById("submenu_donnee_client").style.color = "#3b3e40"; document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; document.getElementById("submenu_contact").style.background = "#d8edfc"; document.getElementById("submenu_contact").style.color = "#3b3e40"; document.getElementById("submenu_activite").style.background = "#104277"; document.getElementById("submenu_activite").style.color = "white"; } async function submenu_devis() { setsubmenu("submenu_devis"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); } async function submenu_cmd() { setsubmenu("submenu_cmd"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); } async function submenu_factures() { setsubmenu("submenu_factures"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); } async function submenu_stagiaires() { setsubmenu("submenu_stagiaires"); /* Ceci est super crade, fair eun wait de pour attendre l'afficage avant de desacitcation si on a desactiver, mais bon ... on avance. */ await sleep(5); } function DataUpdated() { setdatamodification("1"); } function DataEditMode() { setformedit_mode("1"); Enable_fields(); } function AnnulerEdit() { setformedit_mode("0"); setdatamodification("0"); Disable_fields(); clear_fields(); fillfield_Only_Main_Data(props.client_mail); } function DataUpdated_Invoice_Data() { setdatamodification_invoice("1"); } function DataEditMode_Invoice_Data() { setformedit_mode_invoice("1"); Enable_invoice_fields(); } function DataUpdated_Contact_Data() { setdatamodification_contact("1"); } function DataEditMode_Contact_Data() { setformedit_mode_contact("1"); Enable_contact_fields(); } function AnnulerEdit_Invoice_Data() { setformedit_mode_invoice("0"); setdatamodification_invoice("0"); Disable_invoice_fields(); clear_invoice_fields(); fillfield_Invoice_Data(props.client_mail); } function SetTabFocus() { document.getElementById("submenu_donnee_client").style.background = "#d8edfc"; document.getElementById("submenu_donnee_client").style.color = "#3b3e40"; document.getElementById("submenu_donnee_facturation").style.background = "#d8edfc"; document.getElementById("submenu_donnee_facturation").style.color = "#3b3e40"; if (String(submenu) === "submenu_donnee_client") { document.getElementById("submenu_donnee_client").style.background = "#104277"; document.getElementById("submenu_donnee_client").style.color = "white"; } else if (String(submenu) === "submenu_donnees_facturation") { document.getElementById("submenu_donnee_facturation").style.background = "#104277"; document.getElementById("submenu_donnee_facturation").style.color = "white"; } } const [addcontact, setaddcontact] = useState("0"); function Add_Contact() { setis_contact_include_com(false); setdatamodification_contact("0"); setformedit_mode_contact("1"); clean_contact_set_values(); setaddcontact("1"); setcurrent_contact_recid(""); } function Close_Contact() { setaddcontact("0"); setdatamodification_contact("0"); setformedit_mode_contact("0"); clear_contact_fields(); clean_contact_set_values(); setdatamodification_invoice("0"); setformedit_mode_contact("0"); setcurrent_contact_recid(""); setis_contact_include_com(false); } const [New_Get_List_Client_Type_result, setNew_Get_List_Client_Type_result] = useState([]); const [Get_List_Client_Type_api, setGet_List_Client_Type_api] = useState(); const [Get_List_Client_Type_message, setGet_List_Client_Type_message] = useState(); const [Get_List_Client_Type_result, setGet_List_Client_Type_result] = useState(); function Get_List_Client_Type(event) { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); const related_collection = "partner_client" form.append("token", stored_cookie); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Client_Type_List/"; axios.post(myurl, form).then(res => { //console.log(" In Get_List_Client_Type res.data.status = " + res.data.status); //console.log(" In Get_List_Client_Type res.data.message r_class = " + res.data.message); if (String(res.data.status) === String("true")) { setGet_List_Client_Type_api("true"); setGet_List_Client_Type_result(res.data.message); var new_data2 = []; const new_data = res.data.message.map((x) => { //--- var localid = JSON.parse(x).id; var local_id = JSON.parse(x)._id; var local_code = JSON.parse(x).code; //--- var node = { "_id": local_id, "id": localid, "label": local_code, "code": local_code, }; new_data2.push(node); }); //--- var node = { "_id": "", "id": "", "label": "", "code": "", }; new_data2.push(node); if (new_data2.length > 0) setNew_Get_List_Client_Type_result(new_data2); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); } else { setGet_List_Client_Type_api("false"); setGet_List_Client_Type_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( Get_List_Client_Type = ', error); setGet_List_Client_Type_api("false"); alert(" Impossible de récupérer les types de clients"); }) } useEffect(() => { Get_List_Client_Type(); if (String(props.new_customer) !== "1") { setformedit_mode("0"); setformedit_mode_invoice("0"); submenu_donnee_client(); fillfield(); setdatamodification("0"); setdatamodification_invoice("0"); Get_List_Contact_Of_client_Part(); } else { setformedit_mode("1"); setformedit_mode_invoice("1"); } }, [props.client_mail,]); const [fillfield_api, setfillfield_api] = useState(""); const [fillfield_result, setfillfield_result] = useState(""); const [fillfield_message, setfillfield_message] = useState(""); function fillfield() { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("_id", props.client_id); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Partner_Client_From_Id/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In fillfield res.data.status = " + res.data.status); //console.log(" In fillfield res.data.message = " + res.data.message); setfillfield_api("true"); setfillfield_result(res.data.message); var mylocalclient = JSON.parse(res.data.message); if (mylocalclient) { if (mylocalclient.nom) { setclient_nom(mylocalclient.nom); } else { setclient_nom(""); } if (mylocalclient.email) { setclient_email(mylocalclient.email); } else { setclient_email(""); } if (mylocalclient.raison_sociale) { setclient_raison_sociale(mylocalclient.raison_sociale); } else { setclient_raison_sociale(""); } if (String(mylocalclient.is_financeur) === "1") setp_client_is_financeur(true); else setp_client_is_financeur(false); if (String(mylocalclient.is_client) === "1") setp_client_is_client(true); else setp_client_is_client(false); if (String(mylocalclient.is_fournisseur) === "1") setp_client_is_fournisseur(true); else setp_client_is_fournisseur(false); if (mylocalclient.adr_adresse) setclient_adresse(mylocalclient.adr_adresse); else setclient_adresse(""); if (mylocalclient.adr_ville) setclient_ville(mylocalclient.adr_ville); else setclient_ville(""); if (mylocalclient.adr_pays) setclient_pays(mylocalclient.adr_pays); else setclient_pays(""); if (mylocalclient.siret) setclient_siret(mylocalclient.siret); else setclient_siret(""); if (mylocalclient.client_type_id) { setp_client_type_id(mylocalclient.client_type_id); setp_client_type_label(mylocalclient.client_type_code); } else { setp_client_type_id(""); setp_client_type_label(""); } if (mylocalclient.tva) setclient_tva(mylocalclient.tva); else setclient_tva(""); if (mylocalclient.website) setclient_website(mylocalclient.website); else setclient_website(""); if (mylocalclient.telephone) setclient_telephone(mylocalclient.telephone); else setclient_telephone(""); // Remplissage des doonées de facturation if (mylocalclient.invoice_email) setclient_invoice_email(mylocalclient.invoice_email); else setclient_invoice_email(""); if (mylocalclient.invoice_nom) setclient_invoice_nom(mylocalclient.invoice_nom); else setclient_invoice_nom(""); if (mylocalclient.invoice_siret) setclient_invoice_siret(mylocalclient.invoice_siret); else setclient_invoice_siret(""); if (mylocalclient.invoice_tva) setclient_invoice_tva(mylocalclient.invoice_tva); else setclient_invoice_tva(""); if (mylocalclient.invoice_adresse) setclient_invoice_adresse(mylocalclient.invoice_adresse); else setclient_invoice_adresse(""); if (mylocalclient.invoice_ville) setclient_invoice_ville(mylocalclient.invoice_ville); else setclient_invoice_ville(""); if (mylocalclient.invoice_code_postal) setclient_invoice_code_postal(mylocalclient.invoice_code_postal); else setclient_invoice_code_postal(""); if (mylocalclient.invoice_pays) setclient_invoice_pays(mylocalclient.invoice_pays); else setclient_invoice_pays(""); setdatamodification("0"); setdatamodification_invoice("0"); Disable_fields(); //Disable_invoice_fields(); } } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setfillfield_api("false"); setfillfield_message(res.data.message); } }).catch((error) => { console.warn('Not good man :( fillfield = ', error); setfillfield_result("false"); setfillfield_message(" Impossible de recuperer les informations du client") }) } const [fillfield_Invoice_Data_api, setfillfield_Invoice_Data_api] = useState(""); const [fillfield_Invoice_Data_result, setfillfield_Invoice_Data_result] = useState(""); const [fillfield_Invoice_Data_message, setfillfield_Invoice_Data_message] = useState(""); function fillfield_Invoice_Data(cust_email) { var val = cust_email; var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("_id", props.client_id); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Partner_Client_From_Id/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In fillfield_Invoice_Data res.data.status = " + res.data.status); //console.log(" In fillfield_Invoice_Data res.data.message = " + res.data.message); setfillfield_Invoice_Data_api("true"); setfillfield_Invoice_Data_result(res.data.message); var mylocalclient = JSON.parse(res.data.message); if (mylocalclient) { // Remplissage des doonées de facturation if (mylocalclient.invoice_email) setclient_invoice_email(mylocalclient.invoice_email); else setclient_invoice_email(""); if (mylocalclient.invoice_nom) setclient_invoice_nom(mylocalclient.invoice_nom); else setclient_invoice_nom(""); if (mylocalclient.invoice_siret) setclient_invoice_siret(mylocalclient.invoice_siret); else setclient_invoice_siret(""); if (mylocalclient.invoice_tva) setclient_invoice_tva(mylocalclient.invoice_tva); else setclient_invoice_tva(""); if (mylocalclient.invoice_adresse) setclient_invoice_adresse(mylocalclient.invoice_adresse); else setclient_invoice_adresse(""); if (mylocalclient.invoice_ville) setclient_invoice_ville(mylocalclient.invoice_ville); else setclient_invoice_ville(""); if (mylocalclient.invoice_code_postal) setclient_invoice_code_postal(mylocalclient.invoice_code_postal); else setclient_invoice_code_postal(""); if (mylocalclient.invoice_pays) setclient_invoice_pays(mylocalclient.invoice_pays); else setclient_invoice_pays(""); Disable_invoice_fields(); } } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setfillfield_Invoice_Data_api("false"); setfillfield_Invoice_Data_message(res.data.message); } }).catch((error) => { console.warn('Not good man :( fillfield_Invoice_Data = ', error); setfillfield_Invoice_Data_result("false"); setfillfield_Invoice_Data_message(" Impossible de recuperer les informations du client") }) } const [fillfield_Only_Main_Data_api, setfillfield_Only_Main_Data_api] = useState(""); const [fillfield_Only_Main_Data_result, setfillfield_Only_Main_Data_result] = useState(""); const [fillfield_Only_Main_Data_message, setfillfield_Only_Main_Data_message] = useState(""); function fillfield_Only_Main_Data(cust_email) { var val = cust_email; var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("_id", props.client_id); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Partner_Client_From_Id/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In fillfield_Only_Main_Data res.data.status = " + res.data.status); //console.log(" In fillfield_Only_Main_Data res.data.message = " + res.data.message); setfillfield_Only_Main_Data_api("true"); setfillfield_Only_Main_Data_result(res.data.message); var mylocalclient = JSON.parse(res.data.message); if (mylocalclient) { if (mylocalclient.raison_sociale) { setclient_raison_sociale(mylocalclient.raison_sociale); } else { setclient_raison_sociale(""); } if (mylocalclient.adr_adresse) setclient_adresse(mylocalclient.adr_adresse); else setclient_adresse(""); if (mylocalclient.adr_ville) setclient_ville(mylocalclient.adr_ville); else setclient_ville(""); if (mylocalclient.adr_pays) setclient_pays(mylocalclient.adr_pays); else setclient_pays(""); if (mylocalclient.siret) setclient_siret(mylocalclient.siret); else setclient_siret(""); if (mylocalclient.tva) setclient_tva(mylocalclient.tva); else setclient_tva(""); if (mylocalclient.website) setclient_website(mylocalclient.website); else setclient_website(""); if (mylocalclient.telephone) setclient_telephone(mylocalclient.telephone); else setclient_telephone(""); Disable_fields(); } } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setfillfield_Only_Main_Data_api("false"); setfillfield_Only_Main_Data_message(res.data.message); } }).catch((error) => { console.warn('Not good man :( fillfield_Only_Main_Data = ', error); setfillfield_Only_Main_Data_result("false"); setfillfield_Only_Main_Data_message(" Impossible de recuperer les informations du client") }) } const [Get_List_Contact_Of_client_Part_api, setGet_List_Contact_Of_client_Part_api] = useState(); const [Get_List_Contact_Of_client_Part_message, setGet_List_Contact_Of_client_Part_message] = useState(); const [Get_List_Contact_Of_client_Part_result, setGet_List_Contact_Of_client_Part_result] = useState(); function Get_List_Contact_Of_client_Part(event) { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); const related_collection = "partner_client" form.append("token", stored_cookie); form.append("related_collection", related_collection); form.append("related_collection_owner_id", props.client_id); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Entity_Contact/"; axios.post(myurl, form).then(res => { //console.log(" In Get_List_Contact_Of_client_Part res.data.status = " + res.data.status); //console.log(" In Get_List_Contact_Of_client_Part res.data.message r_class = " + res.data.message); if (String(res.data.status) === String("true")) { setGet_List_Contact_Of_client_Part_api("true"); setGet_List_Contact_Of_client_Part_result(res.data.message); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); } else { setGet_List_Contact_Of_client_Part_api("false"); setGet_List_Contact_Of_client_Part_message(res.data.message); } }).catch((error) => { console.warn('Not good man :( Get_List_Contact_Of_client_Part = ', error); setGet_List_Contact_Of_client_Part_api("false"); //setmyApimyApiMessage("") }) } function clear_fields() { if (document.getElementsByName("client_email")) { document.getElementsByName("client_email")[0].value = ""; } if (document.getElementsByName("client_nom")) { document.getElementsByName("client_nom")[0].value = ""; } if (document.getElementsByName("client_raison_sociale")) { document.getElementsByName("client_raison_sociale")[0].value = ""; } if (document.getElementsByName("client_adresse")) { document.getElementsByName("client_adresse")[0].value = ""; } if (document.getElementsByName("client_ville")) { document.getElementsByName("client_ville")[0].value = ""; } if (document.getElementsByName("client_pays")) { document.getElementsByName("client_pays")[0].value = ""; } if (document.getElementsByName("client_email")) { document.getElementsByName("client_email")[0].value = ""; } if (document.getElementsByName("client_siret")) { document.getElementsByName("client_siret")[0].value = ""; } if (document.getElementsByName("client_type_id")) { document.getElementsByName("client_type_id")[0].value = ""; } if (document.getElementsByName("client_tva")) { document.getElementsByName("client_tva")[0].value = ""; } if (document.getElementsByName("client_website")) { document.getElementsByName("client_website")[0].value = ""; } if (document.getElementsByName("client_code_postal")) { document.getElementsByName("client_code_postal")[0].value = ""; } if (document.getElementsByName("client_telephone")) { document.getElementsByName("client_telephone")[0].value = ""; } } function Disable_fields() { if (document.getElementsByName("client_email" && document.getElementsByName("client_email")[0])) { document.getElementsByName("client_email")[0].disabled = true; document.getElementsByName("client_email")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_nom") && document.getElementsByName("client_nom")[0]) { document.getElementsByName("client_nom")[0].disabled = true; document.getElementsByName("client_nom")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_raison_sociale") && document.getElementsByName("client_raison_sociale")[0]) { document.getElementsByName("client_raison_sociale")[0].disabled = true; document.getElementsByName("client_raison_sociale")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_adresse") && document.getElementsByName("client_adresse")[0]) { document.getElementsByName("client_adresse")[0].disabled = true; document.getElementsByName("client_adresse")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_ville") && document.getElementsByName("client_ville")[0]) { document.getElementsByName("client_ville")[0].disabled = true; document.getElementsByName("client_ville")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_pays") && document.getElementsByName("client_pays")[0]) { document.getElementsByName("client_pays")[0].disabled = true; document.getElementsByName("client_pays")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_email")) { document.getElementsByName("client_email")[0].disabled = true; document.getElementsByName("client_email")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_siret")) { document.getElementsByName("client_siret")[0].disabled = true; document.getElementsByName("client_siret")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_type_id")) { document.getElementsByName("client_type_id")[0].disabled = true; document.getElementsByName("client_type_id")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_tva")) { document.getElementsByName("client_tva")[0].disabled = true; document.getElementsByName("client_tva")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_website")) { document.getElementsByName("client_website")[0].disabled = true; document.getElementsByName("client_website")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_code_postal")) { document.getElementsByName("client_code_postal")[0].disabled = true; document.getElementsByName("client_code_postal")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_telephone")) { document.getElementsByName("client_telephone")[0].disabled = true; document.getElementsByName("client_telephone")[0].style.backgroundColor = "#ECEFF1"; } } function Enable_fields() { if (document.getElementsByName("client_email")) { document.getElementsByName("client_email")[0].disabled = false; document.getElementsByName("client_email")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_nom")) { document.getElementsByName("client_nom")[0].disabled = false; document.getElementsByName("client_nom")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_raison_sociale")) { document.getElementsByName("client_raison_sociale")[0].disabled = false; document.getElementsByName("client_raison_sociale")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_adresse")) { document.getElementsByName("client_adresse")[0].disabled = false; document.getElementsByName("client_adresse")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_ville")) { document.getElementsByName("client_ville")[0].disabled = false; document.getElementsByName("client_ville")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_pays")) { document.getElementsByName("client_pays")[0].disabled = false; document.getElementsByName("client_pays")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_email")) { document.getElementsByName("client_email")[0].disabled = false; document.getElementsByName("client_email")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_siret")) { document.getElementsByName("client_siret")[0].disabled = false; document.getElementsByName("client_siret")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_type_id")) { document.getElementsByName("client_type_id")[0].disabled = false; document.getElementsByName("client_type_id")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_tva")) { document.getElementsByName("client_tva")[0].disabled = false; document.getElementsByName("client_tva")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_website")) { document.getElementsByName("client_website")[0].disabled = false; document.getElementsByName("client_website")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_code_postal")) { document.getElementsByName("client_code_postal")[0].disabled = false; document.getElementsByName("client_code_postal")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_telephone")) { document.getElementsByName("client_telephone")[0].disabled = false; document.getElementsByName("client_telephone")[0].style.backgroundColor = "#FFFFFF"; } } async function Disable_contact_fields() { await sleep(5); if (document.getElementsByName("contact_email")) { document.getElementsByName("contact_email")[0].disabled = true; document.getElementsByName("contact_email")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_nom")) { document.getElementsByName("contact_nom")[0].disabled = true; document.getElementsByName("contact_nom")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_prenom")) { document.getElementsByName("contact_prenom")[0].disabled = true; document.getElementsByName("contact_prenom")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_fonction")) { document.getElementsByName("contact_fonction")[0].disabled = true; document.getElementsByName("contact_fonction")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_civilite")) { document.getElementsByName("contact_civilite")[0].disabled = true; document.getElementsByName("contact_civilite")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_siret")) { document.getElementsByName("contact_siret")[0].disabled = true; document.getElementsByName("contact_siret")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_tva")) { document.getElementsByName("contact_tva")[0].disabled = true; document.getElementsByName("contact_tva")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_adresse")) { document.getElementsByName("contact_adresse")[0].disabled = true; document.getElementsByName("contact_adresse")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_ville")) { document.getElementsByName("contact_ville")[0].disabled = true; document.getElementsByName("contact_ville")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_code_postal")) { document.getElementsByName("contact_code_postal")[0].disabled = true; document.getElementsByName("contact_code_postal")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_pays")) { document.getElementsByName("contact_pays")[0].disabled = true; document.getElementsByName("contact_pays")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_telephone")) { document.getElementsByName("contact_telephone")[0].disabled = true; document.getElementsByName("contact_telephone")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("contact_telephone_mobile")) { document.getElementsByName("contact_telephone_mobile")[0].disabled = true; document.getElementsByName("contact_telephone_mobile")[0].style.backgroundColor = "#ECEFF1"; } } function Enable_contact_fields() { if (document.getElementsByName("contact_email")) { document.getElementsByName("contact_email")[0].disabled = false; document.getElementsByName("contact_email")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_nom")) { document.getElementsByName("contact_nom")[0].disabled = false; document.getElementsByName("contact_nom")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_prenom")) { document.getElementsByName("contact_prenom")[0].disabled = false; document.getElementsByName("contact_prenom")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_civilite")) { document.getElementsByName("contact_civilite")[0].disabled = false; document.getElementsByName("contact_civilite")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_fonction")) { document.getElementsByName("contact_fonction")[0].disabled = false; document.getElementsByName("contact_fonction")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_siret")) { document.getElementsByName("contact_siret")[0].disabled = false; document.getElementsByName("contact_siret")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_tva")) { document.getElementsByName("contact_tva")[0].disabled = false; document.getElementsByName("contact_tva")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_adresse")) { document.getElementsByName("contact_adresse")[0].disabled = false; document.getElementsByName("contact_adresse")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_ville")) { document.getElementsByName("contact_ville")[0].disabled = false; document.getElementsByName("contact_ville")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_code_postal")) { document.getElementsByName("contact_code_postal")[0].disabled = false; document.getElementsByName("contact_code_postal")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_pays")) { document.getElementsByName("contact_pays")[0].disabled = false; document.getElementsByName("contact_pays")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_telephone")) { document.getElementsByName("contact_telephone")[0].disabled = false; document.getElementsByName("contact_telephone")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("contact_telephone_mobile")) { document.getElementsByName("contact_telephone_mobile")[0].disabled = false; document.getElementsByName("contact_telephone_mobile")[0].style.backgroundColor = "#FFFFFF"; } } const [Add_New_PartnerClient_api, setAdd_New_PartnerClient_api] = useState(""); const [Add_New_PartnerClient_result, setAdd_New_PartnerClient_result] = useState(""); const [Add_New_PartnerClient_message, setAdd_New_PartnerClient_message] = useState(""); function Add_New_PartnerClient(event) { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); // Recupeation des données à enregister var client_email = "" if (document.getElementsByName("client_email")) { client_email = String(document.getElementsByName("client_email")[0].value).trim(); } var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; if (!client_email.match(validRegex)) { alert("L'adresse email est invalide."); return; } form.append("email", client_email); var client_nom = "" if (document.getElementsByName("client_nom")) { client_nom = String(document.getElementsByName("client_nom")[0].value).trim(); } form.append("nom", client_nom); if (String(client_nom).trim() === "") { alert("Le nom du client est invalide."); return; } var client_raison_sociale = "" if (document.getElementsByName("client_raison_sociale")) { client_raison_sociale = document.getElementsByName("client_raison_sociale")[0].value; } form.append("raison_sociale", client_raison_sociale); var client_adresse = "" if (document.getElementsByName("client_adresse")) { client_adresse = document.getElementsByName("client_adresse")[0].value; } form.append("adr_adresse", client_adresse); var client_code_postal = "" if (document.getElementsByName("client_code_postal")) { client_code_postal = document.getElementsByName("client_code_postal")[0].value; } form.append("adr_code_postal", client_code_postal); var client_ville = "" if (document.getElementsByName("client_ville")) { client_ville = document.getElementsByName("client_ville")[0].value; } form.append("adr_ville", client_ville); var client_pays = "" if (document.getElementsByName("client_pays")) { client_pays = document.getElementsByName("client_pays")[0].value; } form.append("adr_pays", client_pays); var client_telephone = "" if (document.getElementsByName("client_telephone")) { client_telephone = document.getElementsByName("client_telephone")[0].value; } form.append("telephone", client_telephone); var client_siret = "" if (document.getElementsByName("client_siret")) { client_siret = document.getElementsByName("client_siret")[0].value; } form.append("siret", client_siret); var client_tva = "" if (document.getElementsByName("client_tva")) { client_tva = document.getElementsByName("client_tva")[0].value; } form.append("tva", client_tva); var client_website = "" if (document.getElementsByName("client_website")) { client_website = document.getElementsByName("client_website")[0].value; } form.append("website", client_website); if (p_client_type_id) form.append("client_type_id", p_client_type_id); else form.append("client_type_id", ""); if (String(p_client_is_financeur) === "true") form.append("is_financeur", "1"); else form.append("is_financeur", "0"); if (String(p_client_is_fournisseur) === "true") form.append("is_fournisseur", "1"); else form.append("is_fournisseur", "0"); if (String(p_client_is_client) === "true") form.append("is_client", "1"); else form.append("is_client", "0"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Partner_Client/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In Add_New_PartnerClient res.data.status = " + res.data.status); //console.log(" In Add_New_PartnerClient res.data.message = " + res.data.message); setAdd_New_PartnerClient_api("true"); setAdd_New_PartnerClient_result(res.data.message); setformedit_mode("0"); setdatamodification("0"); Disable_fields(); alert(res.data.message); props.Get_List_Partner_Clients(); props.father_scroll_to_top(); props.close_detail_client(); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setAdd_New_PartnerClient_api("false"); setAdd_New_PartnerClient_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( Add_New_PartnerClient = ', error); setAdd_New_PartnerClient_result("false"); setAdd_New_PartnerClient_message(" Impossible de recuperer les informations du client") alert(" Impossible de recuperer les informations du client"); }) } const [recordPartnerClient_api, setrecordPartnerClient_api] = useState(""); const [recordPartnerClient_result, setrecordPartnerClient_result] = useState(""); const [recordPartnerClient_message, setrecordPartnerClient_message] = useState(""); function recordPartnerClient(event) { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("_id", props.client_id); // Recupeation des données à enregister var client_email = "" if (document.getElementsByName("client_email")) { client_email = String(document.getElementsByName("client_email")[0].value).trim(); } var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; if (!client_email.match(validRegex)) { alert("L'adresse email est invalide."); return; } form.append("email", client_email); var client_nom = "" if (document.getElementsByName("client_nom")) { client_nom = document.getElementsByName("client_nom")[0].value; } if (String(client_nom).trim() === "") { alert("Le nom du client est invalide."); return; } form.append("nom", client_nom); var client_raison_sociale = "" if (document.getElementsByName("client_raison_sociale")) { client_raison_sociale = document.getElementsByName("client_raison_sociale")[0].value; } form.append("raison_sociale", client_raison_sociale); var client_adresse = "" if (document.getElementsByName("client_adresse")) { client_adresse = document.getElementsByName("client_adresse")[0].value; } form.append("adr_adresse", client_adresse); var client_code_postal = "" if (document.getElementsByName("client_code_postal")) { client_code_postal = document.getElementsByName("client_code_postal")[0].value; } form.append("adr_code_postal", client_code_postal); var client_ville = "" if (document.getElementsByName("client_ville")) { client_ville = document.getElementsByName("client_ville")[0].value; } form.append("adr_ville", client_ville); var client_pays = "" if (document.getElementsByName("client_pays")) { client_pays = document.getElementsByName("client_pays")[0].value; } form.append("adr_pays", client_pays); var client_telephone = "" if (document.getElementsByName("client_telephone")) { client_telephone = document.getElementsByName("client_telephone")[0].value; } form.append("telephone", client_telephone); var client_siret = "" if (document.getElementsByName("client_siret")) { client_siret = document.getElementsByName("client_siret")[0].value; } form.append("siret", client_siret); var client_tva = "" if (document.getElementsByName("client_tva")) { client_tva = document.getElementsByName("client_tva")[0].value; } form.append("tva", client_tva); var client_website = "" if (document.getElementsByName("client_website")) { client_website = document.getElementsByName("client_website")[0].value; } form.append("website", client_website); if (p_client_type_id) form.append("client_type_id", p_client_type_id); else form.append("client_type_id", ""); if (String(p_client_is_financeur) === "true") form.append("is_financeur", "1"); else form.append("is_financeur", "0"); if (String(p_client_is_fournisseur) === "true") form.append("is_fournisseur", "1"); else form.append("is_fournisseur", "0"); if (String(p_client_is_client) === "true") form.append("is_client", "1"); else form.append("is_client", "0"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Partner_Client/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In recordPartnerClient res.data.status = " + res.data.status); //console.log(" In recordPartnerClient res.data.message = " + res.data.message); setrecordPartnerClient_api("true"); setrecordPartnerClient_result(res.data.message); setformedit_mode("0"); setdatamodification("0"); fillfield(); Disable_fields(); alert(res.data.message); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setrecordPartnerClient_api("false"); setrecordPartnerClient_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( recordPartnerClient = ', error); setrecordPartnerClient_result("false"); setrecordPartnerClient_message(" Impossible de recuperer les informations du client") alert(" Impossible de recuperer les informations du client"); }) } // Fonction de mise à jour des données de facturation const [recordPartnerClient_Invoice_Data_api, setrecordPartnerClient_Invoice_Data_api] = useState(""); const [recordPartnerClient_Invoice_Data_result, setrecordPartnerClient_Invoice_Data_result] = useState(""); const [recordPartnerClient_Invoice_Data_message, setrecordPartnerClient_Invoice_Data_message] = useState(""); function recordPartnerClient_Invoice_Data(event) { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); // Recupeation des données à enregister form.append("email", p_client_email); form.append("nom", p_client_nom); // Données de facturation var client_invoice_email = "" if (document.getElementsByName("client_invoice_email")) { client_invoice_email = document.getElementsByName("client_invoice_email")[0].value; } form.append("invoice_email", client_invoice_email); var client_invoice_nom = "" if (document.getElementsByName("client_invoice_nom")) { client_invoice_nom = document.getElementsByName("client_invoice_nom")[0].value; } form.append("invoice_nom", client_invoice_nom); var client_invoice_siret = "" if (document.getElementsByName("client_invoice_siret")) { client_invoice_siret = document.getElementsByName("client_invoice_siret")[0].value; } form.append("invoice_siret", client_invoice_siret); var client_invoice_tva = "" if (document.getElementsByName("client_invoice_tva")) { client_invoice_tva = document.getElementsByName("client_invoice_tva")[0].value; } form.append("invoice_tva", client_invoice_tva); var client_invoice_adresse = "" if (document.getElementsByName("client_invoice_adresse")) { client_invoice_adresse = document.getElementsByName("client_invoice_adresse")[0].value; } form.append("invoice_adresse", client_invoice_adresse); var client_invoice_ville = "" if (document.getElementsByName("client_invoice_ville")) { client_invoice_ville = document.getElementsByName("client_invoice_ville")[0].value; } form.append("invoice_ville", client_invoice_ville); var client_invoice_code_postal = "" if (document.getElementsByName("client_invoice_email")) { client_invoice_code_postal = document.getElementsByName("client_invoice_code_postal")[0].value; } form.append("invoice_code_postal", client_invoice_code_postal); var client_invoice_pays = "" if (document.getElementsByName("client_invoice_pays")) { client_invoice_pays = document.getElementsByName("client_invoice_pays")[0].value; } form.append("invoice_pays", client_invoice_pays); form.append("_id", props.client_id); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Partner_Client/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In recordPartnerClient_Invoice_Data res.data.status = " + res.data.status); //console.log(" In recordPartnerClient_Invoice_Data res.data.message = " + res.data.message); setrecordPartnerClient_Invoice_Data_api("true"); setrecordPartnerClient_Invoice_Data_result(res.data.message); setformedit_mode_invoice("0"); setdatamodification_invoice("0"); alert(" Les données de facturation ont été mises à jour.") Disable_invoice_fields(); alert(res.data.message); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setrecordPartnerClient_Invoice_Data_api("false"); setrecordPartnerClient_Invoice_Data_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( recordPartnerClient_Invoice_Data = ', error); setrecordPartnerClient_Invoice_Data_result("false"); setrecordPartnerClient_Invoice_Data_message(" Impossible de recuperer les informations du client") alert(" Impossible de recuperer les informations du client"); }) } function clear_invoice_fields() { if (document.getElementsByName("client_invoice_email")) { document.getElementsByName("client_invoice_email")[0].value = ""; } if (document.getElementsByName("client_invoice_nom")) { document.getElementsByName("client_invoice_nom")[0].value = ""; } if (document.getElementsByName("client_invoice_siret")) { document.getElementsByName("client_invoice_siret")[0].value = ""; } if (document.getElementsByName("client_invoice_tva")) { document.getElementsByName("client_invoice_tva")[0].value = ""; } if (document.getElementsByName("client_invoice_adresse")) { document.getElementsByName("client_invoice_adresse")[0].value = ""; } if (document.getElementsByName("client_invoice_ville")) { document.getElementsByName("client_invoice_ville")[0].value = ""; } if (document.getElementsByName("client_invoice_code_postal")) { document.getElementsByName("client_invoice_code_postal")[0].value = ""; } if (document.getElementsByName("client_invoice_pays")) { document.getElementsByName("client_invoice_pays")[0].value = ""; } } function Disable_invoice_fields() { if (document.getElementsByName("client_invoice_email")) { document.getElementsByName("client_invoice_email")[0].disabled = true; document.getElementsByName("client_invoice_email")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_nom")) { document.getElementsByName("client_invoice_nom")[0].disabled = true; document.getElementsByName("client_invoice_nom")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_siret")) { document.getElementsByName("client_invoice_siret")[0].disabled = true; document.getElementsByName("client_invoice_siret")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_tva")) { document.getElementsByName("client_invoice_tva")[0].disabled = true; document.getElementsByName("client_invoice_tva")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_adresse")) { document.getElementsByName("client_invoice_adresse")[0].disabled = true; document.getElementsByName("client_invoice_adresse")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_ville")) { document.getElementsByName("client_invoice_ville")[0].disabled = true; document.getElementsByName("client_invoice_ville")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_code_postal")) { document.getElementsByName("client_invoice_code_postal")[0].disabled = true; document.getElementsByName("client_invoice_code_postal")[0].style.backgroundColor = "#ECEFF1"; } if (document.getElementsByName("client_invoice_pays")) { document.getElementsByName("client_invoice_pays")[0].disabled = true; document.getElementsByName("client_invoice_pays")[0].style.backgroundColor = "#ECEFF1"; console.log("iiiiii"); } } function Enable_invoice_fields() { if (document.getElementsByName("client_invoice_email")) { document.getElementsByName("client_invoice_email")[0].disabled = false; document.getElementsByName("client_invoice_email")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_nom")) { document.getElementsByName("client_invoice_nom")[0].disabled = false; document.getElementsByName("client_invoice_nom")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_siret")) { document.getElementsByName("client_invoice_siret")[0].disabled = false; document.getElementsByName("client_invoice_siret")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_tva")) { document.getElementsByName("client_invoice_tva")[0].disabled = false; document.getElementsByName("client_invoice_tva")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_adresse")) { document.getElementsByName("client_invoice_adresse")[0].disabled = false; document.getElementsByName("client_invoice_adresse")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_ville")) { document.getElementsByName("client_invoice_ville")[0].disabled = false; document.getElementsByName("client_invoice_ville")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_code_postal")) { document.getElementsByName("client_invoice_code_postal")[0].disabled = false; document.getElementsByName("client_invoice_code_postal")[0].style.backgroundColor = "#FFFFFF"; } if (document.getElementsByName("client_invoice_pays")) { document.getElementsByName("client_invoice_pays")[0].disabled = false; document.getElementsByName("client_invoice_pays")[0].style.backgroundColor = "#FFFFFF"; } } function close_detail_client() { props.close_detail_client(); } function retour_liste_contact() { setaddcontact("0"); setdatamodification_contact('0'); } function clean_contact_set_values() { setp_contact_email(""); setp_contact_nom(""); setp_contact_prenom(""); setcontact_siret(""); setcontact_tva(""); setcontact_adresse(""); setcontact_ville(""); setcontact_code_postal(""); setcontact_pays(""); setcontact_telephone(""); setp_contact_telephone_mobile(""); setp_contact_fonction(""); setp_contact_civilite(""); } function clear_contact_fields() { if (document.getElementsByName("contact_email")) { document.getElementsByName("contact_email")[0].value = ""; } if (document.getElementsByName("contact_nom")) { document.getElementsByName("contact_nom")[0].value = ""; } if (document.getElementsByName("contact_prenom")) { document.getElementsByName("contact_prenom")[0].value = ""; } if (document.getElementsByName("contact_siret")) { document.getElementsByName("contact_siret")[0].value = ""; } if (document.getElementsByName("contact_tva")) { document.getElementsByName("contact_tva")[0].value = ""; } if (document.getElementsByName("contact_adresse")) { document.getElementsByName("contact_adresse")[0].value = ""; } if (document.getElementsByName("contact_ville")) { document.getElementsByName("contact_ville")[0].value = ""; } if (document.getElementsByName("contact_code_postal")) { document.getElementsByName("contact_code_postal")[0].value = ""; } if (document.getElementsByName("contact_pays")) { document.getElementsByName("contact_pays")[0].value = ""; } if (document.getElementsByName("contact_telephone")) { document.getElementsByName("contact_telephone")[0].value = ""; } if (document.getElementsByName("contact_telephone_mobile")) { document.getElementsByName("contact_telephone_mobile")[0].value = ""; } } // Fonction de mise à jour des données de facturation const [recordPartnerClient_Contact_Data_api, setrecordPartnerClient_Contact_Data_api] = useState(""); const [recordPartnerClient_Contact_Data_result, setrecordPartnerClient_Contact_Data_result] = useState(""); const [recordPartnerClient_Contact_Data_message, setrecordPartnerClient_Contact_Data_message] = useState(""); function recordPartnerClient_Contact_Data(event) { var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); // Recupeation des données à enregister var myurl = ""; if (current_contact_recid && String(current_contact_recid).length > 3) { // Il s'agit d'un mise à jour. on a une valeur dans le current_activite_recid myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Contact/"; form.append("_id", selected_contact_id); } else { // Il s'agit d'un ajout d'une nouvelle activité. on a rien dans le current_activite_recid myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Contact/"; form.append("related_collection", "partner_client"); form.append("related_collection_owner_id", props.client_id); } //console.log(" ### current_contact_recid = ", current_contact_recid, " myurl = ", myurl) // Données de contact du client du partner var contact_email = "" if (document.getElementsByName("contact_email")) { contact_email = String(document.getElementsByName("contact_email")[0].value).trim(); } // Pour activier la fontion de "include com", le contact foit avoir une adresse email var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; if (!contact_email.match(validRegex)) { alert("L'adresse email est invalide. Pour créer un contact l'adresse email est obligatoire"); return; } form.append("email", contact_email); var contact_nom = "" if (document.getElementsByName("contact_nom")) { contact_nom = String(document.getElementsByName("contact_nom")[0].value).trim(); } form.append("nom", contact_nom); if (contact_nom.length < 2) { alert("Le nom du contact est invalide "); return; } var contact_prenom = "" if (document.getElementsByName("contact_prenom")) { contact_prenom = document.getElementsByName("contact_prenom")[0].value; } form.append("prenom", contact_prenom); var contact_fonction = "" if (document.getElementsByName("contact_fonction")) { contact_fonction = document.getElementsByName("contact_fonction")[0].value; } form.append("fonction", contact_fonction); var contact_civilite = "" if (p_contact_civilite) { contact_civilite = p_contact_civilite; } form.append("civilite", contact_civilite); var contact_siret = "" if (document.getElementsByName("contact_siret")) { contact_siret = document.getElementsByName("contact_siret")[0].value; } form.append("siret", contact_siret); var contact_tva = "" if (document.getElementsByName("contact_tva")) { contact_tva = document.getElementsByName("contact_tva")[0].value; } form.append("tva", contact_tva); var contact_adresse = "" if (document.getElementsByName("contact_adresse")) { contact_adresse = document.getElementsByName("contact_adresse")[0].value; } form.append("adr_adresse", contact_adresse); var contact_ville = "" if (document.getElementsByName("contact_ville")) { contact_ville = document.getElementsByName("contact_ville")[0].value; } form.append("adr_ville", contact_ville); var contact_code_postal = "" if (document.getElementsByName("contact_code_postal")) { contact_code_postal = document.getElementsByName("contact_code_postal")[0].value; } form.append("adr_code_postal", contact_code_postal); var contact_pays = "" if (document.getElementsByName("contact_pays")) { contact_pays = document.getElementsByName("contact_pays")[0].value; } form.append("adr_pays", contact_pays); var include_com = "0" if (is_contact_include_com) { include_com = "1"; } form.append("include_com", include_com); var contact_telephone = "" if (document.getElementsByName("contact_telephone")) { contact_telephone = document.getElementsByName("contact_telephone")[0].value; } form.append("telephone", contact_telephone); var contact_telephone_mobile = "" if (document.getElementsByName("contact_telephone_mobile")) { contact_telephone_mobile = document.getElementsByName("contact_telephone_mobile")[0].value; } form.append("telephone_mobile", contact_telephone_mobile); axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In recordPartnerClient_Contact_Data res.data.status = " + res.data.status); //console.log(" In recordPartnerClient_Contact_Data res.data.message = " + res.data.message); setrecordPartnerClient_Contact_Data_api("true"); setrecordPartnerClient_Contact_Data_result(res.data.message); Get_List_Contact_Of_client_Part(); setaddcontact("0"); setdatamodification_contact(""); setis_contact_include_com(false) alert(res.data.message); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setrecordPartnerClient_Contact_Data_api("false"); setrecordPartnerClient_Contact_Data_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( recordPartnerClient_Contact_Data = ', error); setrecordPartnerClient_Contact_Data_result("false"); setrecordPartnerClient_Contact_Data_message(" Impossible d'enregistrer les doonées du contact") alert(" Impossible d'enregistrer les doonées du contact"); }) } const [Display_Part_Client_Contact_api, setDisplay_Part_Client_Contact_api] = useState(""); const [Display_Part_Client_Contact_result, setDisplay_Part_Client_Contact_result] = useState(""); const [Display_Part_Client_Contact_message, setDisplay_Part_Client_Contact_message] = useState(""); function Display_Part_Client_Contact(event) { var form = new FormData(); var contactmail = event.currentTarget.getAttribute('contactmail'); var contact_id = event.currentTarget.getAttribute('contact_id'); setelected_contact_id(contact_id); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("_id", contact_id); // Recupeation des données à enregister form.append("related_collection", "partner_client"); form.append("related_collection_owner_id", props.client_id); //console.log(" ### contactmail = ", contactmail); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Contact/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In Display_Part_Client_Contact res.data.status = " + res.data.status); //console.log(" In Display_Part_Client_Contact res.data.message = " + res.data.message); setDisplay_Part_Client_Contact_api("true"); setDisplay_Part_Client_Contact_result(res.data.message); Get_List_Contact_Of_client_Part(); setaddcontact("1"); var mylocalclient_contact = JSON.parse(res.data.message); if (mylocalclient_contact) { // Remplissage des doonées du contact if (mylocalclient_contact.nom) setp_contact_nom(mylocalclient_contact.nom); else setp_contact_nom(""); if (mylocalclient_contact.email) setp_contact_email(mylocalclient_contact.email); else setp_contact_email(""); if (mylocalclient_contact.prenom) setp_contact_prenom(mylocalclient_contact.prenom); else setp_contact_prenom(""); setis_contact_include_com(false); if (mylocalclient_contact.include_com) { if (String(mylocalclient_contact.include_com) === "1") setis_contact_include_com(true); } if (mylocalclient_contact.siret) setcontact_siret(mylocalclient_contact.siret); else setcontact_siret(""); if (mylocalclient_contact.tva) setcontact_tva(mylocalclient_contact.tva); else setcontact_tva(""); if (mylocalclient_contact.adr_adresse) setcontact_adresse(mylocalclient_contact.adr_adresse); else setcontact_adresse(""); if (mylocalclient_contact.adr_ville) setcontact_ville(mylocalclient_contact.adr_ville); else setcontact_ville(""); if (mylocalclient_contact.adr_code_postal) setcontact_code_postal(mylocalclient_contact.adr_code_postal); else setcontact_code_postal(""); if (mylocalclient_contact.adr_pays) setcontact_pays(mylocalclient_contact.adr_pays); else setcontact_pays(""); if (mylocalclient_contact.telephone) setcontact_telephone(mylocalclient_contact.telephone); else setcontact_telephone(""); if (mylocalclient_contact.telephone_mobile) setp_contact_telephone_mobile(mylocalclient_contact.telephone_mobile); else setp_contact_telephone_mobile(""); if (mylocalclient_contact.fonction) setp_contact_fonction(mylocalclient_contact.fonction); else setp_contact_fonction(""); if (mylocalclient_contact.civilite) setp_contact_civilite(mylocalclient_contact.civilite); else setp_contact_civilite(""); if (mylocalclient_contact.recid) setcurrent_contact_recid(mylocalclient_contact.recid); else setcurrent_contact_recid(""); } Disable_contact_fields(); setformedit_mode_contact("0"); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setDisplay_Part_Client_Contact_api("false"); setDisplay_Part_Client_Contact_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( Display_Part_Client_Contact = ', error); setDisplay_Part_Client_Contact_result("false"); setDisplay_Part_Client_Contact_message(" Impossible de recuperer les detail du contact") alert(" Impossible de recuperer les details du contact"); }) } const [Delete_Part_Client_Contact_api, setDelete_Part_Client_Contact_api] = useState(""); const [Delete_Part_Client_Contact_result, setDelete_Part_Client_Contact_result] = useState(""); const [Delete_Part_Client_Contact_message, setDelete_Part_Client_Contact_message] = useState(""); function Delete_Part_Client_Contact(event) { var form = new FormData(); var contactmail = event.currentTarget.getAttribute('contactmail'); var contact_id = event.currentTarget.getAttribute('contact_id'); setelected_contact_id(contact_id); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("_id", contact_id); form.append("related_collection", "partner_client"); form.append("related_collection_owner_id", props.client_id); //console.log(" ### contactmail = ", contactmail); var myurl = process.env.REACT_APP_API_URL + "myclass/api/Delete_Given_Contact/"; axios.post(myurl, form).then(res => { if (String(res.data.status) === String("true")) { //console.log(" In Delete_Part_Client_Contact res.data.status = " + res.data.status); //console.log(" In Delete_Part_Client_Contact res.data.message = " + res.data.message); setDelete_Part_Client_Contact_api("true"); setDelete_Part_Client_Contact_result(res.data.message); Get_List_Contact_Of_client_Part(); } else if (String(res.data.status) === String("Err_Connexion")) { alert('Erreur: ' + res.data.message); history.push("/Connexion"); return; } else { setDelete_Part_Client_Contact_api("false"); setDelete_Part_Client_Contact_message(res.data.message); alert(res.data.message); } }).catch((error) => { console.warn('Not good man :( Delete_Part_Client_Contact = ', error); setDelete_Part_Client_Contact_result("false"); setDelete_Part_Client_Contact_message(" Impossible de recuperer les detail du contact") alert(" Impossible de supprimer le contact"); }) } const [is_contact_include_com, setis_contact_include_com] = useState(false); const New_civilite = [ { "id": "Mme", "label": "Mme", "value": "Mme" }, { "id": "M", "label": "M", "value": "M" }, { "id": "Neutre", "label": "Neutre", "value": "Neutre" }, { "id": "", "label": "", "value": "" }, ] const [p_client_is_financeur, setp_client_is_financeur] = useState(false); const [p_client_is_fournisseur, setp_client_is_fournisseur] = useState(false); const [p_client_is_client, setp_client_is_client] = useState(true); return (
{String(props.new_customer) === "1" &&
Raison sociale
setclient_raison_sociale(e.target.value)} />
Nom
setclient_nom(e.target.value)} />
Type client
{ if (value && value._id) { setp_client_type_id(value._id); } }} //value={p_one_detail_client_rattachement_nom} renderInput={(params) => } /> {/* { setp_client_type_id(e.target.value); }} >   {Get_List_Client_Type_result && Get_List_Client_Type_result.map((myclass) => ( {JSON.parse(myclass).code} ))} */}
N° Siret
setclient_siret(e.target.value)} />
N° TVA
setclient_tva(e.target.value)} />
Email
setclient_email(e.target.value)} />
Adresse
setclient_adresse(e.target.value)} />
ville
setclient_ville(e.target.value)} />
Code Postal
setclient_code_postal(e.target.value)} />
Pays
setclient_pays(e.target.value)} />
Téléphone
setclient_telephone(e.target.value)} />
Site web
setclient_website(e.target.value)} />
 
 
Enregistrer   } modal nested position="center center" > {close => (
MySy Information
{' '} Confirmez la création du client.
)}
} {String(props.new_customer) !== "1" &&
{/* */}
{String(submenu).trim() === "submenu_donnee_client" &&
Raison sociale
setclient_raison_sociale(e.target.value)} />
Nom
setclient_nom(e.target.value)} />
{String(formedit_mode) !== "1" &&
Type client
} {New_Get_List_Client_Type_result && New_Get_List_Client_Type_result.length > 1 && String(formedit_mode) === "1" &&
Type client
(data)._id === String(p_client_type_id))[0].label} onChange={(event, value) => { if (value && value._id) { setp_client_type_id(value._id); DataUpdated(); } }} renderInput={(params) => } /> {/* { setp_client_type_id(e.target.value); }} > {Get_List_Client_Type_result && Get_List_Client_Type_result.map((myclass) => ( {JSON.parse(myclass).code} ))} */}
}
N° Siret
setclient_siret(e.target.value)} />
N° TVA
setclient_tva(e.target.value)} />
Email
setclient_email(e.target.value)} />
Adresse
setclient_adresse(e.target.value)} />
Ville
setclient_ville(e.target.value)} />
Code Postal
setclient_code_postal(e.target.value)} />
Pays
setclient_pays(e.target.value)} />
Telephone
setclient_telephone(e.target.value)} />
Site web 1
setclient_website(e.target.value)} />
 
{String(datamodification) === "1" &&
/!\ Pensez à enregistrer les modifications
} {String(formedit_mode) === "1" &&
} {String(formedit_mode) !== "1" &&
}
} {String(submenu).trim() === "submenu_donnees_facturation" &&
Email de Facturation
setclient_invoice_email(e.target.value)} />
Nom de Facturation
setclient_invoice_nom(e.target.value)} />
N° Siret Facturation
setclient_invoice_siret(e.target.value)} />
N° TVA Facturation
setclient_invoice_tva(e.target.value)} />
Adresse
setclient_invoice_adresse(e.target.value)} />
Ville
setclient_invoice_ville(e.target.value)} />
Code Postal
setclient_invoice_code_postal(e.target.value)} />
Pays
setclient_invoice_pays(e.target.value)} />
 
{String(datamodification_invoice) === "1" &&
/!\ Pensez à enregistrer les modifications
} {String(formedit_mode_invoice) === "1" &&
} {String(formedit_mode_invoice) !== "1" &&
}
} {String(submenu).trim() === "submenu_contact" &&
{String(addcontact) !== "1" &&
Ajouter un contact
{Get_List_Contact_Of_client_Part_result && String(Get_List_Contact_Of_client_Part_api) === "true" && Get_List_Contact_Of_client_Part_result.map((client) => (
{(JSON.parse(client).nom || JSON.parse(client).prenom) && } modal nested position="center center" > {close => (
MySy Information
{' '} En confirmant cette opération, le contact sera définitivement supprimé.
)} }

))}
} {String(addcontact) === "1" &&
{String(formedit_mode_contact) === "1" &&
Civilité
(data).value === String(p_contact_civilite))[0].label} options={New_civilite} onChange={(event, value) => { if (value && value.value) { setp_contact_civilite(value.value); setdatamodification_contact("1"); } }} renderInput={(params) => } /> {/* setp_contact_civilite(e.target.value)} > Mme.   M.   Neutre   */}
} {String(formedit_mode_contact) !== "1" &&
Civilité
}
Nom
setp_contact_nom(e.target.value)} />
Prénom
setp_contact_prenom(e.target.value)} />
Email
setp_contact_email(e.target.value)} />
Fonction
setp_contact_fonction(e.target.value)} />
Téléphone Fixe
setcontact_telephone(e.target.value)} />
Téléphone Mobile
setp_contact_telephone_mobile(e.target.value)} />
Adresse
setcontact_adresse(e.target.value)} />
ville
setcontact_ville(e.target.value)} />
Code Postal
setcontact_code_postal(e.target.value)} />
Pays
setcontact_pays(e.target.value)} />
N° Siret
setcontact_siret(e.target.value)} />
N° TVA
setcontact_tva(e.target.value)} />

 
{String(datamodification_contact) === "1" &&
/!\ Pensez à enregistrer les modifications
} {String(formedit_mode_contact) === "1" &&
} {String(formedit_mode_contact) !== "1" &&
}
}
} {String(submenu).trim() === "submenu_activite" &&
< PartnerClientActivite email={p_client_email} conntected_employee_id={props.conntected_employee_id} />
}
  Fermer
}
); } export default AddParnerClient;