05/06/23 - 15h

recette2
cherif 2023-06-05 14:56:59 +02:00
parent d06f050160
commit d57808f868
4 changed files with 206 additions and 34 deletions

View File

@ -30,6 +30,8 @@ import SendIcon from '@mui/icons-material/Send';
import { confirmAlert } from 'react-confirm-alert'; // Import
import { RiAddCircleLine } from "react-icons/ri";
import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif";
import 'react-tooltip/dist/react-tooltip.css'
import { Tooltip } from 'react-tooltip'
function Abonnement(props) {
@ -644,6 +646,15 @@ function Abonnement(props) {
const [new_nb_formations, setnew_nb_formations] = useState();
function Change_Partne_Nb_Ftion() {
setcode_promo_code("");
setcode_promo_type("");
setcode_promo_valeur("");
setcode_promo_text_to_display("");
sethandleOnblur_Code_Promo_api("");
sethandleOnblur_Code_Promo_result("");
sethandleOnblur_Code_Promo_message("");
setchangepartnb_ftion(true);
setnew_nb_formations(parnternbformation);
get_production_service_by_pack();
@ -676,6 +687,14 @@ function Abonnement(props) {
}
function annule_enreg_new_ftion() {
setcode_promo_code("");
setcode_promo_type("");
setcode_promo_valeur("");
setcode_promo_text_to_display("");
sethandleOnblur_Code_Promo_api("");
sethandleOnblur_Code_Promo_result("");
sethandleOnblur_Code_Promo_message("");
setchangepartnb_ftion(false);
}
@ -775,8 +794,13 @@ function Abonnement(props) {
form.append("token", stored_cookie);
form.append("periodicite", "mensuel");
form.append("discount", "0");
//form.append("discount", "0");
form.append("pack", currentpack);
form.append("discount_code", code_promo_code);
form.append("discount_type", code_promo_type);
form.append("discount_valeur", code_promo_valeur);
form.append("discount_qty", new_nb_formations);
/*
/!\ : Important, il faut preciser le nombre d'article envoyé avec ceci : form.append("nb_product", nb_article);
@ -793,12 +817,13 @@ function Abonnement(props) {
form.append("0", JSON.stringify({
"code": currentpack, "prix": packprice, "comment": "nc", "qty": new_nb_formations, "pack_products": prod_service
"code": currentpack, "prix": packprice, "comment": "nc", "qty": new_nb_formations,
"pack_products": prod_service
}));
//form.append("1", JSON.stringify({ "code": "art_supp", "prix": "120", "comment": "nc" }));
setLoading(true);
var myurl = process.env.REACT_APP_API_URL + "myclass/api/createOrder/";
@ -838,7 +863,7 @@ function Abonnement(props) {
setLoading(false);
});
// setLoading(false);
// setLoading(false);
}
@ -954,14 +979,80 @@ function Abonnement(props) {
return;
}
confirmSNEwAbonnement();
}
const [code_promo_code, setcode_promo_code] = useState("");
const [code_promo_type, setcode_promo_type] = useState("");
const [code_promo_valeur, setcode_promo_valeur] = useState("");
const [code_promo_text_to_display, setcode_promo_text_to_display] = useState("");
const [handleOnblur_Code_Promo_api, sethandleOnblur_Code_Promo_api] = useState("");
const [handleOnblur_Code_Promo_result, sethandleOnblur_Code_Promo_result] = useState("");
const [handleOnblur_Code_Promo_message, sethandleOnblur_Code_Promo_message] = useState("");
const handleOnblur_Code_Promo = (event) => {
setcode_promo_code("");
setcode_promo_type("");
setcode_promo_valeur("");
setcode_promo_text_to_display("");
sethandleOnblur_Code_Promo_api("");
sethandleOnblur_Code_Promo_result("");
sethandleOnblur_Code_Promo_message("");
setcode_promo_code(event.target.value);
//console.log(" ### event.target.value = ", event.target.value);
const formData = new FormData();
const url = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_Code_Promo/";
formData.append('token', stored_part);
formData.append('code_promo', event.target.value);
axios.post(url, formData).then(res => {
//console.log(" In getCurrentUserData res.data.status = " + res.data.status);
//console.log(" In getCurrentUserData res.data.message = " + res.data.message);
if (String(res.data.status) === "true") {
sethandleOnblur_Code_Promo_api("true");
sethandleOnblur_Code_Promo_result(res.data.message);
var mycodepromo_data = JSON.parse(res.data.message);
if (mycodepromo_data) {
//console.log(' mycodepromo_data = ', mycodepromo_data);
if (mycodepromo_data.type) {
setcode_promo_type(mycodepromo_data.type);
}
if (mycodepromo_data.valeur) {
setcode_promo_valeur(mycodepromo_data.valeur);
}
if (String(mycodepromo_data.type).toLocaleLowerCase() === "fix") {
setcode_promo_text_to_display("- " + mycodepromo_data.valeur + " €")
}
else if (String(mycodepromo_data.type).toLocaleLowerCase() === "percent") {
setcode_promo_text_to_display("- " + mycodepromo_data.valeur + " % ")
}
}
}
else {
sethandleOnblur_Code_Promo_api("false");
sethandleOnblur_Code_Promo_message(res.data.message);
}
}).catch((error) => {
console.warn('Erro handleOnblur_Code_Promo = ', error);
sethandleOnblur_Code_Promo_api("false");
})
}
return (
<div className="abonnement">
{isLoading && <div className="loader-container">
<div className="mysy_spinner"> <img src={img_loading_spin} /> </div>
{isLoading && <div className="loader-container">
<div className="mysy_spinner"> <img src={img_loading_spin} /> </div>
</div>}
@ -1011,7 +1102,7 @@ function Abonnement(props) {
}
{changepartnb_ftion && <div className="div_row_gauche pave_change_ftion" >
<div style={{ "width": "100%" }} >
<div style={{ "width": "100%", "float": "left" }} >
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
<b><u> Mesnuel </u> </b>
@ -1021,7 +1112,7 @@ function Abonnement(props) {
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "width": "100%", "float": "left" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
Nombre :
</div>
@ -1037,7 +1128,7 @@ function Abonnement(props) {
/>
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "width": "100%", "float": "left" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
Total HT :
</div>
@ -1047,27 +1138,89 @@ function Abonnement(props) {
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "width": "100%", "float": "left" }} id="div_nb_formation" className="mob_heigh">
<Tooltip id="tooltip_id_1" />
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }} className="block_remise">
<a data-tooltip-id="tooltip_id_1" data-tooltip-content="Saisir le code remise">
Code remise :
<input type="text" id="discount_val" name="discount_val"
minlength="4" maxlength="20" size="20" style={{ "width": "50%", "float": "right" }}
onBlur={handleOnblur_Code_Promo}>
</input>
</a>
</div>
{/*<div style={{ "textAlign": "right", "width": "50%", "float": "left" }} className="block_remise">
val_remise_ici
</div>*/}
{(!code_promo_text_to_display || String(code_promo_text_to_display)) === "" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }} className="block_remise">
0
</div>
}
{code_promo_text_to_display && String(code_promo_text_to_display) != "" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right", "color": "green", "fontSize": "bold" }} className="block_remise">
{code_promo_text_to_display}
</div>
}
</div>
<div style={{ "width": "100%", "float": "left" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
TVA :
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{packprice * new_nb_formations * .2}
</div>
{String(handleOnblur_Code_Promo_api) !== "true" && <div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{(packprice * new_nb_formations * 0.2).toFixed(2)}
</div>}
{String(handleOnblur_Code_Promo_api) === "true" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{String(code_promo_type) === "fix" && <nav>
{(((packprice * new_nb_formations) - parseFloat(code_promo_valeur)) * 0.2).toFixed(2)}
</nav>}
{String(code_promo_type) === "percent" && <nav>
{((((packprice * new_nb_formations) * (1 - (parseFloat(code_promo_valeur) / 100)))) * 0.2).toFixed(2)}
</nav>}
</div>}
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "width": "100%", "float": "left" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
Total TTC :
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{packprice * new_nb_formations * 1.2}
</div>
{String(handleOnblur_Code_Promo_api) !== "true" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{(packprice * new_nb_formations * 1.2).toFixed(2)}
</div>
}
{String(handleOnblur_Code_Promo_api) === "true" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{String(code_promo_type) === "fix" && <nav>
{(((packprice * new_nb_formations) - parseFloat(code_promo_valeur)) * 1.2).toFixed(2)}
</nav>}
{String(code_promo_type) === "percent" && <nav>
{((((packprice * new_nb_formations) * (1 - (parseFloat(code_promo_valeur) / 100)))) * 1.2).toFixed(2)}
</nav>}
</div>
}
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "width": "100%", "float": "left" }} id="div_nb_formation" className="mob_heigh">
<div className="pave_btn_enreg_new_nb_ftion" >
<Button className="btn_enreg_new_nb_ftion" onClick={make_new_abonnement} >Enregistrer </Button>
</div>

View File

@ -555,6 +555,9 @@ function CheckOut(props) {
form1.append("token", stored_cookie);
form1.append("pack", currentpack);
form1.append("qty", nb_formations);
form1.append("discount_code", code_promo_code);
form1.append("discount_type", code_promo_type);
form1.append("discount_valeur", code_promo_valeur);
fetch(myurl, {
method: 'POST',
@ -1299,8 +1302,8 @@ function CheckOut(props) {
<div style={{ "width": "90%", "float": "left" }}>
<Tooltip id="tooltip_id_1" />
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
<a data-tooltip-id="tooltip_id_1" data-tooltip-content="Saisir le code promo">
Code promo :
<a data-tooltip-id="tooltip_id_1" data-tooltip-content="Saisir le code remise">
Code remise :
<input type="text" id="discount_val" name="discount_val"
minlength="4" maxlength="20" size="20" style={{ "width": "50%", "float": "right" }}
onBlur={handleOnblur_Code_Promo}>
@ -1332,7 +1335,7 @@ function CheckOut(props) {
{String(handleOnblur_Code_Promo_api) !== "true" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{packprice * nb_formations }
{(packprice * nb_formations).toFixed(2) }
</div>
}
@ -1340,11 +1343,11 @@ function CheckOut(props) {
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{String(code_promo_type) === "fix" && <nav>
{((packprice * nb_formations) - parseFloat(code_promo_valeur)) }
{(((packprice * nb_formations) - parseFloat(code_promo_valeur))).toFixed(2) }
</nav>}
{String(code_promo_type) === "percent" && <nav>
{(((packprice * nb_formations) * (1 - (parseFloat(code_promo_valeur) / 100)))) }
{((((packprice * nb_formations) * (1 - (parseFloat(code_promo_valeur) / 100))))).toFixed(2) }
</nav>}
</div>
@ -1362,7 +1365,7 @@ function CheckOut(props) {
</div>
{String(handleOnblur_Code_Promo_api) !== "true" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{packprice * nb_formations * 0.2}
{(packprice * nb_formations * 0.2).toFixed(2)}
</div>}
{String(handleOnblur_Code_Promo_api) === "true" &&
@ -1386,7 +1389,7 @@ function CheckOut(props) {
{String(handleOnblur_Code_Promo_api) !== "true" &&
<div style={{ "textAlign": "right", "width": "50%", "float": "right" }}>
{packprice * nb_formations * 1.2}
{(packprice * nb_formations * 1.2).toFixed(2)}
</div>
}

View File

@ -564,7 +564,7 @@ const Partner = (props) => {
my_lms_url = (JSON.parse(res.data.message).lms_virtualhost_url) + "user_portal.php?recid=" + encodeURIComponent(JSON.parse(res.data.message).lms_part_recid) +
"&mysytoken=" + encodeURIComponent(JSON.parse(res.data.message).lms_pwd_mask);
console.log(" ### LMS url = ", my_lms_url);
//console.log(" ### LMS url = ", my_lms_url);
setpartner_lms_url(my_lms_url);
}

View File

@ -450,14 +450,16 @@
}
.pave_nb_ftion {}
.pave_nb_ftion {
width: 100% !important;
}
.pave_change_ftion {
text-align: right;
border-left: 2px solid;
padding-left: 5px;
width: 50%;
width: 100% !important;
padding-right: 1px;
}
.pave_btn_enreg_new_nb_ftion {
@ -474,6 +476,9 @@
float: left;
}
.block_remise{
width: 100% !important;
}
}
@ -669,14 +674,17 @@
}
.pave_nb_ftion {}
.pave_nb_ftion {
width: 100% !important;
}
.pave_change_ftion {
text-align: right;
border-left: 2px solid;
padding-left: 5px;
width: 50%;
width: 100% !important;
padding-right: 3px;
}
.pave_btn_enreg_new_nb_ftion {
@ -692,7 +700,8 @@
width: 100%;
float: left;
}
.block_remise{
}
}
@ -896,13 +905,17 @@
font-size: small;
}
.pave_nb_ftion {}
.pave_nb_ftion {
width: 100% !important;
}
.pave_change_ftion {
text-align: right;
border-left: 2px solid;
padding-left: 5px;
width: 100% !important;
padding-right: 3px;
}
.pave_btn_enreg_new_nb_ftion {
@ -918,6 +931,9 @@
float: left;
}
.block_remise{
}
}