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

93 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
{
var res = resultSet.fetchResult ();
2015-07-17 14:34:42 +00:00
var debt = resultSet.fetchValue ();
2015-07-07 15:27:47 +00:00
2015-07-17 14:34:42 +00:00
if (res)
{
Vn.Cookie.unset ('order');
this.pay = debt > this.$('order-form').get ('credit');
2015-07-07 15:27:47 +00:00
2015-07-17 14:34:42 +00:00
this.popup = new Htk.Popup ();
this.popup.setChildNode (this.$('success-dialog'));
this.popup.showCenter ();
}
else
2015-08-17 18:02:14 +00:00
this.disableButtons (false);
2015-07-07 15:27:47 +00:00
}
,onAcceptClick: function ()
{
this.popup.hide ();
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'});
}
});