forked from DGNum/gestioCOF
adapt code to is_checkout removal
This commit is contained in:
parent
cadaf43131
commit
d7740e66fe
6 changed files with 105 additions and 40 deletions
|
@ -794,15 +794,27 @@ $(document).ready(function() {
|
|||
updateBasketRel();
|
||||
}
|
||||
|
||||
function addDeposit(amount, is_checkout=1) {
|
||||
function addDeposit(amount) {
|
||||
var deposit_basket_html = $(item_basket_default_html);
|
||||
var amount = parseFloat(amount).toFixed(2);
|
||||
var index = addDepositToFormset(amount, is_checkout);
|
||||
var text = is_checkout ? 'Charge' : 'Édition';
|
||||
var index = addDepositToFormset(amount);
|
||||
deposit_basket_html
|
||||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text(text).end()
|
||||
.find('.name').text('Charge').end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
basket_container.prepend(deposit_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
||||
function addEdit(amount) {
|
||||
var deposit_basket_html = $(item_basket_default_html);
|
||||
var amount = parseFloat(amount).toFixed(2);
|
||||
var index = addEditToFormset(amount);
|
||||
deposit_basket_html
|
||||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text('Édition').end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
basket_container.prepend(deposit_basket_html);
|
||||
updateBasketRel();
|
||||
|
@ -910,10 +922,9 @@ $(document).ready(function() {
|
|||
// Ask deposit or withdraw
|
||||
// -----
|
||||
|
||||
function askDeposit(is_checkout=1) {
|
||||
var title = is_checkout ? 'Montant de la charge' : "Montant de l'édition";
|
||||
function askDeposit() {
|
||||
$.confirm({
|
||||
title: title,
|
||||
title: 'Montant de la charge',
|
||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
|
@ -923,7 +934,34 @@ $(document).ready(function() {
|
|||
var amount = this.$content.find('input').val();
|
||||
if (!$.isNumeric(amount) || amount <= 0)
|
||||
return false;
|
||||
addDeposit(amount, is_checkout);
|
||||
addDeposit(amount);
|
||||
},
|
||||
onOpen: function() {
|
||||
var that = this
|
||||
this.$content.find('input').on('keydown', function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
that.$confirmButton.click();
|
||||
}
|
||||
});
|
||||
},
|
||||
onClose: function() { this._lastFocused = (articleSelect.val() ? articleNb : articleSelect) ; }
|
||||
});
|
||||
}
|
||||
|
||||
function askEdit() {
|
||||
$.confirm({
|
||||
title: "Montant de l'édition",
|
||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
closeAnimation:'bottom',
|
||||
keyboardEnabled: true,
|
||||
confirm: function() {
|
||||
var amount = this.$content.find('input').val();
|
||||
if (!$.isNumeric(amount))
|
||||
return false;
|
||||
addEdit(amount);
|
||||
},
|
||||
onOpen: function() {
|
||||
var that = this
|
||||
|
@ -988,7 +1026,7 @@ $(document).ready(function() {
|
|||
var mngmt_total_forms = 1;
|
||||
var prefix_regex = /__prefix__/;
|
||||
|
||||
function addOperationToFormset(type, amount, article='', article_nb='', is_checkout=1) {
|
||||
function addOperationToFormset(type, amount, article='', article_nb='') {
|
||||
var operation_html = operation_empty_html.clone();
|
||||
var index = mngmt_total_forms;
|
||||
|
||||
|
@ -998,8 +1036,7 @@ $(document).ready(function() {
|
|||
.find('#id_form-__prefix__-type').val(type).end()
|
||||
.find('#id_form-__prefix__-amount').val((parseFloat(amount)).toFixed(2)).end()
|
||||
.find('#id_form-__prefix__-article').val(article).end()
|
||||
.find('#id_form-__prefix__-article_nb').val(article_nb).end()
|
||||
.find('#id_form-__prefix__-is_checkout').val(is_checkout);
|
||||
.find('#id_form-__prefix__-article_nb').val(article_nb).end();
|
||||
|
||||
mngmt_total_forms_input.val(index+1);
|
||||
mngmt_total_forms++;
|
||||
|
@ -1014,12 +1051,16 @@ $(document).ready(function() {
|
|||
return index;
|
||||
}
|
||||
|
||||
function addDepositToFormset(amount, is_checkout=1) {
|
||||
return addOperationToFormset('deposit', amount, '', '', is_checkout);
|
||||
function addDepositToFormset(amount) {
|
||||
return addOperationToFormset('deposit', amount, '', '');
|
||||
}
|
||||
|
||||
function addWithdrawToFormset(amount, is_checkout=1) {
|
||||
return addOperationToFormset('withdraw', amount, '', '', is_checkout);
|
||||
function addEditToFormset(amount) {
|
||||
return addOperationToFormset('edit', amount, '', '');
|
||||
}
|
||||
|
||||
function addWithdrawToFormset(amount) {
|
||||
return addOperationToFormset('withdraw', amount, '', '');
|
||||
}
|
||||
|
||||
function addPurchaseToFormset(article_id, article_nb, amount=0) {
|
||||
|
@ -1295,7 +1336,7 @@ $(document).ready(function() {
|
|||
return false;
|
||||
case 119:
|
||||
// F8 - Edition
|
||||
askDeposit(0);
|
||||
askEdit();
|
||||
return false;
|
||||
case 120:
|
||||
// F9 - Addcost
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue