Commit 18d6f8ba by Alexis Aoun

Rajout de la popup pour le prix au kilo

Lorsque le barcode d un produit aura une valeur encode du type price_to_weight un popup s'affichera  pour confirmer que le prix au kilo est bon.
Si ce nest pas le cas un input field apparaitra permettant de rentrer la bonne valeur. Celle ci sera juste utiliser pour le calcule du poids et
ne sera pas envoye a odoo
parent 9bef85c5
...@@ -70,6 +70,7 @@ function select_product_from_bc(barcode) { ...@@ -70,6 +70,7 @@ function select_product_from_bc(barcode) {
let p = barcodes.get_corresponding_odoo_product(barcode); let p = barcodes.get_corresponding_odoo_product(barcode);
var qtyIsWeight = false; var qtyIsWeight = false;
var qtyIsPriceToWeight = false; var qtyIsPriceToWeight = false;
var priceToWeightIsCorrect = true;
console.log(p); console.log(p);
...@@ -108,10 +109,53 @@ function select_product_from_bc(barcode) { ...@@ -108,10 +109,53 @@ function select_product_from_bc(barcode) {
if(qtyIsWeight) if(qtyIsWeight)
found.data.product_qty = p.qty; found.data.product_qty = p.qty;
else if(qtyIsPriceToWeight) else if(qtyIsPriceToWeight){
found.data.product_qty = p.qty; openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed);
//On inverse en quelque sorte les boutons succes et d'annulation en mettant "Oui" sur le btn d'annulation
// et "Non" sur le bouton de reussite.
//Cela nous permet de reecrire moins de code puisque si la reponse est Oui on ne veut
//rien modifier et sortir du pop up, ce qui correspond au comportement du bouton annulation
//(ou aussi appeler cancel button)
document.querySelector('#modal_closebtn_bottom').innerHTML = 'Oui';
document.getElementById("modal_closebtn_bottom").style.backgroundColor = "green";
document.getElementsByClassName("btn--success")[0].style.backgroundColor = "red";
document.querySelector('#product_to_verify').innerHTML = p.data[0];
document.querySelector('#price_to_verify').innerHTML = p.data[6];
document.getElementById("new_price_to_weight").style.display = "none";
document.getElementsByClassName("btn--success")[0].style.display = "";
}
//TODO not the cleanest way to manage the callback, needs improvement
//TODO too much repeating code, needs refactor
function price_to_weight_confirmed(){
console.log("confirming")
if(priceToWeightIsCorrect)
found.data.product_qty = p.qty;
else
found.data.product_qty = p.value/document.getElementById("new_price_to_weight").value;
if (found.data !== null) {
setLineEdition(found.data);
if (found.place === 'to_process') {
let row = table_to_process.row($('#'+found.data.product_id[0]));
remove_from_toProcess(row, found.data);
}
}
}
function price_to_weight_is_wrong(){
document.getElementById("new_price_to_weight").style.display = "";
document.getElementsByClassName("btn--success")[0].style.display = "none";
document.querySelector('#modal_closebtn_bottom').innerHTML = 'OK';
priceToWeightIsCorrect = false;
}
if (found.data !== null) { if (found.data !== null && !qtyIsPriceToWeight) {
setLineEdition(found.data); setLineEdition(found.data);
if (found.place === 'to_process') { if (found.place === 'to_process') {
let row = table_to_process.row($('#'+found.data.product_id[0])); let row = table_to_process.row($('#'+found.data.product_id[0]));
......
...@@ -177,6 +177,12 @@ ...@@ -177,6 +177,12 @@
<div id="modal_FAQ_content"></div> <div id="modal_FAQ_content"></div>
<div id="modal_qtiesValidated"></div> <div id="modal_qtiesValidated"></div>
<div id="modal_pricesValidated"></div> <div id="modal_pricesValidated"></div>
<div id="modal_confirm_price_to_weight">
<h3>Confirmation du prix</h3>
<p>Est ce que le prix au kilo du produit <b><span id="product_to_verify"></span></b>
est bien <b><span id="price_to_verify"></span></b> euros/Kg ?</p>
<textarea name="Prix au Kilo" id="new_price_to_weight" cols="30" rows="1"></textarea>
</div>
</div> </div>
<br/> <br/>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment