2015-01-23 13:09:30 +00:00
|
|
|
|
2015-02-01 03:21:54 +00:00
|
|
|
Vn.Basket = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
|
|
|
Extends: Vn.Module
|
|
|
|
|
2015-07-28 19:14:26 +00:00
|
|
|
,open: function ()
|
|
|
|
{
|
|
|
|
if (this.basketChecked)
|
|
|
|
this.parent ();
|
|
|
|
}
|
|
|
|
|
2015-07-10 12:30:08 +00:00
|
|
|
,activate: function ()
|
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
Vn.BasketChecker.check (this.conn,
|
2015-07-15 13:39:07 +00:00
|
|
|
this.onBasketCheck.bind (this));
|
2015-07-10 12:30:08 +00:00
|
|
|
}
|
2015-02-01 03:21:54 +00:00
|
|
|
|
2015-07-28 19:14:26 +00:00
|
|
|
,onBasketCheck: function (isOk)
|
2015-02-01 03:21:54 +00:00
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
if (!isOk)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.basketChecked = true;
|
|
|
|
this.open ();
|
2015-02-01 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 12:06:19 +00:00
|
|
|
,onConfigureClick: function ()
|
2015-02-01 03:21:54 +00:00
|
|
|
{
|
2015-08-17 18:02:14 +00:00
|
|
|
Htk.Toast.showWarning (_('RememberReconfiguringImpact'));
|
2015-07-10 12:30:08 +00:00
|
|
|
this.hash.set ({'form': 'ecomerce/checkout'});
|
2015-02-01 03:21:54 +00:00
|
|
|
}
|
2015-06-30 12:06:19 +00:00
|
|
|
|
|
|
|
,onCheckoutClick: function ()
|
2015-02-01 03:21:54 +00:00
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
this.hash.set ({'form': 'ecomerce/confirm'});
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,amountRender: function (renderer, form)
|
|
|
|
{
|
|
|
|
var amount = form.get ('amount');
|
|
|
|
var grouping = form.get ('grouping');
|
|
|
|
|
|
|
|
if (amount && grouping)
|
|
|
|
renderer.value = amount / grouping;
|
|
|
|
else
|
|
|
|
renderer.value = null;
|
|
|
|
}
|
|
|
|
|
2015-03-27 19:10:49 +00:00
|
|
|
,onAmountChange: function (renderer, row, newValue)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
var model = this.$('items');
|
2015-01-23 13:09:30 +00:00
|
|
|
model.set (row, 'amount', newValue * model.get (row, 'grouping'));
|
|
|
|
}
|
|
|
|
|
2015-07-07 15:27:47 +00:00
|
|
|
,featuresRender: function (renderer, form)
|
|
|
|
{
|
|
|
|
renderer.value = form.get ('Medida') +' '+ form.get ('Categoria') +' '+ form.get ('Color');
|
|
|
|
}
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
,stemsRender: function (renderer, form)
|
|
|
|
{
|
2015-07-07 15:27:47 +00:00
|
|
|
renderer.value = Vn.Value.format (form.get ('price'), '%.2d€') +' x '+ form.get ('amount');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
if (form.get ('amount') > form.get ('available'))
|
|
|
|
renderer.td.className = 'available-exceeded';
|
|
|
|
else
|
|
|
|
renderer.td.className = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
,subtotalRender: function (renderer, form)
|
|
|
|
{
|
|
|
|
renderer.value = this.subtotal (form);
|
|
|
|
}
|
|
|
|
|
|
|
|
,subtotal: function (form)
|
|
|
|
{
|
2015-06-30 12:06:19 +00:00
|
|
|
return form.get ('amount') * form.get ('price');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,availableRender: function (renderer, form)
|
|
|
|
{
|
|
|
|
if (form.get ('amount') > form.get ('avail'))
|
|
|
|
renderer.value = 'unavailable';
|
|
|
|
else
|
|
|
|
renderer.value = 'invisible';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-10 12:30:08 +00:00
|
|
|
|
|
|
|
|