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() { let params = Vn.Url.makeUri({ authorization: this.conn.token, recipientId: this.gui.user.id, type: 'deliveryNote' }); window.open(`/api/Tickets/${this.$('ticket-id').value}/delivery-note-pdf?${params}`); }, 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'; }, });