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

58 lines
1.5 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 myTicket_logAccess(#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);
},
repeaterFunc: function(res, form) {
var discount = res.$('discount');
discount.style.display = form.get('discount') ? 'inline' : 'none';
res.$('discount-subtotal').value = this.discountSubtotal(form);
res.$('subtotal').value = this.subtotal(form);
},
discountSubtotal: function(form) {
return form.get('quantity') * form.get('price');
},
subtotal: function(form) {
var discount = form.get('discount');
return this.discountSubtotal(form) * ((100 - discount) / 100);
},
servicesFunc: function(res, form) {
res.$('subtotal').value = form.get('quantity') * form.get('price');
},
onServicesChanged: function(model) {
this.$('services').node.style.display =
model.numRows > 0 ? 'block' : 'none';
},
onPackagesChanged: function(model) {
this.$('packages').node.style.display =
model.numRows > 0 ? 'block' : 'none';
},
});