forked from verdnatura/hedera-web
95 lines
1.6 KiB
JavaScript
Executable File
95 lines
1.6 KiB
JavaScript
Executable File
|
|
Vn.Confirm = new Class
|
|
({
|
|
Extends: Vn.Form
|
|
|
|
,open: function ()
|
|
{
|
|
this.close ();
|
|
this.isOpen = true;
|
|
|
|
Vn.BasketChecker.check (this.conn,
|
|
this.onBasketCheck.bind (this));
|
|
}
|
|
|
|
,onBasketCheck: function (isOk)
|
|
{
|
|
if (isOk)
|
|
this.loadUi ();
|
|
}
|
|
|
|
,onOrderReady: function (form)
|
|
{
|
|
if (form.row < 0)
|
|
return;
|
|
|
|
if (form.get ('method') != 'PICKUP')
|
|
{
|
|
Vn.Node.show (this.$('address'));
|
|
Vn.Node.setText (this.$('method'), _('Agency'));
|
|
}
|
|
else
|
|
{
|
|
Vn.Node.hide (this.$('address'));
|
|
Vn.Node.setText (this.$('method'), _('Warehouse'));
|
|
}
|
|
}
|
|
|
|
,onImportReady: function (form)
|
|
{
|
|
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 ()
|
|
{
|
|
this.disableButtons (true);
|
|
this.$('confirm-query').execute ();
|
|
}
|
|
|
|
,onConfirm: function (query, resultSet)
|
|
{
|
|
this.disableButtons (false);
|
|
|
|
var res = resultSet.fetchResult ();
|
|
|
|
if (res)
|
|
{
|
|
Vn.Cookie.unset ('order');
|
|
|
|
var debt = resultSet.fetchValue ();
|
|
this._pay = debt > this.$('order-form').get ('credit');
|
|
|
|
this.$('success-dialog').show ();
|
|
}
|
|
}
|
|
|
|
,onAcceptClick: function ()
|
|
{
|
|
this.$('success-dialog').hide ();
|
|
}
|
|
|
|
,onPopupClose: function ()
|
|
{
|
|
if (this._pay)
|
|
Vn.Tpv.pay (this.conn, this.$('total').value,
|
|
this.$('order-form').get ('company_id'));
|
|
else
|
|
this.hash.set ({'form': 'ecomerce/orders'});
|
|
}
|
|
});
|
|
|