warning if not enough stock
This commit is contained in:
parent
711ef7e97b
commit
080ff0f821
2 changed files with 23 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -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<articlesList.length && id != articlesList[i][1]) i++;
|
||||
article_data = articlesList[i];
|
||||
|
||||
stock = article_data[4] ;
|
||||
return (stock >= 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()
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue