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

69 lines
1.2 KiB
JavaScript
Executable File

Vn.Orders = new Class
({
Extends: Vn.Form
,activate: function ()
{
this.tpv = new Vn.Tpv ({conn: this.conn});
this.tpv.check (this._onTpvCheck.bind (this));
}
,_onTpvCheck: function (tpv, tpvOrder, tpvStatus)
{
if (tpvStatus === 'ko')
this.$('error-dialog').show ();
}
,onBasketClick: function ()
{
this.hash.set ({'form': 'ecomerce/basket'});
}
,repeaterFunc: function (res, form)
{
res.$('link').href = this.hash.make ({
'form': 'ecomerce/ticket',
'ticket': form.get ('ticket_id')
});
}
// TPV
,balanceConditionalFunc: function (field, value)
{
if (value >= 0)
Vn.Node.removeClass (this.$('balance'), 'negative');
else
Vn.Node.addClass (this.$('balance'), 'negative');
}
,onPayButtonClick: function ()
{
var amount = -this.$('debt').value;
amount = amount <= 0 ? null : amount;
var defaultAmountStr = '';
if (amount !== null)
defaultAmountStr = Vn.Value.format (amount, '%.2d');
var amount = parseFloat (prompt (_('AmountToPay:'), defaultAmountStr));
this.tpv.pay (amount, null);
}
,onCancelPay: function ()
{
this.$('error-dialog').hide ();
}
,onRetryPay: function ()
{
this.$('error-dialog').hide ();
this.tpv.retryPay ();
}
});