forked from DGNum/gestioCOF
- Affichage des prix/solde de compte en UKF (donc en prennant en compte le
statut COF) - Possible de sélectionner des items (charges/retraits/achats) dans le panier et de les en enlever en pressant "Suppr" - Possibilité de quitter la fenêtre de charge/retrait avec Echap (Correction effectuée dans jconfirm.js pour éviter le bug ou "Enter" ajoutait 2 fois la charge/retrait) - Ajout/Modif de raccourcis: Shift+F2 reset le panier, F2 le compte sélectionné, F3 ouvre la fenêtre de charge, Shift+F3 celle de retrait - JS : Clean des fonctions de reset/Renommage de fonctions pour être plus clair/Un peu de réorganisation
This commit is contained in:
parent
8a85125fee
commit
8c3488a610
6 changed files with 203 additions and 73 deletions
6
kfet/static/kfet/css/jquery-ui.min.css
vendored
Normal file
6
kfet/static/kfet/css/jquery-ui.min.css
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/*! jQuery UI - v1.12.0 - 2016-08-17
|
||||||
|
* http://jqueryui.com
|
||||||
|
* Includes: selectable.css
|
||||||
|
* Copyright jQuery Foundation and other contributors; Licensed MIT */
|
||||||
|
|
||||||
|
.ui-selectable{-ms-touch-action:none;touch-action:none}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}
|
|
@ -315,3 +315,8 @@ input[type=number]::-webkit-outer-spin-button {
|
||||||
padding-right:10px;
|
padding-right:10px;
|
||||||
text-align:right;
|
text-align:right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#basket tr.ui-selected, #basket tr.ui-selecting {
|
||||||
|
background-color:#C8102E;
|
||||||
|
color:#FFF;
|
||||||
|
}
|
||||||
|
|
6
kfet/static/kfet/js/jquery-confirm.js
vendored
6
kfet/static/kfet/js/jquery-confirm.js
vendored
|
@ -438,15 +438,17 @@ var jconfirm, Jconfirm;
|
||||||
} else {
|
} else {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
}/*
|
||||||
if ($.inArray(key, this.confirmKeys) !== -1) {
|
if ($.inArray(key, this.confirmKeys) !== -1) {
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* Confirm key pressed.
|
* Confirm key pressed.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
if (this.$confirmButton) {
|
if (this.$confirmButton) {
|
||||||
this.$confirmButton.click();
|
this.$confirmButton.click();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
},
|
},
|
||||||
setDialogCenter: function () {
|
setDialogCenter: function () {
|
||||||
if (this.$contentPane.css('display') == 'none') {
|
if (this.$contentPane.css('display') == 'none') {
|
||||||
|
|
6
kfet/static/kfet/js/jquery-ui.min.js
vendored
Normal file
6
kfet/static/kfet/js/jquery-ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -2,9 +2,11 @@
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
|
|
||||||
{% block extra_head %}
|
{% block extra_head %}
|
||||||
|
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/jquery-ui.min.css' %}">
|
||||||
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/kpsul_grid.css' %}">
|
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/kpsul_grid.css' %}">
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -130,6 +132,14 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var subvention_cof = 25;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Account data management
|
// Account data management
|
||||||
// -----
|
// -----
|
||||||
|
@ -142,7 +152,7 @@ $(document).ready(function() {
|
||||||
'pk' : 0,
|
'pk' : 0,
|
||||||
'name' : '',
|
'name' : '',
|
||||||
'email': '',
|
'email': '',
|
||||||
'is_cof' : false,
|
'is_cof' : '',
|
||||||
'promo' : '',
|
'promo' : '',
|
||||||
'balance': '',
|
'balance': '',
|
||||||
'trigramme' : '',
|
'trigramme' : '',
|
||||||
|
@ -153,8 +163,15 @@ $(document).ready(function() {
|
||||||
|
|
||||||
// Display data
|
// Display data
|
||||||
function displayAccountData() {
|
function displayAccountData() {
|
||||||
|
var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : '';
|
||||||
|
if (balance != '')
|
||||||
|
balance = amountToUKF(account_data['balance'], account_data['is_cof']);
|
||||||
for (var elem in account_data) {
|
for (var elem in account_data) {
|
||||||
$('#account-'+elem).text(account_data[elem]);
|
if (elem == 'balance') {
|
||||||
|
$('#account-balance').text(balance);
|
||||||
|
} else {
|
||||||
|
$('#account-'+elem).text(account_data[elem]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (account_data['is_frozen']) {
|
if (account_data['is_frozen']) {
|
||||||
$('#account').attr('data-balance', 'frozen');
|
$('#account').attr('data-balance', 'frozen');
|
||||||
|
@ -176,6 +193,11 @@ $(document).ready(function() {
|
||||||
displayAccountData();
|
displayAccountData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetAccount() {
|
||||||
|
resetAccountData();
|
||||||
|
triInput.val('');
|
||||||
|
}
|
||||||
|
|
||||||
// Store data
|
// Store data
|
||||||
function storeAccountData(data) {
|
function storeAccountData(data) {
|
||||||
account_data = $.extend({}, account_data_default, data);
|
account_data = $.extend({}, account_data_default, data);
|
||||||
|
@ -237,7 +259,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear data
|
// Clear data
|
||||||
function resetCheckoutData() {
|
function resetCheckout() {
|
||||||
checkout_data = checkout_data_default;
|
checkout_data = checkout_data_default;
|
||||||
$('#id_checkout').val(0);
|
$('#id_checkout').val(0);
|
||||||
checkoutInput.find('option:first').prop('selected', true);
|
checkoutInput.find('option:first').prop('selected', true);
|
||||||
|
@ -260,7 +282,7 @@ $(document).ready(function() {
|
||||||
data : { 'pk': id },
|
data : { 'pk': id },
|
||||||
})
|
})
|
||||||
.done(function(data) { storeCheckoutData(data) })
|
.done(function(data) { storeCheckoutData(data) })
|
||||||
.fail(function() { resetCheckoutData() });
|
.fail(function() { resetCheckout() });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event listener
|
// Event listener
|
||||||
|
@ -342,6 +364,7 @@ $(document).ready(function() {
|
||||||
for (var elem in article) {
|
for (var elem in article) {
|
||||||
article_html.find('.'+elem).text(article[elem])
|
article_html.find('.'+elem).text(article[elem])
|
||||||
}
|
}
|
||||||
|
article_html.find('.price').text(amountToUKF(article['price'], false));
|
||||||
var category_html = articles_container
|
var category_html = articles_container
|
||||||
.find('.category[data-category='+article['category_id']+']');
|
.find('.category[data-category='+article['category_id']+']');
|
||||||
if (category_html.length == 0) {
|
if (category_html.length == 0) {
|
||||||
|
@ -372,7 +395,7 @@ $(document).ready(function() {
|
||||||
articlesList.push([article['name'],article['id'],article['category_id'],article['price']]);
|
articlesList.push([article['name'],article['id'],article['category_id'],article['price']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArticlesData() {
|
function getArticles() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url : "{% url 'kfet.kpsul.articles_data' %}",
|
url : "{% url 'kfet.kpsul.articles_data' %}",
|
||||||
|
@ -385,6 +408,11 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetArticles() {
|
||||||
|
articles_container.find('tr').remove();
|
||||||
|
articlesList = [];
|
||||||
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Article selection
|
// Article selection
|
||||||
// -----
|
// -----
|
||||||
|
@ -392,8 +420,8 @@ $(document).ready(function() {
|
||||||
var articleSelect = $('#article_autocomplete');
|
var articleSelect = $('#article_autocomplete');
|
||||||
var articleId = $('#article_id');
|
var articleId = $('#article_id');
|
||||||
var articleNb = $('#article_number');
|
var articleNb = $('#article_number');
|
||||||
// 8:Backspace|9:Tab|13:Enter|112-117:F1-6|121:F10|122:F11|123:F12
|
// 8:Backspace|9:Tab|13:Enter|46:DEL|112-117:F1-6|121:F10|122:F11|123:F12
|
||||||
var normalKeys = /^(8|9|13|112|113|114|115|116|117|121|122|123)$/;
|
var normalKeys = /^(8|9|13|46|112|113|114|115|116|117|121|122|123)$/;
|
||||||
var articlesList = [];
|
var articlesList = [];
|
||||||
|
|
||||||
function deleteNonMatching(array, str) {
|
function deleteNonMatching(array, str) {
|
||||||
|
@ -487,29 +515,13 @@ $(document).ready(function() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
var item_basket_default_html = '<tr><td class="amount"></td><td class="number"></td><td class="name"></td></tr>';
|
|
||||||
var basket_container = $('#basket table');
|
|
||||||
var arrowKeys = /^(37|38|39|40)$/;
|
|
||||||
|
|
||||||
function addArticleToBasket(id, nb) {
|
|
||||||
var i = 0;
|
|
||||||
while (i<articlesList.length && id != articlesList[i][1]) i++;
|
|
||||||
article_data = articlesList[i];
|
|
||||||
article_basket_html = $(item_basket_default_html);
|
|
||||||
article_basket_html
|
|
||||||
.find('.number').text(nb).end()
|
|
||||||
.find('.name').text(article_data[0]).end()
|
|
||||||
.find('.amount').text(- Math.round(100 * article_data[3] * nb)/10);
|
|
||||||
basket_container.prepend(article_basket_html);
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_nb_ok(nb) {
|
function is_nb_ok(nb) {
|
||||||
return /^[0-9]+$/.test(nb) && nb > 0 && nb <= 24;
|
return /^[0-9]+$/.test(nb) && nb > 0 && nb <= 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
articleNb.on('keypress', function(e) {
|
articleNb.on('keypress', function(e) {
|
||||||
if (e.keyCode == 13 && is_nb_ok(articleNb.val()) && articleId.val() > 0) {
|
if (e.keyCode == 13 && is_nb_ok(articleNb.val()) && articleId.val() > 0) {
|
||||||
addArticleToBasket(articleId.val(), articleNb.val());
|
addPurchase(articleId.val(), articleNb.val());
|
||||||
articleSelect.val('');
|
articleSelect.val('');
|
||||||
articleNb.val('');
|
articleNb.val('');
|
||||||
articleSelect.focus();
|
articleSelect.focus();
|
||||||
|
@ -527,15 +539,112 @@ $(document).ready(function() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// -----
|
||||||
|
// Basket
|
||||||
|
// -----
|
||||||
|
|
||||||
|
var item_basket_default_html = '<tr><td class="amount"></td><td class="number"></td><td class="name"></td></tr>';
|
||||||
|
var basket_container = $('#basket table');
|
||||||
|
var arrowKeys = /^(37|38|39|40)$/;
|
||||||
|
|
||||||
|
function addPurchase(id, nb) {
|
||||||
|
var i = 0;
|
||||||
|
while (i<articlesList.length && id != articlesList[i][1]) i++;
|
||||||
|
article_data = articlesList[i];
|
||||||
|
var reduc_divisor = 1;
|
||||||
|
if (account_data['is_cof'])
|
||||||
|
reduc_divisor = 1 + subvention_cof / 100;
|
||||||
|
console.log(reduc_divisor);
|
||||||
|
var amount_euro = - article_data[3] * nb / reduc_divisor;
|
||||||
|
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
||||||
|
article_basket_html = $(item_basket_default_html);
|
||||||
|
article_basket_html
|
||||||
|
.attr('data-opeindex', index)
|
||||||
|
.find('.number').text(nb).end()
|
||||||
|
.find('.name').text(article_data[0]).end()
|
||||||
|
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof']));
|
||||||
|
basket_container.prepend(article_basket_html);
|
||||||
|
updateBasketRel();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDeposit(amount) {
|
||||||
|
var deposit_basket_html = $(item_basket_default_html);
|
||||||
|
var index = addDepositToFormset(amount);
|
||||||
|
deposit_basket_html
|
||||||
|
.attr('data-opeindex', index)
|
||||||
|
.find('.name').text('Charge').end()
|
||||||
|
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||||
|
basket_container.prepend(deposit_basket_html);
|
||||||
|
updateBasketRel();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addWithdraw(amount) {
|
||||||
|
var withdraw_basket_html = $(item_basket_default_html);
|
||||||
|
var amount = -amount;
|
||||||
|
var index = addWithdrawToFormset(amount);
|
||||||
|
withdraw_basket_html
|
||||||
|
.attr('data-opeindex', index)
|
||||||
|
.find('.name').text('Retrait').end()
|
||||||
|
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||||
|
basket_container.prepend(withdraw_basket_html);
|
||||||
|
updateBasketRel();
|
||||||
|
}
|
||||||
|
|
||||||
|
basket_container.selectable({
|
||||||
|
filter: 'tr',
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('keypress', function (e) {
|
||||||
|
if (e.keyCode == 46) {
|
||||||
|
// DEL (Suppr)
|
||||||
|
basket_container.find('.ui-selected').each(function () {
|
||||||
|
deleteFromBasket($(this).data('opeindex'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function getAmountBasket() {
|
||||||
|
var total = 0;
|
||||||
|
formset_container.find('[data-opeindex]').each(function () {
|
||||||
|
var opeindex = $(this).attr('data-opeindex');
|
||||||
|
if (!$(this).find('#id_form-'+opeindex+'-DELETE').prop('checked'))
|
||||||
|
total += parseFloat($(this).find('#id_form-'+opeindex+'-amount').val());
|
||||||
|
});
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
var basketrel_container = $('#basket_rel');
|
||||||
|
|
||||||
|
/*
|
||||||
|
function updateBasketRel() {
|
||||||
|
if (account_data['trigramme'] == 'LIQ') {
|
||||||
|
var basketrel_html = '';
|
||||||
|
} else {
|
||||||
|
var basketrel_html = 'Total: '+amountToUKF(getAmountBasket(), account_data['id_cof']);
|
||||||
|
}
|
||||||
|
basketrel_container.html(basketrel_html);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
function deleteFromBasket(opeindex) {
|
||||||
|
basket_container.find('[data-opeindex='+opeindex+']').remove();
|
||||||
|
deleteFromFormset(opeindex);
|
||||||
|
}
|
||||||
|
|
||||||
function resetBasket() {
|
function resetBasket() {
|
||||||
basket_container.find('tr').remove();
|
basket_container.find('tr').remove();
|
||||||
mngmt_total_forms = 1;
|
mngmt_total_forms = 1;
|
||||||
mngmt_total_forms_input.val(1);
|
mngmt_total_forms_input.val(1);
|
||||||
formset_container.find('div').remove();
|
formset_container.find('div').remove();
|
||||||
|
updateBasketRel();
|
||||||
|
articleId.val(0);
|
||||||
|
articleSelect.val('');
|
||||||
|
articleNb.val('');
|
||||||
|
displayMatchedArticles(articlesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Add deposit or withdraw
|
// Ask deposit or withdraw
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
function askDeposit() {
|
function askDeposit() {
|
||||||
|
@ -545,6 +654,7 @@ $(document).ready(function() {
|
||||||
backgroundDismiss: true,
|
backgroundDismiss: true,
|
||||||
animation:'top',
|
animation:'top',
|
||||||
closeAnimation:'bottom',
|
closeAnimation:'bottom',
|
||||||
|
keyboardEnabled: true,
|
||||||
confirm: function() {
|
confirm: function() {
|
||||||
var amount = this.$content.find('input').val();
|
var amount = this.$content.find('input').val();
|
||||||
if (!$.isNumeric(amount) || amount <= 0)
|
if (!$.isNumeric(amount) || amount <= 0)
|
||||||
|
@ -569,6 +679,7 @@ $(document).ready(function() {
|
||||||
backgroundDismiss: true,
|
backgroundDismiss: true,
|
||||||
animation:'top',
|
animation:'top',
|
||||||
closeAnimation:'bottom',
|
closeAnimation:'bottom',
|
||||||
|
keyboardEnabled: true,
|
||||||
confirm: function() {
|
confirm: function() {
|
||||||
var amount = this.$content.find('input').val();
|
var amount = this.$content.find('input').val();
|
||||||
if (!$.isNumeric(amount) || amount <= 0)
|
if (!$.isNumeric(amount) || amount <= 0)
|
||||||
|
@ -586,25 +697,6 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDeposit(amount) {
|
|
||||||
var deposit_basket_html = $(item_basket_default_html);
|
|
||||||
var index = addDepositToFormset(amount);
|
|
||||||
deposit_basket_html
|
|
||||||
.find('.name').text('Charge').end()
|
|
||||||
.find('.amount').text(amount);
|
|
||||||
basket_container.prepend(deposit_basket_html);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addWithdraw(amount) {
|
|
||||||
var withdraw_basket_html = $(item_basket_default_html);
|
|
||||||
var amount = -amount;
|
|
||||||
var index = addWithdrawToFormset(amount);
|
|
||||||
withdraw_basket_html
|
|
||||||
.find('.name').text('Retrait').end()
|
|
||||||
.find('.amount').text(amount);
|
|
||||||
basket_container.prepend(withdraw_basket_html);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
|
|
||||||
var depositButton = $('#operation_deposit');
|
var depositButton = $('#operation_deposit');
|
||||||
|
@ -614,7 +706,7 @@ $(document).ready(function() {
|
||||||
withdrawButton.on('click', function() { askWithdraw(); });
|
withdrawButton.on('click', function() { askWithdraw(); });
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Add operations to form
|
// Operation formset management
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
var operation_empty_html = $('#operation_empty_html')
|
var operation_empty_html = $('#operation_empty_html')
|
||||||
|
@ -628,10 +720,9 @@ $(document).ready(function() {
|
||||||
var mngmt_total_forms = 1;
|
var mngmt_total_forms = 1;
|
||||||
var prefix_regex = /__prefix__/;
|
var prefix_regex = /__prefix__/;
|
||||||
|
|
||||||
function add_operation_to_formset(type, amount, article='', article_nb='', is_checkout=1) {
|
function addOperationToFormset(type, amount, article='', article_nb='', is_checkout=1) {
|
||||||
var operation_html = operation_empty_html.clone();
|
var operation_html = operation_empty_html.clone();
|
||||||
var index = mngmt_total_forms;
|
var index = mngmt_total_forms;
|
||||||
console.log(operation_html);
|
|
||||||
|
|
||||||
operation_html.attr('data-opeindex', index);
|
operation_html.attr('data-opeindex', index);
|
||||||
|
|
||||||
|
@ -641,7 +732,6 @@ $(document).ready(function() {
|
||||||
.find('#id_form-__prefix__-article').val(article).end()
|
.find('#id_form-__prefix__-article').val(article).end()
|
||||||
.find('#id_form-__prefix__-article_nb').val(article_nb).end()
|
.find('#id_form-__prefix__-article_nb').val(article_nb).end()
|
||||||
.find('#id_form-__prefix__-is_checkout').val(is_checkout);
|
.find('#id_form-__prefix__-is_checkout').val(is_checkout);
|
||||||
console.log(operation_html);
|
|
||||||
|
|
||||||
mngmt_total_forms_input.val(index+1);
|
mngmt_total_forms_input.val(index+1);
|
||||||
mngmt_total_forms++;
|
mngmt_total_forms++;
|
||||||
|
@ -651,18 +741,25 @@ $(document).ready(function() {
|
||||||
var id = 'id_' + name;
|
var id = 'id_' + name;
|
||||||
$(this).attr({'name': name, 'id': id});
|
$(this).attr({'name': name, 'id': id});
|
||||||
});
|
});
|
||||||
console.log(operation_html);
|
|
||||||
formset_container.append(operation_html);
|
formset_container.append(operation_html);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDepositToFormset(amount, is_checkout=1) {
|
function addDepositToFormset(amount, is_checkout=1) {
|
||||||
return add_operation_to_formset('deposit', amount, '', '', is_checkout);
|
return addOperationToFormset('deposit', amount, '', '', is_checkout);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addWithdrawToFormset(amount, is_checkout=1) {
|
function addWithdrawToFormset(amount, is_checkout=1) {
|
||||||
return add_operation_to_formset('withdraw', amount, '', '', is_checkout);
|
return addOperationToFormset('withdraw', amount, '', '', is_checkout);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPurchaseToFormset(article_id, article_nb, amount=0) {
|
||||||
|
return addOperationToFormset('purchase', amount, article_id, article_nb);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFromFormset(opeindex) {
|
||||||
|
formset_container.find('#id_form-'+opeindex+'-DELETE').prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
@ -673,13 +770,14 @@ $(document).ready(function() {
|
||||||
var history_operationgroup_html = '<div class="opegroup"><div class="general"></div></div>';
|
var history_operationgroup_html = '<div class="opegroup"><div class="general"></div></div>';
|
||||||
var history_operation_html = '<div class="ope"></div>';
|
var history_operation_html = '<div class="ope"></div>';
|
||||||
|
|
||||||
function getTextOpe(ope) {
|
function getTextOpe(ope, is_cof=false) {
|
||||||
|
var amount = amountToUKF(ope['amount'], is_cof);
|
||||||
if (ope['type'] == 'deposit') {
|
if (ope['type'] == 'deposit') {
|
||||||
return ope['amount']+' € - Charge';
|
return amount + ' - Charge';
|
||||||
} else if (ope['type'] == 'withdraw') {
|
} else if (ope['type'] == 'withdraw') {
|
||||||
return ope['amount']+' € - Retrait';
|
return amount + ' - Retrait';
|
||||||
} else {
|
} else {
|
||||||
return ope['amount']+' € - '+ope['article_nb']+' '+ope['article__name'];
|
return amount +' - '+ope['article_nb']+' '+ope['article__name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,7 +801,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
ope_html
|
ope_html
|
||||||
.attr('data-ope', ope['id'])
|
.attr('data-ope', ope['id'])
|
||||||
.text(getTextOpe(ope));
|
.text(getTextOpe(ope, opegroup['is_cof']));
|
||||||
opegroup_html.append(ope_html);
|
opegroup_html.append(ope_html);
|
||||||
}
|
}
|
||||||
// Ajout du groupe
|
// Ajout du groupe
|
||||||
|
@ -723,6 +821,10 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetHistory() {
|
||||||
|
history_container.find('.opegroup').remove();
|
||||||
|
}
|
||||||
|
|
||||||
function cancelOpeGroup(opegroup) {
|
function cancelOpeGroup(opegroup) {
|
||||||
var opegroup_html = history_container.find('[data-opegroup='+opegroup['id']+']');
|
var opegroup_html = history_container.find('[data-opegroup='+opegroup['id']+']');
|
||||||
opegroup_html.find('.amount').text(opegroup['amount']);
|
opegroup_html.find('.amount').text(opegroup['amount']);
|
||||||
|
@ -775,12 +877,7 @@ $(document).ready(function() {
|
||||||
// Reset functions
|
// Reset functions
|
||||||
|
|
||||||
function coolReset(give_tri_focus=true) {
|
function coolReset(give_tri_focus=true) {
|
||||||
resetAccountData();
|
resetAccount();
|
||||||
articleId.val(0);
|
|
||||||
articleSelect.val('');
|
|
||||||
articleNb.val('');
|
|
||||||
displayMatchedArticles(articlesList);
|
|
||||||
triInput.val('');
|
|
||||||
resetBasket();
|
resetBasket();
|
||||||
if (give_tri_focus)
|
if (give_tri_focus)
|
||||||
triInput.focus();
|
triInput.focus();
|
||||||
|
@ -788,10 +885,10 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function hardReset(give_tri_focus=true) {
|
function hardReset(give_tri_focus=true) {
|
||||||
coolReset(give_tri_focus);
|
coolReset(give_tri_focus);
|
||||||
articles_container.find('tr').remove();
|
resetCheckout();
|
||||||
articlesList = [];
|
resetArticles();
|
||||||
resetCheckoutData();
|
resetHistory();
|
||||||
getArticlesData();
|
getArticles();
|
||||||
getHistory();
|
getHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,12 +901,26 @@ $(document).ready(function() {
|
||||||
coolReset();
|
coolReset();
|
||||||
return false;
|
return false;
|
||||||
case 113:
|
case 113:
|
||||||
// F2 - Deposit
|
if (e.shiftKey) {
|
||||||
askDeposit();
|
// Shift+F2 - Basket reset
|
||||||
|
resetBasket();
|
||||||
|
articleSelect.focus();
|
||||||
|
} else {
|
||||||
|
// F2 - Account reset
|
||||||
|
resetAccount();
|
||||||
|
triInput.focus();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case 114:
|
case 114:
|
||||||
// F3 - Withdraw
|
if (e.shiftKey) {
|
||||||
askWithdraw();
|
// Shift+F3 - Withdraw
|
||||||
|
askWithdraw();
|
||||||
|
articleSelect.focus();
|
||||||
|
} else {
|
||||||
|
// F3 - Withdraw
|
||||||
|
askDeposit();
|
||||||
|
articleSelect.focus();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case 121:
|
case 121:
|
||||||
// F10 - Hard reset
|
// F10 - Hard reset
|
||||||
|
|
|
@ -771,7 +771,7 @@ def kpsul_cancel_operations(request):
|
||||||
def kpsul_history(request):
|
def kpsul_history(request):
|
||||||
opegroups_list = (OperationGroup.objects
|
opegroups_list = (OperationGroup.objects
|
||||||
.values(
|
.values(
|
||||||
'id', 'amount', 'at', 'checkout_id',
|
'id', 'amount', 'at', 'checkout_id', 'is_cof',
|
||||||
'valid_by__trigramme', 'on_acc__trigramme')
|
'valid_by__trigramme', 'on_acc__trigramme')
|
||||||
.select_related('valid_by', 'on_acc')
|
.select_related('valid_by', 'on_acc')
|
||||||
.filter(at__gt=timezone.now()-timedelta(hours=4)))
|
.filter(at__gt=timezone.now()-timedelta(hours=4)))
|
||||||
|
|
Loading…
Reference in a new issue