11/09/23 - 19h

recette2
cherif 2023-09-11 19:02:11 +02:00
parent 2f07038f9c
commit 684c1a551d
1 changed files with 374 additions and 21 deletions

View File

@ -40,6 +40,7 @@ import DialogTitle from '@mui/material/DialogTitle';
import { TransitionProps } from '@mui/material/transitions';
const Partner_Commande = (props) => {
const history = useHistory();
@ -308,6 +309,9 @@ const Partner_Commande = (props) => {
setp_add_line_item_comment(String(cellValues.row.order_line_comment));
Get_Given_Line_Of_Partner_Order_Line_Data(order_line_id, order_internal_ref);
setDialog_Detail_Article_open(true);
//alert(" afficher le detail de la ligne " + String(order_line_id));
@ -629,11 +633,11 @@ const Partner_Commande = (props) => {
var mylocal_order = JSON.parse(res.data.message);
document.getElementsByName("detail_header_type")[0].value = "";
//document.getElementsByName("detail_header_type")[0].value = "";
if (mylocal_order.order_header_type)
setp_detail_header_type(mylocal_order.order_header_type);
document.getElementsByName("detail_header_status")[0].value = "";
//document.getElementsByName("detail_header_status")[0].value = "";
if (mylocal_order.order_header_status) {
setp_detail_header_statut(mylocal_order.order_header_status);
if (String(mylocal_order.order_header_status) === "0") {
@ -658,49 +662,49 @@ const Partner_Commande = (props) => {
setp_detail_header_statut_label("Brouillon");
}
document.getElementsByName("detail_header_ref_interne")[0].value = "";
//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);
}
document.getElementsByName("detail_header_ref_cient")[0].value = "";
//document.getElementsByName("detail_header_ref_cient")[0].value = "";
if (mylocal_order.order_header_ref_client) {
setp_detail_header_ref_interne(mylocal_order.order_header_ref_client);
}
document.getElementsByName("detail_header_date_cmd")[0].value = "";
//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);
}
document.getElementsByName("detail_header_date_expiration")[0].value = "";
//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);
}
document.getElementsByName("detail_nom_client")[0].value = "";
//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);
}
document.getElementsByName("detail_header_description")[0].value = "";
//document.getElementsByName("detail_header_description")[0].value = "";
if (mylocal_order.order_header_description) {
setp_detail_header_description(mylocal_order.order_header_description);
}
document.getElementsByName("detail_header_comment")[0].value = "";
//document.getElementsByName("detail_header_comment")[0].value = "";
if (mylocal_order.order_header_comment) {
setp_detail_header_comment(mylocal_order.order_header_comment);
}
document.getElementsByName("detail_header_vendeur_nom_prenom")[0].value = "";
// 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);
@ -776,7 +780,7 @@ const Partner_Commande = (props) => {
setp_detail_header_type_reduction_valeur(mylocal_order.order_header_type_reduction_valeur);
}
//document.getElementsByName("detail_header_montant_reduction")[0].value = "";
if (mylocal_order.order_header_montant_reduction) {
setp_detail_header_montant_reduction(mylocal_order.order_header_montant_reduction);
}
@ -886,6 +890,157 @@ const Partner_Commande = (props) => {
}
const [Get_Given_Line_Of_Partner_Order_Line_Data_api, setGet_Given_Line_Of_Partner_Order_Line_Data_api] = useState();
const [Get_Given_Line_Of_Partner_Order_Line_Data_message, setGet_Given_Line_Of_Partner_Order_Line_Data_message] = useState();
const [Get_Given_Line_Of_Partner_Order_Line_Data_result, setGet_Given_Line_Of_Partner_Order_Line_Data_result] = useState();
function Get_Given_Line_Of_Partner_Order_Line_Data(local_order_line_id, local_order_header_ref_interne) {
setOrder_data_changed("");
setorder_data_edit_mode("");
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("order_line_id", local_order_line_id);
form.append("order_header_ref_interne", local_order_header_ref_interne);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Line_Of_Partner_Order_Lines/";
axios.post(myurl, form).then(res => {
if (String(res.data.status) === "true") {
//console.log(" In Get_Given_Line_Of_Partner_Order_Line_Data res.data.status = " + res.data.status);
//console.log(" In Get_Given_Line_Of_Partner_Order_Line_Data res.data.message r_class = " + res.data.message);
setGet_Given_Line_Of_Partner_Order_Line_Data_api("true");
setGet_Given_Line_Of_Partner_Order_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);
}
if (mylocal_order.order_line_qty) {
setp_add_line_item_qty(mylocal_order.order_line_qty);
}
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);
}
if (mylocal_order.order_line_type_reduction) {
setp_add_line_item_type_reduction(mylocal_order.order_line_type_reduction);
}
if (mylocal_order.order_line_type_valeur) {
setp_add_line_item_reduction_value(mylocal_order.order_line_type_valeur);
}
if (mylocal_order.order_line_type) {
setp_add_line_item_type(mylocal_order.order_line_type);
}
if (mylocal_order.order_line_status) {
setp_add_line_item_status(mylocal_order.order_line_status);
}
if (mylocal_order.order_line_comment) {
setp_add_line_item_comment(mylocal_order.order_line_comment);
}
if (mylocal_order.title) {
setp_add_line_item_title(mylocal_order.title);
}
if (mylocal_order.order_line_montant_hors_taxes) {
setp_add_line_item_total_amount_ht(mylocal_order.order_line_montant_hors_taxes);
console.log(" ### mylocal_order.order_line_montant_hors_taxes = ", mylocal_order.order_line_montant_hors_taxes);
}
/*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 {
alert(" Aucune ligne commande/devis recuperée");
}
} else if (String(res.data.status) === String("Err_Connexion")) {
alert('Erreur: ' + res.data.message);
history.push("/Connexion");
}
else {
setGet_Given_Line_Of_Partner_Order_Line_Data_api("false");
setGet_Given_Line_Of_Partner_Order_Line_Data_message(res.data.message);
alert(res.data.message);
}
}).catch((error) => {
console.warn('Not good man :( Get_Given_Line_Of_Partner_Order_Line_Data = ', error);
setGet_Given_Line_Of_Partner_Order_Line_Data_api("false");
alert(" Impossible de recuperer les données de la ligne ");
//setmyApimyApiMessage("")
})
}
const hiddenFileInput_session = React.useRef(null);
function submenu_import_order() {
@ -1213,6 +1368,9 @@ const Partner_Commande = (props) => {
setOrder_data_changed("");
setorder_data_edit_mode("");
disable_Order_Header_DetailFields();
order_header_submenu_main();
}
@ -1387,7 +1545,7 @@ const Partner_Commande = (props) => {
setOrder_data_changed("");
setorder_data_edit_mode("");
Display_Detail_Order_data(selected_id);
alert(" La mise à jour du "+String(p_detail_header_type)+" été correctement faite.");
alert(" La mise à jour du " + String(p_detail_header_type) + " été correctement faite.");
if (myRef_head)
myRef_head.current.scrollIntoView({ behavior: "smooth" });
@ -1476,6 +1634,17 @@ const Partner_Commande = (props) => {
form.append("order_line_type", p_add_line_item_type);
form.append("order_line_comment", p_add_line_item_comment);
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", p_add_line_item_reduction_total_amount);
form.append("order_line_montant_hors_taxes", p_add_line_item_total_amount_ht);
form.append("order_line_tax", p_add_line_item_taxe);
form.append("order_line_tax_amount", p_add_line_item_taxe_amount);
form.append("order_line_montant_toutes_taxes", p_add_line_item_total_amount_ttc);
//onsole.log("### form = ", form);
@ -1547,6 +1716,16 @@ const Partner_Commande = (props) => {
setp_add_line_item_qty("");
setp_add_line_item_price("");
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_status(p_detail_header_statut);
setp_add_line_item_type(p_detail_header_type);
@ -1761,6 +1940,74 @@ const Partner_Commande = (props) => {
}
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();
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 total_base1 = (unit_price * qty).toFixed(2);
var total_reduction = 0;
var total_base2 = 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;
total_base2 = (total_base1 - total_reduction).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;
total_base2 = (total_base1 - total_reduction).toFixed(2);
}
else {
total_base2 = total_base1
}
console.log(" ### qty = ", qty, " ### unit_price = ", unit_price, " ### total_base1 = ", total_base1, " ### total_reduction = ",
total_reduction, ' ### total_base2 = ', total_base2, " ### reduct_value = ", reduct_value);
var montant_taxe_tva = (total_base2 * 0.2).toFixed(2);
var montant_ttc = total_base2 * 1.2; //(total_base2 + montant_taxe_tva).toFixed(2);
setp_add_line_item_reduction_total_amount(String(total_reduction));
setp_add_line_item_total_amount_ht(String(total_base2));
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));
}
function Compute_Order_Header_Price() {
if( String(Order_data_changed) === "1"){
alert(" Merci d'enregistrer les modification avant de lancer le calcul");
}
console.log(" Calcul Prix Cmd")
}
return (
@ -1809,7 +2056,7 @@ const Partner_Commande = (props) => {
label="Article"
select
fullWidth
variant="standard"
//variant="standard"
value={p_add_line_item}
onChange={(e) => {
setp_add_line_item(e.target.value);
@ -1841,11 +2088,11 @@ const Partner_Commande = (props) => {
label="Quantité"
type="number"
fullWidth
variant="standard"
//variant="standard"
value={p_add_line_item_qty}
onChange={(e) => {
setp_add_line_item_qty(e.target.value);
Recalcul_Item_Amounts();
}
}
/>
@ -1853,16 +2100,74 @@ const Partner_Commande = (props) => {
autoFocus
margin="dense"
id="ref_article_unit_price"
label="Prix Unitaie"
label="Prix Unitaire"
type="number"
fullWidth
variant="standard"
//variant="standard"
value={p_add_line_item_price}
onChange={(e) => {
setp_add_line_item_price(e.target.value);
Recalcul_Item_Amounts();
}
}
/>
<TextField
autoFocus
margin="dense"
id="ref_article_type_reduction"
label="Type reduction"
select
fullWidth
//variant="standard"
value={p_add_line_item_type_reduction}
onChange={(e) => {
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');
}
}
>
<MenuItem value="fixe" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Montant &nbsp;</MenuItem>
<MenuItem value="percent" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Pourcentage &nbsp;</MenuItem>
</TextField>
<TextField
autoFocus
margin="dense"
id="ref_article_reduction_value"
label="Reduction"
type="number"
fullWidth
//variant="standard"
value={p_add_line_item_reduction_value}
onChange={(e) => {
setp_add_line_item_reduction_value(e.target.value);
Recalcul_Item_Amounts();
}
}
/>
<TextField
autoFocus
margin="dense"
id="ref_article_reduction_total_amount"
label="Total Reduction"
type="text"
fullWidth
//variant="standard"
value={p_add_line_item_reduction_total_amount}
/>
@ -1881,10 +2186,31 @@ const Partner_Commande = (props) => {
}
}
label="Commentaire"
variant="standard"
//variant="standard"
multiline
minRows={2}
maxRows={2}
rows={2}
/>
<TextField
autoFocus
margin="dense"
id="ref_article_total_amount_ht"
label="Total HT"
type="text"
fullWidth
//variant="standard"
value={p_add_line_item_total_amount_ht}
onChange={(e) => {
setp_add_line_item_total_amount_ht(e.target.value);
}
}
/>
</DialogContent>
@ -2992,11 +3318,16 @@ const Partner_Commande = (props) => {
</TextField>
</div>}
</div>}
{String(header_submenu) === "detail" && <div>
<h3> Affichage détai header </h3>
<Button variant="outlined" onClick={Compute_Order_Header_Price} className="detail_class_submenu" id='order_header_main' name='order_header_main'>Mettre a jour prix CMD</Button>
<div className="session_caract"> Total Hors Taxes <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
@ -3064,13 +3395,13 @@ const Partner_Commande = (props) => {
/>
</div>
<div className="session_caract"> Type de Reduction <br />
{String(order_data_edit_mode) === "1" && <div className="session_caract"> Type de Reduction <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction"
id="detail_header_type_reduction"
select
InputLabelProps={{
shrink: true,
}}
@ -3083,8 +3414,30 @@ const Partner_Commande = (props) => {
}
}
>
<MenuItem value="fixe" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Montant &nbsp;</MenuItem>
<MenuItem value="percent" style={{ "paddingLeft": "5px", "textAlign": "left", "width": "100%" }} >Pourcentage &nbsp;</MenuItem>
</TextField>
</div>}
{String(order_data_edit_mode) !== "1" && <div className="session_caract"> Type de Reduction <br />
<TextField
sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
required
name="detail_header_type_reduction"
id="detail_header_type_reduction"
InputLabelProps={{
shrink: true,
}}
disabled={false}
className="disabled_style"
value={p_detail_header_type_reduction}
/>
</div>
</div>}
<div className="session_caract"> Valeur reduction <br />