$(function () { ;('use strict') // variables var form = $('.validate-form'), assetPath = '../../../app-assets/', dtInvoiceTable = $('.invoice-list-table'), invoicePreview = 'app-invoice-preview.html', invoiceEdit = 'app-invoice-edit.html', accountNumberMask = $('.account-number-mask'), accountZipCode = $('.account-zip-code'), select2 = $('.select2'), cancelSubscription = document.querySelector('.cancel-subscription') if ($('body').attr('data-framework') === 'laravel') { assetPath = $('body').attr('data-asset-path') invoicePreview = assetPath + 'app/invoice/preview' invoiceEdit = assetPath + 'app/invoice/edit' } // jQuery Validation for all forms // -------------------------------------------------------------------- if (form.length) { form.each(function () { var $this = $(this) $this.validate({ rules: { addCard: { required: true }, companyName: { required: true }, billingEmail: { required: true } } }) $this.on('submit', function (e) { e.preventDefault() }) }) } // cancel subscription button if (cancelSubscription) { cancelSubscription.onclick = function () { Swal.fire({ text: 'Are you sure you would like to cancel your subscription?', icon: 'warning', showCancelButton: true, confirmButtonText: 'Yes', customClass: { confirmButton: 'btn btn-primary', cancelButton: 'btn btn-outline-danger ms-1' }, buttonsStyling: false }).then(function (result) { if (result.value) { Swal.fire({ icon: 'success', title: 'Unsubscribed!', text: 'Your subscription cancelled successfully.', customClass: { confirmButton: 'btn btn-success' } }) } else if (result.dismiss === Swal.DismissReason.cancel) { Swal.fire({ title: 'Cancelled', text: 'Unsubscription Cancelled!!', icon: 'error', customClass: { confirmButton: 'btn btn-success' } }) } }) } } //phone if (accountNumberMask.length) { accountNumberMask.each(function () { new Cleave($(this), { phone: true, phoneRegionCode: 'US' }) }) } //zip code if (accountZipCode.length) { accountZipCode.each(function () { new Cleave($(this), { delimiter: '', numeral: true }) }) } // For all Select2 if (select2.length) { select2.each(function () { var $this = $(this) $this.wrap('
') $this.select2({ dropdownParent: $this.parent() }) }) } // datatable if (dtInvoiceTable.length) { var dtInvoice = dtInvoiceTable.DataTable({ ajax: assetPath + 'data/invoice-list.json', // JSON file to add data autoWidth: false, pageLength: 6, columns: [ // columns according to JSON { data: 'responsive_id' }, { data: 'invoice_id' }, { data: 'invoice_status' }, { data: 'issued_date' }, { data: 'due_date' }, { data: 'total' }, { data: 'balance' }, { data: 'invoice_status' }, { data: '' } ], columnDefs: [ { // For Responsive className: 'control', responsivePriority: 2, targets: 0 }, { // Invoice ID targets: 1, width: '46px', render: function (data, type, full, meta) { var $invoiceId = full['invoice_id'] // Creates full output for row var $rowOutput = ' #' + $invoiceId + '' return $rowOutput } }, { // Invoice status targets: 2, width: '42px', render: function (data, type, full, meta) { var $invoiceStatus = full['invoice_status'], $dueDate = full['due_date'], $balance = full['balance'], roleObj = { Sent: { class: 'bg-light-secondary', icon: 'send' }, Paid: { class: 'bg-light-success', icon: 'check-circle' }, Draft: { class: 'bg-light-primary', icon: 'save' }, Downloaded: { class: 'bg-light-info', icon: 'arrow-down-circle' }, 'Past Due': { class: 'bg-light-danger', icon: 'info' }, 'Partial Payment': { class: 'bg-light-warning', icon: 'pie-chart' } } return ( " Balance: ' + $balance + '