2015-01-23 13:09:30 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
Hedera.Orders = new Class({
|
|
|
|
Extends: Hedera.Form,
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
activate: function() {
|
2022-05-30 01:30:33 +00:00
|
|
|
this.tpv = new Hedera.Tpv({
|
|
|
|
conn: this.conn,
|
|
|
|
hash: this.hash
|
|
|
|
});
|
2019-02-14 15:26:13 +00:00
|
|
|
this.tpv.check(this._onTpvCheck.bind(this));
|
|
|
|
},
|
2016-01-15 12:31:08 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
_onTpvCheck: function(tpv, tpvOrder, tpvStatus) {
|
2016-01-15 12:31:08 +00:00
|
|
|
if (tpvStatus === 'ko')
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.errorDialog.show();
|
2019-02-14 15:26:13 +00:00
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
onBasketClick: function() {
|
2022-05-30 01:30:33 +00:00
|
|
|
this.hash.setAll({form: 'ecomerce/basket'});
|
2019-02-14 15:26:13 +00:00
|
|
|
},
|
2015-12-02 17:26:58 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
repeaterFunc: function(res, form) {
|
2022-05-28 01:18:06 +00:00
|
|
|
res.$.link.href = this.hash.make({
|
2017-12-14 14:33:48 +00:00
|
|
|
form: 'ecomerce/ticket',
|
2022-05-28 15:49:46 +00:00
|
|
|
ticket: form.$.id
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
2019-02-14 15:26:13 +00:00
|
|
|
},
|
2015-07-28 19:14:26 +00:00
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
// TPV
|
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
balanceConditionalFunc: function(field, value) {
|
2015-11-30 16:46:24 +00:00
|
|
|
if (value >= 0)
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.removeClass(this.$.balance, 'negative');
|
2015-01-23 13:09:30 +00:00
|
|
|
else
|
2022-05-28 01:18:06 +00:00
|
|
|
Vn.Node.addClass(this.$.balance, 'negative');
|
2019-02-14 15:26:13 +00:00
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
onPayButtonClick: function() {
|
2022-05-28 01:18:06 +00:00
|
|
|
var amount = -this.$.debt.value;
|
2015-01-23 13:09:30 +00:00
|
|
|
amount = amount <= 0 ? null : amount;
|
|
|
|
|
|
|
|
var defaultAmountStr = '';
|
|
|
|
|
2015-07-10 12:30:08 +00:00
|
|
|
if (amount !== null)
|
2019-02-14 15:26:13 +00:00
|
|
|
defaultAmountStr = Vn.Value.format(amount, '%.2d');
|
2017-12-01 14:38:23 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
amount = prompt(_('AmountToPay:'), defaultAmountStr);
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
if (amount != null) {
|
|
|
|
amount = parseFloat(amount.replace(',', '.'));
|
|
|
|
this.tpv.pay(amount, null);
|
2017-12-01 14:38:23 +00:00
|
|
|
}
|
2019-02-14 15:26:13 +00:00
|
|
|
},
|
2016-01-15 12:31:08 +00:00
|
|
|
|
2019-02-14 15:26:13 +00:00
|
|
|
onDialogResponse: function(dialog, response) {
|
2016-10-20 08:37:08 +00:00
|
|
|
if (response == Htk.Dialog.Button.RETRY)
|
2019-02-14 15:26:13 +00:00
|
|
|
this.tpv.retryPay();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|