2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
Vn.Ticket = new Class
|
|
|
|
({
|
|
|
|
Extends: Vn.Module
|
|
|
|
|
|
|
|
,activate: function ()
|
|
|
|
{
|
2015-03-06 23:33:54 +00:00
|
|
|
this.$('print').addEventListener ('click', this.printClicked.bind (this));
|
|
|
|
this.$('subtotal').renderer = this.subtotalRenderer.bind (this);
|
|
|
|
this.$('ticket-subtotal').func = this.subtotal;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,printClicked: function (event)
|
|
|
|
{
|
|
|
|
var report = window.open ('', 'report',
|
|
|
|
'resizable=yes,height=600,width=750,scrollbars=yes,menubar=no');
|
2015-03-07 00:56:24 +00:00
|
|
|
report.document.body.innerHTML = this.$('report').innerHTML;
|
2015-01-23 13:09:30 +00:00
|
|
|
report.print ();
|
|
|
|
}
|
|
|
|
|
|
|
|
,subtotalRenderer: function (column, form)
|
|
|
|
{
|
|
|
|
column.value = this.subtotal (form);
|
|
|
|
}
|
|
|
|
|
|
|
|
,subtotal: function (form)
|
|
|
|
{
|
|
|
|
var price = form.get ('price');
|
|
|
|
var discount = form.get ('discount');
|
|
|
|
|
|
|
|
if (price && form.get ('fixed'))
|
|
|
|
return form.get ('amount') * price * ((100 - discount) / 100);
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|