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

38 lines
834 B
JavaScript
Executable File

Vn.Ticket = new Class
({
Extends: Vn.Module
,activate: function ()
{
this.$('print').addEventListener ('click', this.printClicked.bind (this));
this.$('subtotal').renderer = this.subtotalRenderer.bind (this);
this.$('ticket-subtotal').func = this.subtotal;
}
,printClicked: function (event)
{
var report = window.open ('', 'report',
'resizable=yes,height=600,width=750,scrollbars=yes,menubar=no');
report.document.body.innerHTML = this.$('report').innerHTML;
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;
}
});