From 080ff0f8218d404db4d56171bdab7e0652ee654f Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 13 Dec 2016 01:41:59 -0200 Subject: [PATCH] warning if not enough stock --- kfet/static/kfet/css/kpsul.css | 5 +++++ kfet/templates/kfet/kpsul.html | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/kfet/static/kfet/css/kpsul.css b/kfet/static/kfet/css/kpsul.css index 9fd53604..8e713651 100644 --- a/kfet/static/kfet/css/kpsul.css +++ b/kfet/static/kfet/css/kpsul.css @@ -383,6 +383,11 @@ input[type=number]::-webkit-outer-spin-button { color:#FFF; } +#basket tr.low-stock { + background-color:rgba(236,100,0,0.6); + color:#FFF; +} + /* History */ .kpsul_middle_right_col { diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index a78028bf..4177c16d 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -589,7 +589,7 @@ $(document).ready(function() { }); $after.after(article_html); // Pour l'autocomplétion - articlesList.push([article['name'],article['id'],article['category_id'],article['price']]); + articlesList.push([article['name'],article['id'],article['category_id'],article['price'], article['stock']]); } function getArticles() { @@ -792,11 +792,22 @@ $(document).ready(function() { .find('.number').text(nb).end() .find('.name').text(article_data[0]).end() .find('.amount').text(amountToUKF(amount_euro, account_data['is_cof'])); + if (is_low_stock(id, nb)) + article_basket_html.addClass('low-stock'); basket_container.prepend(article_basket_html); updateBasketRel(); } } + function is_low_stock(id, nb) { + var i = 0 ; + while (i= 0 && stock < nb) ; + } + function addDeposit(amount, is_checkout=1) { var deposit_basket_html = $(item_basket_default_html); var amount = parseFloat(amount).toFixed(2); @@ -922,9 +933,12 @@ $(document).ready(function() { } else if (nb_after > 0 && nb_after <= 25) { amountEuro_after = amountEuroPurchase(id, nb_after); amountUKF_after = amountToUKF(amountEuro_after, account_data['is_cof']); - basket_container.find('[data-opeindex='+opeindex+']') - .find('.amount').text(amountUKF_after).end() - .find('.number').text(nb_after).end() ; + var article_html = basket_container.find('[data-opeindex='+opeindex+']'); + article_html.find('.amount').text(amountUKF_after).end() + .find('.number').text(nb_after).end() ; + + if (is_low_stock(id, nb_after)) + article_html.addClass('low-stock'); updateExistingFormset(opeindex, nb_after, amountEuro_after); updateBasketRel(); }