diff --git a/src/components/Employes.js b/src/components/Employes.js index 1fd9036..9fa914a 100644 --- a/src/components/Employes.js +++ b/src/components/Employes.js @@ -1093,6 +1093,7 @@ const Employes = (props) => { const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("archive", "0"); + form.append("is_ftion_initiale", "2"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class_Without_Scope_Action/"; diff --git a/src/components/Intranet_Commande_Devis.js b/src/components/Intranet_Commande_Devis.js index e9d424a..d6a2789 100644 --- a/src/components/Intranet_Commande_Devis.js +++ b/src/components/Intranet_Commande_Devis.js @@ -730,6 +730,7 @@ const Intranet_Commande_Devis = (props) => { const stored_cookie = getCookie('tokenmysych'); form.append("token", stored_cookie); form.append("archive", "0"); + form.append("is_ftion_initiale", "2"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class/"; diff --git a/src/components/Intranet_Mes_Stagiaires.js b/src/components/Intranet_Mes_Stagiaires.js index bca0dac..38395fb 100644 --- a/src/components/Intranet_Mes_Stagiaires.js +++ b/src/components/Intranet_Mes_Stagiaires.js @@ -4170,6 +4170,7 @@ registerLocale('fr', fr); const stored_cookie = getCookie('tokenmysych'); form.append("token", stored_cookie); form.append("archive", "0"); + form.append("is_ftion_initiale", "2"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class/"; setLoading(true); diff --git a/src/components/Module_Ent_Mes_Formations.js b/src/components/Module_Ent_Mes_Formations.js index a22cf8f..36e784d 100644 --- a/src/components/Module_Ent_Mes_Formations.js +++ b/src/components/Module_Ent_Mes_Formations.js @@ -115,7 +115,7 @@ const useStyles = makeStyles((theme) => ({ color: 'gray', }, })); - + const Module_Ent_Mes_Formations = (props) => { registerLocale('fr', fr); const classes = useStyles(); @@ -419,88 +419,93 @@ const Module_Ent_Mes_Formations = (props) => { const [Get_List_Ent_Formation_api, setGet_List_Ent_Formation_api] = useState(); const [Get_List_Ent_Formation_message, setGet_List_Ent_Formation_message] = useState(); const [Get_List_Ent_Formation_result, setGet_List_Ent_Formation_result] = useState(); - function Get_List_Ent_Formation(local_apprenant_id) { - - var form = new FormData(); - const stored_cookie = getCookie('tokenmysych'); - - form.append("token", stored_cookie); - form.append("apprenant_id", local_apprenant_id); - var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_List_Class/"; + async function Get_List_Ent_Formation(local_apprenant_id) { + try { + var form = new FormData(); + const stored_cookie = getCookie("tokenmysych"); - setLoading(true); - axios.post(myurl, form).then(res => { - //console.log(" In Get_List_Ent_Formation res.data.status = " + res.data.status); - //console.log(" In Get_List_Ent_Formation res.data.message r_class = " + res.data.message); + form.append("token", stored_cookie); + form.append("apprenant_id", local_apprenant_id); + + var myurl = + process.env.REACT_APP_API_URL + "myclass/api/Get_Ent_Student_List_Class/"; + + setLoading(true); + + const response = await fetch(myurl, { + method: "POST", + body: form, + }); + + const res = await response.json(); setLoading(false); - if (String(res.data.status) === String("true")) { + // console.log(" In Get_List_Ent_Formation res.status = " + res.status); + // console.log(" In Get_List_Ent_Formation res.message = " + res.message); + + if (String(res.status) === "true") { setGet_List_Ent_Formation_api("true"); - setGet_List_Ent_Formation_result(res.data.message); + setGet_List_Ent_Formation_result(res.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 external_code = JSON.parse(x).external_code; - var title = JSON.parse(x).title; - var objectif = JSON.parse(x).objectif; - var programme = JSON.parse(x).programme; - var prerequis = JSON.parse(x).prerequis; - var description = JSON.parse(x).description; - var associated_session_id = JSON.parse(x).session_id; - var associated_inscription_id = JSON.parse(x).inscription_id; + res.message.map((x) => { + const parsed = typeof x === "string" ? JSON.parse(x) : x; - var session_code_session = JSON.parse(x).session_code_session; - var session_date_debut = JSON.parse(x).session_date_debut; - var session_date_fin = JSON.parse(x).session_date_fin; + var localid = parsed.id; + var local_id = parsed._id; + var external_code = parsed.external_code; + var title = parsed.title; + var objectif = parsed.objectif; + var programme = parsed.programme; + var prerequis = parsed.prerequis; + var description = parsed.description; + var associated_session_id = parsed.session_id; + var associated_inscription_id = parsed.inscription_id; + var session_code_session = parsed.session_code_session; + var session_date_debut = parsed.session_date_debut; + var session_date_fin = parsed.session_date_fin; - - //--- var node = { - "_id": local_id, - "id": localid, - "label": external_code, - "external_code": external_code, - "title": title, - "objectif": objectif, - "programme": programme, - "prerequis": prerequis, - "description": description, - "associated_session_id": associated_session_id, - "associated_inscription_id": associated_inscription_id, - "session_code_session": session_code_session, - "session_date_debut": session_date_debut, - "session_date_fin": session_date_fin, - + _id: local_id, + id: localid, + label: external_code, + external_code: external_code, + title: title, + objectif: objectif, + programme: programme, + prerequis: prerequis, + description: description, + associated_session_id: associated_session_id, + associated_inscription_id: associated_inscription_id, + session_code_session: session_code_session, + session_date_debut: session_date_debut, + session_date_fin: session_date_fin, }; + new_data2.push(node); }); - if (new_data2.length > 0) + if (new_data2.length > 0) { setNew_Get_List_Ent_Formation_result(new_data2); - } - else if (String(res.data.status) === String("Err_Connexion")) { - alert('Erreur: ' + res.data.message); + } + } else if (String(res.status) === "Err_Connexion") { + alert("Erreur: " + res.message); history.push("/ent_student"); - } - else { + } else { setGet_List_Ent_Formation_api("false"); - setGet_List_Ent_Formation_message(res.data.message); - alert('Erreur: ' + res.data.message); + setGet_List_Ent_Formation_message(res.message); + alert("Erreur: " + res.message); } - - }).catch((error) => { + } catch (error) { setLoading(false); - console.warn('Not good man :( Get_List_Ent_Formation = ', error); + console.warn("Not good man :( Get_List_Ent_Formation = ", error); setGet_List_Ent_Formation_api("false"); - alert('Erreur: Impossible de recuperer la liste des formation'); - }) + alert("Erreur: Impossible de recuperer la liste des formation"); + } } const [Getall_Sequence_Of_Session_result_planning_view, setGetall_Sequence_Of_Session_result_planning_view] = useState([]); @@ -2830,7 +2835,7 @@ const Module_Ent_Mes_Formations = (props) => { {String(submenu) === "absences" && Get_Given_Class_Data_result && Get_Given_Class_Data_result.length > 0 &&
- + { //placeholder="Minimum 3 rows" style={{ border: "1px solid gainsboro", width: '99%', padding: '2px', - maxHeight: '15rem', height: '5rem', minHeight: '5rem', marginBottom: '3rem' + maxHeight: '15rem', height: '10rem', minHeight: '10rem', marginBottom: '3rem' }} value={p_detail_stage_contrainte} onChange={(e) => { @@ -4868,7 +4868,7 @@ const Module_Gestion_Stage = (props) => { //placeholder="Minimum 3 rows" style={{ border: "1px solid gainsboro", width: '99%', padding: '2px', - maxHeight: '15rem', height: '5rem', minHeight: '5rem', marginBottom: '3rem' + maxHeight: '15rem', height: '10rem', minHeight: '10rem', marginBottom: '3rem' }} value={p_detail_stage_remuneration} onChange={(e) => { @@ -5030,7 +5030,7 @@ const Module_Gestion_Stage = (props) => { } {stage_submenu === "stage_suivi" && <> -
stage_suivi
+
diff --git a/src/components/PROD_050426/DisplayPartnerSession.js b/src/components/PROD_050426/DisplayPartnerSession.js index ee45b75..211c938 100644 --- a/src/components/PROD_050426/DisplayPartnerSession.js +++ b/src/components/PROD_050426/DisplayPartnerSession.js @@ -7965,6 +7965,7 @@ const [p_session_mode_animation_detail_organisation, setp_session_mode_animation form.append("token", stored_cookie); form.append("archive", "0"); + var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class/"; diff --git a/src/components/Partner_Commande.js b/src/components/Partner_Commande.js index b7445a4..f9feac7 100644 --- a/src/components/Partner_Commande.js +++ b/src/components/Partner_Commande.js @@ -799,6 +799,7 @@ const Partner_Commande = (props) => { const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("archive", "0"); + form.append("is_ftion_initiale", "2"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class/"; @@ -7241,7 +7242,7 @@ const Partner_Commande = (props) => {
-
Date cmd +
Date cmd
{
}
- +
) } -export default Partner_Commande; \ No newline at end of file +export default Partner_Commande; + + +const local_css = ` + .react-datepicker-wrapper{ +width: 100%; + } +`; \ No newline at end of file diff --git a/src/components/Partner_Facture.js b/src/components/Partner_Facture.js index 5980bb9..ad935ec 100644 --- a/src/components/Partner_Facture.js +++ b/src/components/Partner_Facture.js @@ -135,29 +135,58 @@ const Partner_Facture = (props) => { const [p_filtre1, setp_filtre1] = useState(""); const [p_filtre1_value, setp_filtre1_value] = useState(); + const [p_filtre1_entre_from_value, setp_filtre1_entre_from_value] = useState(); + const [p_filtre1_entre_to_value, setp_filtre1_entre_to_value] = useState(); const [p_filtre2, setp_filtre2] = useState(""); const [p_filtre2_value, setp_filtre2_value] = useState(); + const [p_filtre2_entre_from_value, setp_filtre2_entre_from_value] = useState(); + const [p_filtre2_entre_to_value, setp_filtre2_entre_to_value] = useState(); const [p_filtre3, setp_filtre3] = useState(""); const [p_filtre3_value, setp_filtre3_value] = useState(); + const [p_filtre3_entre_from_value, setp_filtre3_entre_from_value] = useState(); + const [p_filtre3_entre_to_value, setp_filtre3_entre_to_value] = useState(); const [p_filtre4, setp_filtre4] = useState(""); const [p_filtre4_value, setp_filtre4_value] = useState(); - + const [p_filtre4_entre_from_value, setp_filtre4_entre_from_value] = useState(); + const [p_filtre4_entre_to_value, setp_filtre4_entre_to_value] = useState(); const [p_filter_date_creation_du, setp_filter_date_creation_du] = useState(new Date().toLocaleDateString('fr-FR')); const [p_filter_date_creation_au, setp_filter_date_creation_au] = useState(new Date().toLocaleDateString('fr-FR')); const [p_filter_date_echeance, setp_filter_date_echeance] = useState(new Date().toLocaleDateString('fr-FR')); + + const [p_filter_date_echeance_from, setp_filter_date_echeance_from] = useState(new Date().toLocaleDateString('fr-FR')); + const [p_filter_date_echeance_to, setp_filter_date_echeance_to] = useState(new Date().toLocaleDateString('fr-FR')); + + const [p_filtre_echeance_operateur, setp_filtre_echeance_operateur] = useState(); const [p_filtre_montant_ttc_operateur, setp_filtre_montant_ttc_operateur] = useState(); const [p_filtre_solde_operateur, setp_filtre_solde_operateur] = useState(); + const [p_filtre_solde_operateur_entre_from, setp_filtre_solde_operateur_entre_from] = useState(); + const [p_filtre_solde_operateur_entre_to, setp_filtre_solde_operateur_entre_to] = useState(); + const [p_filtre_montant_ttc_from, setp_filtre_montant_ttc_from] = useState(); + const [p_filtre_montant_ttc_to, setp_filtre_montant_ttc_to] = useState(); + + const [p_filtre_echeance_from, setp_filtre_echeance_from] = useState(); + const [p_filtre_echeance_to, setp_filtre_echeance_to] = useState(); + + + + + function local_format_monetaire(local_amount) { + return new Intl.NumberFormat('fr-FR', { + style: 'currency', + currency: 'EUR', + }).format(Number(local_amount)); + } function ExpandableCell_50({ value }) { const [expanded, setExpanded] = React.useState(false); @@ -188,6 +217,36 @@ const Partner_Facture = (props) => { ); } + function ExpandableCell_String_to_monetaire({ value }) { + const [expanded, setExpanded] = React.useState(false); + + const number = parseFloat(value); + var new_value = "" + if (isNaN(number)) { + new_value = "—" + } else { + new_value = new Intl.NumberFormat('fr-FR', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }).format(number); + } + + + + return ( + + ); + } + const columns = [ @@ -204,10 +263,26 @@ const Partner_Facture = (props) => { { field: 'order_header_vendeur_id', headerName: 'Vendeur Id', width: 0, hide: true, editable: false, disableExport: true }, { field: 'order_header_vendeur_nom_prenom', headerName: 'Vendeur', width: 150, flex: 1, editable: false }, { field: 'order_header_date_cmd', headerName: 'Date Cmd', width: 150, hide: true, editable: false }, - { field: 'total_header_hors_taxe_before_header_reduction', headerName: 'Montant HT', width: 150, hide: false, editable: false }, - { field: 'order_header_tax_amount', headerName: 'Taxe', width: 150, hide: false, editable: false }, - { field: 'total_header_toutes_taxes', headerName: 'Montant TTC', width: 150, hide: false, editable: false }, - { field: 'reste_to_paye', headerName: 'A payer', width: 150, hide: false, editable: false }, + { + field: 'total_header_hors_taxe_before_header_reduction', headerName: 'Montant HT', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { + field: 'order_header_tax_amount', headerName: 'Taxe', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { + field: 'total_header_toutes_taxes', headerName: 'Montant TTC', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { + field: 'reste_to_paye', headerName: 'A payer', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + { field: 'credit_note_ref', headerName: 'Ref. Avoir', width: 150, hide: true, editable: false, }, { field: 'invoice_header_origin', headerName: 'Fact. Orig.', width: 150, hide: false, editable: false, }, @@ -338,6 +413,7 @@ const Partner_Facture = (props) => { @@ -8328,9 +8948,16 @@ const Partner_Facture = (props) => {
 
{String(display_detail_invoice) === "1" &&
- {p_detail_header_invoice_header_type === "brouillon" && } - {p_detail_header_invoice_header_type !== "brouillon" && } + {p_detail_header_invoice_header_type !== "avoir" && <> + {p_detail_header_invoice_header_type === "brouillon" && } + {p_detail_header_invoice_header_type !== "brouillon" && } + } + + {p_detail_header_invoice_header_type === "avoir" && <> + + + }
@@ -8347,855 +8974,873 @@ const Partner_Facture = (props) => {
{String(header_submenu) !== "paiement" &&
-
- {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && - Invoice_data_edit_mode !== "1" &&
+
-
Num Facture
- +
+
- InputLabelProps={{ - shrink: true, - }} - disabled={false} - className="disabled_style" - value={p_detail_header_invoice_header_ref_interne} +
+ + Infos facture + +
+ +
- /> -
-
Type Document
- - InputLabelProps={{ - shrink: true, - }} - disabled={false} - className="disabled_style" - value={p_detail_header_invoice_header_type} +
Num Facture
+ -
+ /> +
-
Date Facture
- Type Document
+ -
+ /> +
+ +
Date Facture
+ +
-
Ref. Commande
- Ref. Commande
+ -
+ /> +
-
Conditions Paiement
+
Conditions Paiement
- {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && 0 && (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style" + value={New_Getall_Partner_Paiement_Condition_result.filter((data) => (data)._id === String(p_detail_header_condition_paiement_id))[0].label} - />} -
+ />} +
-
Date Commande
- Date Commande
+ -
+ /> +
-
Nom Client
- Nom Client
+ + InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style disabled_style_left_text_with_visualiser_icone" + value={p_detail_header_client_nom} + /> - - - } + + + {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && + Invoice_data_edit_mode === "1" &&
+ +
Num Facture
+ +
+ +
Type Document
+ +
+ +
Date Facture
+ { + setp_detail_header_invoice_date(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + +
+ + + + +
Ref. Commande
+ { + setp_detail_header_ref_interne(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Conditions Paiement
+ {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + setInvoice_data_changed("1"); + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + setp_detail_header_condition_paiement_code(value.code); + + } else { + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + } + + }} + + renderInput={(params) => + } + />} + +
+ +
Date Commande
+ { + setp_detail_header_date_cmd(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + + +
+ + + + + + + +
Email Client
+ +
+ + +
Commande Ref. Externe
+ { + setp_detail_header_ref_client(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Description
+ { + setp_detail_header_description(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Commentaire
+ { + setp_detail_header_comment(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Vendeur
+ { + setp_detail_header_vendeur_nom(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
} + + {String(header_submenu) === "detail" &&
+
Type de Reduction (entete)
+
-
- -
-
Email Client
- Valeur reduction (entete)
+ +
- /> -
+
Montant Reduction (entete)
+ Commande Ref. Externe
- -
- -
Description
- -
- -
Commentaire
- -
- -
Vendeur
- -
- -
} - - - {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && - Invoice_data_edit_mode === "1" &&
- -
Num Facture
- -
- -
Type Document
- -
- -
Date Facture
- { - setp_detail_header_invoice_date(format(date, 'dd/MM/yyyy')); - setInvoice_data_changed("1"); - } - } - showTimeSelect={false} - //filterTime={filterPassedTime_start} - dateFormat="dd/MM/yyyy" - className="disabled_style enable_style" - locale={'fr'} - /> - -
+ InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style" + value={p_detail_header_total_reduction_amount} - -
Ref. Commande
- { - setp_detail_header_ref_interne(e.target.value); - setInvoice_data_changed("1"); - } - } - - - /> -
- -
Conditions Paiement
- {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && - (data)._id === String(p_detail_header_condition_paiement_id))[0].label} - options={New_Getall_Partner_Paiement_Condition_result} - onChange={(event, value) => { - setInvoice_data_changed("1"); - if (value && value._id) { - setp_detail_header_condition_paiement_id(value._id); - setp_detail_header_condition_paiement_code(value.code); - - } else { - setp_detail_header_condition_paiement_id(""); - setp_detail_header_condition_paiement_code(""); - } - - }} - - renderInput={(params) => - } - />} - -
- -
Date Commande
- { - setp_detail_header_date_cmd(format(date, 'dd/MM/yyyy')); - setInvoice_data_changed("1"); - } - } - showTimeSelect={false} - //filterTime={filterPassedTime_start} - dateFormat="dd/MM/yyyy" - className="disabled_style enable_style" - locale={'fr'} - /> - - -
+ /> +
+
Total Ligne HT avant reduction
+ Nom Client
- +
- InputLabelProps={{ - shrink: true, - }} - disabled={true} - className="disabled_style disabled_style_left_text_with_visualiser_icone" - value={p_detail_header_client_nom} - /> + } + + {String(header_submenu) === "facturation" && Invoice_data_edit_mode !== "1" &&
+ + + + +
Date échéance
+ +
+ +
Adresse Facturation
+ +
+ +
Code postal
+ +
+ +
Ville
+ +
+ +
Pays
+ +
+ +
Lieu Formation
+ - if (p_detail_header_client_nom_id && String(p_detail_header_client_nom_id).length > 2) { - window.open( - process.env.REACT_APP_FRONT_URL + "Partner/mes_clients/" + String(p_detail_header_client_nom_id), - '_blank' - ); - } - } - } - > -
-
-
- -
-
Email Client
- -
- - -
Commande Ref. Externe
- { - setp_detail_header_ref_client(e.target.value); - setInvoice_data_changed("1"); - } - } - - - /> -
- -
Description
- { - setp_detail_header_description(e.target.value); - setInvoice_data_changed("1"); - } - } - - - /> -
- -
Commentaire
- { - setp_detail_header_comment(e.target.value); - setInvoice_data_changed("1"); - } - } - - - /> -
- -
Vendeur
- { - setp_detail_header_vendeur_nom(e.target.value); - setInvoice_data_changed("1"); - } - } - - - /> -
- -
} - - {String(header_submenu) === "detail" &&
-
Type de Reduction (entete)
- - -
- - -
Valeur reduction (entete)
- -
- -
Montant Reduction (entete)
- -
- - - -
Total Ligne HT avant reduction
- -
- -
Total Ligne Reduction
- -
- -
Total Ligne HT apres reduction
- -
- - -
Total Ligne Taxes
- -
- -
Entete : Total reduction
- -
- - - -
Entete : Total HT avant reduction d'entete
- -
- -
Entete : Total HT apres reduction d'entete
- -
- -
} - - {String(header_submenu) === "facturation" && Invoice_data_edit_mode !== "1" &&
- - - - -
Date échéance
- -
- -
Adresse Facturation
- -
- -
Code postal
- -
- -
Ville
- -
- -
Pays
- -
- -
Lieu Formation
- - - -
- - - {/* + {/*
Adresse Livraison
{
*/} -
} +
} - {String(header_submenu) === "facturation" && Invoice_data_edit_mode === "1" && p_detail_header_invoice_header_type === "brouillon" && -
+ {String(header_submenu) === "facturation" && Invoice_data_edit_mode === "1" && p_detail_header_invoice_header_type === "brouillon" && +
-
Condition Paiement  
- {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && - (data)._id === String(p_detail_header_condition_paiement_id))[0].label} - options={New_Getall_Partner_Paiement_Condition_result} - onChange={(event, value) => { - setInvoice_data_changed("1"); - if (value && value._id) { - setp_detail_header_condition_paiement_id(value._id); - setp_detail_header_condition_paiement_code(value.code); - setp_detail_header_condition_paiement(value.code) +
Condition Paiement  
+ {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + setInvoice_data_changed("1"); + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + setp_detail_header_condition_paiement_code(value.code); + setp_detail_header_condition_paiement(value.code) - } else { - setp_detail_header_condition_paiement_id(""); - setp_detail_header_condition_paiement_code(""); - setp_detail_header_condition_paiement("") - } + } else { + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + setp_detail_header_condition_paiement("") + } - }} + }} - renderInput={(params) => - } - />} + /> + } + />} -
+
-
Date échéance
- { - setp_detail_header_date_echeance(format(date, 'dd/MM/yyyy')); - setInvoice_data_changed("1"); - } - } - showTimeSelect={false} - //filterTime={filterPassedTime_start} - dateFormat="dd/MM/yyyy" - className="disabled_style enable_style" - locale={'fr'} - /> +
Date échéance
+ { + setp_detail_header_date_echeance(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> -
+
-
Adresse Facturation
- Adresse Facturation
+ { - setp_detail_header_fact_adr(e.target.value); - setInvoice_data_changed("1"); - } - } + InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style" + value={p_detail_header_fact_adr} + onChange={(e) => { + setp_detail_header_fact_adr(e.target.value); + setInvoice_data_changed("1"); + } + } - /> -
+ /> +
-
Code postal
- Code postal
+ { - setp_detail_header_fact_code_postal(e.target.value); - setInvoice_data_changed("1"); - } - } + InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style" + value={p_detail_header_fact_code_postal} + onChange={(e) => { + setp_detail_header_fact_code_postal(e.target.value); + setInvoice_data_changed("1"); + } + } - /> -
+ /> +
-
Ville
- Ville
+ { - setp_detail_header_fact_ville(e.target.value); - setInvoice_data_changed("1"); - } - } + InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style" + value={p_detail_header_fact_ville} + onChange={(e) => { + setp_detail_header_fact_ville(e.target.value); + setInvoice_data_changed("1"); + } + } - /> -
+ /> +
-
Pays
- Pays
+ { - setp_detail_header_fact_pays(e.target.value); - setInvoice_data_changed("1"); - } - } + InputLabelProps={{ + shrink: true, + }} + disabled={false} + className="disabled_style" + value={p_detail_header_fact_pays} + onChange={(e) => { + setp_detail_header_fact_pays(e.target.value); + setInvoice_data_changed("1"); + } + } - /> -
+ /> +
-
Lieu Formation
- { - setp_detail_lieu_formation(e.target.value); - setInvoice_data_changed("1"); - } - } - /> +
Lieu Formation
+ { + setp_detail_lieu_formation(e.target.value); + setInvoice_data_changed("1"); + } + } + /> -
+
- {/* + {/*
Adresse Livraison
{
*/} -
} +
} + + + + + +
+
+ + + + +
+ +
+
+ +
+ Actions +
+ +
+ + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Confirmer + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + Souhaitez-vous valider le document et créer la facture
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && + Imprimer pdf + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + Souhaitez-vous imprimer la Facture Originale ou la Facture acquittée ?
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && } + + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && String(history_securite_read) === "1" && } + + + +
 
+ {String(props.check_user_acces_right("facture_client", "write")) === "1" && } + + {p_detail_header_invoice_header_type === "brouillon" && <> +
 
+
 
+ } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode !== "1" && + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode === "1" && + } + + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode === "1" && + } + + + + +
 
+ + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type && String(p_detail_header_invoice_header_type) === "facture" && + String(p_detail_header_credit_note_ref) === "" && + Annuler (Avoir) + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + En confirmant cette opération, La facture sera annulée et un avoir créé .
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
} + + + +
+
+
+ +
-
- {/*String(props.check_user_acces_right("facture_client", "write")) === "1" && */} - {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && - Confirmer - - } - modal - nested - position="center center" - > - {close => ( -
- -
MySy Information
-
- {' '} - Souhaitez-vous valider le document et créer la facture
- -
-
-
- - -
-
- -
-
-
- )} -
- - } - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && - Imprimer pdf - - } - modal - nested - position="center center" - > - {close => ( -
- -
MySy Information
-
- {' '} - Souhaitez-vous imprimer la Facture Originale ou la Facture acquittée ?
- -
-
-
- - -
-
- -
-
-
- )} -
- - } - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && } - - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && String(history_securite_read) === "1" && } - - - -
 
- {String(props.check_user_acces_right("facture_client", "write")) === "1" && } - - {p_detail_header_invoice_header_type === "brouillon" && <> -
 
-
 
- } - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && - Invoice_data_edit_mode !== "1" && - } - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && - Invoice_data_edit_mode === "1" && - } - - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && - Invoice_data_edit_mode === "1" && - } - - - - -
 
- - - {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type && String(p_detail_header_invoice_header_type) === "facture" && - String(p_detail_header_credit_note_ref) === "" && - Annuler (Avoir) - - } - modal - nested - position="center center" - > - {close => ( -
- -
MySy Information
-
- {' '} - En confirmant cette opération, La facture sera annulée et un avoir créé .
- -
-
-
- - -
-
- -
-
-
- )} -
} -
} @@ -9769,7 +10444,7 @@ const Partner_Facture = (props) => { {String(header_submenu) === "paiement" &&
{New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result && New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result.length > 0 && -
+
{New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result &&
@@ -9821,15 +10496,15 @@ const Partner_Facture = (props) => { }, '& .line--statut--selected': { backgroundColor: '#e9f7f1', - color: "#0a2a4d", + color: "#0a2a4d", }, '& .line--statut--pair': { backgroundColor: 'rgba(235, 235, 235, .7)', - color: "#0a2a4d", + color: "#0a2a4d", }, '& .line--statut--impair': { backgroundColor: '#FFFFFF', - color: "#0a2a4d", + color: "#0a2a4d", }, @@ -9944,7 +10619,7 @@ const Partner_Facture = (props) => {
- {String(header_submenu) !== "paiement" &&
+ {String(header_submenu) !== "paiement" &&
{p_detail_header_invoice_header_type === "brouillon" && String(props.check_user_acces_right("facture", "write")) === "1" && @@ -9972,12 +10647,12 @@ const Partner_Facture = (props) => { // Gestion des cellule a distance ou presentiel '& .cell--distantiel': { backgroundColor: '#AFE1AF', - color: "#0a2a4d", + color: "#0a2a4d", }, '& .cell--presentiel': { backgroundColor: '#AFE1AF', - color: "#0a2a4d", + color: "#0a2a4d", }, @@ -9989,11 +10664,11 @@ const Partner_Facture = (props) => { '& .line--statut--inscrit': { backgroundColor: '#CEF6D8', - color: "#0a2a4d", + color: "#0a2a4d", }, '& .line--statut--preinscrit': { backgroundColor: '#F7F2E0', - color: "#0a2a4d", + color: "#0a2a4d", }, /*"& .MuiDataGrid-virtualScrollerRenderZone": { @@ -10186,6 +10861,10 @@ width: 100%; .react-datepicker-wrapper{ width: 100%; - } + + .datepicker_complement { + margin: 0px !important; + width: 100% !important; +} `; \ No newline at end of file diff --git a/src/components/Partner_Facture_ARG.js b/src/components/Partner_Facture_ARG.js new file mode 100644 index 0000000..197fc83 --- /dev/null +++ b/src/components/Partner_Facture_ARG.js @@ -0,0 +1,12282 @@ +import React, { useRef, useState, useEffect } from "react"; +import TextField from '@mui/material/TextField'; +import MenuItem from '@mui/material/MenuItem'; +import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css +import Button from '@mui/material/Button'; +import axios from "axios"; +import { useParams } from 'react-router-dom'; +import { getCookie } from 'react-use-cookie'; +import { useHistory } from "react-router-dom"; +import { FcAddDatabase } from "react-icons/fc"; +import { + DataGrid, frFR, GridToolbar, + +} from '@mui/x-data-grid'; +import { FcCancel } from "react-icons/fc"; +import * as XLSX from 'xlsx'; +import TextareaAutosize from '@mui/material/TextareaAutosize'; +import { Fab } from "@material-ui/core"; +import { IoMdAddCircle } from "react-icons/io"; +import Chip from "@mui/material/Chip"; +import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css"; + +import { FcViewDetails, FcInfo } from "react-icons/fc"; +import 'react-tooltip/dist/react-tooltip.css' +import { Tooltip } from 'react-tooltip' + +import fileDownload from 'js-file-download' +import Popup from 'reactjs-popup'; +import 'reactjs-popup/dist/index.css'; + +import fr from 'date-fns/locale/fr'; +import { registerLocale } from 'react-datepicker'; +import DatePicker from "react-datepicker"; +import "react-datepicker/dist/react-datepicker.css"; +import { format } from 'date-fns' +import moment from "moment"; +import InputAdornment from '@mui/material/InputAdornment'; +import { AiFillCloseCircle } from "react-icons/ai"; +import Box from '@mui/material/Box'; + +import { CiTrash } from "react-icons/ci"; +import { MdAddCircleOutline, MdRemoveCircleOutline } from "react-icons/md"; +import Autocomplete from '@mui/material/Autocomplete'; +import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif"; +import { IoAddCircleOutline } from "react-icons/io5"; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; +import Link from '@mui/material/Link'; +import { PiDotsThree } from "react-icons/pi"; +import { gridClasses } from '@mui/x-data-grid'; +import { + GridToolbarContainer, GridToolbarExport, GridToolbarColumnsButton, + GridToolbarFilterButton, GridToolbarDensitySelector, GridToolbarExportContainer, useGridApiContext, + gridFilteredSortedRowIdsSelector, + gridVisibleColumnFieldsSelector, + + +} from '@mui/x-data-grid'; + +import Timeline from '@mui/lab/Timeline'; +import TimelineItem from '@mui/lab/TimelineItem'; +import TimelineSeparator from '@mui/lab/TimelineSeparator'; +import TimelineConnector from '@mui/lab/TimelineConnector'; +import TimelineContent from '@mui/lab/TimelineContent'; +import TimelineDot from '@mui/lab/TimelineDot'; +import TimelineOppositeContent, { + timelineOppositeContentClasses, +} from '@mui/lab/TimelineOppositeContent'; + +//import { utils, writeFileXLSX } from "xlsx"; +import { ContextMenu } from "react-contextmenu"; + +import { FcOpenedFolder } from "react-icons/fc"; +import Module_Historique_Action from "./Module_Historique_Action"; + + +import { makeStyles } from "@material-ui/core/styles"; +import Paper from '@material-ui/core/Paper'; +import Draggable from 'react-draggable'; +import { IconButton } from '@material-ui/core'; +import CancelPresentationIcon from '@mui/icons-material/CancelPresentation'; +import Module_Alert_Confirmation from "./Module_Alert_Confirmation"; + +function PaperComponent(props) { + return ( + + + + ); +} + + +const useStyles = makeStyles((theme) => ({ + + dialog: { + position: 'absolute', + // left: 10, + top: 400 + }, + + paper: { + overflowY: 'unset', + }, + customizedButton: { + position: 'absolute', + left: '98%', + top: '-3%', + backgroundColor: 'lightgray', + color: 'gray', + }, +})); + +const Partner_Facture_ARG = (props) => { + const classes = useStyles(); + const { action, orderid } = useParams(); + + registerLocale('fr', fr); + const history = useHistory(); + const [submenu, setsubmenu] = useState(""); + const [rowss, setRows] = useState([]); + const [rowss_total_data, setRows_total_data] = useState([]); + const [selectionModel, setSelectionModel] = React.useState([]); + + const [rows_invoice_lines, setrows_invoice_lines] = useState([]); + const [selectionModel_invoice_lines, setselectionModel_invoice_lines] = React.useState([]); + const [gridline_id, setgridline_id] = useState(""); + var date_today_90j = new Date(); + date_today_90j.setDate(date_today_90j.getDate() + 90); + + const [p_filtre1, setp_filtre1] = useState(""); + const [p_filtre1_value, setp_filtre1_value] = useState(); + const [p_filtre1_entre_from_value, setp_filtre1_entre_from_value] = useState(); + const [p_filtre1_entre_to_value, setp_filtre1_entre_to_value] = useState(); + + + const [p_filtre2, setp_filtre2] = useState(""); + const [p_filtre2_value, setp_filtre2_value] = useState(); + const [p_filtre2_entre_from_value, setp_filtre2_entre_from_value] = useState(); + const [p_filtre2_entre_to_value, setp_filtre2_entre_to_value] = useState(); + + + const [p_filtre3, setp_filtre3] = useState(""); + const [p_filtre3_value, setp_filtre3_value] = useState(); + const [p_filtre3_entre_from_value, setp_filtre3_entre_from_value] = useState(); + const [p_filtre3_entre_to_value, setp_filtre3_entre_to_value] = useState(); + + + const [p_filtre4, setp_filtre4] = useState(""); + const [p_filtre4_value, setp_filtre4_value] = useState(); + const [p_filtre4_entre_from_value, setp_filtre4_entre_from_value] = useState(); + const [p_filtre4_entre_to_value, setp_filtre4_entre_to_value] = useState(); + + + const [p_filter_date_creation_du, setp_filter_date_creation_du] = useState(new Date().toLocaleDateString('fr-FR')); + const [p_filter_date_creation_au, setp_filter_date_creation_au] = useState(new Date().toLocaleDateString('fr-FR')); + const [p_filter_date_echeance, setp_filter_date_echeance] = useState(new Date().toLocaleDateString('fr-FR')); + + const [p_filter_date_echeance_from, setp_filter_date_echeance_from] = useState(new Date().toLocaleDateString('fr-FR')); + const [p_filter_date_echeance_to, setp_filter_date_echeance_to] = useState(new Date().toLocaleDateString('fr-FR')); + + + const [p_filtre_echeance_operateur, setp_filtre_echeance_operateur] = useState(); + const [p_filtre_montant_ttc_operateur, setp_filtre_montant_ttc_operateur] = useState(); + const [p_filtre_solde_operateur, setp_filtre_solde_operateur] = useState(); + + const [p_filtre_solde_operateur_entre_from, setp_filtre_solde_operateur_entre_from] = useState(); + const [p_filtre_solde_operateur_entre_to, setp_filtre_solde_operateur_entre_to] = useState(); + + const [p_filtre_montant_ttc_from, setp_filtre_montant_ttc_from] = useState(); + const [p_filtre_montant_ttc_to, setp_filtre_montant_ttc_to] = useState(); + + const [p_filtre_echeance_from, setp_filtre_echeance_from] = useState(); + const [p_filtre_echeance_to, setp_filtre_echeance_to] = useState(); + + + + + function local_format_monetaire(local_amount) { + return new Intl.NumberFormat('fr-FR', { + style: 'currency', + currency: 'EUR', + }).format(Number(local_amount)); + } + + function ExpandableCell_50({ value }) { + const [expanded, setExpanded] = React.useState(false); + + return ( + + ); + } + + function ExpandableCell_String_to_monetaire({ value }) { + const [expanded, setExpanded] = React.useState(false); + + const number = parseFloat(value); + var new_value = "" + if (isNaN(number)) { + new_value = "—" + } else { + new_value = new Intl.NumberFormat('fr-FR', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }).format(number); + } + + + + return ( + + ); + } + + + + const columns = [ + { field: '_id', headerName: '_id', hide: true, disableExport: true, }, + { field: 'id', headerName: 'id', hide: true, disableExport: true }, + { field: 'invoice_header_ref_interne', headerName: 'Num Facture', minWidth: 200, flex: 1, hide: false, editable: false, }, + { field: 'order_header_ref_interne', headerName: 'Réf. Cmd', minWidth: 200, flex: 1, hide: true, editable: false }, + { field: 'invoice_header_type', headerName: 'Type', width: 100, hide: false, editable: false }, + { field: 'invoice_date', headerName: 'Date Facture', width: 150, hide: false, editable: false }, + { field: 'invoice_date_echeance', headerName: 'Echéance', width: 150, hide: false, editable: false }, + + { field: 'order_header_client_id', headerName: 'Client_Id', width: 150, hide: true, editable: false, disableExport: true }, + { field: 'order_header_client_nom', headerName: 'Nom Client', minWidth: 150, flex: 1 }, + { field: 'order_header_vendeur_id', headerName: 'Vendeur Id', width: 0, hide: true, editable: false, disableExport: true }, + { field: 'order_header_vendeur_nom_prenom', headerName: 'Vendeur', width: 150, flex: 1, editable: false }, + { field: 'order_header_date_cmd', headerName: 'Date Cmd', width: 150, hide: true, editable: false }, + { + field: 'total_header_hors_taxe_before_header_reduction', headerName: 'Montant HT', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { + field: 'order_header_tax_amount', headerName: 'Taxe', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { + field: 'total_header_toutes_taxes', headerName: 'Montant TTC', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { + field: 'reste_to_paye', headerName: 'A payer', width: 150, hide: false, editable: false, + renderCell: (params) => , + }, + + { field: 'credit_note_ref', headerName: 'Ref. Avoir', width: 150, hide: true, editable: false, }, + { field: 'invoice_header_origin', headerName: 'Fact. Orig.', width: 150, hide: false, editable: false, }, + + { + field: "delete", headerName: 'Supprimer', disableExport: true, + renderCell: (cellValues) => { + return ( +
+ {String(props.check_user_acces_right("facture", "write")) === "1" && + cellValues.row.invoice_header_type !== "brouillon" && } + {String(props.check_user_acces_right("facture", "write")) === "1" && + cellValues.row.invoice_header_type === "brouillon" && { + // handleClick_delete(event, cellValues); + }} + > + + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + En confirmant cette opération, le document sera définitivement supprimé.
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
} +
+ + ); + } + } + + + ] + + + const columns_invoice_lines = [ + { field: '_id', headerName: '_id', hide: true, editable: false }, + { field: 'id', headerName: 'id', hide: true, editable: false }, + { field: 'invoice_line_type', headerName: 'invoice_line_type', hide: true, editable: false }, + { field: 'order_line_formation', headerName: 'intenal_url', width: 0, hide: true, editable: false }, + { + field: 'order_line_formation_title', headerName: 'Titre', width: 250, hide: false, editable: false, flex: 1, + renderCell: (cellValues) => { + return ( +
+ +
+ ); + } + }, + { field: 'order_line_formation_external_code', headerName: 'Code Formation', width: 150, hide: false, editable: false }, + { field: 'order_line_session_code', headerName: 'Code Session', width: 150, hide: false, editable: false }, + { field: 'order_line_formation_duration', headerName: 'Durée', width: 80, hide: false, editable: false }, + + { field: 'order_line_qty', headerName: 'Qte', width: 100, hide: false, editable: false }, + { field: 'order_line_prix_unitaire', headerName: 'Prix Unit.', width: 100, hide: false, editable: false }, + + { field: 'order_line_montant_hors_taxes', headerName: 'Total HT', width: 100, hide: false, editable: false }, + + { field: 'order_header_id', headerName: 'Id_Entete', hide: true, editable: false }, + { field: 'order_header_ref_interne', headerName: 'Ref_Interne', hide: true, editable: false }, + { field: 'order_line_type', headerName: 'Type', width: 100, hide: false, editable: false }, + { field: 'order_line_type_article', headerName: 'Type Article', width: 100, hide: true, editable: false }, + + { + field: "Detail", headerName: 'Voir détail', + renderCell: (cellValues) => { + return ( + + + + ); + } + }, + + { + field: "delete", headerName: 'Supprimer', disableExport: true, + renderCell: (cellValues) => { + return ( +
+ {String(props.check_user_acces_right("facture", "write")) === "1" && + String(is_document_invoiced) === "1" && } + {String(props.check_user_acces_right("facture", "write")) === "1" && + String(is_document_invoiced) !== "1" && { + // handleClick_delete(event, cellValues); + }} + > + + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + En confirmant cette opération, la ligne sera définitivement supprimée.
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
} +
+ + ); + } + }, + + { field: 'order_line_comment', headerName: 'Commentaire', width: 150, hide: true, editable: false, }, + + ] + + const columns_paiement = [ + { field: '_id', headerName: '_id', hide: true }, + { field: 'id', headerName: 'id', hide: true }, + { field: 'invoice_id', headerName: 'invoice_id', width: 0, hide: true, editable: false }, + { field: 'paiement_date', headerName: 'Date', minWidth: 200, flex: 1, renderCell: (params) => , }, + { field: 'paiement_ref', headerName: 'Réference', minWidth: 200, flex: 1, renderCell: (params) => , }, + { field: 'paiement_amount', headerName: 'Montant', minWidth: 200, flex: 1, renderCell: (params) => , }, + { field: 'paiement_mode', headerName: 'Mode', minWidth: 200, flex: 1, renderCell: (params) => , }, + + { + field: "delete", headerName: 'Supprimer', + renderCell: (cellValues) => { + return ( + <> + {String(props.check_user_acces_right("facture_client", "write")) === "1" && + + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + En confirmant cette opération, le paiement sera définitivement supprimé.
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
} + + + + ); + } + } + + ] + + const [Delete_Draft_Invoice_Header_AndLine_Data_api, setDelete_Draft_Invoice_Header_AndLine_Data_api] = useState(); + const [Delete_Draft_Invoice_Header_AndLine_Data_message, setDelete_Draft_Invoice_Header_AndLine_Data_message] = useState(); + const [Delete_Draft_Invoice_Header_AndLine_Data_result, setDelete_Draft_Invoice_Header_AndLine_Data_result] = useState(); + function Delete_Draft_Invoice_Header_AndLine_Data(event, cellValues) { + + var invoice_id = cellValues.row._id; + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_header_id", invoice_id); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Delete_Partner_Draft_Invoice/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Delete_Draft_Invoice_Header_AndLine_Data res.data.status = " + res.data.status); + //console.log(" In Delete_Draft_Invoice_Header_AndLine_Data res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + setDelete_Draft_Invoice_Header_AndLine_Data_api("true"); + setDelete_Draft_Invoice_Header_AndLine_Data_result(res.data.message); + + setdisplay_detail_invoice(""); + clean_order_detail_fields(); + + Getall_Parter_Invoice_No_Filter(); + + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + } + else { + setDelete_Draft_Invoice_Header_AndLine_Data_api("false"); + setDelete_Draft_Invoice_Header_AndLine_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + + } + + }).catch((error) => { + setLoading(false); + + setDelete_Draft_Invoice_Header_AndLine_Data_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de supprimer le document"); + setalert_type("error"); + }) + } + + + const [Delete_Draft_Invoice_Line_Data_api, setDelete_Draft_Invoice_Line_Data_api] = useState(); + const [Delete_Draft_Invoice_Line_Data_message, setDelete_Draft_Invoice_Line_Data_message] = useState(); + const [Delete_Draft_Invoice_Line_Data_result, setDelete_Draft_Invoice_Line_Data_result] = useState(); + function Delete_Draft_Invoice_Line_Data(event, cellValues) { + + var partner_invoice_line = cellValues.row._id; + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_header_id", selected_id); + form.append("partner_invoice_line", partner_invoice_line); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Delete_Partner_Draft_Invoice_Line/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Delete_Draft_Invoice_Line_Data res.data.status = " + res.data.status); + //console.log(" In Delete_Draft_Invoice_Line_Data res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + setDelete_Draft_Invoice_Line_Data_api("true"); + setDelete_Draft_Invoice_Line_Data_result(res.data.message); + + setdisplay_detail_invoice(""); + clean_order_detail_fields(); + + Display_Detail_Invoice_data(selected_id); + + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + } + else { + setDelete_Draft_Invoice_Line_Data_api("false"); + setDelete_Draft_Invoice_Line_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + + } + + }).catch((error) => { + setLoading(false); + + setDelete_Draft_Invoice_Line_Data_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de supprimer la ligne"); + setalert_type("error"); + }) + } + + const [handleClick_delete_Paiement_api, sethandleClick_delete_Paiement_api] = useState(); + const [handleClick_delete_Paiement_message, sethandleClick_delete_Paiement_message] = useState(); + const [handleClick_delete_Paiement_result, sethandleClick_delete_Paiement_result] = useState(); + function handleClick_delete_Paiement(event, cellValues) { + + var paiement_id = cellValues.row._id; + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", paiement_id); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Delete_Given_Invoice_Paiement/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + if (String(res.data.status) === String("true")) { + //console.log(" In handleClick_delete_Paiement res.data.status = " + res.data.status); + //console.log(" In handleClick_delete_Paiement res.data.message r_class = " + res.data.message); + sethandleClick_delete_Paiement_api("true"); + sethandleClick_delete_Paiement_result(res.data.message); + + Getall_Invoice_Paiement(); + Getall_Invoice_Paiement_Payed_Remain_Amounts(); + clear_Paiement_DetailFields() + + // alert(res.data.message) + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + + } + else { + sethandleClick_delete_Paiement_api("false"); + sethandleClick_delete_Paiement_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( handleClick_delete_Paiement = ', error); + sethandleClick_delete_Paiement_api("false"); + alert(" Impossible de supprimer le paiement"); + //setmyApimyApiMessage("") + }) + } + + + + const [is_document_invoiced, setis_document_invoiced] = useState("1"); + + + const [selectionModel_paiement, setselectionModel_paiement] = React.useState([]); + + const [gridline_paiment_id, setgridline_paiment_id] = useState(""); + + const [selected_invoice_line_id, setselected_invoice_line_id] = useState(""); + const [p_add_line_item, setp_add_line_item] = useState(); + + const [p_add_line_invoice_line_type, setp_add_line_invoice_line_type] = useState(); + + const [p_add_line_item_type_article, setp_add_line_item_type_article] = useState(""); + + const [p_add_line_item_internal_url, setp_add_line_item_internal_url] = useState(); + const [p_add_line_item_title, setp_add_line_item_title] = useState(); + const [p_add_line_item_qty, setp_add_line_item_qty] = useState(); + const [p_add_line_item_price, setp_add_line_item_price] = useState(); + const [p_add_line_item_comment, setp_add_line_item_comment] = useState(); + const [p_add_line_item_status, setp_add_line_item_status] = useState(); + const [p_add_line_item_type, setp_add_line_item_type] = useState(); + + const [p_add_line_item_type_reduction, setp_add_line_item_type_reduction] = useState("fixe"); + const [p_add_line_item_reduction_value, setp_add_line_item_reduction_value] = useState(); + const [p_add_line_item_reduction_total_amount, setp_add_line_item_reduction_total_amount] = useState(); + const [p_add_line_item_total_amount_ht, setp_add_line_item_total_amount_ht] = useState(); + const [p_add_line_item_taxe, setp_add_line_item_taxe] = useState(); + const [p_add_line_item_taxe_amount, setp_add_line_item_taxe_amount] = useState(); + const [p_add_line_item_total_amount_ttc, setp_add_line_item_total_amount_ttc] = useState(); + const [p_add_line_item_duration_concat, setp_add_line_item_duration_concat] = useState(); + + const [p_add_line_item_type_apprenant, setp_add_line_item_type_apprenant] = useState(""); + + + + const [New_Getall_Invoice_Paiement_result, setNew_Getall_Invoice_Paiement_result] = useState([]); + + const [Getall_Invoice_Paiement_api, setGetall_Invoice_Paiement_api] = useState(); + const [Getall_Invoice_Paiement_message, setGetall_Invoice_Paiement_message] = useState(); + const [Getall_Invoice_Paiement_result, setGetall_Invoice_Paiement_result] = useState(); + function Getall_Invoice_Paiement(event) { + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_id", selected_id); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Invoice_Liste_Payement/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Invoice_Paiement res.data.status = " + res.data.status); + // console.log(" In Getall_Invoice_Paiement res.data.message r_class = " + res.data.message); + setGetall_Invoice_Paiement_api("true"); + setGetall_Invoice_Paiement_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_paiement_ref = JSON.parse(x).paiement_ref; + var local_paiement_amount = JSON.parse(x).paiement_amount; + var local_paiement_mode = JSON.parse(x).paiement_mode; + var local_paiement_date = JSON.parse(x).paiement_date; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_paiement_ref + " " + local_paiement_amount, + "paiement_amount": local_paiement_amount, + "paiement_mode": local_paiement_mode, + "paiement_date": local_paiement_date + }; + new_data2.push(node); + }); + + if (new_data2.length > 0) + setNew_Getall_Invoice_Paiement_result(new_data2); + + } + else { + setGetall_Invoice_Paiement_api("false"); + setGetall_Invoice_Paiement_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_Invoice_Paiement = ', error); + setGetall_Invoice_Paiement_api("false"); + alert(" Impossible de recuperer la liste des paiements"); + //setmyApimyApiMessage("") + }) + } + + + const [New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result, setNew_Getall_Invoice_Paiement_Payed_Remain_Amounts_result] = useState([]); + + const [Getall_Invoice_Paiement_Payed_Remain_Amounts_api, setGetall_Invoice_Paiement_Payed_Remain_Amounts_api] = useState(); + const [Getall_Invoice_Paiement_Payed_Remain_Amounts_message, setGetall_Invoice_Paiement_Payed_Remain_Amounts_message] = useState(); + const [Getall_Invoice_Paiement_Payed_Remain_Amounts_result, setGetall_Invoice_Paiement_Payed_Remain_Amounts_result] = useState(); + function Getall_Invoice_Paiement_Payed_Remain_Amounts(event) { + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_id", selected_id); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Invoice_Total_Amount_Payed_And_Remaining_Amount/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Invoice_Paiement_Payed_Remain_Amounts res.data.status = " + res.data.status); + console.log(" In Getall_Invoice_Paiement_Payed_Remain_Amounts res.data.message r_class = " + res.data.message); + setGetall_Invoice_Paiement_Payed_Remain_Amounts_api("true"); + setGetall_Invoice_Paiement_Payed_Remain_Amounts_result(res.data.message); + + var new_data2 = []; + const new_data = res.data.message.map((x) => { + + var local_total_amount = JSON.parse(x).total_amount; + var local_payed_amount = JSON.parse(x).payed_amount; + var local_remaining_amount = JSON.parse(x).remaining_amount; + + + + //--- + var node = { + "total_amount": local_total_amount, + "payed_amount": local_payed_amount, + "remaining_amount": local_remaining_amount, + + }; + new_data2.push(node); + }); + + if (new_data2.length > 0) { + setNew_Getall_Invoice_Paiement_Payed_Remain_Amounts_result(new_data2); + // console.log(" ### new_data2 = ", new_data2) + } + + } + else { + setGetall_Invoice_Paiement_Payed_Remain_Amounts_api("false"); + setGetall_Invoice_Paiement_Payed_Remain_Amounts_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_Invoice_Paiement_Payed_Remain_Amounts = ', error); + setGetall_Invoice_Paiement_Payed_Remain_Amounts_api("false"); + alert(" Impossible de recuperer les montants de la facture"); + //setmyApimyApiMessage("") + }) + } + + function Display_Detail_Invoice_Line(event, cellValues) { + + setarticle_formation_ou_produit(cellValues.row.order_line_type_article); + + var invoice_line_id = String(cellValues.row._id); + + var order_line_formation = String(cellValues.row.order_line_formation); + var order_line_qty = String(cellValues.row.order_line_qty); + var order_line_prix_unitaire = String(cellValues.row.order_line_prix_unitaire); + + + setselected_invoice_line_id(invoice_line_id); + + setp_add_line_item(order_line_formation); + + setp_add_line_item_internal_url(order_line_formation); + + setp_add_line_item_qty(order_line_qty); + setp_add_line_item_price(order_line_prix_unitaire); + setp_add_line_item_status(String(cellValues.row.order_line_status)); + setp_add_line_item_type(String(cellValues.row.order_line_type)); + setp_add_line_item_comment(String(cellValues.row.order_line_comment)); + + setp_add_line_invoice_line_type(String(cellValues.row.invoice_line_type)); + + Get_Given_Line_Of_Partner_Invoice_Line_Data(invoice_line_id, invoice_internal_ref); + + + setDialog_Detail_Article_open(true); + + //alert(" afficher le detail de la ligne " + String(order_line_id)); + + } + + + + function Display_Detail_Invoice_Line_From_datagrid(line) { + + var invoice_line_id = String(line._id); + + var order_line_formation = String(line.order_line_formation); + var order_line_qty = String(line.order_line_qty); + var order_line_prix_unitaire = String(line.order_line_prix_unitaire); + + setarticle_formation_ou_produit(line.order_line_type_article); + setselected_invoice_line_id(invoice_line_id); + + setp_add_line_item(order_line_formation); + + setp_add_line_item_internal_url(order_line_formation); + + setp_add_line_item_qty(order_line_qty); + setp_add_line_item_price(order_line_prix_unitaire); + setp_add_line_item_status(String(line.order_line_status)); + setp_add_line_item_type(String(line.order_line_type)); + setp_add_line_item_comment(String(line.order_line_comment)); + + setp_add_line_invoice_line_type(String(line.invoice_line_type)); + + Get_Given_Line_Of_Partner_Invoice_Line_Data(invoice_line_id, invoice_internal_ref); + + + setDialog_Detail_Article_open(true); + + //alert(" afficher le detail de la ligne " + String(order_line_id)); + + } + + const [Get_Given_Line_Of_Partner_Invoice_Line_Data_api, setGet_Given_Line_Of_Partner_Invoice_Line_Data_api] = useState(); + const [Get_Given_Line_Of_Partner_Invoice_Line_Data_message, setGet_Given_Line_Of_Partner_Invoice_Line_Data_message] = useState(); + const [Get_Given_Line_Of_Partner_Invoice_Line_Data_result, setGet_Given_Line_Of_Partner_Invoice_Line_Data_result] = useState(); + function Get_Given_Line_Of_Partner_Invoice_Line_Data(local_invoice_line_id, local_invoice_header_ref_interne) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_line_id", local_invoice_line_id); + form.append("invoice_header_ref_interne", local_invoice_header_ref_interne); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Line_Of_Partner_Invoice_Lines/"; + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === "true") { + //console.log(" In Get_Given_Line_Of_Partner_Invoice_Line_Data res.data.status = " + res.data.status); + console.log(" In Get_Given_Line_Of_Partner_Invoice_Line_Data res.data.message r_class = " + res.data.message); + setGet_Given_Line_Of_Partner_Invoice_Line_Data_api("true"); + setGet_Given_Line_Of_Partner_Invoice_Line_Data_result(res.data.message); + + if (res.data.message.length > 0) { + var mylocal_order = JSON.parse(res.data.message); + + + if (mylocal_order.order_line_formation) { + setp_add_line_item(mylocal_order.order_line_formation); + setp_add_line_item_internal_url(mylocal_order.order_line_formation); + } else { + setp_add_line_item(""); + setp_add_line_item_internal_url(""); + } + + if (mylocal_order.order_line_type_article) { + setp_add_line_item_type_article(mylocal_order.order_line_type_article); + } else { + setp_add_line_item_type_article(""); + } + + + if (mylocal_order.order_line_qty) { + setp_add_line_item_qty(mylocal_order.order_line_qty); + } + + if (mylocal_order.invoice_line_type) { + setp_add_line_invoice_line_type(mylocal_order.invoice_line_type); + } + + + if (mylocal_order.order_line_prix_unitaire) { + setp_add_line_item_price(mylocal_order.order_line_prix_unitaire); + } + + + /*if (mylocal_order.order_header_id) { + setp_detail_header_type_reduction(mylocal_order.order_header_id); + } + + + if (mylocal_order.order_header_ref_interne) { + setp_detail_header_type_reduction_valeur(mylocal_order.order_header_ref_interne); + }*/ + + + if (mylocal_order.order_line_montant_reduction) { + setp_add_line_item_reduction_total_amount(mylocal_order.order_line_montant_reduction); + } + + + + if (mylocal_order.order_line_montant_toutes_taxes) { + setp_add_line_item_total_amount_ttc(mylocal_order.order_line_montant_toutes_taxes); + + } + + + if (mylocal_order.order_line_tax) { + setp_add_line_item_taxe(mylocal_order.order_line_tax); + } + + + if (mylocal_order.order_line_tax_amount) { + setp_add_line_item_taxe_amount(mylocal_order.order_line_tax_amount); + } else { + setp_add_line_item_taxe_amount(""); + } + + if (mylocal_order.order_line_type_apprenant) { + setp_add_line_item_type_apprenant(mylocal_order.order_line_type_apprenant); + } else { + setp_add_line_item_type_apprenant(""); + } + + + if (mylocal_order.order_line_type_reduction) { + setp_add_line_item_type_reduction(mylocal_order.order_line_type_reduction); + } else { + setp_add_line_item_type_reduction(""); + } + + + if (mylocal_order.order_line_type_valeur) { + setp_add_line_item_reduction_value(mylocal_order.order_line_type_valeur); + } else { + setp_add_line_item_reduction_value(""); + } + + + if (mylocal_order.order_line_type) { + setp_add_line_item_type(mylocal_order.order_line_type); + } else { + setp_add_line_item_type(""); + } + + + if (mylocal_order.order_line_status) { + setp_add_line_item_status(mylocal_order.order_line_status); + } else { + setp_add_line_item_status(""); + } + + + if (mylocal_order.order_line_comment) { + setp_add_line_item_comment(mylocal_order.order_line_comment); + } else { + setp_add_line_item_comment(""); + } + + + if (mylocal_order.title) { + setp_add_line_item_title(mylocal_order.title); + } else { + setp_add_line_item_title(""); + } + + if (mylocal_order.order_line_montant_hors_taxes) { + setp_add_line_item_total_amount_ht(mylocal_order.order_line_montant_hors_taxes); + + } else { + setp_add_line_item_total_amount_ht(""); + } + + + /*if (mylocal_order.domaine) { + setp_detail_header_montant_reduction(mylocal_order.domaine); + }*/ + + + if (mylocal_order.duration_concat) { + setp_add_line_item_duration_concat(mylocal_order.duration_concat); + } else { + setp_add_line_item_duration_concat(""); + } + + + } else { + //setdisplay_alert_mysy("1"); + //setalert_message(" Aucune ligne de facture recuperée"); + //setalert_type("error"); + + } + + + } else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + + else { + setGet_Given_Line_Of_Partner_Invoice_Line_Data_api("false"); + setGet_Given_Line_Of_Partner_Invoice_Line_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( Get_Given_Line_Of_Partner_Invoice_Line_Data = ', error); + setGet_Given_Line_Of_Partner_Invoice_Line_Data_api("false"); + // alert(" Impossible de recuperer les données de la ligne de facture"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de récupérer les données de la ligne de facture"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + + const [isLoading, setLoading] = useState(); + + const [p_detail_header_client_nom, setp_detail_header_client_nom] = useState(); + const [p_detail_header_email_client, setp_detail_header_email_client] = useState(); + const [p_detail_header_client_nom_id, setp_detail_header_client_nom_id] = useState(); + + const [p_detail_header_description, setp_detail_header_description] = useState(); + const [p_detail_header_comment, setp_detail_header_comment] = useState(); + const [p_detail_header_date_cmd, setp_detail_header_date_cmd] = useState(new Date().toLocaleDateString('fr-FR')); + const [p_detail_header_date_expiration, setp_detail_header_date_expiration] = useState(date_today_90j.toLocaleDateString('fr-FR')); + const [p_detail_header_condition_paiement_id, setp_detail_header_condition_paiement_id] = useState(""); + const [p_detail_header_condition_paiement_code, setp_detail_header_condition_paiement_code] = useState(""); + + const [p_detail_header_ref_client, setp_detail_header_ref_client] = useState(); + const [p_detail_header_ref_interne, setp_detail_header_ref_interne] = useState(); + + const [p_detail_header_vendeur_nom, setp_detail_header_vendeur_nom] = useState(); + const [p_detail_header_vendeur_nom_id, setp_detail_header_vendeur_nom_id] = useState(); + + + const [p_detail_header_invoice_header_annotation, setp_detail_header_invoice_header_annotation] = useState(""); + + const [p_detail_header_invoice_header_ref_interne, setp_detail_header_invoice_header_ref_interne] = useState(); + const [p_detail_header_invoice_header_type, setp_detail_header_invoice_header_type] = useState(); + const [p_detail_header_invoice_date, setp_detail_header_invoice_date] = useState(new Date().toLocaleDateString('fr-FR')); + + + const [p_detail_header_type, setp_detail_header_type] = useState(); + const [p_detail_header_statut, setp_detail_header_statut] = useState(); + const [p_detail_header_vendeur_id, setp_detail_header_vendeur_id] = useState(); + const [p_detail_header_client_id, setp_detail_header_client_id] = useState(); + 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_condition_paiement, setp_detail_header_condition_paiement] = useState(); + const [p_detail_header_condition_paiement_desc, setp_detail_header_condition_paiement_desc] = useState(); + const [p_detail_header_date_echeance, setp_detail_header_date_echeance] = useState(new Date().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, setp_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_total_reduction_amount, setp_detail_header_total_reduction_amount] = useState(); + + + const [p_detail_header_credit_note_ref, setp_detail_header_credit_note_ref] = 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(); + const [p_detail_total_header_hors_taxe_before_header_reduction, setp_detail_total_header_hors_taxe_before_header_reduction] = useState(); + const [p_detail_total_header_hors_taxe_after_header_reduction, setp_detail_total_header_hors_taxe_after_header_reduction] = useState(); + const [p_detail_order_header_tax_amount, setp_detail_order_header_tax_amount] = useState(); + const [p_detail_total_header_toutes_taxes, setp_detail_total_header_toutes_taxes] = useState(); + + + + const [p_detail_total_lines_hors_taxe_before_lines_reduction, setp_detail_total_lines_hors_taxe_before_lines_reduction] = useState(); + const [p_detail_total_lines_hors_taxe_after_lines_reduction, setp_detail_total_lines_hors_taxe_after_lines_reduction] = useState(); + + const [New_Get_List_Partner_Clients_result, setNew_Get_List_Partner_Clients_result] = useState([]); + + const [Get_List_Partner_Clients_api, setGet_List_Partner_Clients_api] = useState(); + const [Get_List_Partner_Clients_message, setGet_List_Partner_Clients_message] = useState(); + const [Get_List_Partner_Clients_result, setGet_List_Partner_Clients_result] = useState(); + function Get_List_Partner_Clients(event) { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + + form.append("token", stored_cookie); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Partner_List_Partner_Client/"; + + axios.post(myurl, form).then(res => { + //console.log(" In Get_List_Partner_Clients res.data.status = " + res.data.status); + //console.log(" In Get_List_Partner_Clients res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setGet_List_Partner_Clients_api("true"); + setGet_List_Partner_Clients_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_nom = JSON.parse(x).nom; + var local_raison_sociale = JSON.parse(x).raison_sociale; + var local_cond_paiement_id = JSON.parse(x).invoice_condition_paiement_id; + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_nom, + "nom": local_nom, + "raison_sociale": local_raison_sociale, + "invoice_condition_paiement_id": local_cond_paiement_id, + + }; + new_data2.push(node); + }); + + if (new_data2.length > 0) + setNew_Get_List_Partner_Clients_result(new_data2); + + } + else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + else { + setGet_List_Partner_Clients_api("false"); + setGet_List_Partner_Clients_message(res.data.message); + // alert('Erreur: ' + res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + + } + + }).catch((error) => { + console.warn('Not good man :( Get_List_Partner_Clients = ', error); + setGet_List_Partner_Clients_api("false"); + // alert('Erreur: Impossible de récupérer la liste des clients'); + setdisplay_alert_mysy("1"); + setalert_message("Impossible de récupérer la liste des clients"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + + + + const [Getall_Parter_Invoice_No_Filter_api, setGetall_Parter_Invoice_No_Filter_api] = useState(); + const [Getall_Parter_Invoice_No_Filter_message, setGetall_Parter_Invoice_No_Filter_message] = useState(); + const [Getall_Parter_Invoice_No_Filter_result, setGetall_Parter_Invoice_No_Filter_result] = useState([]); + function Getall_Parter_Invoice_No_Filter(event) { + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Partner_Invoice_no_filter/"; + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Parter_Invoice_No_Filter res.data.status = " + res.data.status); + //console.log(" In Getall_Parter_Invoice_No_Filter res.data.message r_class = " + res.data.message); + // console.log(" In Getall_Parter_Invoice_No_Filter res.data.total_data r_class = ", res.data.total_data); + setGetall_Parter_Invoice_No_Filter_api("true"); + setGetall_Parter_Invoice_No_Filter_result(res.data.message); + setRows(res.data.message); + setRows_total_data(JSON.parse(res.data.total_data)); + } + else { + setGetall_Parter_Invoice_No_Filter_api("false"); + setGetall_Parter_Invoice_No_Filter_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( Getall_Parter_Invoice_No_Filter = ', error); + setGetall_Parter_Invoice_No_Filter_api("false"); + // alert(" Impossible de recuperer la liste des factures"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des factures"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + + const [Getall_Parter_Invoice_With_Filter_On_Client_Id_api, setGetall_Parter_Invoice_With_Filter_On_Client_Id_api] = useState(); + const [Getall_Parter_Invoice_With_Filter_On_Client_Id_message, setGetall_Parter_Invoice_With_Filter_On_Client_Id_message] = useState(); + const [Getall_Parter_Invoice_With_Filter_On_Client_Id_result, setGetall_Parter_Invoice_With_Filter_On_Client_Id_result] = useState(); + function Getall_Parter_Invoice_With_Filter_On_Client_Id(local_client_id) { + + setgridline_id(""); + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("order_header_client_id", local_client_id); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Partner_Invoice_with_filter/"; + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Parter_Invoice_With_Filter_On_Client_Id res.data.status = " + res.data.status); + // console.log(" In Getall_Parter_Invoice_With_Filter_On_Client_Id res.data.message r_class = " + res.data.message); + setGetall_Parter_Invoice_With_Filter_On_Client_Id_api("true"); + setGetall_Parter_Invoice_With_Filter_On_Client_Id_result(res.data.message); + setRows(res.data.message); + setRows_total_data(JSON.parse(res.data.total_data)); + } + else { + setGetall_Parter_Invoice_With_Filter_On_Client_Id_api("false"); + setGetall_Parter_Invoice_With_Filter_On_Client_Id_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( Getall_Parter_Invoice_With_Filter_On_Client_Id = ', error); + setGetall_Parter_Invoice_With_Filter_On_Client_Id_api("false"); + // alert(" Impossible de recuperer la liste des factures"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des factures"); + setalert_type("error"); + //setm yApimyApiMessage("") + }) + } + + const myRef = useRef(null); + + const [history_securite_read, sethistory_securite_read] = useState(""); + + + + const [New_Getall_TrainingSession_result, setNew_Getall_TrainingSession_result] = useState([]); + + const [Getall_TrainingSession_api, setGetall_TrainingSession_api] = useState(); + const [Getall_TrainingSession_message, setGetall_TrainingSession_message] = useState(); + const [Getall_TrainingSession_result, setGetall_TrainingSession_result] = useState(); + function Getall_TrainingSession(event) { + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("archive", "0"); + var myurl = process.env.REACT_APP_API_URL + "myclass/api/GetAllValideSessionPartner_List/"; + + setLoading(true); + + axios.post(myurl, form).then(res => { + + setLoading(false); + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_TrainingSession res.data.status = " + res.data.status); + //console.log(" In Getall_TrainingSession res.data.message r_class = " + res.data.message); + setGetall_TrainingSession_api("true"); + setGetall_TrainingSession_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_internal_url = JSON.parse(x).class_internal_url; + var local_title_session = JSON.parse(x).titre; + var local_code_session = JSON.parse(x).code_session; + + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_code_session, + "class_internal_url": local_internal_url, + "titre": local_title_session, + "code_session": local_code_session, + }; + new_data2.push(node); + + // return {"_id": " + str(local_id) + ", "label": " + local_courrier_template_ref_interne + '" , "courrier_template_ref_interne": "' + local_courrier_template_ref_interne + '", "nom_champ_technique": "' + local_nom_champ_technique + '", "nom_champ_fonctionel": "' + local_nom_champ_fonctionel + '","valide": "1" }; + + }); + + //--- + var node = { + "_id": "", + "id": "", + "label": "", + "class_internal_url": "", + "titre": "", + "code_session": "", + }; + new_data2.push(node); + + if (new_data2.length > 0) { + setNew_Getall_TrainingSession_result(new_data2); + + //console.log(" ### setNew_Getall_TrainingSession_result = ", new_data2); + } + + + } + else { + setGetall_TrainingSession_api("false"); + setGetall_TrainingSession_message(res.data.message); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_TrainingSession = ', error); + setGetall_TrainingSession_api("false"); + //setmyApimyApiMessage("") + }) + } + + const [New_Getall_Partner_Default_Paiement_Mode_result, setNew_Getall_Partner_Default_Paiement_Mode_result] = useState([{ + "_id": "", + "id": "", + "label": "", + "code": "", + "description": "", + }]); + + const [Getall_Partner_Default_Paiement_Mode_api, setGetall_Partner_Default_Paiement_Mode_api] = useState(); + const [Getall_Partner_Default_Paiement_Mode_message, setGetall_Partner_Default_Paiement_Mode_message] = useState(); + const [Getall_Partner_Default_Paiement_Mode_result, setGetall_Partner_Default_Paiement_Mode_result] = useState([]); + function Getall_Partner_Default_Paiement_Mode(event) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Default_Paiement_Mode/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + setLoading(false); + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Partner_Default_Paiement_Mode res.data.status = " + res.data.status); + //console.log(" In Getall_Partner_Default_Paiement_Mode res.data.message r_class = " + res.data.message); + setGetall_Partner_Default_Paiement_Mode_api("true"); + setGetall_Partner_Default_Paiement_Mode_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 local_description = JSON.parse(x).description; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_description, + "code": local_code, + "description": local_description, + }; + new_data2.push(node); + }); + + //--- + var node = { + "_id": "", + "id": "", + "label": "", + "code": "", + "description": "", + }; + new_data2.push(node); + + + //console.log(" ### new_data2 condition paiement = ", new_data2); + + if (new_data2.length > 0) + setNew_Getall_Partner_Default_Paiement_Mode_result(new_data2); + + + } + else { + setGetall_Partner_Default_Paiement_Mode_api("false"); + setGetall_Partner_Default_Paiement_Mode_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_Partner_Default_Paiement_Mode = ', error); + setGetall_Partner_Default_Paiement_Mode_api("false"); + + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des modes de paiement"); + setalert_type("error"); + + //setmyApimyApiMessage("") + }) + } + + useEffect(() => { + + sethistory_securite_read(props.check_user_acces_right("historique", "read")) + Get_List_Partner_Clients(); + Getall_Training_Employee_No_Filter(); + + + if (orderid && String(orderid).length > 3) { + + /* + Dans le cas précis des produits et service, "props.class_external_code" est utilisé comme + l'_id du client*/ + + Getall_Parter_Invoice_With_Filter_On_Client_Id(orderid); + //console.log(" ~### mes facture props action, orderid = ", action, orderid); + + } else { + Getall_Parter_Invoice_No_Filter(); + + } + + + if (document.getElementById('myRef_head')) { + var divh = document.getElementById('myRef_head').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + + + }, []) + + const [display_detail_invoice, setdisplay_detail_invoice] = React.useState(); + + const myRef_head = useRef(null); + const [selected_id, setselected_id] = useState(""); + const [selected_order_line_id, setselected_order_line_id] = useState(""); + const [selected_order_header_type, setselected_order_header_type] = useState(); + + const [order_internal_ref, setorder_internal_ref] = useState(""); + const [invoice_internal_ref, setinvoice_internal_ref] = useState(""); + + function handleClick_edit_invoice_From_Line(selected_row_id) { + + //submenu_detail_employe(); + + var line = JSON.parse(rowss[selected_row_id]); + + //console.log("### line = ", line); + var invoice_id = line._id; + setselected_id(invoice_id); + + var order_ref = line.order_header_ref_interne; + setorder_internal_ref(order_ref); + + var invoice_ref = line.invoice_header_ref_interne; + setinvoice_internal_ref(invoice_ref); + + + + //console.log(" ### employe_id = ", employe_id); + Display_Detail_Invoice_data(invoice_id); + + + if (document.getElementById('myRef')) { + var divh = document.getElementById('myRef').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + setp_detail_paiement_id(""); + order_header_submenu_main(); + + } + + + function Display_Detail_Invoice_data(invoice_id) { + //clearDetailAttendeFields(); + + setdisplay_detail_invoice("1"); + + + setLoading(true); + Get_Invoice_Data(invoice_id); + Get_Partner_Invoice_Lines_from_header_id(invoice_id); + + } + + + const [GetAttendee_api, setGetAttendee_api] = useState(); + const [GetAttendee_message, setGetAttendee_message] = useState(); + const [GetAttendee_result, setGetAttendee_result] = useState(); + function Get_Invoice_Data(invoice_id) { + + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", invoice_id); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Partner_Invoice/"; + + setLoading(true); + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === "true") { + setLoading(false); + //console.log(" In Get_Invoice_Data res.data.status = " + res.data.status); + //console.log(" In Get_Invoice_Data res.data.message r_class = " + res.data.message); + setGetAttendee_api("true"); + setGetAttendee_result(res.data.message); + + if (res.data.message.length > 0) { + var mylocal_order = JSON.parse(res.data.message); + + + if (mylocal_order.invoice_header_ref_interne) + setp_detail_header_invoice_header_ref_interne(mylocal_order.invoice_header_ref_interne); + + + if (mylocal_order.invoice_header_type) + setp_detail_header_invoice_header_type(mylocal_order.invoice_header_type); + else { + setp_detail_header_invoice_header_type(""); + } + + + if (mylocal_order.invoice_date) + setp_detail_header_invoice_date(mylocal_order.invoice_date); + + if (mylocal_order.annotation) + setp_detail_header_invoice_header_annotation(mylocal_order.annotation); + else + setp_detail_header_invoice_header_annotation(""); + + + + //document.getElementsByName("detail_header_type")[0].value = ""; + if (mylocal_order.order_header_type) + setp_detail_header_type(mylocal_order.order_header_type); + else { + setp_detail_header_type("") + } + + + + //document.getElementsByName("detail_header_ref_interne")[0].value = ""; + if (mylocal_order.order_header_ref_interne) { + setp_detail_header_ref_interne(mylocal_order.order_header_ref_interne); + } else { + setp_detail_header_ref_interne("") + } + + //document.getElementsByName("detail_header_ref_cient")[0].value = ""; + if (mylocal_order.order_header_ref_client) { + setp_detail_header_ref_client(mylocal_order.order_header_ref_client); + } else { + setp_detail_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); + setp_detail_header_date_cmd_val(mylocal_order.order_header_date_cmd); + } else { + setp_detail_header_date_cmd(""); + setp_detail_header_date_cmd_val(""); + } + + //document.getElementsByName("detail_header_date_expiration")[0].value = ""; + if (mylocal_order.order_header_date_expiration) { + setp_detail_header_date_expiration(mylocal_order.order_header_date_expiration); + setp_detail_header_date_expiration_val(mylocal_order.order_header_date_cmd); + } + + if (mylocal_order.order_header_condition_paiement_code) { + setp_detail_header_condition_paiement_code(mylocal_order.order_header_paiement_condition_code); + } else { + setp_detail_header_condition_paiement_code("") + } + + if (mylocal_order.order_header_condition_paiement_id) { + setp_detail_header_condition_paiement_id(mylocal_order.order_header_condition_paiement_id); + } else { + setp_detail_header_condition_paiement_id("") + } + + + if (mylocal_order.credit_note_ref) { + setp_detail_header_credit_note_ref(mylocal_order.credit_note_ref); + + } else { + setp_detail_header_credit_note_ref(""); + } + + + + //document.getElementsByName("detail_nom_client")[0].value = ""; + if (mylocal_order.order_header_client_nom) { + setp_detail_header_client_nom(mylocal_order.order_header_client_nom); + setp_detail_header_client_nom_id(mylocal_order.order_header_client_id); + } else { + setp_detail_header_client_nom(""); + setp_detail_header_client_nom_id(""); + } + + + if (mylocal_order.order_header_email_client) { + setp_detail_header_email_client(mylocal_order.order_header_email_client); + } else { + setp_detail_header_email_client("") + } + + + + //document.getElementsByName("detail_header_description")[0].value = ""; + if (mylocal_order.order_header_description) { + setp_detail_header_description(mylocal_order.order_header_description); + } else { + setp_detail_header_description("") + } + + //document.getElementsByName("detail_header_comment")[0].value = ""; + if (mylocal_order.order_header_comment) { + setp_detail_header_comment(mylocal_order.order_header_comment); + } else { + setp_detail_header_comment("") + } + + + // document.getElementsByName("detail_header_vendeur_nom_prenom")[0].value = ""; + if (mylocal_order.order_header_vendeur_nom_prenom) { + setp_detail_header_vendeur_nom(mylocal_order.order_header_vendeur_nom_prenom); + setp_detail_header_vendeur_nom_id(mylocal_order.order_header_vendeur_id); + } else { + setp_detail_header_vendeur_nom(""); + setp_detail_header_vendeur_nom_id(""); + } + + + // 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); + } else { + setp_detail_header_fact_adr("") + } + + //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); + } else { + setp_detail_header_fact_code_postal("") + } + + if (mylocal_order.order_header_lieu_formation) { + setp_detail_lieu_formation(mylocal_order.order_header_lieu_formation); + } else { + setp_detail_lieu_formation("") + } + + + //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); + } else { + setp_detail_header_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); + } else { + setp_detail_header_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); + } else { + setp_detail_header_liv_adr("") + } + + //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); + } else { + setp_detail_header_liv_code_postal("") + } + + if (mylocal_order.invoice_date_echeance) { + setp_detail_header_date_echeance(mylocal_order.invoice_date_echeance); + } else { + // si vide, on prends la date de la facuration : invoice_date + setp_detail_header_date_echeance(mylocal_order.invoice_date); + } + + if (mylocal_order.order_header_condition_paiement_code) { + setp_detail_header_condition_paiement(mylocal_order.order_header_condition_paiement_code); + } else { + setp_detail_header_condition_paiement(""); + } + + if (mylocal_order.order_header_condition_paiement_description) { + setp_detail_header_condition_paiement_desc(mylocal_order.order_header_condition_paiement_description); + } else { + setp_detail_header_condition_paiement_desc(""); + } + + + + //document.getElementsByName("detail_header_liv_ville")[0].value = ""; + if (mylocal_order.order_header_adr_liv_ville) { + setp_detail_header_liv_ville(mylocal_order.order_header_adr_liv_ville); + } else { + setp_detail_header_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); + } else { + setp_detail_header_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); + } else { + setp_detail_header_total_ht("") + } + + //document.getElementsByName("detail_header_total_tax")[0].value = ""; + if (mylocal_order.order_header_tax_amount) { + setp_detail_header_total_tax(mylocal_order.order_header_tax_amount); + } else { + setp_detail_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); + } else { + setp_detail_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); + } else { + setp_detail_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); + } else { + setp_detail_header_type_reduction_valeur("") + } + + + if (mylocal_order.order_header_montant_reduction) { + setp_detail_header_total_reduction_amount(mylocal_order.order_header_montant_reduction); + } else { + setp_detail_header_total_reduction_amount("") + } + + + if (mylocal_order.total_lines_montant_reduction) { + setp_detail_header_montant_reduction(mylocal_order.total_lines_montant_reduction); + } + + if (mylocal_order.total_header_hors_taxe_before_header_reduction) { + setp_detail_total_header_hors_taxe_before_header_reduction(mylocal_order.total_header_hors_taxe_before_header_reduction); + } else { + setp_detail_total_header_hors_taxe_before_header_reduction("") + } + + if (mylocal_order.total_header_hors_taxe_after_header_reduction) { + setp_detail_total_header_hors_taxe_after_header_reduction(mylocal_order.total_header_hors_taxe_after_header_reduction); + } else { + setp_detail_total_header_hors_taxe_after_header_reduction(""); + } + + if (mylocal_order.order_header_tax_amount) { + setp_detail_order_header_tax_amount(mylocal_order.order_header_tax_amount); + } else { + setp_detail_order_header_tax_amount("") + } + + + if (mylocal_order.total_header_toutes_taxes) { + setp_detail_total_header_toutes_taxes(mylocal_order.total_header_toutes_taxes); + } else { + setp_detail_total_header_toutes_taxes("") + } + + if (mylocal_order.total_lines_hors_taxe_before_lines_reduction) { + setp_detail_total_lines_hors_taxe_before_lines_reduction(mylocal_order.total_lines_hors_taxe_before_lines_reduction); + } + + if (mylocal_order.total_lines_hors_taxe_after_lines_reduction) { + setp_detail_total_lines_hors_taxe_after_lines_reduction(mylocal_order.total_lines_hors_taxe_after_lines_reduction); + } else { + setp_detail_total_lines_hors_taxe_after_lines_reduction("") + } + + + disable_Order_Header_DetailFields(); + //order_header_submenu_main(); + + } else { + alert(" Aucune commande/devis recuperé"); + } + + + } else if (String(res.data.status) === String("Err_Connexion")) { + setLoading(false); + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + + else { + setLoading(false); + setGetAttendee_api("false"); + setGetAttendee_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Get_Invoice_Data = ', error); + setGetAttendee_api("false"); + // alert(" Impossible de recuperer les données de la facture"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer les données de la facture"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + const [header_submenu, setheader_submenu] = useState(""); + async function order_header_submenu_main() { + setheader_submenu("main"); + + await sleep(5); + + submenu_color_management("main"); + if (Invoice_data_edit_mode !== "1") + disable_Order_Header_DetailFields(); + } + + async function order_header_submenu_detail() { + setheader_submenu("detail"); + + await sleep(5); + + submenu_color_management("detail"); + + + if (Invoice_data_edit_mode !== "1") + disable_Order_Header_DetailFields(); + + } + + async function order_header_submenu_facturation() { + setheader_submenu("facturation"); + + await sleep(5); + + submenu_color_management("facturation"); + + if (Invoice_data_edit_mode !== "1") + disable_Order_Header_DetailFields(); + + } + + async function order_header_submenu_paiement() { + Getall_Partner_Default_Paiement_Mode(); + + setheader_submenu("paiement"); + + Getall_Invoice_Paiement(); + Getall_Invoice_Paiement_Payed_Remain_Amounts(); + + await sleep(5); + + submenu_color_management("paiement"); + + + + } + + + function submenu_color_management(current_menu) { + const list_sous_menu = ["order_header_facturation", "order_header_detail", "order_header_main", "order_header_detail", "paiement"] + + for (let i = 0; i < list_sous_menu.length; i++) { + + var sous_menu = list_sous_menu[i]; + if (String(sous_menu) !== current_menu) { + if (document.getElementById(sous_menu)) { + document.getElementById(sous_menu).style.backgroundColor = "#d8edfc"; + document.getElementById(sous_menu).style.color = "black"; + document.getElementById(sous_menu).style.fontWeight = "normal"; + } + } + + } + + if (document.getElementById(current_menu)) { + document.getElementById(current_menu).style.backgroundColor = "#107758"; + document.getElementById(current_menu).style.color = "white"; + document.getElementById(current_menu).style.fontWeight = "bold"; + } + + } + + const sleep = (milliseconds) => { + return new Promise(resolve => setTimeout(resolve, milliseconds)) + } + + + function print_invoice_pdf() { + const stored_cookie = getCookie('tokenmysypart'); + + var nom_fichier_cmd = "Facture_" + invoice_internal_ref + ".pdf"; + // console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id); + + var url = process.env.REACT_APP_API_URL + "myclass/api/GerneratePDF_Partner_Invoice/" + stored_cookie + "/" + selected_id; + + //console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id, " --- url =", url); + + axios.get(url, { responseType: 'blob', },) + .then((res) => { + fileDownload(res.data, nom_fichier_cmd) + }).catch((error) => { + console.error('Error:', error); + + }); + } + + + + function print_invoice_pdf_acquited() { + const stored_cookie = getCookie('tokenmysypart'); + + var nom_fichier_cmd = "Facture_" + invoice_internal_ref + ".pdf"; + // console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id); + + var url = process.env.REACT_APP_API_URL + "myclass/api/GerneratePDF_Partner_Invoice_regeneration/" + stored_cookie + "/" + selected_id; + + //console.log(" nom_fichier_cmd = ", nom_fichier_cmd, " --- selected_id = ", selected_id, " --- url =", url); + + axios.get(url, { responseType: 'blob', },) + .then((res) => { + fileDownload(res.data, nom_fichier_cmd) + }).catch((error) => { + console.error('Error:', error); + + }); + } + + + const [Getall_Parter_Invoice_With_Filter_api, setGetall_Parter_Invoice_With_Filter_api] = useState(); + const [Getall_Parter_Invoice_With_Filter_message, setGetall_Parter_Invoice_With_Filter_message] = useState(); + const [Getall_Parter_Invoice_With_Filter_result, setGetall_Parter_Invoice_With_Filter_result] = useState(); + function Getall_Parter_Invoice_With_Filter(event) { + + setgridline_id(""); + + var form = new FormData(); + + // Recuperation des parametres + var filtre1 = p_filtre1; + var filtre2 = p_filtre2; + var filtre3 = p_filtre3; + var filtre4 = p_filtre4; + + var filtre1_value = ""; + var filtre2_value = ""; + var filtre3_value = ""; + var filtre4_value = ""; + // Recuperation des valeurs de filtres + + console.log(" filtre1 = ", p_filtre1) + console.log(" p_filtre_montant_ttc_operateur = ", p_filtre_montant_ttc_operateur) + console.log(" p_filtre1_entre_from_value = ", p_filtre1_entre_from_value) + + if (p_filtre1) { + filtre1_value = p_filtre1_value; + + if (filtre1 === "date_echeance" && p_filter_date_echeance) { + form.append("echeance_operateur", p_filtre_echeance_operateur); + + if (p_filtre_echeance_operateur === "entre") { + form.append("date_echeance_from", p_filter_date_echeance_from); + form.append("date_echeance_to", p_filter_date_echeance_to); + } else { + form.append("date_echeance", p_filter_date_echeance); + } + } + + else if (filtre1 === "date_creation" && p_filter_date_creation_du && p_filter_date_creation_au) { + form.append("date_facture_debut", p_filter_date_creation_du); + form.append("date_facture_fin", p_filter_date_creation_au); + } + + else if (filtre1 === "montant_ttc" && p_filtre_montant_ttc_operateur) { + form.append("montant_ttc_operateur", p_filtre_montant_ttc_operateur); + + if (p_filtre_montant_ttc_operateur === "entre") { + form.append("montant_ttc_from_value", p_filtre_montant_ttc_from); + form.append("montant_ttc_to_from_value", p_filtre_montant_ttc_to); + } else { + form.append("montant_ttc", filtre1_value); + } + + } + + + else if (filtre1 === "solde" && p_filtre_solde_operateur) { + + form.append("solde_operateur", p_filtre_solde_operateur); + if (p_filtre_solde_operateur === "entre") { + form.append("solde_from_value", p_filtre_solde_operateur_entre_from); + form.append("solde_to_value", p_filtre_solde_operateur_entre_to); + } else { + form.append("solde", p_filtre1_value); + } + } + + else if (filtre1_value) { + form.append(filtre1, filtre1_value); + } + + } + + if (p_filtre2) { + filtre2_value = p_filtre2_value; + + if (p_filtre2 === "date_echeance" && p_filter_date_echeance) { + form.append("echeance_operateur", p_filtre_echeance_operateur); + + if (p_filtre_echeance_operateur === "entre") { + form.append("date_echeance_from", p_filter_date_echeance_from); + form.append("date_echeance_to", p_filter_date_echeance_to); + } else { + form.append("date_echeance", p_filter_date_echeance); + } + + } + else if (p_filtre2 === "date_creation" && p_filter_date_creation_du && p_filter_date_creation_au) { + form.append("date_facture_debut", p_filter_date_creation_du); + form.append("date_facture_fin", p_filter_date_creation_au); + } + + + + else if (p_filtre2 === "date_creation" && p_filter_date_creation_du && p_filter_date_creation_au) { + form.append("date_facture_debut", p_filter_date_creation_du); + form.append("date_facture_fin", p_filter_date_creation_au); + } + + + else if (p_filtre2 === "montant_ttc" && p_filtre_montant_ttc_operateur) { + form.append("montant_ttc_operateur", p_filtre_montant_ttc_operateur); + + if (p_filtre_montant_ttc_operateur === "entre") { + form.append("montant_ttc_from_value", p_filtre_montant_ttc_from); + form.append("montant_ttc_to_from_value", p_filtre_montant_ttc_to); + } else { + form.append("montant_ttc", filtre2_value); + } + + } + + else if (p_filtre2 === "solde" && p_filtre2_value && p_filtre_solde_operateur) { + + form.append("solde_operateur", p_filtre_solde_operateur); + if (p_filtre_solde_operateur === "entre") { + form.append("solde_from_value", p_filtre_solde_operateur_entre_from); + form.append("solde_to_value", p_filtre_solde_operateur_entre_to); + } else { + form.append("solde", p_filtre2_value); + } + } + + + else if (filtre2_value) { + form.append(filtre2, filtre2_value); + } + + + } + + if (p_filtre3) { + filtre3_value = p_filtre3_value; + + if (p_filtre3 === "date_echeance" && p_filter_date_echeance) { + form.append("echeance_operateur", p_filtre_echeance_operateur); + + if (p_filtre_echeance_operateur === "entre") { + form.append("date_echeance_from", p_filter_date_echeance_from); + form.append("date_echeance_to", p_filter_date_echeance_to); + } else { + form.append("date_echeance", p_filter_date_echeance); + } + } + else if (p_filtre3 === "date_creation" && p_filter_date_creation_du && p_filter_date_creation_au) { + form.append("date_facture_debut", p_filter_date_creation_du); + form.append("date_facture_fin", p_filter_date_creation_au); + } + + else if (p_filtre3 === "montant_ttc" && p_filtre_montant_ttc_operateur) { + form.append("montant_ttc_operateur", p_filtre_montant_ttc_operateur); + + if (p_filtre_montant_ttc_operateur === "entre") { + form.append("montant_ttc_from_value", p_filtre_montant_ttc_from); + form.append("montant_ttc_to_from_value", p_filtre_montant_ttc_to); + } else { + form.append("montant_ttc", filtre3_value); + } + + } + + + + else if (p_filtre3 === "solde" && p_filtre_solde_operateur) { + + form.append("solde_operateur", p_filtre_solde_operateur); + if (p_filtre_solde_operateur === "entre") { + form.append("solde_from_value", p_filtre_solde_operateur_entre_from); + form.append("solde_to_value", p_filtre_solde_operateur_entre_to); + } else { + form.append("solde", p_filtre3_value); + } + } + + + else if (p_filtre3_value) { + form.append(filtre3, p_filtre3_value); + } + + + } + + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + console.log(" ### form = ", form) + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Partner_Invoice_with_filter/"; + setLoading(true); + axios.post(myurl, form).then(res => { + setLoading(false); + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Parter_Invoice_With_Filter res.data.status = " + res.data.status); + //console.log(" In Getall_Parter_Invoice_With_Filter res.data.message r_class = " + res.data.message); + setGetall_Parter_Invoice_With_Filter_api("true"); + setGetall_Parter_Invoice_With_Filter_result(res.data.message); + setRows(res.data.message); + setRows_total_data(JSON.parse(res.data.total_data)); + } + else { + setGetall_Parter_Invoice_With_Filter_api("false"); + setGetall_Parter_Invoice_With_Filter_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_Parter_Invoice_With_Filter = ', error); + setGetall_Parter_Invoice_With_Filter_api("false"); + // alert(" Impossible de recuperer la liste des factures"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des factures"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + const [Send_Invoice_By_Email_api, setSend_Invoice_By_Email_api] = useState(); + const [Send_Invoice_By_Email_message, setSend_Invoice_By_Email_message] = useState(); + const [Send_Invoice_By_Email_result, setSend_Invoice_By_Email_result] = useState(); + function Send_Invoice_By_Email() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_id", selected_id); + + if (facture_mail_type && facture_mail_type === "aquited") { + form.append("invoice_regeneration", "1"); + } + + for (let i = 0; i < tab_invoice_mail_pieces_jointes_result.length; i++) { + form.append('File', tab_invoice_mail_pieces_jointes_result[i]); + } + + + + //console.log("### form = ", form); + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Send_Partner_Invoice_By_Email/"; + + + axios.post(myurl, form).then(res => { + //console.log(" In Add_Update_One_Order_Line_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_One_Order_Line_Data res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setSend_Invoice_By_Email_api("true"); + setSend_Invoice_By_Email_message(res.data.message); + // alert(res.data.message) + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + } + else { + setSend_Invoice_By_Email_api("false"); + setSend_Invoice_By_Email_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + + console.warn('Send_Invoice_By_Email : Not good man :( Send_Invoice_By_Email = ' + error); + setSend_Invoice_By_Email_api("false"); + + setdisplay_alert_mysy("1"); + setalert_message(" Impossible d'envoyer la facture par email"); + setalert_type("error"); + + // alert(" Impossible d'envoyer la facture par email"); + + + }) + + + } + + + + const [Get_Partner_Invoice_Lines_from_header_id_api, setGet_Partner_Invoice_Lines_from_header_id_api] = useState(); + const [Get_Partner_Invoice_Lines_from_header_id_message, setGet_Partner_Invoice_Lines_from_header_id_message] = useState(); + const [Get_Partner_Invoice_Lines_from_header_id_result, setGet_Partner_Invoice_Lines_from_header_id_result] = useState(); + function Get_Partner_Invoice_Lines_from_header_id(local_invoice_header_id) { + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_header_id", local_invoice_header_id); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Partner_Invoice_Lines/"; + setLoading(true); + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + setLoading(false); + //console.log(" In Get_Partner_Invoice_Lines_from_header_id res.data.status = " + res.data.status); + //console.log(" In Get_Partner_Invoice_Lines_from_header_id res.data.message r_class = " + res.data.message); + setGet_Partner_Invoice_Lines_from_header_id_api("true"); + setGet_Partner_Invoice_Lines_from_header_id_result(res.data.message); + setrows_invoice_lines(res.data.message); + } + else { + setLoading(false); + setGet_Partner_Invoice_Lines_from_header_id_api("false"); + setGet_Partner_Invoice_Lines_from_header_id_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Get_Partner_Invoice_Lines_from_header_id = ', error); + setGet_Partner_Invoice_Lines_from_header_id_api("false"); + // alert(" Impossible de recuperer le detail de la facture"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer le detail de la facture"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + const [Invoice_data_changed, setInvoice_data_changed] = useState(""); + const [Invoice_data_edit_mode, setInvoice_data_edit_mode] = useState(""); + + + + + async function Enable_Order_Header_DetailFields() { + await sleep(5); + + setInvoice_data_edit_mode("1"); + + if (document.getElementsByName("detail_header_order_paiement_condition")[0]) { + document.getElementsByName("detail_header_order_paiement_condition")[0].disabled = false; + document.getElementsByName("detail_header_order_paiement_condition")[0].style.backgroundColor = "#FFFFFF"; + } + + + if (document.getElementsByName("detail_header_date_cmd")[0]) { + document.getElementsByName("detail_header_date_cmd")[0].disabled = false; + document.getElementsByName("detail_header_date_cmd")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_date_expiration")[0]) { + document.getElementsByName("detail_header_date_expiration")[0].disabled = false; + document.getElementsByName("detail_header_date_expiration")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("invoice_date")[0]) { + document.getElementsByName("invoice_date")[0].disabled = false; + document.getElementsByName("invoice_date")[0].style.backgroundColor = "#FFFFFF"; + } + + + + if (document.getElementsByName("detail_header_description")[0]) { + document.getElementsByName("detail_header_description")[0].disabled = false; + document.getElementsByName("detail_header_description")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_comment")[0]) { + document.getElementsByName("detail_header_comment")[0].disabled = false; + document.getElementsByName("detail_header_comment")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_vendeur_nom_prenom")[0]) { + document.getElementsByName("detail_header_vendeur_nom_prenom")[0].disabled = false; + 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_mode_paiement")[0]) { + document.getElementsByName("detail_header_mode_paiement")[0].disabled = false; + document.getElementsByName("detail_header_mode_paiement")[0].style.backgroundColor = "#FFFFFF"; + } + + if (document.getElementsByName("detail_header_date_echeance")[0]) { + document.getElementsByName("detail_header_date_echeance")[0].disabled = false; + document.getElementsByName("detail_header_date_echeance")[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("invoice_date_lieu")[0]) { + document.getElementsByName("invoice_date_lieu")[0].disabled = false; + document.getElementsByName("invoice_date_lieu")[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"; + } + + + } + + async function disable_Order_Header_DetailFields() { + await sleep(5); + setInvoice_data_edit_mode(""); + if (document.getElementsByName("detail_header_num_facture")[0]) { + document.getElementsByName("detail_header_num_facture")[0].disabled = true; + document.getElementsByName("detail_header_num_facture")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_type_document")[0]) { + document.getElementsByName("detail_header_type_document")[0].disabled = true; + document.getElementsByName("detail_header_type_document")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_date_facture")[0]) { + document.getElementsByName("detail_header_date_facture")[0].disabled = true; + document.getElementsByName("detail_header_date_facture")[0].style.backgroundColor = "#ECEFF1"; + } + + + if (document.getElementsByName("detail_header_type")[0]) { + document.getElementsByName("detail_header_type")[0].disabled = true; + document.getElementsByName("detail_header_type")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_status")[0]) { + document.getElementsByName("detail_header_status")[0].disabled = true; + document.getElementsByName("detail_header_status")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_ref_interne")[0]) { + document.getElementsByName("detail_header_ref_interne")[0].disabled = true; + document.getElementsByName("detail_header_ref_interne")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_order_paiement_condition")[0]) { + document.getElementsByName("detail_header_order_paiement_condition")[0].disabled = true; + document.getElementsByName("detail_header_order_paiement_condition")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_date_cmd")[0]) { + document.getElementsByName("detail_header_date_cmd")[0].disabled = true; + document.getElementsByName("detail_header_date_cmd")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_date_expiration")[0]) { + document.getElementsByName("detail_header_date_expiration")[0].disabled = true; + document.getElementsByName("detail_header_date_expiration")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_nom_client")[0]) { + document.getElementsByName("detail_nom_client")[0].disabled = true; + document.getElementsByName("detail_nom_client")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_email_client")[0]) { + document.getElementsByName("detail_header_email_client")[0].disabled = true; + document.getElementsByName("detail_header_email_client")[0].style.backgroundColor = "#ECEFF1"; + } + + + if (document.getElementsByName("detail_header_description")[0]) { + document.getElementsByName("detail_header_description")[0].disabled = true; + document.getElementsByName("detail_header_description")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_comment")[0]) { + document.getElementsByName("detail_header_comment")[0].disabled = true; + document.getElementsByName("detail_header_comment")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_vendeur_nom_prenom")[0]) { + document.getElementsByName("detail_header_vendeur_nom_prenom")[0].disabled = true; + 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_mode_paiement")[0]) { + document.getElementsByName("detail_header_mode_paiement")[0].disabled = true; + document.getElementsByName("detail_header_mode_paiement")[0].style.backgroundColor = "#ECEFF1"; + } + + if (document.getElementsByName("detail_header_date_echeance")[0]) { + document.getElementsByName("detail_header_date_echeance")[0].disabled = true; + document.getElementsByName("detail_header_date_echeance")[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("invoice_date_lieu")[0]) { + document.getElementsByName("invoice_date_lieu")[0].disabled = true; + document.getElementsByName("invoice_date_lieu")[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 clean_all_filters() { + setp_filtre1(""); + setp_filtre1_value(); + + setp_filtre2(""); + setp_filtre2_value(); + + setp_filtre3(""); + setp_filtre3_value(); + + setp_filtre4(""); + setp_filtre4_value(); + + clean_order_detail_fields(); + setsubmenu(); + + setSelectionModel([]); + setselectionModel_invoice_lines([]); + + Getall_Parter_Invoice_No_Filter(); + setdisplay_detail_invoice(); + + setgridline_id(""); + } + + function clean_order_detail_fields() { + setp_detail_header_client_nom(""); + setp_detail_header_email_client(""); + setp_detail_header_client_nom_id(""); + setp_detail_header_description(""); + setp_detail_header_comment(""); + setp_detail_header_date_cmd(new Date().toLocaleDateString('fr-FR')); + setp_detail_header_date_expiration(date_today_90j.toLocaleDateString('fr-FR')); + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + setp_detail_header_ref_client(""); + setp_detail_header_ref_interne(""); + setp_detail_header_vendeur_nom(""); + setp_detail_header_vendeur_nom_id(""); + setp_detail_header_invoice_header_annotation(""); + setp_detail_header_invoice_header_ref_interne(""); + setp_detail_header_invoice_header_type(""); + setp_detail_header_invoice_date(new Date().toLocaleDateString('fr-FR')); + + + setp_detail_header_type(""); + setp_detail_header_statut(""); + setp_detail_header_vendeur_id(""); + setp_detail_header_client_id(""); + setp_detail_header_statut_label(""); + setp_detail_header_date_cmd_val(new Date().toLocaleDateString('fr-FR')); + setp_detail_header_condition_paiement(""); + setp_detail_header_condition_paiement_desc(""); + setp_detail_header_date_echeance(new Date().toLocaleDateString('fr-FR')); + setp_detail_header_fact_adr(""); + + + setp_detail_header_fact_code_postal(""); + setp_detail_header_fact_ville(""); + setp_detail_header_fact_pays(""); + setp_detail_header_liv_adr(""); + setp_detail_header_liv_code_postal(""); + setp_detail_header_liv_ville(""); + setp_detail_header_liv_pays(""); + setp_detail_header_total_ht(""); + setp_detail_header_total_tax(""); + + setp_detail_header_total_ttc(""); + setp_detail_header_type_reduction(""); + setp_detail_header_total_reduction_amount(""); + setp_detail_header_credit_note_ref(""); + setp_detail_header_type_reduction_valeur(""); + setp_detail_header_montant_reduction(""); + setp_detail_total_header_hors_taxe_before_header_reduction(""); + setp_detail_total_header_hors_taxe_after_header_reduction(""); + + setp_detail_order_header_tax_amount(""); + setp_detail_total_header_toutes_taxes(""); + setp_detail_total_lines_hors_taxe_before_lines_reduction(""); + setp_detail_total_lines_hors_taxe_after_lines_reduction(""); + setp_detail_paiement_id(""); + + + setp_detail_paiement_amount(""); + setp_detail_paiement_date(""); + setp_detail_paiement_ref(""); + setp_detail_paiement_comment(""); + setp_detail_paiement_mode(""); + setp_detail_paiement_invoice_id(""); + setp_detail_lieu_formation(""); + } + + const [Dialog_Detail_Article_open, setDialog_Detail_Article_open] = React.useState(false); + + const Close_Dialog_Detail_Article_open = () => { + + setDialog_Detail_Article_open(false); + }; + + const Dialog_1_handleClose = () => { + //alert(" Utiliser le bouton 'fermer' "); + //setOpen(false); + }; + + const Dialog_1_handleClose_buton = () => { + setDialog_1_open(false); + }; + + const [Dialog_1_open, setDialog_1_open] = React.useState(false); + + + const [Get_Given_Paiement_Data_api, setGet_Given_Paiement_Data_api] = useState(); + const [Get_Given_Paiement_Data_message, setGet_Given_Paiement_Data_message] = useState(); + const [Get_Given_Paiement_Data_result, setGet_Given_Paiement_Data_result] = useState(); + function Get_Given_Paiement_Data(local_paiement_id) { + + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", local_paiement_id); + + //console.log(" ## form = ", form); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Invoice_Paiement/"; + setLoading(true); + axios.post(myurl, form).then(res => { + setLoading(false); + if (String(res.data.status) === "true") { + //console.log(" In Get_Given_Paiement_Data res.data.status = " + res.data.status); + // console.log(" In Get_Given_Paiement_Data res.data.message r_class = " + res.data.message); + setGet_Given_Paiement_Data_api("true"); + setGet_Given_Paiement_Data_result(res.data.message); + + if (res.data.message.length > 0) { + var mylocal_document = JSON.parse(res.data.message); + + if (mylocal_document.paiement_amount) + setp_detail_paiement_amount(mylocal_document.paiement_amount); + else + setp_detail_paiement_amount(""); + + if (mylocal_document.paiement_mode) + setp_detail_paiement_mode(mylocal_document.paiement_mode); + else + setp_detail_paiement_mode(""); + + if (mylocal_document.paiement_ref) + setp_detail_paiement_ref(mylocal_document.paiement_ref); + else + setp_detail_paiement_ref(""); + + if (mylocal_document.paiement_date) + setp_detail_paiement_date(mylocal_document.paiement_date); + else + setp_detail_paiement_date(new Date().toLocaleDateString('fr-FR')); + + + + if (mylocal_document.commentaire) + setp_detail_paiement_comment(mylocal_document.commentaire); + else + setp_detail_paiement_comment(""); + + + + } else { + alert(" Aucun paiement recuperé"); + } + + + } else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + + else { + setGet_Given_Paiement_Data_api("false"); + setGet_Given_Paiement_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Get_Given_Paiement_Data = ', error); + setGet_Given_Paiement_Data_api("false"); + // alert(" Impossible de recuperer les données du paiement"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer les données du paiement"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + + const [Dialog_Paiement_1_message, setDialog_Paiement_1_message] = React.useState(false); + const [Dialog_Paiement_1_open, setDialog_Paiement_1_open] = React.useState(false); + + function Dialog_1_handle_change_Paiement(message) { + setDialog_Paiement_1_message(message); + setDialog_Paiement_1_open(true); + } + + const Dialog_Paiement_1_handleClose = () => { + //alert(" Utiliser le bouton 'fermer' "); + //setOpen(false); + }; + + const Dialog_Paiement_1_handleClose_buton = () => { + clear_Paiement_DetailFields(); + setDialog_Paiement_1_open(false); + + if (document.getElementById('myRef')) { + var divh = document.getElementById('myRef').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + }; + + const [p_detail_paiement_id, setp_detail_paiement_id] = useState(""); + const [p_detail_paiement_amount, setp_detail_paiement_amount] = useState(""); + + const [p_detail_paiement_date, setp_detail_paiement_date] = useState(new Date().toLocaleDateString('fr-FR')); + + const [p_detail_paiement_ref, setp_detail_paiement_ref] = useState(""); + const [p_detail_paiement_comment, setp_detail_paiement_comment] = useState(""); + const [p_detail_paiement_mode, setp_detail_paiement_mode] = useState(""); + const [p_detail_paiement_invoice_id, setp_detail_paiement_invoice_id] = useState(""); + + const [p_detail_lieu_formation, setp_detail_lieu_formation] = useState(); + + + function clear_Paiement_DetailFields() { + setp_detail_paiement_id(""); + setp_detail_paiement_amount(""); + setp_detail_paiement_mode(""); + setp_detail_paiement_date(new Date().toLocaleDateString('fr-FR')); + setp_detail_paiement_ref(""); + setp_detail_paiement_comment(""); + } + + + const [Add_Update_Paiement_Data_api, setAdd_Update_Paiement_Data_api] = useState(); + const [Add_Update_Paiement_Data_message, setAdd_Update_Paiement_Data_message] = useState(); + const [Add_Update_Paiement_Data_result, setAdd_Update_Paiement_Data_result] = useState(); + function Add_Update_Paiement_Data() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_id", selected_id); + form.append("paiement_amount", p_detail_paiement_amount); + form.append("paiement_mode", p_detail_paiement_mode); + form.append("paiement_ref", p_detail_paiement_ref); + form.append("paiement_date", p_detail_paiement_date); + form.append("commentaire", p_detail_paiement_comment); + + + // console.log(" form == ", form); + + var myurl = ""; + if (p_detail_paiement_id && String(p_detail_paiement_id).length > 2) { + + form.append("_id", p_detail_paiement_id); + myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Invoice_Paiement/"; + } + else + myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Invoice_Paiement/"; + + setLoading(true); + + axios.post(myurl, form).then(res => { + setLoading(false); + //console.log(" In Add_Update_Paiement_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_Paiement_Data res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + + setAdd_Update_Paiement_Data_api("true"); + setAdd_Update_Paiement_Data_result(res.data.message); + + Getall_Invoice_Paiement(); + Getall_Invoice_Paiement_Payed_Remain_Amounts(); + clear_Paiement_DetailFields() + + Dialog_Paiement_1_handleClose_buton(); + + // alert(res.data.message) + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + if (document.getElementById('myRef')) { + var divh = document.getElementById('myRef').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + + } + else { + setAdd_Update_Paiement_Data_api("false"); + setAdd_Update_Paiement_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Add_Update_Paiement_Data = ' + error); + setAdd_Update_Paiement_Data_api("false"); + // alert(" Impossible d'ajouter ou mettre à jour le paiement "); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible d'ajouter ou mettre à jour le paiement "); + setalert_type("error"); + + }) + } + + + + const [Create_Invoice_Credit_Note_api, setCreate_Invoice_Credit_Note_api] = useState(); + const [Create_Invoice_Credit_Note_message, setCreate_Invoice_Credit_Note_message] = useState(); + const [Create_Invoice_Credit_Note_result, setCreate_Invoice_Credit_Note_result] = useState(); + function Create_Invoice_Credit_Note() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", selected_id); + + + //console.log(" form == ", form); + + var myurl = myurl = process.env.REACT_APP_API_URL + "myclass/api/Create_Invoice_Avoir_Total/"; + + setLoading(true); + + axios.post(myurl, form).then(res => { + setLoading(false); + //console.log(" In Create_Invoice_Credit_Note res.data.status = " + res.data.status); + //console.log(" In Create_Invoice_Credit_Note res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + + setCreate_Invoice_Credit_Note_api("true"); + setCreate_Invoice_Credit_Note_result(res.data.message); + + Get_List_Partner_Clients(); + Getall_Parter_Invoice_No_Filter(); + + Display_Detail_Invoice_data(selected_id); + + // alert(res.data.message) + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + + if (document.getElementById('myRef_head')) { + var divh = document.getElementById('myRef_head').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + + } + else { + setCreate_Invoice_Credit_Note_api("false"); + setCreate_Invoice_Credit_Note_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Create_Invoice_Credit_Note = ' + error); + setCreate_Invoice_Credit_Note_api("false"); + // alert(" Impossible d'ajouter ou mettre à jour le paiement "); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de créer l'avoir "); + setalert_type("error"); + + }) + } + + const [Create_Inscrit_Invoice_api, setCreate_Inscrit_Invoice_api] = useState(); + const [Create_Inscrit_Invoice_message, setCreate_Inscrit_Invoice_message] = useState(); + const [Create_Inscrit_Invoice_result, setCreate_Inscrit_Invoice_result] = useState(); + function Create_Inscrit_Invoice() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("inscription_id", invoice_inscrit_selected_inscrit_id); + form.append("invoice_amount", invoice_inscrit_selected_montant_a_facture); + form.append("session_id", invoice_inscrit_selected_session_id); + form.append("invoice_date", ""); + + + + //console.log(" form == ", form); + + var myurl = myurl = process.env.REACT_APP_API_URL + "myclass/api/Create_Inscrit_Invoice/"; + + setLoading(true); + + axios.post(myurl, form).then(res => { + setLoading(false); + //console.log(" In Create_Inscrit_Invoice res.data.status = " + res.data.status); + //console.log(" In Create_Inscrit_Invoice res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + + setCreate_Inscrit_Invoice_api("true"); + setCreate_Inscrit_Invoice_result(res.data.message); + + Close_Dialog_Rech_Apprenant_Et_Facture_open(); + + Get_List_Partner_Clients(); + Getall_Parter_Invoice_No_Filter(); + + + // alert(res.data.message) + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + + if (document.getElementById('myRef_head')) { + var divh = document.getElementById('myRef_head').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + + } + else { + setCreate_Inscrit_Invoice_api("false"); + setCreate_Inscrit_Invoice_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Create_Inscrit_Invoice = ' + error); + setCreate_Inscrit_Invoice_api("false"); + // alert(" Impossible d'ajouter ou mettre à jour le paiement "); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de créer la facture "); + setalert_type("error"); + + }) + } + + + + const [Dialog_annotation_1_message, setDialog_annotation_1_message] = React.useState(false); + const [Dialog_annotation_1_open, setDialog_annotation_1_open] = React.useState(false); + + function Dialog_1_handle_change_annotation(message) { + setDialog_annotation_1_message(message); + setDialog_annotation_1_open(true); + } + + const Dialog_annotation_1_handleClose = () => { + //alert(" Utiliser le bouton 'fermer' "); + //setOpen(false); + }; + + const Dialog_annotation_1_handleClose_buton = () => { + + setDialog_annotation_1_open(false); + + /* if (document.getElementById('myRef')) { + var divh = document.getElementById('myRef').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + }*/ + + }; + + const [Add_Update_annotation_Data_api, setAdd_Update_annotation_Data_api] = useState(); + const [Add_Update_annotation_Data_message, setAdd_Update_annotation_Data_message] = useState(); + const [Add_Update_annotation_Data_result, setAdd_Update_annotation_Data_result] = useState(); + function Add_Update_annotation_Data() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", selected_id); + form.append("annotation", p_detail_header_invoice_header_annotation); + + + //console.log(" form == ", form); + + var myurl = myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Update_Invoice_Annotation/"; + + setLoading(true); + + axios.post(myurl, form).then(res => { + setLoading(false); + //console.log(" In Add_Update_annotation_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_annotation_Data res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + + setAdd_Update_annotation_Data_api("true"); + setAdd_Update_annotation_Data_result(res.data.message); + + + Dialog_annotation_1_handleClose_buton(); + + // alert(res.data.message) + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + if (document.getElementById('myRef')) { + var divh = document.getElementById('myRef').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + + } + else { + setAdd_Update_annotation_Data_api("false"); + setAdd_Update_annotation_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Add_Update_annotation_Data = ' + error); + setAdd_Update_annotation_Data_api("false"); + // alert(" Impossible d'ajouter ou mettre à jour l'annotation "); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible d'ajouter ou mettre à jour l'annotation "); + setalert_type("error"); + + }) + } + + + const New_Option_Filter = [ + { "id": "ref_interne_invoice", "label": "Num Facture", "value": "ref_interne_invoice" }, + { "id": "client_nom", "label": "Nom Client", "value": "client_nom" }, + { "id": "solde", "label": "Reste à payer", "value": "solde" }, + { "id": "montant_ttc", "label": "Montant TTC", "value": "montant_ttc" }, + { "id": "date_echeance", "label": "Echéance", "value": "date_echeance" }, + { "id": "date_creation", "label": "Date Création (jj/mm/aaaa) ", "value": "date_creation" }, + { "id": "session_code", "label": "Lié a la session/promo (code externe)", "value": "session_code" }, + { "id": "formation", "label": "Lié a la Formation (code externe)", "value": "formation" }, + { "id": "ref_interne_cmd", "label": "Ref. Interne Cmd", "value": "ref_interne_cmd" }, + { "id": "ref_externe", "label": "Ref. Externe Cmd (chez le client)", "value": "ref_externe" }, + { "id": "", "label": "", "value": "" }, + { "id": "1", "label": "", "value": "1" }, // Cette ligne pour couvrir l'ajout d'une ligne de filter. C'est fait expres. + ] + + + const New_Option_filter_montant = [ + { "id": "egale", "label": "=", "value": "egale" }, + { "id": "inf_egale", "label": "<=", "value": "inf_egale" }, + { "id": "sup_egale", "label": ">=", "value": "sup_egale" }, + { "id": "sup", "label": ">", "value": "sup" }, + { "id": "inf", "label": "<", "value": "inf" }, + { "id": "entre", "label": "Entre", "value": "entre" }, + ] + + + + function handleClick_menu_droite_facture(e) { + console.log(" III "); + } + + const New_type_apprenant = [ + { "id": "0", "label": "Autre", "value": "0" }, + { "id": "1", "label": "Salariés", "value": "1" }, + { "id": "2", "label": "Apprentis", "value": "2" }, + { "id": "3", "label": "Particuliers", "value": "3" }, + { "id": "4", "label": "Rech. Emploi", "value": "4" }, + { "id": "", "label": "", "value": "" }, + ] + + + + const New_Option_facture_mail = [ + { "id": "original", "label": "Facture Originale", "value": "original" }, + { "id": "aquited", "label": "Facture Acquittée", "value": "aquited" }, + ] + + const [facture_mail_type, setfacture_mail_type] = useState("original"); + + // DEBUT EXPORT EXCEL DATAGRID + + function CustomToolbar(props) { + + return ( + + + + + + + + + + + ); + } + + function getExcelData(apiRef) { + // Select rows and columns + const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef); + const visibleColumnsField = gridVisibleColumnFieldsSelector(apiRef).filter((data) => (data) !== "__check__"); + + // Format the data. Here we only keep the value + + const data = filteredSortedRowIds.map((id) => { + const row = {}; + visibleColumnsField.forEach((field) => { + var val = apiRef.current.getCellParams(id, field).value; + if (String(field) !== "__check__") + row[field] = apiRef.current.getCellParams(id, field).value; + }); + return row; + }); + + + return data; + } + + + function ExportButton(props) { + return ( + + + + ); + } + + + function handleExport(apiRef, data_colums) { + const data = getExcelData(apiRef); + const visibleColumnsField = gridVisibleColumnFieldsSelector(apiRef).filter((data) => (data) !== "__check__"); + + const local_config = { + keys: visibleColumnsField, + + columnNames: data_colums.filter((mydata) => (mydata).disableExport !== true).map(function (mydata) { + + if (mydata.headerName && visibleColumnsField.includes(mydata.field)) { + if (mydata.headerName) { + return mydata.headerName; + } + } + + }), + + fileName: 'data_' + String(new Date().toJSON().slice(0, 10)).replaceAll("-", "_") + '.xlsx', + sheetName: 'Export_' + String(new Date().toJSON().slice(0, 10)).replaceAll("-", "_"), + }; + + + local_config.columnNames = local_config.columnNames.filter(function (element) { + return element !== undefined; + }); + + + const rows = data.map((row) => { + const mRow = {}; + for (const key of local_config.keys) { + mRow[key] = row[key]; + } + return mRow; + }); + + const worksheet = XLSX.utils.json_to_sheet(rows); + XLSX.utils.sheet_add_aoa(worksheet, [[...local_config.columnNames]], { + origin: 'A1', + }); + + const workbook = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(workbook, worksheet, local_config.sheetName); + XLSX.writeFile(workbook, local_config.fileName, { compression: true }); + } + + function ExportMenuItem(props) { + const apiRef = useGridApiContext(); + const { hideMenu } = props; + + return ( + { + handleExport(apiRef, props.data_colums); + // Hide the export menu after the export + hideMenu?.(); + }} + > + Export Excel + + ); + } + + // FIN EXPORT EXCEL DATAGRID + + const [Dialog_send_invoice_with_PJ_message, setDialog_send_invoice_with_PJ_message] = React.useState(false); + const [Dialog_send_invoice_with_PJ_open, setDialog_send_invoice_with_PJ_open] = React.useState(false); + function Dialog_send_invoice_with_PJ_handle_change_participant_session(message) { + setDialog_send_invoice_with_PJ_message(message); + setDialog_send_invoice_with_PJ_open(true); + } + + const Dialog_send_invoice_with_PJ_handleClose = () => { + //alert(" Utiliser le bouton 'fermer' "); + //setOpen(false); + }; + + const Dialog_send_invoice_with_PJ_handleClose_buton = () => { + setDialog_send_invoice_with_PJ_open(false); + settab_invoice_mail_pieces_jointes_result([]); + }; + + + function Delete_invoice_email_Attached_Doc(event) { + + var doc_to_del_name = event.target.id; + const myArray = tab_invoice_mail_pieces_jointes_result; + + let new_myArray = myArray.filter(file => file.name !== String(doc_to_del_name)); + + var new_tab = [] + for (let i = 0; i < new_myArray.length; i++) { + new_tab.push(new_myArray[i]); + } + + settab_invoice_mail_pieces_jointes_result(new_tab); + + + } + + const [sessions_file_change_1_convention_api, setsessions_file_change_1_convention_api] = useState(); + const [sessions_file_change_1_convention_result, setsessions_file_change_1_convention_result] = useState(); + const [sessions_file_change_1_convention_message, setsessions_file_change_1_convention_message] = useState(); + const sessions_file_change_1_convention = event => { + + const fileUploaded = event.target.files[0]; + let file_size = event.target.files[0].size; + let file_type = event.target.files[0].type; + + + if (file_type !== "application/pdf") { + // alert("Le fichier n'est pas de type PDF"); + setdisplay_alert_mysy("1"); + setalert_message("Le fichier n'est pas de type PDF"); + setalert_type("error"); + return; + } + + + + if (file_size > 10000000) { + //alert("Le fichier ne doit pas depasser un 1 Méga octets"); + //console.log("Le fichier ne doit pas depasser un 1 Méga octets"); + + setdisplay_alert_mysy("1"); + setalert_message("Le fichier ne doit pas depasser un 1 Méga octets"); + setalert_type("error"); + + return; + } + + //var new_node = {'name':event.target.files[0].name, 'type':event.target.files[0].type} + + + var new_tmp = []; + + if (tab_invoice_mail_pieces_jointes_result && tab_invoice_mail_pieces_jointes_result.length > 0) { + + tab_invoice_mail_pieces_jointes_result.map((x) => { + new_tmp.push(x); + + }); + + } + + new_tmp.push(event.target.files[0]) + + settab_invoice_mail_pieces_jointes_result(new_tmp); + + //console.log(" tab_invoice_mail_pieces_jointes_result = ", tab_invoice_mail_pieces_jointes_result) + + + return; + + + }; + + const [tab_invoice_mail_pieces_jointes_result, settab_invoice_mail_pieces_jointes_result] = useState([]); + + const [Dialog_invoice_history_message, setDialog_invoice_history_message] = React.useState(false); + const [Dialog_invoice_history_open, setDialog_invoice_history_open] = React.useState(false); + function Dialog_invoice_history_handle_change_participant_session(message) { + setDialog_invoice_history_message(message); + setDialog_invoice_history_open(true); + } + + const Dialog_invoice_history_handleClose = () => { + //alert(" Utiliser le bouton 'fermer' "); + //setOpen(false); + }; + + const Dialog_invoice_history_handleClose_buton = () => { + setDialog_invoice_history_open(false); + settab_invoice_mail_pieces_jointes_result([]); + + if (document.getElementsByName("invoice_history_bton") && document.getElementsByName("invoice_history_bton")[0]) { + document.getElementsByName("invoice_history_bton")[0].style.backgroundColor = "#d8edfc"; + document.getElementsByName("invoice_history_bton")[0].style.color = "#3b3e40"; + } + }; + + const [display_alert_mysy, setdisplay_alert_mysy] = useState(""); + const [alert_message, setalert_message] = useState(""); + const [alert_type, setalert_type] = useState(""); + + function clear_alert_message() { + setalert_message(""); + } + function clear_alert_type() { + setalert_type(""); + } + + function clear_display_alert_mysy() { + setdisplay_alert_mysy(""); + } + + function submenu_add_one_invoice_client() { + + clean_order_detail_fields(); + + Getall_Partner_Paiement_Condition(); + + setDialog_Detail_Facture_open(true); + + } + + + const [p_add_one_invoice_etudiant, setp_add_one_invoice_etudiant] = useState(""); + const [p_add_one_invoice_client, setp_add_one_invoice_client] = useState(""); + + const [Dialog_Detail_Facture_open, setDialog_Detail_Facture_open] = useState(false); + + const Close_Dialog_Detail_Invoice_open = () => { + // clean_order_detail_fields(); + setDialog_Detail_Facture_open(false); + }; + + const [Get_Givent_Partner_Client_Data_api, setGet_Givent_Partner_Client_Data_api] = useState(); + const [Get_Givent_Partner_Client_Data_message, setGet_Givent_Partner_Client_Data_message] = useState(); + const [Get_Givent_Partner_Client_Data_result, setGet_Givent_Partner_Client_Data_result] = useState(); + function Get_Givent_Partner_Client_Data(local_partner_client_id) { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + + form.append("token", stored_cookie); + form.append("_id", local_partner_client_id); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Partner_Client_From_Id/"; + + axios.post(myurl, form).then(res => { + //console.log(" In Get_Givent_Partner_Client_Data res.data.status = " + res.data.status); + //console.log(" In Get_Givent_Partner_Client_Data res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setGet_Givent_Partner_Client_Data_api("true"); + setGet_Givent_Partner_Client_Data_result(res.data.message); + var mylocalclient = JSON.parse(res.data.message); + + + if (mylocalclient) { + if (mylocalclient.email) { + setp_detail_header_email_client(mylocalclient.email); + } + + // Recuperation de l'adresse de facturation + if (mylocalclient.invoice_adresse) { + setp_detail_header_fact_adr(mylocalclient.invoice_adresse); + } + + if (mylocalclient.invoice_code_postal) { + setp_detail_header_fact_code_postal(mylocalclient.invoice_code_postal); + } + + if (mylocalclient.invoice_ville) { + setp_detail_header_fact_ville(mylocalclient.invoice_ville); + } + + if (mylocalclient.invoice_pays) { + setp_detail_header_fact_pays(mylocalclient.invoice_pays); + } + + + // Recuperation de l'adresse du lieu de formation (par defaut adresse de la societe) + if (mylocalclient.adr_adresse) { + setp_detail_header_liv_adr(mylocalclient.adr_adresse); + } + + if (mylocalclient.adr_code_postal) { + setp_detail_header_liv_code_postal(mylocalclient.adr_code_postal); + } + + if (mylocalclient.adr_ville) { + setp_detail_header_liv_ville(mylocalclient.adr_ville); + } + + if (mylocalclient.adr_pays) { + setp_detail_header_liv_pays(mylocalclient.adr_pays); + } + } + } + else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + else { + setGet_Givent_Partner_Client_Data_api("false"); + setGet_Givent_Partner_Client_Data_message(res.data.message); + // alert('Erreur: ' + res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( Get_Givent_Partner_Client_Data = ', error); + setGet_Givent_Partner_Client_Data_api("false"); + setdisplay_alert_mysy("1"); + setalert_message("Impossible de recuperer les données du client"); + setalert_type("error"); + // alert('Erreur: Impossible de recuperer les données du client'); + //setmyApimyApiMessage("") + }) + } + + const [New_Getall_Partner_Paiement_Condition_result, setNew_Getall_Partner_Paiement_Condition_result] = useState([]); + + const [Getall_Partner_Paiement_Condition_api, setGetall_Partner_Paiement_Condition_api] = useState(); + const [Getall_Partner_Paiement_Condition_message, setGetall_Partner_Paiement_Condition_message] = useState(); + const [Getall_Partner_Paiement_Condition_result, setGetall_Partner_Paiement_Condition_result] = useState([]); + function Getall_Partner_Paiement_Condition(event) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Paiement_Condition/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + setLoading(false); + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Partner_Paiement_Condition res.data.status = " + res.data.status); + //console.log(" In Getall_Partner_Paiement_Condition res.data.message r_class = " + res.data.message); + setGetall_Partner_Paiement_Condition_api("true"); + setGetall_Partner_Paiement_Condition_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 local_description = JSON.parse(x).description; + var local_nb_jour = JSON.parse(x).nb_jour; + var local_depart = JSON.parse(x).depart; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_code, + "code": local_code, + "description": local_description, + "nb_jour": local_nb_jour, + "depart": local_depart, + + }; + new_data2.push(node); + }); + + //--- + var node = { + "_id": "", + "id": "", + "label": "", + "code": "", + "description": "", + "nb_jour": "", + "depart": "", + + }; + new_data2.push(node); + + + //console.log(" ### new_data2 condition paiement = ", new_data2); + + if (new_data2.length > 0) + setNew_Getall_Partner_Paiement_Condition_result(new_data2); + + + } + else { + setGetall_Partner_Paiement_Condition_api("false"); + setGetall_Partner_Paiement_Condition_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_Partner_Paiement_Condition = ', error); + setGetall_Partner_Paiement_Condition_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des conditions de paiement"); + setalert_type("error"); + // alert(" Impossible de recuperer la liste des conditions de paiement"); + //setmyApimyApiMessage("") + }) + } + const [New_Getall_Training_Employee_No_Filter_result, setNew_Getall_Training_Employee_No_Filter_result] = useState([]); + + const [Getall_Training_Employee_No_Filter_api, setGetall_Training_Employee_No_Filter_api] = useState(); + const [Getall_Training_Employee_No_Filter_message, setGetall_Training_Employee_No_Filter_message] = useState(); + const [Getall_Training_Employee_No_Filter_result, setGetall_Training_Employee_No_Filter_result] = useState(); + function Getall_Training_Employee_No_Filter(event) { + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Ressource_Humaine_no_filter/"; + + + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Training_Employee_No_Filter res.data.status = " + res.data.status); + //console.log(" In Getall_Training_Employee_No_Filter res.data.message r_class = " + res.data.message); + setGetall_Training_Employee_No_Filter_api("true"); + setGetall_Training_Employee_No_Filter_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_nom = JSON.parse(x).nom; + var local_prenom = JSON.parse(x).prenom; + var local_ismanager = JSON.parse(x).ismanager; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_nom + " " + local_prenom, + "nom": local_nom, + "prenom": local_prenom, + "ismanager": local_ismanager + }; + new_data2.push(node); + }); + + var node = { + "_id": "", + "id": "", + "label": "", + "nom": "", + "prenom": "", + "ismanager": "" + }; + new_data2.push(node); + + if (new_data2.length > 0) + setNew_Getall_Training_Employee_No_Filter_result(new_data2); + } + else { + setGetall_Training_Employee_No_Filter_api("false"); + setGetall_Training_Employee_No_Filter_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( Getall_Training_Employee_No_Filter = ', error); + setGetall_Training_Employee_No_Filter_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des employés"); + setalert_type("error"); + // alert(" Impossible de recuperer la liste des employés"); + //setmyApimyApiMessage("") + }) + } + + const [Add_Dialog_Invoice_Client_api, setAdd_Dialog_Invoice_Client_api] = useState(); + const [Add_Dialog_Invoice_Client_message, setAdd_Dialog_Invoice_Client_message] = useState(); + const [Add_Dialog_Invoice_Client_result, setAdd_Dialog_Invoice_Client_result] = useState(); + function Add_Dialog_Invoice_Client() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("order_header_client_id", p_detail_header_client_id); + form.append("order_header_description", p_detail_header_description); + form.append("order_header_comment", p_detail_header_comment); + form.append("order_header_lieu_formation", p_detail_lieu_formation); + form.append("order_header_date_cmd", p_detail_header_date_cmd); + form.append("invoice_date", p_detail_header_invoice_date); + form.append("order_header_condition_paiement_id", p_detail_header_condition_paiement_id); + form.append("order_header_ref_client", p_detail_header_ref_client); + form.append("order_header_vendeur_id", p_detail_header_vendeur_id); + + + if (!p_detail_header_client_id || String(p_detail_header_client_id).length < 2) { + // alert(" Vous devez choisir un client"); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message("Vous devez choisir un client"); + setalert_type("error"); + return; + } + //console.log("### form = ", form); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Partner_Draft_Invoice/"; + + + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Add_Update_One_Order_Line_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_One_Order_Line_Data res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + Getall_Parter_Invoice_No_Filter(); + + setAdd_Dialog_Invoice_Client_api("true"); + setAdd_Dialog_Invoice_Client_result(res.data.message); + clean_order_detail_fields(); + Close_Dialog_Detail_Invoice_open(); + + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + + + + + if (document.getElementById('myRef_head')) { + var divh = document.getElementById('myRef_head').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + } + else { + setAdd_Dialog_Invoice_Client_api("false"); + setAdd_Dialog_Invoice_Client_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + + setLoading(false); + console.warn('Add_Dialog_Invoice_Client : Not good man :( Add_Dialog_Invoice_Client = ' + error); + setAdd_Dialog_Invoice_Client_api("false"); + setdisplay_alert_mysy("1"); + setalert_message("Impossible d'ajouter la facture"); + setalert_type("error"); + }) + } + + + const [Update_Draft_Invoice_Client_api, setUpdate_Draft_Invoice_Client_api] = useState(); + const [Update_Draft_Invoice_Client_message, setUpdate_Draft_Invoice_Client_message] = useState(); + const [Update_Draft_Invoice_Client_result, setUpdate_Draft_Invoice_Client_result] = useState(); + function Update_Draft_Invoice_Client() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_header_id", selected_id); + + form.append("order_header_date_cmd", p_detail_header_date_cmd); + form.append("invoice_header_ref_interne", p_detail_header_ref_client); + form.append("order_header_comment", p_detail_header_comment); + form.append("order_header_description", p_detail_header_description); + form.append("order_header_lieu_formation", p_detail_lieu_formation); + + + form.append("order_header_condition_paiement_code", p_detail_header_condition_paiement_code); + form.append("order_header_condition_paiement_id", p_detail_header_condition_paiement_id); + + form.append("invoice_date", p_detail_header_invoice_date); + form.append("invoice_date_echeance", p_detail_header_date_echeance); + + + form.append("order_header_adr_fact_adresse", p_detail_header_fact_adr); + form.append("order_header_adr_fact_code_postal", p_detail_header_fact_code_postal); + form.append("order_header_adr_fact_ville", p_detail_header_fact_ville); + form.append("order_header_adr_fact_pays", p_detail_header_fact_pays); + + form.append("order_header_client_id", p_detail_header_client_id); + form.append("invoice_header_ref_interne", p_detail_header_invoice_header_ref_interne); + form.append("invoice_header_type", p_detail_header_type); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Partner_Draft_Invoice/"; + + + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Add_Update_One_Order_Line_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_One_Order_Line_Data res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + Getall_Parter_Invoice_No_Filter(); + + setUpdate_Draft_Invoice_Client_api("true"); + setUpdate_Draft_Invoice_Client_result(res.data.message); + clean_order_detail_fields(); + + setInvoice_data_changed(""); + setInvoice_data_edit_mode(""); + + Display_Detail_Invoice_data(selected_id); + + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + + + + + if (document.getElementById('myRef_head')) { + var divh = document.getElementById('myRef_head').offsetTop; + window.scrollTo({ + top: divh, + behavior: "smooth", + }); + } + + } + else { + setUpdate_Draft_Invoice_Client_api("false"); + setUpdate_Draft_Invoice_Client_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + + setLoading(false); + console.warn('Update_Draft_Invoice_Client : Not good man :( Update_Draft_Invoice_Client = ' + error); + setUpdate_Draft_Invoice_Client_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de mettre à jour le document "); + setalert_type("error"); + }) + } + + + function Ajouter_une_ligne_article() { + + setarticle_formation_ou_produit("formation"); + // Recuperation des session de formation + Getall_TrainingSession(); + + setp_add_line_session_id(""); + + setinscrit_session([]) + setp_add_line_session_code(""); + setp_add_line_item(""); + setp_add_line_item_qty("1"); + setp_add_line_item_price("0"); + setp_add_line_item_comment(""); + setp_add_line_item_type_reduction(""); + setp_add_line_item_reduction_value(""); + setp_add_line_item_reduction_total_amount(""); + setp_add_line_item_total_amount_ht(""); + setp_add_line_item_taxe(""); + setp_add_line_item_taxe_amount(""); + setp_add_line_item_total_amount_ttc(""); + setp_add_line_item_type_apprenant(""); + + setp_add_line_invoice_line_type(""); + + // setpartner_taux_tva("20"); + + setselected_order_line_id(""); + + setp_add_line_item_status(p_detail_header_statut); + setp_add_line_item_type(p_detail_header_type); + + setDialog_Detail_Article_open(true); + } + + const [article_formation_ou_produit, setarticle_formation_ou_produit] = useState("formation"); + const [p_add_line_session_id, setp_add_line_session_id] = useState(""); + const fixedVal_inscrit = []; + const [inscrit_session, setinscrit_session] = useState([...fixedVal_inscrit]); + const CustomChip = (chipVal, getTagProps) => { + return chipVal.map((item, index) => ( + + )); + }; + + const [p_add_line_session_code, setp_add_line_session_code] = useState(""); + + function Recalcul_Item_Amounts() { + var qty = parseFloat(document.getElementById("ref_article_qty").value); + var unit_price = parseFloat(document.getElementById("ref_article_unit_price").value); + + // var unit_price = parseFloat(p_add_line_item_price); + + var total_base1 = (unit_price * qty).toFixed(2); + var total_reduction = 0; + + + + var reduct_type = document.getElementById("ref_article_type_reduction").value; + var reduct_value = document.getElementById("ref_article_reduction_value").value; + + //var reduct_type = p_add_line_item_type_reduction; + + //console.log(" reduct_type = ", reduct_type); + // console.log(" p_add_line_item_type_reduction = ", p_add_line_item_type_reduction); + + if (String(p_add_line_item_type_reduction) === "fixe") { + // console.log("fixe : p_add_line_item_reduction_value = ", reduct_value); + total_reduction = (parseFloat(String(reduct_value)) * qty).toFixed(2); + + } if (String(p_add_line_item_type_reduction) === "percent") { + // console.log("percent p_add_line_item_reduction_value = ", reduct_value); + total_reduction = ((unit_price * parseFloat(String(reduct_value)) * qty) / 100).toFixed(2); + + } + + + + //console.log(" #### partner_taux_tva = ", partner_taux_tva, " ### qty = ", qty, " ### unit_price = ", unit_price, " ### total_base1 = ", total_base1, " ### total_reduction = ", total_reduction, " ### reduct_value = ", reduct_value); + + var montant_taxe_tva = ((total_base1 - total_reduction) * [parseFloat(String(partner_taux_tva)) / 100]).toFixed(2); + var montant_ttc = ((total_base1 - total_reduction) * (1 + [parseFloat(String(partner_taux_tva)) / 100])).toFixed(2); //(total_base2 + montant_taxe_tva).toFixed(2); + + // 20/08/2024 - enlever la réduction du total ht + total_base1 = total_base1 - total_reduction; + + // console.log(" #### montant_taxe_tva = ", montant_taxe_tva, " ### montant_ttc = ", montant_ttc); + + setp_add_line_item_reduction_total_amount(String(total_reduction)); + setp_add_line_item_total_amount_ht(String(total_base1)); + setp_add_line_item_taxe("tva"); + setp_add_line_item_taxe_amount(String(montant_taxe_tva)); + setp_add_line_item_total_amount_ttc(String(montant_ttc)); + + //console.log(" ### montant tva = ", String(montant_taxe_tva), " ### montant TTC = ", String(montant_ttc)); + } + + const [New_Getall_Partner_Product_Service_result, setNew_Getall_Partner_Product_Service_result] = useState([]); + + const [Getall_Partner_Product_Service_api, setGetall_Partner_Product_Service_api] = useState(); + const [Getall_Partner_Product_Service_message, setGetall_Partner_Product_Service_message] = useState(); + const [Getall_Partner_Product_Service_result, setGetall_Partner_Product_Service_result] = useState([]); + function Getall_Partner_Product_Service(event) { + + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Partner_Produit_Service/"; + + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_Partner_Product_Service res.data.status = " + res.data.status); + //console.log(" In Getall_Partner_Product_Service res.data.message r_class = " + res.data.message); + setGetall_Partner_Product_Service_api("true"); + setGetall_Partner_Product_Service_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 local_nom = JSON.parse(x).nom; + var local_type = JSON.parse(x).type; + var local_code_taxe = JSON.parse(x).code_taxe; + var local_prix_vente = JSON.parse(x).prix_vente; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_code + "-" + local_nom, + "code": local_code, + "nom": local_nom, + "type": local_type, + "code_taxe": local_code_taxe, + "prix_vente": local_prix_vente, + + + }; + new_data2.push(node); + }); + + //--- + var node = { + "_id": "", + "id": "", + "label": "", + "code": "", + "nom": "", + "type": "", + "code_taxe": "", + "prix_vente": "", + + }; + new_data2.push(node); + + + if (new_data2.length > 0) + setNew_Getall_Partner_Product_Service_result(new_data2); + + } + else { + setGetall_Partner_Product_Service_api("false"); + setGetall_Partner_Product_Service_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( Getall_Partner_Product_Service = ', error); + setGetall_Partner_Product_Service_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des produits et services"); + setalert_type("error"); + + }) + } + + const [New_GetCurrentPartnerClass_result, setNew_GetCurrentPartnerClass_result] = useState([]); + + const [GetCurrentPartnerClass_api, setGetCurrentPartnerClass_api] = useState(); + const [GetCurrentPartnerClass_message, setGetCurrentPartnerClass_message] = useState(); + const [GetCurrentPartnerClass_result, setGetCurrentPartnerClass_result] = useState(); + function GetCurrentPartnerClass(event) { + var form = new FormData(); + + + + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("archive", "0"); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class/"; + + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In GetCurrentPartnerClass res.data.status = " + res.data.status); + //console.log(" In GetCurrentPartnerClass res.data.message r_class = " + res.data.message); + setGetCurrentPartnerClass_api("true"); + setGetCurrentPartnerClass_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_internal_url = JSON.parse(x).internal_url; + var local_title = JSON.parse(x).title; + var local_is_published = JSON.parse(x).published; + var local_price = JSON.parse(x).price; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_title, + "internal_url": local_internal_url, + "title": local_title, + "ispublished": local_is_published, + "price": local_price, + }; + new_data2.push(node); + + // return {"_id": " + str(local_id) + ", "label": " + local_courrier_template_ref_interne + '" , "courrier_template_ref_interne": "' + local_courrier_template_ref_interne + '", "nom_champ_technique": "' + local_nom_champ_technique + '", "nom_champ_fonctionel": "' + local_nom_champ_fonctionel + '","valide": "1" }; + + }); + + + var node = { + "_id": "", + "id": "", + "label": "", + "internal_url": "", + "title": "", + "ispublished": "", + "price": "", + }; + new_data2.push(node); + + if (new_data2.length > 0) { + setNew_GetCurrentPartnerClass_result(new_data2); + //console.log(" ### setNew_GetCurrentPartnerClass_result = ", New_GetCurrentPartnerClass_result); + } + + // console.log(" ## new_data2 = ", new_data2) + + } else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + else { + setGetCurrentPartnerClass_api("false"); + setGetCurrentPartnerClass_message(res.data.message); + + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + console.warn('Not good man :( mysearchtext = ', error); + setGetCurrentPartnerClass_api("false"); + + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des formations"); + setalert_type("error"); + }) + } + + const New_Option_formation_produit = [ + { "id": "formation", "label": "Formation", "value": "formation" }, + { "id": "produit", "label": "Produit & Service", "value": "produit" }, + { "id": "", "label": "", "value": "" }, + ] + + const [partner_taux_tva, setpartner_taux_tva] = useState("20"); + + const [Get_Class_Data_api, setGet_Class_Data_api] = useState(); + const [Get_Class_Data_message, setGet_Class_Data_message] = useState(); + const [Get_Class_Data_result, setGet_Class_Data_result] = useState(); + function Get_Class_Data(local_internal_url) { + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("internal_url", local_internal_url); + + + //console.log("### form = ", form); + var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_Class_From_Internal_Url/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Add_Update_One_Order_Line_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_One_Order_Line_Data res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + setGet_Class_Data_api("true"); + setGet_Class_Data_message(res.data.message); + + if (JSON.parse(res.data.message).price) { + setp_add_line_item_price(String(JSON.parse(res.data.message).price)); + document.getElementsByName("ref_article_unit_price")[0].value = String(JSON.parse(res.data.message).price); + + } + + + } + else { + setGet_Class_Data_api("false"); + setGet_Class_Data_message(res.data.message); + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("success"); + } + + }).catch((error) => { + setLoading(false); + + console.warn('Get_Class_Data : Not good man :( Get_Class_Data = ' + error); + setGet_Class_Data_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de récuperer les données de la formation "); + setalert_type("success"); + + }) + } + + + const [New_Getall_TrainingSession_For_Given_Class_result, setNew_Getall_TrainingSession_For_Given_Class_result] = useState([{ + "_id": "", + "id": "", + "label": "", + "code_session": "", + "titre": "", + "date_debut": "", + "date_fin": "", + }]); + const [Getall_TrainingSession_For_Given_Class_api, setGetall_TrainingSession_For_Given_Class_api] = useState(); + const [Getall_TrainingSession_For_Given_Class_message, setGetall_TrainingSession_For_Given_Class_message] = useState(); + const [Getall_TrainingSession_For_Given_Class_result, setGetall_TrainingSession_For_Given_Class_result] = useState([]); + function Getall_TrainingSession_For_Given_Class(local_class_id) { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("class_id", local_class_id); + + + form.append("archive", "0"); + // form.append("type_session", "1"); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Partner_Session_Ftion_Reduice_Fields/"; + + + setLoading(true); + axios.post(myurl, form).then(res => { + + if (String(res.data.status) === String("true")) { + //console.log(" In Getall_TrainingSession_For_Given_Class res.data.status = " + res.data.status); + // console.log(" In Getall_TrainingSession_For_Given_Class res.data.message r_class = " + res.data.message); + setGetall_TrainingSession_For_Given_Class_api("true"); + setGetall_TrainingSession_For_Given_Class_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_session = JSON.parse(x).code_session; + var local_titre = JSON.parse(x).titre; + var local_date_debut = JSON.parse(x).date_debut; + var local_date_fin = JSON.parse(x).date_fin; + var local_session_etape = JSON.parse(x).session_etape; + + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_code_session, + "code_session": local_code_session, + "titre": local_titre, + "date_debut": local_date_debut, + "date_fin": local_date_fin, + "session_etape": local_session_etape, + + + }; + new_data2.push(node); + + }); + var node = { + "_id": "", + "id": "", + "label": "", + "code_session": "", + "titre": "", + "date_debut": "", + "date_fin": "", + }; + new_data2.push(node); + + if (new_data2.length > 0) { + setNew_Getall_TrainingSession_For_Given_Class_result(new_data2); + + } else { + setNew_Getall_TrainingSession_For_Given_Class_result([{ + "_id": "", + "id": "", + "label": "", + "code_session": "", + "titre": "", + "date_debut": "", + "date_fin": "", + }]) + } + + + // console.log(" ### new_data2 = ", new_data2) + } + else { + setGetall_TrainingSession_For_Given_Class_api("false"); + setGetall_TrainingSession_For_Given_Class_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + setLoading(false); + }).catch((error) => { + setLoading(false); + console.warn('Not good man :( Getall_TrainingSession_For_Given_Class = ', error); + setGetall_TrainingSession_For_Given_Class_api("false"); + + setdisplay_alert_mysy("1"); + setalert_message("Impossible de récuperer les sessions"); + setalert_type("error"); + //setmyApimyApiMessage("") + }) + } + + + const [New_Get_List_Inscrit_To_Session_result, setNew_Get_List_Inscrit_To_Session_result] = useState([{ + "_id": "", + "id": "", + "label": "", + "nom": "", + "prenom": "", + "email": "", + "civilite": "", + "date_naissance": "", + }]); + + + const [Get_List_Inscrit_To_Session_api, setGet_List_Inscrit_To_Session_api] = useState(); + const [Get_List_Inscrit_To_Session_message, setGet_List_Inscrit_To_Session_message] = useState(); + const [Get_List_Inscrit_To_Session_result, setGet_List_Inscrit_To_Session_result] = useState(); + function Get_List_Inscrit_To_Session(local_tab_session_id) { + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + + form.append("token", stored_cookie); + form.append("tab_session_id", local_tab_session_id); + form.append("invoice_status", ""); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Inscrit_By_Invoice_Status_For_List_Session/"; + + axios.post(myurl, form).then(res => { + //console.log(" In Get_List_Inscrit_To_Session res.data.status = " + res.data.status); + //console.log(" In Get_List_Inscrit_To_Session res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setGet_List_Inscrit_To_Session_api("true"); + setGet_List_Inscrit_To_Session_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_nom = JSON.parse(x).nom; + var local_prenom = JSON.parse(x).prenom; + var local_email = JSON.parse(x).email; + var local_civilite = JSON.parse(x).civilite; + var local_date_naissance = JSON.parse(x).date_naissance; + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": local_nom + " " + local_prenom, + "nom": local_nom, + "prenom": local_prenom, + "email": local_email, + "civilite": local_civilite, + "date_naissance": local_date_naissance, + + }; + new_data2.push(node); + }); + + //--- + var node = { + "_id": "", + "id": "", + "label": "", + "nom": "", + "prenom": "", + "email": "", + "civilite": "", + "date_naissance": "", + }; + new_data2.push(node); + + if (new_data2.length > 0) + setNew_Get_List_Inscrit_To_Session_result(new_data2); + + } + else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + } + else { + setGet_List_Inscrit_To_Session_api("false"); + setGet_List_Inscrit_To_Session_message(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + + } + + }).catch((error) => { + console.warn('Not good man :( Get_List_Inscrit_To_Session = ', error); + setGet_List_Inscrit_To_Session_api("false"); + setdisplay_alert_mysy("1"); + setalert_message('Impossible de recuperer la liste des inscrits'); + setalert_type("error"); + + //setmyApimyApiMessage("") + }) + } + + + const Update_Dialog_Detail_Article_open = () => { + Add_Update_One_Invoice_Line_Data(); + }; + + const [Add_Update_One_Invoice_Line_Data_api, setAdd_Update_One_Invoice_Line_Data_api] = useState(); + const [Add_Update_One_Invoice_Line_Data_message, setAdd_Update_One_Invoice_Line_Data_message] = useState(); + const [Add_Update_One_Invoice_Line_Data_result, setAdd_Update_One_Invoice_Line_Data_result] = useState(); + function Add_Update_One_Invoice_Line_Data() { + + /*** Recualcule des taux et montants */ + + var qty = parseFloat(document.getElementById("ref_article_qty").value); + var unit_price = parseFloat(document.getElementById("ref_article_unit_price").value); + var total_base1 = (unit_price * qty).toFixed(2); + var total_reduction = 0; + + + + var reduct_type = document.getElementById("ref_article_type_reduction").value; + var reduct_value = document.getElementById("ref_article_reduction_value").value; + + //var reduct_type = p_add_line_item_type_reduction; + + //console.log(" reduct_type = ", reduct_type); + //console.log(" p_add_line_item_type_reduction = ", p_add_line_item_type_reduction); + + if (String(p_add_line_item_type_reduction) === "fixe") { + //console.log("fixe : p_add_line_item_reduction_value = ", reduct_value); + total_reduction = (parseFloat(String(reduct_value)) * qty).toFixed(2); + + + + } if (String(p_add_line_item_type_reduction) === "percent") { + //console.log("percent p_add_line_item_reduction_value = ", reduct_value); + total_reduction = ((unit_price * parseFloat(String(reduct_value)) * qty) / 100).toFixed(2); + + } + + + + // console.log(" GLOBAL #### partner_taux_tva = ", partner_taux_tva, " ### qty = ", qty, " ### unit_price = ", unit_price, " ### total_base1 = ", total_base1, " ### total_reduction = ", total_reduction, " ### reduct_value = ", reduct_value); + + const total_taux_tax_bef = parseFloat(String(partner_taux_tva)) / 100; + + // console.log(" GLOBAL #### total_taux_tax_bef = ", total_taux_tax_bef); + + const total_taux_tax = 1 + total_taux_tax_bef; + + const total_base1_total_reduction = (total_base1 - total_reduction); + + const montant_ttc = (total_base1_total_reduction * total_taux_tax).toFixed(2); + + //console.log(" GLOBAL #### total_taux_tax = ", total_taux_tax); + //console.log(" GLOBAL #### total_base1_total_reduction = ", total_base1_total_reduction); + //console.log(" GLOBAL #### montant_ttc = ", montant_ttc); + + + var montant_taxe_tva = ((total_base1 - total_reduction) * total_taux_tax_bef).toFixed(2); + // var montant_ttc = ((total_base1 - total_reduction) * (1 + [parseFloat(String(partner_taux_tva)) / 100])).toFixed(2); //(total_base2 + montant_taxe_tva).toFixed(2); + + // 20/08/2024 - enlever la réduction du total ht + total_base1 = total_base1 - total_reduction; + + //console.log(" GLOBAL #### montant_taxe_tva = ", montant_taxe_tva, " ### montant_ttc = ", montant_ttc); + + setp_add_line_item_reduction_total_amount(String(total_reduction)); + setp_add_line_item_total_amount_ht(String(total_base1)); + setp_add_line_item_taxe("tva"); + setp_add_line_item_taxe_amount(String(montant_taxe_tva)); + setp_add_line_item_total_amount_ttc(String(montant_ttc)); + /*** FINNN Recualcule des taux et montants */ + + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("order_line_formation", p_add_line_item_internal_url); + form.append("order_line_qty", p_add_line_item_qty); + form.append("order_line_prix_unitaire", p_add_line_item_price); + form.append("invoice_line_id", selected_invoice_line_id); + form.append("order_header_ref_interne", order_internal_ref); + form.append("invoice_header_id", selected_id); + form.append("invoice_line_status", p_add_line_item_status); + form.append("invoice_line_type", p_add_line_item_type); + form.append("order_line_comment", p_add_line_item_comment); + + form.append("order_line_type_article", article_formation_ou_produit); + + form.append("order_line_type_apprenant", String(p_add_line_item_type_apprenant)); + + form.append("order_line_type_reduction", p_add_line_item_type_reduction); + form.append("order_line_type_valeur", p_add_line_item_reduction_value); + form.append("order_line_montant_reduction", String(total_reduction)); + + form.append("order_line_montant_hors_taxes", String(total_base1)); + + form.append("order_line_taux_taxe", partner_taux_tva); + + form.append("order_line_tax", p_add_line_item_taxe); + form.append("order_line_tax_amount", String(montant_taxe_tva)); + form.append("order_line_montant_toutes_taxes", String(montant_ttc)); + + if (p_add_line_session_id && String(p_add_line_session_id).length > 2) + form.append("order_line_session_id", p_add_line_session_id); + else + form.append("order_line_session_id", ""); + + var tab_inscrit_id = [] + for (var i = 0; i < NewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result.length; i++) { + if (NewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result[i]._id.length > 5) + tab_inscrit_id.push(NewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result[i]._id) + } + + //console.log(" ### tab_inscrit_id = ", tab_inscrit_id); + + + + if (tab_inscrit_id && String(tab_inscrit_id).length > 0) + form.append("tab_inscription_ids_from_front", tab_inscrit_id); + else + form.append("tab_inscription_ids_from_front", ""); + + form.append("tab_inscription_ids", ""); + + /* + var tab_inscrit_id = [] + for (var i = 0; i < inscrit_session.length; i++) { + tab_inscrit_id.push(inscrit_session[i]._id) + } + + + var tab_inscrit_id_json_str = JSON.stringify(inscrit_session); + + if (tab_inscrit_id && String(tab_inscrit_id).length > 0) + form.append("order_line_tab_inscrit_id", tab_inscrit_id_json_str); + else + form.append("order_line_tab_inscrit_id", ""); + + */ + + + // Controle des champs obligatoires + if (!p_add_line_item || String(p_add_line_item).length < 2) { + //alert(" Vous devez choisir une formation "); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message("Vous devez choisir une formation "); + setalert_type("error"); + return; + } + + + if (!p_add_line_item_qty || parseFloat(String(p_add_line_item_qty)) <= 0) { + // alert(" La quantité choisie est incorrecte "); + setdisplay_alert_mysy("1"); + setalert_message(" La quantité choisie est incorrecte "); + setalert_type("error"); + return; + } + + if (!p_add_line_item_price || parseFloat(String(p_add_line_item_price)) < 0) { + // alert(" Le prix unitaire est incorrecte "); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(" Le prix unitaire est incorrecte "); + setalert_type("error"); + return; + } + + if (String(p_add_line_item_type_reduction) === "percent" && + (parseFloat(String(p_add_line_item_reduction_value)) < 0 || parseFloat(String(p_add_line_item_reduction_value)) > 100)) { + // alert(" Pour une reduction de type 'pourcentage', la valeur doit être comprise entre 0 et 100 "); + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message("Pour une reduction de type 'pourcentage', la valeur doit être comprise entre 0 et 100"); + setalert_type("error"); + return; + } + + if (String(p_add_line_item_type_reduction) === "fixe" && + (parseFloat(String(p_add_line_item_reduction_value)) < 0 || parseFloat(String(p_add_line_item_reduction_value)) > parseFloat(String(p_add_line_item_price)))) { + // alert(" Pour une reduction de type 'fixe', la valeur ne doit pas excéder le prix unitaire de l'article "); + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(" Pour une reduction de type 'fixe', la valeur ne doit pas excéder le prix unitaire de l'article "); + setalert_type("error"); + return; + } + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Update_Partner_Draft_Invoice_Line/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Add_Update_One_Invoice_Line_Data res.data.status = " + res.data.status); + //console.log(" In Add_Update_One_Invoice_Line_Data res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + setAdd_Update_One_Invoice_Line_Data_api("true"); + setAdd_Update_One_Invoice_Line_Data_result(res.data.message); + clean_article_detail_fields(); + + Display_Detail_Invoice_data(selected_id); + // alert(" L'article a été correctement ajouté / mis à jour."); + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message("L'article a été correctement ajouté / mis à jour."); + setalert_type("success"); + + setDialog_Detail_Article_open(false); + + //myRef_head.current.scrollIntoView({ behavior: "smooth" }); + + } + else { + setAdd_Update_One_Invoice_Line_Data_api("false"); + setAdd_Update_One_Invoice_Line_Data_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Add_Update_One_Invoice_Line_Data = ' + error); + setAdd_Update_One_Invoice_Line_Data_api("false"); + + setdisplay_alert_mysy("1"); + setalert_message(" Impossible d'ajouter / mettre à jour la ligne"); + setalert_type("error"); + + + }) + } + + const [Confrim_Create_Invoice_api, setConfrim_Create_Invoice_api] = useState(); + const [Confrim_Create_Invoice_message, setConfrim_Create_Invoice_message] = useState(); + const [Confrim_Create_Invoice_result, setConfrim_Create_Invoice_result] = useState(); + function Confrim_Create_Invoice() { + + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("invoice_header_id", selected_id); + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Confirm_Partner_Invoice_Header_And_Lines/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + //console.log(" In Confrim_Create_Invoice res.data.status = " + res.data.status); + //console.log(" In Confrim_Create_Invoice res.data.message r_class = " + res.data.message); + + setLoading(false); + if (String(res.data.status) === String("true")) { + setConfrim_Create_Invoice_api("true"); + setConfrim_Create_Invoice_result(res.data.message); + clean_article_detail_fields(); + + Getall_Parter_Invoice_No_Filter(); + + Display_Detail_Invoice_data(selected_id); + // alert(" L'article a été correctement ajouté / mis à jour."); + + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message("L'article a été correctement ajouté / mis à jour."); + setalert_type("success"); + + setDialog_Detail_Article_open(false); + + //myRef_head.current.scrollIntoView({ behavior: "smooth" }); + + } + else { + setConfrim_Create_Invoice_api("false"); + setConfrim_Create_Invoice_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Confrim_Create_Invoice = ' + error); + setConfrim_Create_Invoice_api("false"); + + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de confirmer le document"); + setalert_type("error"); + + + }) + } + + function clean_article_detail_fields() { + + setp_add_line_item(""); + setp_add_line_item_internal_url(""); + setp_add_line_item_title(); + setp_add_line_item_qty("1"); + setp_add_line_item_price('0'); + setp_add_line_item_comment(); + setp_add_line_item_status(); + setp_add_line_item_type(); + setp_add_line_session_id(""); + setp_add_line_session_code(""); + setp_add_line_item_type_apprenant(""); + + setp_add_line_invoice_line_type(""); + + setinscrit_session([]) + } + + const [Dialog_Rech_Apprenant_Et_Facture_open, setDialog_Rech_Apprenant_Et_Facture_open] = useState(false); + + const Close_Dialog_Rech_Apprenant_Et_Facture_open = () => { + // clean_order_detail_fields(); + setDialog_Rech_Apprenant_Et_Facture_open(false); + + clear_apprenant_invoice_fields(); + }; + + function clear_apprenant_invoice_fields() { + setinvoice_inscrit_selected_montant_a_facture("0"); + setinvoice_inscrit_selected_session_id(""); + setinvoice_inscrit_selected_inscrit_id(""); + setinvoice_inscrit_selected_reste_a_facture(""); + setinvoice_inscrit_selected_frais_inscription(""); + + setinvoice_inscrit_selected_total_facture(""); + setNewGetall_TrainingParticipant_List_Invoices_result([]) + setNewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result([{ + "_id": "", + "id": "", + "label": "", + "email": "", + "nom": "", + "prenom": "", + "apprenant_id": "", + }]); + setNewGetall_TrainingParticipant_List_Invoices_result([]); + + } + + const [invoice_inscrit_selected_session_id, setinvoice_inscrit_selected_session_id] = useState(""); + const [invoice_inscrit_selected_inscrit_id, setinvoice_inscrit_selected_inscrit_id] = useState(""); + const [invoice_inscrit_selected_total_facture, setinvoice_inscrit_selected_total_facture] = useState(""); + + const [invoice_inscrit_selected_montant_a_facture, setinvoice_inscrit_selected_montant_a_facture] = useState(""); + + const [invoice_inscrit_selected_reste_a_facture, setinvoice_inscrit_selected_reste_a_facture] = useState(""); + const [invoice_inscrit_selected_frais_inscription, setinvoice_inscrit_selected_frais_inscription] = useState(""); + + + + const [NewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result, setNewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result] = useState([{ + "_id": "", + "id": "", + "label": "", + "email": "", + "nom": "", + "prenom": "", + "apprenant_id": "", + }]); + + // Important, ici on ne va recuperer que la liste des inscrit a une session / promo pour qui il reste de choses a facturer + const [Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_api, setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_api] = useState(); + const [Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_message, setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_message] = useState(); + const [Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result, setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result] = useState([]); + function Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment(local_session_id, local_client_rattachement_id) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("session_id", local_session_id); + + if (local_client_rattachement_id && local_client_rattachement_id.length > 5) + form.append("client_rattachement_id", local_client_rattachement_id) + + + //console.log(" ### Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment form = ", form) + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Insription_From_Session_id_Reduice_Fields_With_Filter_With_To_Paie/"; + + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + if (String(res.data.status) === String("true")) { + setLoading(false); + //console.log(" In Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment res.data.status = " + res.data.status); + //console.log(" In Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment res.data.message r_class = " + res.data.message); + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_api("true"); + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_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 email = JSON.parse(x).email; + var nom = JSON.parse(x).nom; + var prenom = JSON.parse(x).prenom; + var apprenant_id = JSON.parse(x).apprenant_id; + + //--- + var node = { + "_id": local_id, + "id": localid, + "label": prenom + " " + nom + " " + email, + "email": email, + "nom": nom, + "prenom": prenom, + "apprenant_id": apprenant_id, + }; + new_data2.push(node); + + // return {"_id": " + str(local_id) + ", "label": " + local_courrier_template_ref_interne + '" , "courrier_template_ref_interne": "' + local_courrier_template_ref_interne + '", "nom_champ_technique": "' + local_nom_champ_technique + '", "nom_champ_fonctionel": "' + local_nom_champ_fonctionel + '","valide": "1" }; + + }); + + //--- + var node = { + "_id": "", + "id": "", + "label": "", + "email": "", + "nom": "", + "prenom": "", + "apprenant_id": "", + }; + new_data2.push(node); + + if (new_data2.length > 0) + setNewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result(new_data2); + + + } + else { + setLoading(false); + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_api("false"); + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + + console.warn('Not good man :( Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment = ', error); + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des inscrits"); + setalert_type("error"); + + }) + } + + + + const [Nb_Invoiced_Inscrit_Of_Session, setNb_Invoiced_Inscrit_Of_Session] = useState(""); + + const [Get_Nb_Invoiced_Inscrit_Of_Session_api, setGet_Nb_Invoiced_Inscrit_Of_Session_api] = useState(); + const [Get_Nb_Invoiced_Inscrit_Of_Session_message, setGet_Nb_Invoiced_Inscrit_Of_Session_message] = useState(); + const [Get_Nb_Invoiced_Inscrit_Of_Session_result, setGet_Nb_Invoiced_Inscrit_Of_Session_result] = useState([]); + function Get_Nb_Invoiced_Inscrit_Of_Session(local_session_id) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("session_id", local_session_id); + + //console.log(" ### Get_Nb_Invoiced_Inscrit_Of_Session form = ", form) + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Nb_Insription_From_Session_Full_Invoiced/"; + + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + if (String(res.data.status) === String("true")) { + setLoading(false); + //console.log(" In Get_Nb_Invoiced_Inscrit_Of_Session res.data.status = " + res.data.status); + // console.log(" In Get_Nb_Invoiced_Inscrit_Of_Session res.data.message r_class = " + res.data.message); + setGet_Nb_Invoiced_Inscrit_Of_Session_api("true"); + setGet_Nb_Invoiced_Inscrit_Of_Session_result(res.data.message); + + setNb_Invoiced_Inscrit_Of_Session(res.data.message); + + } + else { + setLoading(false); + setGet_Nb_Invoiced_Inscrit_Of_Session_api("false"); + setGet_Nb_Invoiced_Inscrit_Of_Session_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + + console.warn('Not good man :( Get_Nb_Invoiced_Inscrit_Of_Session = ', error); + setGet_Nb_Invoiced_Inscrit_Of_Session_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer le nombre d'inscrits completement facturé"); + setalert_type("error"); + + }) + } + + const [NewGetall_TrainingParticipant_List_Invoices_result, setNewGetall_TrainingParticipant_List_Invoices_result] = useState([]); + + const [Getall_TrainingParticipant_List_Invoices_api, setGetall_TrainingParticipant_List_Invoices_api] = useState(); + const [Getall_TrainingParticipant_List_Invoices_message, setGetall_TrainingParticipant_List_Invoices_message] = useState(); + const [Getall_TrainingParticipant_List_Invoices_result, setGetall_TrainingParticipant_List_Invoices_result] = useState([]); + function Getall_TrainingParticipant_List_Invoices(local_inscrit_id) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("inscription_id", local_inscrit_id); + + //console.log(" ### Getall_TrainingParticipant_List_Invoices form = ", form) + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Inscrit_Invoices/"; + + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + if (String(res.data.status) === String("true")) { + setLoading(false); + //console.log(" In Getall_TrainingParticipant_List_Invoices res.data.status = " + res.data.status); + // console.log(" In Getall_TrainingParticipant_List_Invoices res.data.message r_class = " + res.data.message); + setGetall_TrainingParticipant_List_Invoices_api("true"); + setGetall_TrainingParticipant_List_Invoices_result(res.data.message); + + var local_json = JSON.parse(res.data.message); + + var total_facture_ligne = local_json.total_facture_line; + setinvoice_inscrit_selected_total_facture(total_facture_ligne); + + setinvoice_inscrit_selected_reste_a_facture(local_json.reste_a_facturer); + setinvoice_inscrit_selected_frais_inscription(local_json.frais_inscription); + + + var new_data2 = []; + const new_data = local_json.liste_facture.map((x) => { + + //--- + var invoice_header_ref_interne = (x).invoice_header_ref_interne; + var invoice_date = (x).invoice_date; + var order_line_montant_hors_taxes = (x).order_line_montant_hors_taxes; + + + + //--- + var node = { + "invoice_header_ref_interne": invoice_header_ref_interne, + "invoice_date": invoice_date, + "order_line_montant_hors_taxes": order_line_montant_hors_taxes, + "total_facture_ligne": total_facture_ligne, + }; + new_data2.push(node); + + // return {"_id": " + str(local_id) + ", "label": " + local_courrier_template_ref_interne + '" , "courrier_template_ref_interne": "' + local_courrier_template_ref_interne + '", "nom_champ_technique": "' + local_nom_champ_technique + '", "nom_champ_fonctionel": "' + local_nom_champ_fonctionel + '","valide": "1" }; + + }); + + + if (new_data2.length > 0) + setNewGetall_TrainingParticipant_List_Invoices_result(new_data2); + else + setNewGetall_TrainingParticipant_List_Invoices_result([]); + + + } + else { + setLoading(false); + setGetall_TrainingParticipant_List_Invoices_api("false"); + setGetall_TrainingParticipant_List_Invoices_message(res.data.message); + // alert(res.data.message); + setdisplay_alert_mysy("1"); + setalert_message(res.data.message); + setalert_type("error"); + } + + }).catch((error) => { + setLoading(false); + + console.warn('Not good man :( Getall_TrainingParticipant_List_Invoices = ', error); + setGetall_TrainingParticipant_List_Invoices_api("false"); + setdisplay_alert_mysy("1"); + setalert_message(" Impossible de recuperer la liste des factures de l'inscrit"); + setalert_type("error"); + + }) + } + + return ( + +
+ {isLoading &&
+
+
} + + {/*** Affichage des messages d'alerte*/} + {display_alert_mysy && String(display_alert_mysy) === "1" && + + } + {/*** FIN Affichage des messages d'alerte*/} + + + + {/********** Dialog pour recherche Apprenant puis facture */} + null} + + PaperProps={{ + + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '10rem', + margin: "2px", + maxWidth: 'unset', + width: '50rem' + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + > + + Nouvelle facture Apprenant + + +
+
Promotion
+ (data)._id === String(p_add_line_session_id))[0].label} + onChange={(event, value) => { + setinvoice_inscrit_selected_inscrit_id(""); + setNewGetall_TrainingParticipant_List_Invoices_result([]); + setGetall_TrainingParticipant_List_Invoices_result([]); + + if (value && value._id) { + setinvoice_inscrit_selected_session_id(value._id); + Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment(value._id, ""); + Get_Nb_Invoiced_Inscrit_Of_Session(value._id); + + } else { + setinvoice_inscrit_selected_session_id(""); + setNb_Invoiced_Inscrit_Of_Session("") + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result([[{ + "_id": "", + "id": "", + "label": "", + "email": "", + "nom": "", + "prenom": "", + "apprenant_id": "", + }]]); + + + } + + + }} + + renderInput={(params) => + } + /> +
+ +
+ + + Inscrit  + +
+ {NewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result && NewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result.length > 0 && (data)._id === String(invoice_inscrit_selected_inscrit_id))[0].label} + onChange={(event, value) => { + if (value && value._id) { + setinvoice_inscrit_selected_inscrit_id(value._id); + Getall_TrainingParticipant_List_Invoices(value._id); + + } else { + setinvoice_inscrit_selected_inscrit_id(""); + setNewGetall_TrainingParticipant_List_Invoices_result([]); + setGetall_TrainingParticipant_List_Invoices_result([]); + setNb_Invoiced_Inscrit_Of_Session("") + + + } + + }} + + renderInput={(params) => + } + />} + +
+
+ + {Nb_Invoiced_Inscrit_Of_Session && Nb_Invoiced_Inscrit_Of_Session.length > 0 && + JSON.parse(Nb_Invoiced_Inscrit_Of_Session).nb_fully_invoiced_inscrit > 0 &&
+ Inscriptions complétement Facturées : {JSON.parse(Nb_Invoiced_Inscrit_Of_Session).nb_fully_invoiced_inscrit} sur / {JSON.parse(Nb_Invoiced_Inscrit_Of_Session).session_nb_inscrit} +
} + + + {NewGetall_TrainingParticipant_List_Invoices_result && NewGetall_TrainingParticipant_List_Invoices_result.length > 0 &&
+
+ +
+
+ +
+ Liste des factures : {local_format_monetaire(invoice_inscrit_selected_total_facture)} +
+ + + + + + {NewGetall_TrainingParticipant_List_Invoices_result && + NewGetall_TrainingParticipant_List_Invoices_result.map((invoice) => ( + + + + {invoice.invoice_date} + + + + + + {invoice.invoice_header_ref_interne} : {local_format_monetaire(invoice.order_line_montant_hors_taxes)} HT + + + ))} + + + + + +
+
+ + + +
+
} +
 
+ + {invoice_inscrit_selected_inscrit_id && invoice_inscrit_selected_inscrit_id.length > 5 &&
+
Saisir le montant à facturer ( reste à facturer = {local_format_monetaire(invoice_inscrit_selected_reste_a_facture)}) HT
+ { + setinvoice_inscrit_selected_montant_a_facture(e.target.value); + } + } + + /> +
+ + +
} + + +
 
+ +
+ + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ + {/********** FIN Dialog pour recherche Apprenant puis facture */} + + + {/********** Dialog pour une entete de Facture */} + null} + + PaperProps={{ + + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '10rem', + margin: "2px", + maxWidth: 'unset', + width: '50rem' + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + > + + Nouvelle facture + + +
Client + { + if (value && value._id) { + + setp_detail_header_client_id(value._id); + Get_Givent_Partner_Client_Data(value._id); + setp_detail_paiement_id(value.invoice_condition_paiement_id); + } + + }} + + renderInput={(params) => + } + /> + +
+ + +
+ +
Date Ordre
+ + { + setp_detail_header_date_cmd(format(date, 'dd/MM/yyyy')); + + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + style={{ "width": "100%" }} + locale={'fr'} + fullWidth + /> +
+ +
Date Facture
+ { + setp_detail_header_invoice_date(format(date, 'dd/MM/yyyy')); + + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + style={{ "width": "100%" }} + locale={'fr'} + fullWidth + /> +
+ + +
+
+
Description
+ { + setp_detail_header_description(e.target.value); + + } + } + /> +
+ +
Ref. externe
+ { + setp_detail_header_ref_client(e.target.value); + + } + } + /> +
+ +
+
+ +
Vendeur
+ + { + if (value && value._id) { + setp_detail_header_vendeur_id(value._id); + + } else { + setp_detail_header_vendeur_id(""); + } + }} + + renderInput={(params) => + } + /> + + +
+ +
Conditions Paiement
+ + {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + } else { + setp_detail_header_condition_paiement_id("") + } + + }} + + renderInput={(params) => + } + />} + +
+ +
+ + +
+
Lieu de formation
+ { + setp_detail_lieu_formation(e.target.value); + } + } + + + /> +
+ + +
Commentaire
+ { + setp_detail_header_comment(e.target.value); + } + } + + + /> +
+
+
 
+ +
+ + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ + {/********** FIN Dialog pour une entete de Facture */} + + + {/********** Dialog pour ajouter une ligne à une Facture */} + null} + + PaperProps={{ + + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '10rem', + margin: "2px", + maxWidth: 'unset', + width: '50rem' + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" > + + Edition Détail ligne {String(p_detail_header_type).toLocaleUpperCase()} + + + {/*p_add_line_item = {p_add_line_item}
*/} + + + {(!selected_order_line_id || String(selected_order_line_id).length < 3) && +
Type Article + + (data).id === String(article_formation_ou_produit))[0].label} + fullWidth + onChange={(event, value) => { + if (value && value.id) { + setarticle_formation_ou_produit(value.id); + setp_add_line_item(""); + setp_add_line_item_qty("1"); + setp_add_line_item_price("0"); + setp_add_line_session_id(""); + setp_add_line_session_code(""); + + setp_add_line_invoice_line_type(""); + + + } + }} + + renderInput={(params) => + + } + /> +
+ } + + {/*** Si c'est pour une formation */} + {article_formation_ou_produit && String(article_formation_ou_produit) === "formation" && +
+
+ {New_GetCurrentPartnerClass_result && New_GetCurrentPartnerClass_result.length > 0 && + (p_add_line_item || String(p_add_line_item) === "") && String(p_detail_header_statut_label).toLowerCase() !== "facturé" && +
Formation + (data).internal_url === String(p_add_line_item))[0].label} + + onChange={(event, value) => { + // setp_champ_table(value.nom_champ_technique); + setp_add_line_session_id(""); + + if (value && value.internal_url) { + + setp_add_line_item_price(value.price); + document.getElementsByName("ref_article_unit_price")[0].value = String(value.price); + + + setp_add_line_item(value.internal_url); + setp_add_line_item_internal_url(value.internal_url); + Get_Class_Data(value.internal_url); + setp_add_line_item_title(value.title); + Getall_TrainingSession_For_Given_Class(value._id); + + Recalcul_Item_Amounts(); + + } else { + setp_add_line_item(""); + setp_add_line_item_internal_url(""); + setp_add_line_item_title(""); + setp_add_line_item_price("0"); + document.getElementsByName("ref_article_unit_price")[0].value = "0"; + + } + }} + + + renderInput={(params) => + } + /> + + + +
} + + {(p_add_line_item || String(p_add_line_item) === "") && String(p_detail_header_statut_label).toLowerCase() !== "facturé" + && New_Getall_TrainingSession_For_Given_Class_result && New_Getall_TrainingSession_For_Given_Class_result.length > 0 && +
Session + + + (data)._id === String(p_add_line_session_id))[0].label} + + onChange={(event, value) => { + + if (value && value._id) { + setp_add_line_session_id(value._id); + setp_add_line_session_code(value.code_session); + Getall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment(value._id, p_detail_header_client_nom_id); + } else { + + setp_add_line_session_id(""); + setp_add_line_session_code(""); + setNewGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result([]); + setGetall_TrainingParticipant_Reduce_Fields_With_Remaining_Paiment_result([]); + } + }} + + + renderInput={(params) => + } + /> + + + +
} + +
+ {/*(p_add_line_item || String(p_add_line_item) === "") && String(p_detail_header_statut_label).toLowerCase() !== "facturé" + && New_Get_List_Inscrit_To_Session_result && New_Get_List_Inscrit_To_Session_result.length > 0 && +
Inscrit(s) + + { + + setinscrit_session([ + ...fixedVal_inscrit, + ...newValue.filter((i) => fixedVal_inscrit.indexOf(i) === -1), + ]); + + + + }} + value={inscrit_session} + + + + renderInput={(params) => + } + /> + + + +
*/} + + +
+ {New_GetCurrentPartnerClass_result && New_GetCurrentPartnerClass_result.length > 0 && p_add_line_item + && String(p_detail_header_statut_label).toLowerCase() === "facturé" && +
Formation + + (data).internal_url === String(p_add_line_item))[0].label} + + + + renderInput={(params) => + } + /> + + + +
} + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" + && New_Getall_TrainingSession_result && New_Getall_TrainingSession_result.length > 0 && +
Session + + (data).class_internal_url === String(p_add_line_item)) + } + + value={New_Getall_TrainingSession_result.filter((data) => (data)._id === String(p_add_line_session_id))[0].label} + + + + renderInput={(params) => + } + /> + + + +
} + +
+ + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" && +
+ + +
Quantité + + { + setp_add_line_item_qty(e.target.value); + Recalcul_Item_Amounts(); + } + } + type="number" + disabled={Boolean(parseInt(is_document_invoiced))} + + /> + +
+ +
Prix Unitaire + { + setp_add_line_item_price(e.target.value); + Recalcul_Item_Amounts(); + } + } + + type="number" + disabled={Boolean(parseInt(is_document_invoiced))} + + /> +
+ + +
} + + + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" && + +
+
Quantité + + +
+ +
Prix Unitaire + +
+ +
} + + + + + + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" && + +
+ +
Taux TVA + { + setpartner_taux_tva(e.target.value); + Recalcul_Item_Amounts(); + + } + } + disabled={Boolean(parseInt(is_document_invoiced))} + type="number" + /> +
+ + +
+ val.value === String(p_add_line_item_type_apprenant))[0].label} + onChange={(event, value) => { + if (value && value.id) { + setp_add_line_item_type_apprenant(value.id); + } else { + setp_add_line_item_type_apprenant(""); + } + }} + + renderInput={(params) => + } + /> +
+
} + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
+ + +
Taux TVA + +
+ +
Type apprenant + val.value === String(p_add_line_item_type_apprenant))[0].label} + disabled={Boolean(parseInt(is_document_invoiced))} + type="text" + /> +
+
} + +
} + + + {/*** Si c'est pour un produit ou service */} + {article_formation_ou_produit && String(article_formation_ou_produit) === "produit" && +
+ {/*New_Getall_Partner_Product_Service_result && New_Getall_Partner_Product_Service_result.length > 0 && + (p_add_line_item || String(p_add_line_item) === "") && String(p_detail_header_statut_label).toLowerCase() !== "facturé" && +
Produit & Service + (data)._id === String(p_add_line_item))[0].label} + + onChange={(event, value) => { + // setp_champ_table(value.nom_champ_technique); + if (value && value._id) { + setp_add_line_item(value._id); + setp_add_line_item_internal_url(value._id); + setp_add_line_item_price(value.prix_vente); + setpartner_taux_tva(value.code_taxe); + //Get_Class_Data(value.internal_url); + setp_add_line_item_title(value.code); + } else { + setp_add_line_item(""); + setp_add_line_item_internal_url(""); + setp_add_line_item_title(""); + + } + }} + + + renderInput={(params) => + } + /> +
*/} + + +
+ + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Article + p_add_line_item = {p_add_line_item} + {New_Getall_Partner_Product_Service_result && New_Getall_Partner_Product_Service_result.length > 0 && (data)._id === String(p_add_line_item))[0].label} + + />} + + +
} + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Quantité + + + +
} + +
+ +
+ + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" && +
+ + {New_Getall_Partner_Product_Service_result && New_Getall_Partner_Product_Service_result.length > 0 && + (p_add_line_item || String(p_add_line_item) === "") && String(p_detail_header_statut_label).toLowerCase() !== "facturé" && +
Produit & Service + (data)._id === String(p_add_line_item))[0].label} + disabled={Boolean(parseInt(is_document_invoiced))} + onChange={(event, value) => { + // setp_champ_table(value.nom_champ_technique); + if (value && value._id) { + setp_add_line_item_price(value.prix_vente); + document.getElementsByName("ref_article_unit_price")[0].value = String(value.prix_vente); + + + setp_add_line_item(value._id); + setp_add_line_item_internal_url(value._id); + + setpartner_taux_tva(value.code_taxe); + + setp_add_line_item_title(value.code); + + + Recalcul_Item_Amounts(); + } else { + setp_add_line_item(""); + setp_add_line_item_internal_url(""); + setp_add_line_item_title(""); + + } + }} + + + renderInput={(params) => + } + /> +
} + + +
} + + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" &&
Quantité + + { + setp_add_line_item_qty(e.target.value); + Recalcul_Item_Amounts(); + } + } + type="number" + disabled={Boolean(parseInt(is_document_invoiced))} + /> + +
} +
+ +
+ + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" &&
Prix Unitaire + { + setp_add_line_item_price(e.target.value); + Recalcul_Item_Amounts(); + } + } + disabled={Boolean(parseInt(is_document_invoiced))} + type="number" + + /> +
} + + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" &&
Taux TVA + { + setpartner_taux_tva(e.target.value); + Recalcul_Item_Amounts(); + } + } + disabled={Boolean(parseInt(is_document_invoiced))} + type="number" + /> +
} + +
+
+ + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Prix Unitaire + +
} + + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Taux TVA + +
} + +
+ +
} + +
+ {String(p_detail_header_statut_label).toLowerCase() !== "facturé" &&
Type reduction + { + setp_add_line_item_type_reduction(e.target.value); + //console.log(" ## e.target.value = ", e.target.value); + setp_add_line_item_reduction_value("0"); + setp_add_line_item_reduction_total_amount('0'); + setp_add_line_item_reduction_value('0'); + setp_add_line_item_total_amount_ht('0'); + + } + } + + > + Montant   + Pourcentage   + + +
} + + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" &&
Reduction + { + + setp_add_line_item_reduction_value(e.target.value); + Recalcul_Item_Amounts(); + } + } + disabled={Boolean(parseInt(is_document_invoiced))} + type="number" + /> + +
} + +
+ +
+ + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Type reduction + + +
} + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Reduction + + +
} +
+ + + + + + + +
+
Total Reduction + + +
+ +
Total HT + + +
+ +
+ + {String(p_detail_header_statut_label).toLowerCase() !== "facturé" &&
Commentaire + { + setp_add_line_item_comment(e.target.value); + } + } + //label="Commentaire" + //variant="standard" + multiline + minRows={2} + maxRows={2} + rows={2} + disabled={Boolean(parseInt(is_document_invoiced))} + + /> + +
} + + {String(p_detail_header_statut_label).toLowerCase() === "facturé" &&
Commentaire + + +
} + +
+ + + + + + + + + {String(is_document_invoiced) !== "1" &&
+
+ +
+
+ +
+ +
} + {String(is_document_invoiced) === "1" &&
+
+   +
+
+ +
+ +
} + +
+
+ {/********** Fin Dialog pour ajouter une ligne à une Facture */} + + + {/* Dialog affichage historique facture */} + null} + + PaperProps={{ + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '5rem', + margin: "2px", + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + > + + MySy Information + + +
+
+ +
+ + +
+ + +
+
+ + +
+ + + + + + + + + +
+
+   +
+ + +
+ +
+
+ +
+ +
+ {/* FIN Dialog affichage historique facture */} + + + {/* Dialog envoie facture mail avec PJ */} + null} + + PaperProps={{ + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '5rem', + margin: "2px", + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + > + + MySy Information + + + Envoi Facture par email + + + +
+ +
+
+
+
+
+ Facture Originale ou Acquittée ? + {New_Option_facture_mail && New_Option_facture_mail.length > 0 && (data).value === String(facture_mail_type))[0].label} + options={New_Option_facture_mail} + onChange={(event, value) => { + if (value && value.value) { + setfacture_mail_type(value.value); + } else { + setfacture_mail_type(""); + } + + }} + + renderInput={(params) => + } + />} + +
+
+   +
+ +
+ Pièces jointes à la facture + +
+ +
+ +
+ +
+ + +
+ + + {tab_invoice_mail_pieces_jointes_result &&
+ +
+ Liste des pièces jointes
+ {
+ {tab_invoice_mail_pieces_jointes_result && tab_invoice_mail_pieces_jointes_result.map((val) => ( +
+
+ + +
+ ))} +
} +
+
} + + + +
+
+ + +
+ + + + + + + + + +
+
+ +
+ + +
+ +
+
+ +
+ +
+ {/* FIN Dialog envoie facture mail avec PJ */} + + + + + {/*** Paiement */} + null} + + PaperProps={{ + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '5rem', + margin: "2px", + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + + > + + Paiement + + + {Dialog_Paiement_1_message} + + + + +
Réf. Paiement + { + setp_detail_paiement_ref(e.target.value); + } + } + /> + +
+ + +
Montant + { + setp_detail_paiement_amount(e.target.value); + } + } + /> + +
+ +
Mode Paiement + + {New_Getall_Partner_Default_Paiement_Mode_result && New_Getall_Partner_Default_Paiement_Mode_result.length > 0 && + (data).label === String(p_detail_paiement_mode))[0].label} + options={New_Getall_Partner_Default_Paiement_Mode_result} + // className="disabled_style" + fullWidth + onChange={(event, value) => { + if (value && value.label) { + setp_detail_paiement_mode(value.label); + console.log(" IIII") + } else { + setp_detail_paiement_mode(""); + + } + + }} + + renderInput={(params) => + } + /> + + } + +
+ + {p_detail_paiement_date &&
Date paiement
+ { + setp_detail_paiement_date(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style session_caract_Dialog_DatePicker" + locale={'fr'} + fullWidth + + /> + +
} + +
Commentaire + { + setp_detail_paiement_comment(e.target.value); + } + } + /> + +
+ +
+ + + + + + + + +
+
+ + {String(p_detail_paiement_id).trim().length > 2 && } + {String(p_detail_paiement_id).trim() === "" && } +
+ +
+ +
+
+ +
+ +
+ + {/*** Fin Paiement */} + + + {/*** annotation */} + null} + + PaperProps={{ + + className: classes.paper, // Apply the paper style + style: { + overflowY: 'unset', + position: 'absolute', + top: '5rem', + margin: "2px", + }, + }} + hideBackdrop={true} + disableScrollLock + classes={{ + paper: classes.dialog + }} + + PaperComponent={PaperComponent} + aria-labelledby="draggable-dialog-title" + + > + + Annotation + + + {Dialog_annotation_1_message} + + + + + + { + setp_detail_header_invoice_header_annotation(e.target.value); + } + } + maxRows={10} + variant="outlined" + fullWidth + /> + + + + + + + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + {/*** Fin annotation */} + + {/******** Menu Clique Droit test */} + + { + if (p_detail_header_client_nom_id && String(p_detail_header_client_nom_id).length > 2) { + window.open( + process.env.REACT_APP_FRONT_URL + "Partner/affichage/" + String("selected_class_external_code") + "/" + String("selected_internal_url"), + '_blank' + ); + } + } + }> + ContextMenu Item 1 + + + ContextMenu Item 2 + + + + ContextMenu Item 3 + + + + {/******** FIN Menu Clique Droit test */} + +

Mes Factures

+
+
Utilisez les filtres !
+
+
+ + {New_Option_Filter && New_Option_Filter.length > 0 && (data).value === String(p_filtre1))[0].label} + options={New_Option_Filter} + onChange={(event, value) => { + if (value && value.value) { + setp_filtre1(value.value); + } else { + setp_filtre1(""); + } + if (value.value === "solde") { + setp_filtre1_value("0"); + } else { + setp_filtre1_value(""); + } + + }} + + renderInput={(params) => + } + />} + + +
+ + + + {p_filtre1 && String(p_filtre1) !== "solde" && String(p_filtre1) !== "date_creation" && + String(p_filtre1) !== "date_echeance" && String(p_filtre1) !== "montant_ttc" &&
+ {p_filtre1 && String(p_filtre1) !== "solde" && + { setp_filtre1_value(e.target.value); }} + InputProps={{ + endAdornment: ( + + { + setp_filtre1_value(""); + }} /> + + ), + }} + /> + } + + +
} + + {p_filtre1 && String(p_filtre1) === "solde" &&
+ + + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_solde_operateur(value.value); + else { + setp_filtre_solde_operateur(''); + } + + }} + + renderInput={(params) => + } + />} +
+
+ + {p_filtre_solde_operateur !== "entre" &&
+ { setp_filtre1_value(e.target.value); }} + + /> +
} + + {p_filtre_solde_operateur === "entre" &&
+
+ +
+ { setp_filtre_solde_operateur_entre_from(e.target.value); }} + + /> + +
+
+ Et + +
+
+ + { setp_filtre_solde_operateur_entre_to(e.target.value); }} + + /> +
+ +
+
} + +
} + + {p_filtre1 && String(p_filtre1) === "date_creation" &&
+ +
+ +
+ { + setp_filter_date_creation_du(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+
+ Au + +
+
+ + { + setp_filter_date_creation_au(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> +
+ +
+ +
} + + {p_filtre1 && String(p_filtre1) === "date_echeance" &&
+ + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_echeance_operateur(value.value); + else + setp_filtre_echeance_operateur(""); + }} + + renderInput={(params) => + } + />} +
+
+ +
+ +
+ + {p_filtre_echeance_operateur !== "entre" &&
+ { + setp_filter_date_echeance(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
} + + {p_filtre_echeance_operateur === "entre" &&
+
+ { + setp_filter_date_echeance_from(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+
+ Au + +
+
+ + { + setp_filter_date_echeance_to(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> +
+ +
} + + +
+ +
+
} + + {p_filtre1 && String(p_filtre1) === "montant_ttc" &&
+ + + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_montant_ttc_operateur(value.value); + else + setp_filtre_montant_ttc_operateur(""); + + }} + + renderInput={(params) => + } + />} +
+
+ + {p_filtre_montant_ttc_operateur !== "entre" &&
+ { setp_filtre1_value(e.target.value); }} + + /> +
} + + {p_filtre_montant_ttc_operateur === "entre" &&
+ +
+ +
+ { setp_filtre_montant_ttc_from(e.target.value); }} + + /> + +
+
+ Et + +
+
+ + { setp_filtre_montant_ttc_to(e.target.value); }} + + /> +
+ +
+ + +
} + +
} + + + {p_filtre1 && } + {p_filtre1 && } + + +
+ + {p_filtre2 && +
+
+ {New_Option_Filter && New_Option_Filter.length > 0 && (data).value === String(p_filtre2))[0].label} + options={New_Option_Filter} + onChange={(event, value) => { + if (value && value.value) { + setp_filtre2(value.value); + if (value.value === "solde") { + setp_filtre2_value("0"); + } else { + setp_filtre2_value(""); + } + + } + + }} + + renderInput={(params) => + } + />} +
+ + + {p_filtre2 && String(p_filtre2) !== "solde" && String(p_filtre2) !== "date_creation" && + String(p_filtre2) !== "date_echeance" && String(p_filtre2) !== "montant_ttc" &&
+ {String(p_filtre2).length > 2 && + setp_filtre2_value(e.target.value)} + InputProps={{ + endAdornment: ( + + { + setp_filtre2_value(""); + }} /> + + ), + }} + + />} +
} + + {p_filtre2 && String(p_filtre2) === "solde" && String(p_filtre2).length > 2 &&
+ + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_solde_operateur(value.value); + else + setp_filtre_solde_operateur(""); + }} + + renderInput={(params) => + } + />} +
+
+ + {p_filtre_solde_operateur !== "entre" &&
+ setp_filtre2_value(e.target.value)} + + + /> +
} + + {p_filtre_solde_operateur === "entre" &&
+
+ +
+ { setp_filtre_solde_operateur_entre_from(e.target.value); }} + + /> + +
+
+ Et + +
+
+ + { setp_filtre_solde_operateur_entre_to(e.target.value); }} + + /> +
+ +
+
} +
} + + {p_filtre2 && String(p_filtre2) === "date_creation" &&
+ +
+ +
+ { + setp_filter_date_creation_du(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+
+ Au + +
+
+ + { + setp_filter_date_creation_au(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> +
+ +
+ +
} + + + {p_filtre2 && String(p_filtre2) === "date_echeance" &&
+ + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + + if (value && value.value) { + setp_filtre_echeance_operateur(value.value); + + } + else + setp_filtre_echeance_operateur(""); + }} + + renderInput={(params) => + } + />} +
+
+ + {p_filtre_echeance_operateur !== "entre" &&
+ +
+ +
+ { + setp_filter_date_echeance(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+ + +
+ +
} + + {p_filtre_echeance_operateur === "entre" &&
+ +
+ { + setp_filter_date_echeance_from(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+
+ Au + +
+ +
+ + { + setp_filter_date_echeance_to(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> +
+ +
} + +
} + + {p_filtre2 && String(p_filtre2) === "montant_ttc" &&
+ + + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + + if (value && value.value) { + setp_filtre_montant_ttc_operateur(value.value); + + } + else + setp_filtre_montant_ttc_operateur(""); + + }} + + renderInput={(params) => + } + />} +
+
+ + {p_filtre_montant_ttc_operateur !== "entre" &&
+ { setp_filtre2_value(e.target.value); }} + + /> +
} + + {p_filtre_montant_ttc_operateur === "entre" &&
+ +
+ +
+ { setp_filtre_montant_ttc_from(e.target.value); }} + + /> + +
+
+ Et + +
+
+ + { setp_filtre_montant_ttc_to(e.target.value); }} + + /> +
+ +
+ + +
} + +
} + + + + {String(p_filtre2).length > 2 && } + + {String(p_filtre2).length > 2 && } + +
+ } + + + {p_filtre3 && +
+
+ {New_Option_Filter && New_Option_Filter.length > 0 && (data).value === String(p_filtre3))[0].label} + options={New_Option_Filter} + onChange={(event, value) => { + if (value && value.value) { + setp_filtre3(value.value); + + if (value.value === "solde") { + setp_filtre3_value("0"); + } else { + setp_filtre3_value(""); + } + + } + + }} + + renderInput={(params) => + } + />} +
+ {p_filtre3 && String(p_filtre3) !== "solde" && String(p_filtre3) !== "date_creation" && String(p_filtre3) !== "date_echeance" + && String(p_filtre3) !== "montant_ttc" && + String(p_filtre3).length > 2 &&
+ {String(p_filtre3).length > 2 && + setp_filtre3_value(e.target.value)} + InputProps={{ + endAdornment: ( + + { + setp_filtre3_value(""); + }} /> + + ), + }} + + />} +
} + + {p_filtre3 && String(p_filtre3) === "solde" && String(p_filtre3).length > 2 &&
+ + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_solde_operateur(value.value); + else + setp_filtre_solde_operateur(""); + }} + + renderInput={(params) => + } + />} +
+
+ {p_filtre_solde_operateur !== "entre" &&
+ setp_filtre3_value(e.target.value)} + + /> +
} + + {p_filtre_solde_operateur === "entre" &&
+
+ +
+ { setp_filtre_solde_operateur_entre_from(e.target.value); }} + + /> + +
+
+ Et + +
+
+ + { setp_filtre_solde_operateur_entre_to(e.target.value); }} + + /> +
+ +
+
} + +
} + + {p_filtre3 && String(p_filtre3) === "date_creation" &&
+ +
+ +
+ { + setp_filter_date_creation_du(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+
+ Au + +
+
+ + { + setp_filter_date_creation_au(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> +
+ +
+ +
} + + + {p_filtre3 && String(p_filtre3) === "date_echeance" &&
+ + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_echeance_operateur(value.value); + else + setp_filtre_echeance_operateur(''); + }} + + renderInput={(params) => + } + />} +
+
+ +
+ +
+ + {p_filtre_echeance_operateur !== "entre" &&
+ { + setp_filter_date_echeance(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
} + + {p_filtre_echeance_operateur === "entre" &&
+
+ { + setp_filter_date_echeance_from(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> + +
+
+ Au + +
+
+ + { + setp_filter_date_echeance_to(format(date, 'd/MM/yyyy')); + + } + } + showTimeSelect={false} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style datepicker_complement" + locale={'fr'} + + /> +
+ +
} + + + + +
+ +
+
} + + {p_filtre3 && String(p_filtre3) === "montant_ttc" &&
+ + + + +
+ {New_Option_filter_montant && New_Option_filter_montant.length > 0 && { + if (value && value.value) + setp_filtre_montant_ttc_operateur(value.value); + else + setp_filtre_montant_ttc_operateur(""); + + }} + + renderInput={(params) => + } + />} +
+
+ + {p_filtre_montant_ttc_operateur !== "entre" &&
+ { setp_filtre3_value(e.target.value); }} + + /> +
} + + {p_filtre_montant_ttc_operateur === "entre" &&
+ +
+ +
+ { setp_filtre_montant_ttc_from(e.target.value); }} + + /> + +
+
+ Et + +
+
+ + { setp_filtre_montant_ttc_to(e.target.value); }} + + /> +
+ +
+ + +
} + + +
} + + + + {String(p_filtre3).length > 2 && } +
+ } + + +
+ +
+ +
+ +
+ + +
+ +
+ +
+
+ +
+ +
+ + {/*rowss_total_data && rowss_total_data.length > 0 && rowss_total_data.map((val) => ())*/} + +
+
+   + + { + setSelectionModel(newSelectionModel); + /*if (newSelectionModel.length === 1) + handleClick_edit_invoice_From_Line(newSelectionModel);*/ + if (newSelectionModel.length !== 1) { + //clean_order_detail_fields(); + //setsubmenu(); + setdisplay_detail_invoice(); + + } + }} + + + + onRowDoubleClick={(newSelectionModel) => { + GetCurrentPartnerClass(); + Getall_Partner_Paiement_Condition(); + setInvoice_data_changed(""); + setInvoice_data_edit_mode(""); + Getall_Partner_Product_Service(); + setgridline_id(newSelectionModel.row.id); + setp_detail_header_client_nom_id(newSelectionModel.row.order_header_client_id); + handleClick_edit_invoice_From_Line(newSelectionModel.row.id); + + if (newSelectionModel.row.invoice_header_type === "brouillon") { + setis_document_invoiced("0"); + } else { + setis_document_invoiced("1"); + } + } + } + selectionModel={selectionModel} + + localeText={frFR.components.MuiDataGrid.defaultProps.localeText} + rows={rowss.map((item, index) => ( + { + id: index, + _id: JSON.parse(item)._id, + order_header_ref_interne: JSON.parse(item).order_header_ref_interne, + + invoice_header_ref_interne: JSON.parse(item).invoice_header_ref_interne, + invoice_header_type: JSON.parse(item).invoice_header_type, + order_header_date_expiration: JSON.parse(item).order_header_date_expiration, + invoice_date: JSON.parse(item).invoice_date, + total_header_hors_taxe_after_header_reduction: JSON.parse(item).total_header_hors_taxe_after_header_reduction, + total_header_hors_taxe_before_header_reduction: JSON.parse(item).total_header_hors_taxe_before_header_reduction, + + invoice_date_echeance: JSON.parse(item).invoice_date_echeance, + + order_header_tax_amount: JSON.parse(item).order_header_tax_amount, + total_header_toutes_taxes: JSON.parse(item).total_header_toutes_taxes, + order_header_client_id: JSON.parse(item).order_header_client_id, + order_header_client_nom: JSON.parse(item).order_header_client_nom, + order_header_vendeur_id: JSON.parse(item).order_header_vendeur_id, + order_header_vendeur_nom_prenom: JSON.parse(item).order_header_vendeur_nom_prenom, + order_header_date_cmd: JSON.parse(item).order_header_date_cmd, + + reste_to_paye: JSON.parse(item).reste_to_paye, + credit_note_ref: JSON.parse(item).credit_note_ref, + invoice_header_origin: JSON.parse(item).invoice_header_origin, + + } + ))} + + columns={columns} + pageSize={10} + className="datagridclass" + + rowsPerPageOptions={[10]} + //disableSelectionOnClick + /* components={{ + Toolbar: GridToolbar, + }}*/ + + + //sx={datagridSx} + getCellClassName={(params) => { + + }} + getRowClassName={(params) => { + + if (parseInt(parseFloat(params.row.reste_to_paye)) <= 0 && String(params.row.invoice_header_type) === "facture") { + + return 'line--statut--payed'; + } + + // Pour la gestion de la couleur de zone double cliquée + if (String(params.row.id) === String(gridline_id)) { + return 'line--statut--selected'; + } + else if (parseInt(String(params.row.id)) % 2 === 0) { + return 'line--statut--pair'; + } + else if (parseInt(String(params.row.id)) % 2 !== 0) { + return 'line--statut--impair'; + } + }} + + + /> + +
+ +
+ + +
+ +
+ +
+ + {String(props.check_user_acces_right("facture", "write")) === "1" &&
+ + + + + + + +
} +
+ +
+ +
 
+ {String(display_detail_invoice) === "1" && +
+ {p_detail_header_invoice_header_type === "brouillon" && } + {p_detail_header_invoice_header_type !== "brouillon" && } + +
+
+
+ {String(Invoice_data_changed) === "1" && String(Invoice_data_edit_mode) === "1" &&
+ /!\ Pensez à enregistrer les modifications +
} +
+ + + + {p_detail_header_invoice_header_type !== "brouillon" && } + + +
+ + {String(header_submenu) !== "paiement" &&
+ + + ------- +
+ +
+
+
+ +
+ Infos Facture +
+ +
+ + + + {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && + Invoice_data_edit_mode !== "1" &&
+ +
Num Facture
+ +
+ +
Type Document
+ +
+ +
Date Facture
+ +
+ + + + +
Ref. Commande
+ +
+ +
Conditions Paiement
+ + {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + + />} +
+ +
Date Commande
+ +
+ + + + + + + +
Email Client
+ +
+ + +
Commande Ref. Externe
+ +
+ +
Description
+ +
+ +
Commentaire
+ +
+ +
Vendeur
+ +
+ +
} + + + {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && + Invoice_data_edit_mode === "1" &&
+ +
Num Facture
+ +
+ +
Type Document
+ +
+ +
Date Facture
+ { + setp_detail_header_invoice_date(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + +
+ + + + +
Ref. Commande
+ { + setp_detail_header_ref_interne(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Conditions Paiement
+ {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + setInvoice_data_changed("1"); + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + setp_detail_header_condition_paiement_code(value.code); + + } else { + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + } + + }} + + renderInput={(params) => + } + />} + +
+ +
Date Commande
+ { + setp_detail_header_date_cmd(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + + +
+ + + + + + + +
Email Client
+ +
+ + +
Commande Ref. Externe
+ { + setp_detail_header_ref_client(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Description
+ { + setp_detail_header_description(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Commentaire
+ { + setp_detail_header_comment(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Vendeur
+ { + setp_detail_header_vendeur_nom(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
} + + {String(header_submenu) === "detail" &&
+
Type de Reduction (entete)
+ + +
+ + +
Valeur reduction (entete)
+ +
+ +
Montant Reduction (entete)
+ +
+ + + +
Total Ligne HT avant reduction
+ +
+ +
Total Ligne Reduction
+ +
+ +
Total Ligne HT apres reduction
+ +
+ + +
Total Ligne Taxes
+ +
+ +
Entete : Total reduction
+ +
+ + + +
Entete : Total HT avant reduction d'entete
+ +
+ +
Entete : Total HT apres reduction d'entete
+ +
+ +
} + + {String(header_submenu) === "facturation" && Invoice_data_edit_mode !== "1" &&
+ + + + +
Date échéance
+ +
+ +
Adresse Facturation
+ +
+ +
Code postal
+ +
+ +
Ville
+ +
+ +
Pays
+ +
+ +
Lieu Formation
+ + + +
+ + + {/* +
Adresse Livraison
+ +
+ +
Code postal
+ +
+ +
Ville
+ +
+ +
Pays
+ +
*/} + + +
} + + + {String(header_submenu) === "facturation" && Invoice_data_edit_mode === "1" && p_detail_header_invoice_header_type === "brouillon" && +
+ +
Condition Paiement  
+ {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + setInvoice_data_changed("1"); + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + setp_detail_header_condition_paiement_code(value.code); + setp_detail_header_condition_paiement(value.code) + + } else { + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + setp_detail_header_condition_paiement("") + } + + }} + + renderInput={(params) => + } + />} + + +
+ + +
Date échéance
+ { + setp_detail_header_date_echeance(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + + +
+ +
Adresse Facturation
+ { + setp_detail_header_fact_adr(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Code postal
+ { + setp_detail_header_fact_code_postal(e.target.value); + setInvoice_data_changed("1"); + } + } + + /> +
+ +
Ville
+ { + setp_detail_header_fact_ville(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Pays
+ { + setp_detail_header_fact_pays(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Lieu Formation
+ { + setp_detail_lieu_formation(e.target.value); + setInvoice_data_changed("1"); + } + } + /> + + +
+ + {/* + +
Adresse Livraison
+ { + setp_detail_header_liv_adr(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Code postal
+ { + setp_detail_header_liv_code_postal(e.target.value); + setInvoice_data_changed("1"); + } + } + + /> +
+ +
Ville
+ { + setp_detail_header_liv_ville(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Pays
+ { + setp_detail_header_liv_pays(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+*/} + +
} + + + + + +
+
+
+ +
+ +
+ +
+
+ +
+ Actions +
+ +
+ + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Confirmer + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + Souhaitez-vous valider le document et créer la facture
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && + Imprimer pdf + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + Souhaitez-vous imprimer la Facture Originale ou la Facture acquittée ?
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && } + + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && String(history_securite_read) === "1" && } + + + +
 
+ {String(props.check_user_acces_right("facture_client", "write")) === "1" && } + + {p_detail_header_invoice_header_type === "brouillon" && <> +
 
+
 
+ } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode !== "1" && + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode === "1" && + } + + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode === "1" && + } + + + + +
 
+ + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type && String(p_detail_header_invoice_header_type) === "facture" && + String(p_detail_header_credit_note_ref) === "" && + Annuler (Avoir) + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + En confirmant cette opération, La facture sera annulée et un avoir créé .
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
} + + + +
+
+
+ +
+ + + +
+ + + ------------- + + + +
+ + {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && + Invoice_data_edit_mode !== "1" &&
+ +
Num Facture
+ +
+ +
Type Document
+ +
+ +
Date Facture
+ +
+ + + + +
Ref. Commande
+ +
+ +
Conditions Paiement
+ + {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + + />} +
+ +
Date Commande
+ +
+ + + + + + + +
Email Client
+ +
+ + +
Commande Ref. Externe
+ +
+ +
Description
+ +
+ +
Commentaire
+ +
+ +
Vendeur
+ +
+ +
} + + + {String(header_submenu) !== "detail" && String(header_submenu) !== "facturation" && + Invoice_data_edit_mode === "1" &&
+ +
Num Facture
+ +
+ +
Type Document
+ +
+ +
Date Facture
+ { + setp_detail_header_invoice_date(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + +
+ + + + +
Ref. Commande
+ { + setp_detail_header_ref_interne(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Conditions Paiement
+ {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + setInvoice_data_changed("1"); + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + setp_detail_header_condition_paiement_code(value.code); + + } else { + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + } + + }} + + renderInput={(params) => + } + />} + +
+ +
Date Commande
+ { + setp_detail_header_date_cmd(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + + +
+ + + + + + + +
Email Client
+ +
+ + +
Commande Ref. Externe
+ { + setp_detail_header_ref_client(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Description
+ { + setp_detail_header_description(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Commentaire
+ { + setp_detail_header_comment(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Vendeur
+ { + setp_detail_header_vendeur_nom(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
} + + {String(header_submenu) === "detail" &&
+
Type de Reduction (entete)
+ + +
+ + +
Valeur reduction (entete)
+ +
+ +
Montant Reduction (entete)
+ +
+ + + +
Total Ligne HT avant reduction
+ +
+ +
Total Ligne Reduction
+ +
+ +
Total Ligne HT apres reduction
+ +
+ + +
Total Ligne Taxes
+ +
+ +
Entete : Total reduction
+ +
+ + + +
Entete : Total HT avant reduction d'entete
+ +
+ +
Entete : Total HT apres reduction d'entete
+ +
+ +
} + + {String(header_submenu) === "facturation" && Invoice_data_edit_mode !== "1" &&
+ + + + +
Date échéance
+ +
+ +
Adresse Facturation
+ +
+ +
Code postal
+ +
+ +
Ville
+ +
+ +
Pays
+ +
+ +
Lieu Formation
+ + + +
+ + + {/* +
Adresse Livraison
+ +
+ +
Code postal
+ +
+ +
Ville
+ +
+ +
Pays
+ +
*/} + + +
} + + + {String(header_submenu) === "facturation" && Invoice_data_edit_mode === "1" && p_detail_header_invoice_header_type === "brouillon" && +
+ +
Condition Paiement  
+ {New_Getall_Partner_Paiement_Condition_result && New_Getall_Partner_Paiement_Condition_result.length > 0 && + (data)._id === String(p_detail_header_condition_paiement_id))[0].label} + options={New_Getall_Partner_Paiement_Condition_result} + onChange={(event, value) => { + setInvoice_data_changed("1"); + if (value && value._id) { + setp_detail_header_condition_paiement_id(value._id); + setp_detail_header_condition_paiement_code(value.code); + setp_detail_header_condition_paiement(value.code) + + } else { + setp_detail_header_condition_paiement_id(""); + setp_detail_header_condition_paiement_code(""); + setp_detail_header_condition_paiement("") + } + + }} + + renderInput={(params) => + } + />} + + +
+ + +
Date échéance
+ { + setp_detail_header_date_echeance(format(date, 'dd/MM/yyyy')); + setInvoice_data_changed("1"); + } + } + showTimeSelect={false} + //filterTime={filterPassedTime_start} + dateFormat="dd/MM/yyyy" + className="disabled_style enable_style" + locale={'fr'} + /> + + +
+ +
Adresse Facturation
+ { + setp_detail_header_fact_adr(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Code postal
+ { + setp_detail_header_fact_code_postal(e.target.value); + setInvoice_data_changed("1"); + } + } + + /> +
+ +
Ville
+ { + setp_detail_header_fact_ville(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Pays
+ { + setp_detail_header_fact_pays(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Lieu Formation
+ { + setp_detail_lieu_formation(e.target.value); + setInvoice_data_changed("1"); + } + } + /> + + +
+ + {/* + +
Adresse Livraison
+ { + setp_detail_header_liv_adr(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Code postal
+ { + setp_detail_header_liv_code_postal(e.target.value); + setInvoice_data_changed("1"); + } + } + + /> +
+ +
Ville
+ { + setp_detail_header_liv_ville(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+ +
Pays
+ { + setp_detail_header_liv_pays(e.target.value); + setInvoice_data_changed("1"); + } + } + + + /> +
+*/} + +
} + + + +
+ +
+ {/*String(props.check_user_acces_right("facture_client", "write")) === "1" && */} + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Confirmer + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + Souhaitez-vous valider le document et créer la facture
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && + Imprimer pdf + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + Souhaitez-vous imprimer la Facture Originale ou la Facture acquittée ?
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && } + + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && String(history_securite_read) === "1" && } + + + +
 
+ {String(props.check_user_acces_right("facture_client", "write")) === "1" && } + + {p_detail_header_invoice_header_type === "brouillon" && <> +
 
+
 
+ } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode !== "1" && + } + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode === "1" && + } + + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type === "brouillon" && + Invoice_data_edit_mode === "1" && + } + + + + +
 
+ + + {String(props.check_user_acces_right("facture_client", "write")) === "1" && p_detail_header_invoice_header_type && String(p_detail_header_invoice_header_type) === "facture" && + String(p_detail_header_credit_note_ref) === "" && + Annuler (Avoir) + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + En confirmant cette opération, La facture sera annulée et un avoir créé .
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
} +
+ +
} + + + {String(header_submenu) === "paiement" &&
+ + {New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result && New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result.length > 0 && +
+ {New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result && +
+ + + {New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result + && New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result[0] && + New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result[0]['remaining_amount'] && + + parseFloat(New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result[0]['remaining_amount']) > 0 && } + + {New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result + && New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result[0] && + New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result[0]['remaining_amount'] && + + + parseFloat(New_Getall_Invoice_Paiement_Payed_Remain_Amounts_result[0]['remaining_amount']) <= 0 && } +
} + + +
+   + + + { + setselectionModel_paiement(newSelectionModel); + //console.log("ch selected--" + newSelectionModel_insc); + }} + selectionModel={selectionModel_paiement} + + localeText={frFR.components.MuiDataGrid.defaultProps.localeText} + rows={Getall_Invoice_Paiement_result.map((item, index) => ( + { + id: index, + _id: JSON.parse(item)._id, + invoice_id: JSON.parse(item).invoice_id, + paiement_amount: JSON.parse(item).paiement_amount, + paiement_mode: JSON.parse(item).paiement_mode, + paiement_ref: JSON.parse(item).paiement_ref, + paiement_date: JSON.parse(item).paiement_date, + + } + ))} + + columns={columns_paiement} + pageSize={10} + className="datagridclass" + + getCellClassName={(params) => { + + + }} + + onRowDoubleClick={(newSelectionModel) => { + + setgridline_paiment_id(newSelectionModel.row.id); + setp_detail_paiement_id(newSelectionModel.row._id); + Get_Given_Paiement_Data(newSelectionModel.row._id); + + setDialog_Paiement_1_open(true); + } + } + + rowsPerPageOptions={[10]} + disableSelectionOnClick + components={{ + Toolbar: GridToolbar, + }} + + getRowClassName={(params) => { + + // Pour la gestion de la couleur de zone double cliquée + if (String(params.row.id) === String(gridline_paiment_id)) { + return 'line--statut--selected'; + } + else if (parseInt(String(params.row.id)) % 2 === 0) { + return 'line--statut--pair'; + } + else if (parseInt(String(params.row.id)) % 2 !== 0) { + return 'line--statut--impair'; + } + }} + + getEstimatedRowHeight={() => 200} + getRowHeight={() => "auto"} + sx={{ + + [`& .${gridClasses.cell}`]: { + py: 1, + }, + }} + + /> + + + +
+ + +
+
+ +
+ +
+ +
+ +
+
+ + +
} +
} +
+ + + {String(header_submenu) !== "paiement" &&
+ +
+ {p_detail_header_invoice_header_type === "brouillon" && String(props.check_user_acces_right("facture", "write")) === "1" && + } + +
+   + + { + //setselectionModel_order_lines(newSelectionModel); + /*if (newSelectionModel.length === 1) + handleClick_edit_order_From_Line(newSelectionModel); + if (newSelectionModel.length !== 1) { + setsubmenu(); + setdisplay_detail_order(); + setadd_One_Order(); + }*/ + }} + selectionModel={selectionModel_invoice_lines} + + localeText={frFR.components.MuiDataGrid.defaultProps.localeText} + rows={rows_invoice_lines.map((item, index) => ( + { + id: index, + _id: JSON.parse(item)._id, + order_line_formation: JSON.parse(item).order_line_formation, + order_line_qty: JSON.parse(item).order_line_qty, + order_line_status: JSON.parse(item).order_line_status, + order_line_prix_unitaire: JSON.parse(item).order_line_prix_unitaire, + order_header_id: JSON.parse(item).order_header_id, + order_header_ref_interne: JSON.parse(item).order_header_ref_interne, + order_line_type: JSON.parse(item).order_line_type, + order_line_formation_title: JSON.parse(item).title, + order_line_formation_duration: JSON.parse(item).duration_concat, + order_line_comment: JSON.parse(item).order_line_comment, + order_line_formation_external_code: JSON.parse(item).order_line_formation_external_code, + order_line_montant_hors_taxes: JSON.parse(item).order_line_montant_hors_taxes, + + order_line_type_article: JSON.parse(item).order_line_type_article, + + order_line_session_code: JSON.parse(item).order_line_session_code, + order_line_session_id: JSON.parse(item).order_line_session_id, + invoice_line_type: JSON.parse(item).invoice_line_type, + + } + ))} + + + onRowDoubleClick={(newSelectionModel) => { + setarticle_formation_ou_produit(newSelectionModel.row.order_line_type_article); + Display_Detail_Invoice_Line_From_datagrid(newSelectionModel.row); + } + } + + columns={columns_invoice_lines} + pageSize={10} + className="datagridclass" + + rowsPerPageOptions={[10]} + //disableSelectionOnClick + components={{ + Toolbar: GridToolbar, + }} + + + /> + +
+ +
+ +
+
} +
} + + +
+ ) +} + + +export default Partner_Facture_ARG; + +const local_css = ` +:root { + --bg: #f6f8fb; + --card: #ffffff; + --text: #0f172a; + --muted: #64748b; + --border: #e5e7eb; + --shadow: 0 10px 25px rgba(2, 6, 23, .06); + --green-700: #0f6b53; + --green-600: #167a5e; + --green-100: #e9f7f1; + --blue-600: #2563eb; + --radius: 14px; + --radius-sm: 10px; +} + .Grid_2_col{ + margin-top: 12px; + display:grid; + grid-template-columns: 1.2fr 1fr; + gap: 14px; + padding:5px; +} + +.Grid_2_col_sub_colone { + background: #fff; + border: 1px solid #e5e7eb; + border-radius: 14px; + box-shadow: 0 6px 18px rgba(2,6,23,.04); + padding: 0px; + display: flex; + flex-direction: column; + gap: 14px; +} + + .Grid_1_col{ + margin-top: 12px; + display:grid; + grid-template-columns: 1fr; + gap: 14px; + padding:5px; +} + +.Grid_2_col_sub_colone_header { + background: #dbeafe; + border-top-right-radius: 10px; + border-top-left-radius: 10px; + text-align: center; + font-family: DM Sans; + font-weight: 700; + height: 2rem; + padding-top: 5px; + font-size: 15px; +} + +.Grid_2_col_sub_colone_bottom_menu{ + +} + +.card__header{ +background: #e2e8f0; + font-size: small; + text-align: center; +} + +.card__title{ + display:flex; + align-items:center; + gap: 10px; +} + +.card__icon{ + width: 34px; + height: 34px; + display:grid; + place-items:center; + border-radius: 12px; + background:#eff6ff; + border:1px solid #dbeafe; +} + +.card__header h2{ + margin:0; + font-size: 15px; + letter-spacing: -0.01em; +} + +.card__actions{ display:flex; align-items:center; gap:8px; } + +.block_detail_action{ +width: 100%; + float: left; + background: #fafafa; + padding: 10px; + border: unset; + border-radius: 10px; + } + + .react-datepicker-wrapper{ +width: 100%; + } + + .datepicker_complement { + margin: 0px !important; + width: 100% !important; +} +`; \ No newline at end of file diff --git a/src/components/Pricing.js b/src/components/Pricing.js index 93f88a8..7b0d7ba 100644 --- a/src/components/Pricing.js +++ b/src/components/Pricing.js @@ -203,7 +203,7 @@ registerLocale('fr', fr); var form = new FormData(); const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); - + form.append("is_ftion_initiale", "2"); var myurl = process.env.REACT_APP_API_URL + "myclass/api/get_partner_class/"; diff --git a/src/components/Student_Account_Ent.js b/src/components/Student_Account_Ent.js index e3580eb..c420248 100644 --- a/src/components/Student_Account_Ent.js +++ b/src/components/Student_Account_Ent.js @@ -402,7 +402,7 @@ function Student_Account_Ent() { var form = new FormData(); - + const stored_cookie = getCookie('tokenmysych'); form.append("token", stored_cookie); diff --git a/src/styles/components/_partner_facture.scss b/src/styles/components/_partner_facture.scss index db70426..8ee182f 100644 --- a/src/styles/components/_partner_facture.scss +++ b/src/styles/components/_partner_facture.scss @@ -1843,7 +1843,7 @@ .session_caract_Dialog { font-family: 'DM Sans'; - color: #0a2a4d; + color: #0a2a4d; width: 100%; padding: 5px; float: left; @@ -2342,8 +2342,9 @@ border: none; } - .datepicker_complement { + .datepicker_complement { margin: 0px !important; + width: 100% !important; } .datagridclass { @@ -2402,10 +2403,10 @@ } - .css-1v4ccyo { + .css-1v4ccyo { height: 3.5rem !important; font-size: small; - color: #0a2a4d !important; + color: #0a2a4d !important; } option { @@ -2500,8 +2501,8 @@ } .css-1t8l2tu-MuiInputBase-input-MuiOutlinedInput-input { - color: #0a2a4d !important; - + color: #0a2a4d !important; + font-size: small !important; font-family: "DM Sans" !important; padding-left: 5px !important;