0
1
Fork 0
hedera-web-mindshore/forms/ecomerce/orders/orders.js

67 lines
1.2 KiB
JavaScript
Raw Normal View History

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