From b8ae482a600b0205491cc34fb39acedb6254f14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Thu, 18 Aug 2016 16:38:44 +0200 Subject: [PATCH] Fin panier ? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout des infos panier en fonction du trigramme (LIQ ou compte) - Mise à jour des infos panier si le compte sélectionné change - Correction sur calcul d'un montant en UKF --- kfet/templates/kfet/kpsul.html | 63 +++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 12 deletions(-) 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() {