diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 4a7fb3aa..37ba3e5b 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -136,8 +136,8 @@ $(document).ready(function() { function amountToUKF(amount, is_cof=false) { if (is_cof) - return Math.round(amount * (1+subvention_cof/100) * 100) / 10; - return Math.round(amount * 100) / 10; + return Math.round(amount * (1+subvention_cof/100) * 10); + return Math.round(amount * 10); } // ----- @@ -201,6 +201,7 @@ $(document).ready(function() { // Store data function storeAccountData(data) { account_data = $.extend({}, account_data_default, data); + account_data['balance'] = parseFloat(account_data['balance']); $('#id_on_acc').val(account_data['pk']); displayAccountData(); } @@ -215,7 +216,9 @@ $(document).ready(function() { }) .done(function(data) { storeAccountData(data); - articleSelect.focus(); + articleSelect.focus(); + updateBasketAmount(); + updateBasketRel(); }) .fail(function() { resetAccountData() }); } @@ -548,15 +551,18 @@ $(document).ready(function() { var basket_container = $('#basket table'); var arrowKeys = /^(37|38|39|40)$/; - function addPurchase(id, nb) { + function amountEuroPurchase(id,nb) { var i = 0; while (i'; + if (amount < 5) + basketrel_html += '
Sur 5€: '+ (5-amount).toFixed(2) +' €
'; + if (amount < 10) + basketrel_html += '
Sur 10€: '+ (10-amount).toFixed(2) +' €
'; + if (amount < 20) + basketrel_html += '
Sur 20€: '+ (20-amount).toFixed(2) +' €
'; + } else if (account_data['trigramme'] != '' && !isBasketEmpty()) { + var amount = getAmountBasket(); + var amountUKF = amountToUKF(amount, account_data['is_cof']); + var newBalance = account_data['balance'] + amount; + var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof']); + basketrel_html += '
Total: '+amountUKF+'
'; + basketrel_html += '
Nouveau solde: '+newBalanceUKF+'
'; + if (newBalance < 0) + basketrel_html += '
Manque: '+ (-newBalance).toFixed(2) +' €
'; } basketrel_container.html(basketrel_html); - }*/ + } function deleteFromBasket(opeindex) { basket_container.find('[data-opeindex='+opeindex+']').remove(); deleteFromFormset(opeindex); + updateBasketRel(); } function resetBasket() {