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