55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
|
|
Hedera.Ticket = new Class
|
|
({
|
|
Extends: Hedera.Form
|
|
|
|
,onTicketChange: function (ticket)
|
|
{
|
|
if (!ticket.value)
|
|
return;
|
|
|
|
var batch = new Sql.Batch ();
|
|
batch.addValue ('ticket', ticket.value);
|
|
this.conn.execQuery ('CALL myTicketLogAccess (#ticket)', null, batch);
|
|
}
|
|
|
|
,onTicketReady: function (form)
|
|
{
|
|
if (form.get ('method') != 'PICKUP')
|
|
Vn.Node.setText (this.$('method'), _('Agency'));
|
|
else
|
|
Vn.Node.setText (this.$('method'), _('Warehouse'));
|
|
}
|
|
|
|
,onPrintClick: function ()
|
|
{
|
|
var batch = new Sql.Batch ();
|
|
batch.addValue ('ticket', this.$('ticket-id').value);
|
|
this.gui.openReport ('delivery-note', batch);
|
|
}
|
|
|
|
,subtotalRenderer: function (column, form)
|
|
{
|
|
column.value = this.subtotal (form);
|
|
}
|
|
|
|
,repeaterFunc: function (res, form)
|
|
{
|
|
res.$('subtotal').value = this.subtotal (form);
|
|
}
|
|
|
|
,subtotal: function (form)
|
|
{
|
|
var price = form.get ('price');
|
|
var discount = form.get ('discount');
|
|
return form.get ('quantity') * price * ((100 - discount) / 100);
|
|
}
|
|
|
|
,onPackagesChanged: function (model)
|
|
{
|
|
this.$('packages').node.style.display =
|
|
model.numRows > 0 ? 'block' : 'none';
|
|
}
|
|
});
|
|
|