Modal.Invoice = Modal.Invoice || {}; Modal.Invoice.ApplyPayment = class extends _modal { /** * Get class name. * @return {string} */ getClassName() { return 'Modal.Invoice.ApplyPayment'; } /** * * @param {object} parameters * @param {number} parameters.id * @param {jQuery} parameters.$context * @param {function()} parameters.onApply */ constructor(parameters) { super(parameters); this.init(); } /** * Initialize modal. */ init() { let me = this; Server.call( this.getURI(), { func: 'apiGetModal', id: me.parameters.id }, function (data) { me.create( data.modal_id, data.modal, function () { me.applyPayment( () => { if ($.isFunction(me.parameters.onApply)) { me.parameters.onApply(); } me.close(); } ); return false; } ); me.bind(); }, this.parameters.$context, 'Loading apply payment modal...' ); } /** * Apply payment to invoice. * @param {function()} callback */ applyPayment(callback) { Server.call( this.getURI(), { func: 'apiApplyPayment', form: this.form(null, 'get values') }, function (data) { if ($.isFunction(callback)) { callback(); } }, null, 'Applying payment to invoice...' ); } };