73 lines
1.3 KiB
JavaScript
73 lines
1.3 KiB
JavaScript
|
|
Hedera.Orders = new Class
|
|
({
|
|
Extends: Hedera.Form
|
|
|
|
,activate: function ()
|
|
{
|
|
this.tpv = new Hedera.Tpv ({
|
|
conn: this.conn,
|
|
hash: this.hash
|
|
});
|
|
this.tpv.check (this._onTpvCheck.bind (this));
|
|
|
|
var params = this.params;
|
|
|
|
if (!params.$.from)
|
|
{
|
|
var from = new Date ();
|
|
from.setDate (from.getDate () - 30);
|
|
from.setHours (0, 0, 0, 0);
|
|
params.assign ({from: from});
|
|
}
|
|
}
|
|
|
|
,_onTpvCheck: function (tpv, tpvOrder, tpvStatus)
|
|
{
|
|
if (tpvStatus === 'ko')
|
|
this.$.errorDialog.show ();
|
|
}
|
|
|
|
,onBasketClick: function ()
|
|
{
|
|
this.hash.setAll ({form: 'ecomerce/basket'});
|
|
}
|
|
|
|
// 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.$.debt;
|
|
|
|
amount = amount <= 0 ? null : amount;
|
|
|
|
var defaultAmountStr = '';
|
|
|
|
if (amount !== null)
|
|
defaultAmountStr = Vn.Value.format (amount, '%.2d');
|
|
|
|
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 ();
|
|
}
|
|
});
|
|
|