diff --git a/src/components/Config_Document.js b/src/components/Config_Document.js index 625b847..05f852a 100644 --- a/src/components/Config_Document.js +++ b/src/components/Config_Document.js @@ -339,8 +339,8 @@ const Config_Documents = (props) => { axios.post(myurl, form).then(res => { if (String(res.data.status) === "true") { - //console.log(" In Get_Default_Original_Partner_Document_Data res.data.status = " + res.data.status); - //console.log(" In Get_Default_Original_Partner_Document_Data res.data.message r_class = " + res.data.message); + console.log(" In Get_Default_Original_Partner_Document_Data res.data.status = " + res.data.status); + console.log(" In Get_Default_Original_Partner_Document_Data res.data.message r_class = " + res.data.message); setGet_Default_Original_Partner_Document_Data_api("true"); setGet_Default_Original_Partner_Document_Data_result(res.data.message); @@ -366,8 +366,8 @@ const Config_Documents = (props) => { setfield_programme(""); if (mylocal_document.contenu_doc) { - setp_detail_contenu_doc(mylocal_document.contenu_doc); - setfield_programme(mylocal_document.contenu_doc); + setp_detail_contenu_doc(String(mylocal_document.contenu_doc)); + setfield_programme(String(mylocal_document.contenu_doc)); } disable_Partner_DocumentFields(); diff --git a/src/components/Partner_Commande.js b/src/components/Partner_Commande.js index ec19c4c..7ff5836 100644 --- a/src/components/Partner_Commande.js +++ b/src/components/Partner_Commande.js @@ -51,7 +51,7 @@ const Partner_Commande = (props) => { const [selectionModel_order_lines, setselectionModel_order_lines] = React.useState([]); var date_today_90j = new Date(); - date_today_90j.setDate(date_today_90j.getDate() +90); + date_today_90j.setDate(date_today_90j.getDate() + 90); const [p_filtre1, setp_filtre1] = useState(); const [p_filtre1_value, setp_filtre1_value] = useState(); @@ -444,6 +444,8 @@ const Partner_Commande = (props) => { Getall_Training_Employee_No_Filter(); Getall_Parter_Orders_No_Filter(); GetCurrentPartnerClass(); + if (myRef_head) + myRef_head.current.scrollIntoView({ behavior: "smooth" }); }, []) const [Getall_Parter_Orders_No_Filter_api, setGetall_Parter_Orders_No_Filter_api] = useState(); @@ -573,7 +575,9 @@ const Partner_Commande = (props) => { //console.log(" ### employe_id = ", employe_id); Display_Detail_Order_data(order_id); - if (myRef.current) { + + + if (myRef) { myRef.current.scrollIntoView({ behavior: "smooth" }); } @@ -659,6 +663,12 @@ const Partner_Commande = (props) => { setp_detail_header_ref_interne(mylocal_order.order_header_ref_interne); } + document.getElementsByName("detail_header_ref_cient")[0].value = ""; + if (mylocal_order.order_header_ref_client) { + setp_detail_header_ref_interne(mylocal_order.order_header_ref_client); + } + + document.getElementsByName("detail_header_date_cmd")[0].value = ""; if (mylocal_order.order_header_date_cmd) { setp_detail_header_date_cmd(mylocal_order.order_header_date_cmd); @@ -697,7 +707,82 @@ const Partner_Commande = (props) => { } + // Recuperation des adresses (livraison / lieu execution - Facturation ) + //document.getElementsByName("detail_header_fact_adresse")[0].value = ""; + if (mylocal_order.order_header_adr_fact_adresse) { + setp_detail_header_fact_adr(mylocal_order.order_header_adr_fact_adresse); + } + + //document.getElementsByName("detail_header_fact_code_postal")[0].value = ""; + if (mylocal_order.order_header_adr_fact_code_postal) { + setp_detail_header_fact_code_postal(mylocal_order.order_header_adr_fact_code_postal); + } + + //document.getElementsByName("detail_header_fact_ville")[0].value = ""; + if (mylocal_order.order_header_adr_fact_ville) { + setp_detail_header_fact_ville(mylocal_order.order_header_adr_fact_ville); + } + + //document.getElementsByName("detail_header_fact_pays")[0].value = ""; + if (mylocal_order.order_header_adr_fact_pays) { + setp_detail_header_fact_pays(mylocal_order.order_header_adr_fact_pays); + } + + //document.getElementsByName("detail_header_liv_adresse")[0].value = ""; + if (mylocal_order.order_header_adr_liv_adresse) { + setp_detail_header_liv_adr(mylocal_order.order_header_adr_liv_adresse); + } + + //document.getElementsByName("detail_header_liv_code_postal")[0].value = ""; + if (mylocal_order.order_header_adr_liv_code_postal) { + setp_detail_header_liv_code_postal(mylocal_order.order_header_adr_liv_code_postal); + } + + //document.getElementsByName("detail_header_liv_ville")[0].value = ""; + if (mylocal_order.order_header_adr_liv_ville) { + sep_detail_header_liv_ville(mylocal_order.order_header_adr_liv_ville); + } + + //document.getElementsByName("detail_header_liv_pays")[0].value = ""; + if (mylocal_order.order_header_adr_liv_pays) { + setp_detail_header_liv_pays(mylocal_order.order_header_adr_liv_pays); + } + + + // Recuperation des montant, taxes et autres reductions + //document.getElementsByName("detail_header_total_ht")[0].value = ""; + if (mylocal_order.order_header_total_ht) { + setp_detail_header_total_ht(mylocal_order.order_header_total_ht); + } + + //document.getElementsByName("detail_header_total_tax")[0].value = ""; + if (mylocal_order.order_header_total_tax) { + setp_detail_header_total_tax(mylocal_order.order_header_total_tax); + } + + + //document.getElementsByName("detail_header_total_ttc")[0].value = ""; + if (mylocal_order.order_header_total_ttc) { + setp_detail_header_total_ttc(mylocal_order.order_header_total_ttc); + } + + //document.getElementsByName("detail_header_type_reduction")[0].value = ""; + if (mylocal_order.order_header_type_reduction) { + setp_detail_header_type_reduction(mylocal_order.order_header_type_reduction); + } + + //document.getElementsByName("detail_header_type_reduction_valeur")[0].value = ""; + if (mylocal_order.order_header_type_reduction_valeur) { + setp_detail_header_type_reduction_valeur(mylocal_order.order_header_type_reduction_valeur); + } + + //document.getElementsByName("detail_header_montant_reduction")[0].value = ""; + if (mylocal_order.order_header_montant_reduction) { + setp_detail_header_montant_reduction(mylocal_order.order_header_montant_reduction); + } + disable_Order_Header_DetailFields(); + order_header_submenu_main(); } else { alert(" Aucune commande/devis recuperé"); @@ -845,7 +930,24 @@ const Partner_Commande = (props) => { const [p_detail_header_statut_label, setp_detail_header_statut_label] = useState(); const [p_detail_header_date_cmd_val, setp_detail_header_date_cmd_val] = useState(new Date().toLocaleDateString('fr-FR')); - const [p_detail_header_date_expiration_val, setp_detail_header_date_expiration_val] = useState(date_today_90j.toLocaleDateString('fr-FR')); + const [p_detail_header_date_expiration_val, setp_detail_header_date_expiration_val] = useState(date_today_90j.toLocaleDateString('fr-FR')); + const [p_detail_header_fact_adr, setp_detail_header_fact_adr] = useState(); + const [p_detail_header_fact_code_postal, setp_detail_header_fact_code_postal] = useState(); + const [p_detail_header_fact_ville, setp_detail_header_fact_ville] = useState(); + const [p_detail_header_fact_pays, setp_detail_header_fact_pays] = useState(); + + + const [p_detail_header_liv_adr, setp_detail_header_liv_adr] = useState(); + const [p_detail_header_liv_code_postal, setp_detail_header_liv_code_postal] = useState(); + const [p_detail_header_liv_ville, sep_detail_header_liv_ville] = useState(); + const [p_detail_header_liv_pays, setp_detail_header_liv_pays] = useState(); + const [p_detail_header_total_ht, setp_detail_header_total_ht] = useState(); + const [p_detail_header_total_tax, setp_detail_header_total_tax] = useState(); + const [p_detail_header_total_ttc, setp_detail_header_total_ttc] = useState(); + const [p_detail_header_type_reduction, setp_detail_header_type_reduction] = useState(); + const [p_detail_header_type_reduction_valeur, setp_detail_header_type_reduction_valeur] = useState(); + const [p_detail_header_montant_reduction, setp_detail_header_montant_reduction] = useState(); + function Enable_Order_Header_DetailFields() { @@ -896,6 +998,84 @@ const Partner_Commande = (props) => { document.getElementsByName("detail_header_vendeur_nom_prenom")[0].style.backgroundColor = "#FFFFFF"; } + //---- + if (document.getElementsByName("detail_header_ref_cient")[0]) { + document.getElementsByName("detail_header_ref_cient")[0].disabled = false; + document.getElementsByName("detail_header_ref_cient")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_fact_adresse")[0]) { + document.getElementsByName("detail_header_fact_adresse")[0].disabled = false; + document.getElementsByName("detail_header_fact_adresse")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_fact_code_postal")[0]) { + document.getElementsByName("detail_header_fact_code_postal")[0].disabled = false; + document.getElementsByName("detail_header_fact_code_postal")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_fact_ville")[0]) { + document.getElementsByName("detail_header_fact_ville")[0].disabled = false; + document.getElementsByName("detail_header_fact_ville")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_fact_pays")[0]) { + document.getElementsByName("detail_header_fact_pays")[0].disabled = false; + document.getElementsByName("detail_header_fact_pays")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_liv_adresse")[0]) { + document.getElementsByName("detail_header_liv_adresse")[0].disabled = false; + document.getElementsByName("detail_header_liv_adresse")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_liv_code_postal")[0]) { + document.getElementsByName("detail_header_liv_code_postal")[0].disabled = false; + document.getElementsByName("detail_header_liv_code_postal")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_liv_ville")[0]) { + document.getElementsByName("detail_header_liv_ville")[0].disabled = false; + document.getElementsByName("detail_header_liv_ville")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_liv_pays")[0]) { + document.getElementsByName("detail_header_liv_pays")[0].disabled = false; + document.getElementsByName("detail_header_liv_pays")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_total_ht")[0]) { + document.getElementsByName("detail_header_total_ht")[0].disabled = false; + document.getElementsByName("detail_header_total_ht")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_total_tax")[0]) { + document.getElementsByName("detail_header_total_tax")[0].disabled = false; + document.getElementsByName("detail_header_total_tax")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_total_ttc")[0]) { + document.getElementsByName("detail_header_total_ttc")[0].disabled = false; + document.getElementsByName("detail_header_total_ttc")[0].style.backgroundColor = "#FFFFFF"; + } + + + if (document.getElementsByName("detail_header_type_reduction")[0]) { + document.getElementsByName("detail_header_type_reduction")[0].disabled = false; + document.getElementsByName("detail_header_type_reduction")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_type_reduction_valeur")[0]) { + document.getElementsByName("detail_header_type_reduction_valeur")[0].disabled = false; + document.getElementsByName("detail_header_type_reduction_valeur")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_montant_reduction")[0]) { + document.getElementsByName("detail_header_montant_reduction")[0].disabled = false; + document.getElementsByName("detail_header_montant_reduction")[0].style.backgroundColor = "#FFFFFF"; + } + + } function disable_Order_Header_DetailFields() { @@ -946,6 +1126,84 @@ const Partner_Commande = (props) => { document.getElementsByName("detail_header_vendeur_nom_prenom")[0].style.backgroundColor = "#ECEFF1"; } + //--- + if (document.getElementsByName("detail_header_ref_cient")[0]) { + document.getElementsByName("detail_header_ref_cient")[0].disabled = true; + document.getElementsByName("detail_header_ref_cient")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_fact_adresse")[0]) { + document.getElementsByName("detail_header_fact_adresse")[0].disabled = true; + document.getElementsByName("detail_header_fact_adresse")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_fact_code_postal")[0]) { + document.getElementsByName("detail_header_fact_code_postal")[0].disabled = true; + document.getElementsByName("detail_header_fact_code_postal")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_fact_ville")[0]) { + document.getElementsByName("detail_header_fact_ville")[0].disabled = true; + document.getElementsByName("detail_header_fact_ville")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_fact_pays")[0]) { + document.getElementsByName("detail_header_fact_pays")[0].disabled = true; + document.getElementsByName("detail_header_fact_pays")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_liv_adresse")[0]) { + document.getElementsByName("detail_header_liv_adresse")[0].disabled = true; + document.getElementsByName("detail_header_liv_adresse")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_liv_code_postal")[0]) { + document.getElementsByName("detail_header_liv_code_postal")[0].disabled = true; + document.getElementsByName("detail_header_liv_code_postal")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_liv_ville")[0]) { + document.getElementsByName("detail_header_liv_ville")[0].disabled = true; + document.getElementsByName("detail_header_liv_ville")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_liv_pays")[0]) { + document.getElementsByName("detail_header_liv_pays")[0].disabled = true; + document.getElementsByName("detail_header_liv_pays")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_total_ht")[0]) { + document.getElementsByName("detail_header_total_ht")[0].disabled = true; + document.getElementsByName("detail_header_total_ht")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_total_tax")[0]) { + document.getElementsByName("detail_header_total_tax")[0].disabled = true; + document.getElementsByName("detail_header_total_tax")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_total_ttc")[0]) { + document.getElementsByName("detail_header_total_ttc")[0].disabled = true; + document.getElementsByName("detail_header_total_ttc")[0].style.backgroundColor = "#ECEFF1"; + } + + + if (document.getElementsByName("detail_header_type_reduction")[0]) { + document.getElementsByName("detail_header_type_reduction")[0].disabled = true; + document.getElementsByName("detail_header_type_reduction")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_type_reduction_valeur")[0]) { + document.getElementsByName("detail_header_type_reduction_valeur")[0].disabled = true; + document.getElementsByName("detail_header_type_reduction_valeur")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_montant_reduction")[0]) { + document.getElementsByName("detail_header_montant_reduction")[0].disabled = true; + document.getElementsByName("detail_header_montant_reduction")[0].style.backgroundColor = "#ECEFF1"; + } + + } function Annule_Order_DetailFields() { @@ -1020,6 +1278,88 @@ const Partner_Commande = (props) => { form.append("order_header_ref_client", ""); + // ---- + if (p_detail_header_fact_adr) + form.append("order_header_adr_fact_adresse", p_detail_header_fact_adr); + else + form.append("order_header_adr_fact_adresse", ""); + + if (p_detail_header_fact_code_postal) + form.append("order_header_adr_fact_code_postal", p_detail_header_fact_code_postal); + else + form.append("order_header_adr_fact_code_postal", ""); + + + if (p_detail_header_fact_ville) + form.append("order_header_adr_fact_ville", p_detail_header_fact_ville); + else + form.append("order_header_adr_fact_ville", ""); + + + if (p_detail_header_fact_pays) + form.append("order_header_adr_fact_pays", p_detail_header_fact_pays); + else + form.append("order_header_adr_fact_pays", ""); + + + if (p_detail_header_liv_adr) + form.append("order_header_adr_liv_adresse", p_detail_header_liv_adr); + else + form.append("order_header_adr_liv_adresse", ""); + + if (p_detail_header_liv_code_postal) + form.append("order_header_adr_liv_code_postal", p_detail_header_liv_code_postal); + else + form.append("order_header_adr_liv_code_postal", ""); + + if (p_detail_header_liv_ville) + form.append("order_header_adr_liv_ville", p_detail_header_liv_ville); + else + form.append("order_header_adr_liv_ville", ""); + + if (p_detail_header_liv_pays) + form.append("order_header_adr_liv_pays", p_detail_header_liv_pays); + else + form.append("order_header_adr_liv_pays", ""); + + + + + //--- + + if (p_detail_header_total_ht) + form.append("order_header_total_ht", p_detail_header_total_ht); + else + form.append("order_header_total_ht", ""); + + if (p_detail_header_total_tax) + form.append("order_header_total_tax", p_detail_header_total_tax); + else + form.append("order_header_total_tax", ""); + + if (p_detail_header_total_ttc) + form.append("order_header_ref_client", p_detail_header_total_ttc); + else + form.append("order_header_ref_client", ""); + + + if (p_detail_header_type_reduction) + form.append("order_header_type_reduction", p_detail_header_type_reduction); + else + form.append("order_header_type_reduction", ""); + + + if (p_detail_header_type_reduction_valeur) + form.append("order_header_type_reduction_valeur", p_detail_header_type_reduction_valeur); + else + form.append("order_header_type_reduction_valeur", ""); + + + if (p_detail_header_montant_reduction) + form.append("order_header_montant_reduction", p_detail_header_montant_reduction); + else + form.append("order_header_montant_reduction", ""); + //console.log(" form == ", form); @@ -1047,9 +1387,10 @@ const Partner_Commande = (props) => { setOrder_data_changed(""); setorder_data_edit_mode(""); Display_Detail_Order_data(selected_id); - alert(" La mise à jour été correctement faite."); + alert(" La mise à jour du "+String(p_detail_header_type)+" été correctement faite."); - myRef_head.current.scrollIntoView({ behavior: "smooth" }); + if (myRef_head) + myRef_head.current.scrollIntoView({ behavior: "smooth" }); } else { @@ -1062,7 +1403,7 @@ const Partner_Commande = (props) => { console.warn('UpdateStagiaireData : Not good man :( Update_One_Order_Data = ' + error); setUpdate_One_Order_Data_api("false"); - alert(" Impossible de mettre à jour la commande/devis"); + alert(" Impossible de mettre à jour "); }) } @@ -1340,6 +1681,87 @@ const Partner_Commande = (props) => { } + const [header_submenu, setheader_submenu] = useState(""); + async function order_header_submenu_main() { + setheader_submenu("main"); + + await sleep(5); + + if (document.getElementById("order_header_main")) { + document.getElementById("order_header_main").style.backgroundColor = "#104277"; + document.getElementById("order_header_main").style.color = "white"; + } + + if (document.getElementById("order_header_detail")) { + document.getElementById("order_header_detail").style.backgroundColor = "#d8edfc"; + document.getElementById("order_header_detail").style.color = "black"; + } + + if (document.getElementById("order_header_facturation")) { + document.getElementById("order_header_facturation").style.backgroundColor = "#d8edfc"; + document.getElementById("order_header_facturation").style.color = "black"; + } + + if (String(order_data_edit_mode) !== "1") { + disable_Order_Header_DetailFields(); + } + } + + async function order_header_submenu_detail() { + setheader_submenu("detail"); + + await sleep(5); + + if (document.getElementById("order_header_detail")) { + document.getElementById("order_header_detail").style.backgroundColor = "#104277"; + document.getElementById("order_header_detail").style.color = "white"; + } + + if (document.getElementById("order_header_main")) { + document.getElementById("order_header_main").style.backgroundColor = "#d8edfc"; + document.getElementById("order_header_main").style.color = "black"; + } + + if (document.getElementById("order_header_facturation")) { + document.getElementById("order_header_facturation").style.backgroundColor = "#d8edfc"; + document.getElementById("order_header_facturation").style.color = "black"; + } + if (String(order_data_edit_mode) !== "1") { + disable_Order_Header_DetailFields(); + } + } + + async function order_header_submenu_facturation() { + setheader_submenu("facturation"); + + await sleep(5); + + if (document.getElementById("order_header_facturation")) { + document.getElementById("order_header_facturation").style.backgroundColor = "#104277"; + document.getElementById("order_header_facturation").style.color = "white"; + } + + if (document.getElementById("order_header_detail")) { + document.getElementById("order_header_detail").style.backgroundColor = "#d8edfc"; + document.getElementById("order_header_detail").style.color = "black"; + } + + if (document.getElementById("order_header_main")) { + document.getElementById("order_header_main").style.backgroundColor = "#d8edfc"; + document.getElementById("order_header_main").style.color = "black"; + } + + if (String(order_data_edit_mode) !== "1") { + disable_Order_Header_DetailFields(); + } + } + + const sleep = (milliseconds) => { + return new Promise(resolve => setTimeout(resolve, milliseconds)) + } + + + return (