2015-01-23 13:09:30 +00:00
|
|
|
|
2018-08-30 13:26:05 +00:00
|
|
|
Hedera.Ticket = new Class({
|
|
|
|
Extends: Hedera.Form,
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2018-08-30 13:26:05 +00:00
|
|
|
onTicketChange: function(ticket) {
|
2016-10-27 11:22:04 +00:00
|
|
|
if (!ticket.value)
|
|
|
|
return;
|
|
|
|
|
2018-08-30 13:26:05 +00:00
|
|
|
var batch = new Sql.Batch();
|
|
|
|
batch.addValue('ticket', ticket.value);
|
2019-05-21 14:16:27 +00:00
|
|
|
this.conn.execQuery('CALL myTicket_logAccess(#ticket)', null, batch);
|
2018-08-30 13:26:05 +00:00
|
|
|
},
|
2016-10-27 11:22:04 +00:00
|
|
|
|
2018-08-30 13:26:05 +00:00
|
|
|
onTicketReady: function(form) {
|
|
|
|
if (form.get('method') != 'PICKUP')
|
|
|
|
Vn.Node.setText(this.$('method'), _('Agency'));
|
2018-02-06 08:57:05 +00:00
|
|
|
else
|
2018-08-30 13:26:05 +00:00
|
|
|
Vn.Node.setText(this.$('method'), _('Warehouse'));
|
|
|
|
},
|
|
|
|
|
|
|
|
onPrintClick: function() {
|
2022-05-05 13:56:17 +00:00
|
|
|
let params = Vn.Url.makeUri({
|
|
|
|
authorization: this.conn.token,
|
|
|
|
ticketId: this.$('ticket-id').value,
|
|
|
|
recipientId: this.gui.user.id,
|
|
|
|
type: 'deliveryNote'
|
|
|
|
});
|
|
|
|
window.open(`/api/report/delivery-note?${params}`);
|
2018-08-30 13:26:05 +00:00
|
|
|
},
|
2022-05-05 13:56:17 +00:00
|
|
|
|
2018-08-30 13:26:05 +00:00
|
|
|
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);
|
|
|
|
},
|
2020-10-23 10:10:41 +00:00
|
|
|
|
|
|
|
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';
|
|
|
|
},
|
2018-08-30 13:26:05 +00:00
|
|
|
|
|
|
|
onPackagesChanged: function(model) {
|
2018-01-05 12:57:35 +00:00
|
|
|
this.$('packages').node.style.display =
|
|
|
|
model.numRows > 0 ? 'block' : 'none';
|
2020-10-23 10:10:41 +00:00
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
|
|
|
|