hedera-web/forms/ecomerce/orders/orders.js

73 lines
1.3 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 ()
{
2017-04-05 14:06:07 +00:00
this.tpv = new Hedera.Tpv ({
conn: this.conn,
hash: this.hash
});
this.tpv.check (this._onTpvCheck.bind (this));
2017-03-23 16:20:51 +00:00
2017-10-10 11:58:25 +00:00
var params = this.params;
if (!params.$.from)
2017-03-30 11:44:53 +00:00
{
var from = new Date ();
2017-04-05 14:06:07 +00:00
from.setDate (from.getDate () - 30);
2017-03-30 11:44:53 +00:00
from.setHours (0, 0, 0, 0);
2017-10-10 11:58:25 +00:00
params.assign ({from: from});
2017-03-30 11:44:53 +00:00
}
}
,_onTpvCheck: function (tpv, tpvOrder, tpvStatus)
{
if (tpvStatus === 'ko')
2017-10-20 17:09:06 +00:00
this.$.errorDialog.show ();
}
2015-07-10 12:30:08 +00:00
,onBasketClick: function ()
{
2017-04-08 11:42:27 +00:00
this.hash.setAll ({form: 'ecomerce/basket'});
}
// TPV
,balanceConditionalFunc: function (field, value)
{
if (value >= 0)
2017-10-20 17:09:06 +00:00
Vn.Node.removeClass (this.$.balance, 'negative');
else
2017-10-20 17:09:06 +00:00
Vn.Node.addClass (this.$.balance, 'negative');
}
,onPayButtonClick: function ()
{
2017-10-20 17:09:06 +00:00
var amount = -this.$.debt.$.debt;
2015-02-08 15:38:38 +00:00
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-10-10 11:58:25 +00:00
amount = prompt (_('AmountToPay:'), defaultAmountStr);
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 ();
}
});