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

95 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-07-07 15:27:47 +00:00
Vn.Confirm = new Class
({
Extends: Vn.Form
2015-12-10 13:48:43 +00:00
,open: function ()
{
this.close ();
this.isOpen = true;
Vn.BasketChecker.check (this.conn,
this.onBasketCheck.bind (this));
}
,onBasketCheck: function (isOk)
{
if (isOk)
this.loadUi ();
}
2015-07-07 15:27:47 +00:00
2015-07-17 14:34:42 +00:00
,onOrderReady: function (form)
{
if (form.row < 0)
return;
if (form.get ('method') != 'PICKUP')
{
Vn.Node.show (this.$('address'));
2015-07-17 14:34:42 +00:00
Vn.Node.setText (this.$('method'), _('Agency'));
}
else
{
Vn.Node.hide (this.$('address'));
2015-07-17 14:34:42 +00:00
Vn.Node.setText (this.$('method'), _('Warehouse'));
}
}
,onImportReady: function (form)
2015-07-07 15:27:47 +00:00
{
if (form.row != -1)
this.$('total').value = form.get ('tax_base') + form.get ('vat');
else
this.$('total').value = null;
}
,disableButtons: function (disable)
{
this.$('modify').disabled = disable;
this.$('confirm').disabled = disable;
}
,onModifyClick: function ()
{
window.history.back();
}
,onConfirmClick: function ()
{
2015-08-17 18:02:14 +00:00
this.disableButtons (true);
2015-07-17 14:34:42 +00:00
this.$('confirm-query').execute ();
2015-07-07 15:27:47 +00:00
}
2015-07-17 14:34:42 +00:00
,onConfirm: function (query, resultSet)
2015-07-07 15:27:47 +00:00
{
this.disableButtons (false);
2015-07-07 15:27:47 +00:00
var res = resultSet.fetchResult ();
2015-07-17 14:34:42 +00:00
if (res)
{
Vn.Cookie.unset ('order');
2015-07-07 15:27:47 +00:00
var debt = resultSet.fetchValue ();
this._pay = debt > this.$('order-form').get ('credit');
this.$('success-dialog').show ();
2015-07-17 14:34:42 +00:00
}
2015-07-07 15:27:47 +00:00
}
,onAcceptClick: function ()
{
this.$('success-dialog').hide ();
}
,onPopupClose: function ()
{
if (this._pay)
Vn.Tpv.pay (this.conn, this.$('total').value,
2015-07-07 15:27:47 +00:00
this.$('order-form').get ('company_id'));
else
this.hash.set ({'form': 'ecomerce/orders'});
}
});