/**
* App Invoice List (jquery)
*/
'use strict';
$(function () {
// Variable declaration for table
var dt_invoice_table = $('.invoice-list-table');
// Invoice datatable
if (dt_invoice_table.length) {
var dt_invoice = dt_invoice_table.DataTable({
ajax: assetsPath + 'json/invoice-list.json', // JSON file to add data
columns: [
// columns according to JSON
{ data: '' },
{ data: 'invoice_id' },
{ data: 'invoice_status' },
{ data: 'issued_date' },
{ data: 'client_name' },
{ data: 'total' },
{ data: 'balance' },
{ data: 'invoice_status' },
{ data: 'action' }
],
columnDefs: [
{
// For Responsive
className: 'control',
responsivePriority: 2,
searchable: false,
targets: 0,
render: function (data, type, full, meta) {
return '';
}
},
{
// Invoice ID
targets: 1,
render: function (data, type, full, meta) {
var $invoice_id = full['invoice_id'];
// Creates full output for row
var $row_output = '#' + $invoice_id + '';
return $row_output;
}
},
{
// Invoice status
targets: 2,
render: function (data, type, full, meta) {
var $invoice_status = full['invoice_status'],
$due_date = full['due_date'],
$balance = full['balance'];
var roleBadgeObj = {
Sent: '',
Draft:
'',
'Past Due':
'',
'Partial Payment':
'',
Paid: '',
Downloaded:
''
};
return (
" Balance: ' +
$balance +
'
Due Date: ' +
$due_date +
"'>" +
roleBadgeObj[$invoice_status] +
''
);
}
},
{
// Client name and Service
targets: 3,
responsivePriority: 4,
render: function (data, type, full, meta) {
var $name = full['client_name'],
$service = full['service'],
$image = full['avatar_image'],
$rand_num = Math.floor(Math.random() * 11) + 1,
$user_img = $rand_num + '.png';
if ($image === true) {
// For Avatar image
var $output =
'';
} else {
// For Avatar badge
var stateNum = Math.floor(Math.random() * 6),
states = ['success', 'danger', 'warning', 'info', 'primary', 'secondary'],
$state = states[stateNum],
$name = full['client_name'],
$initials = $name.match(/\b\w/g) || [];
$initials = (($initials.shift() || '') + ($initials.pop() || '')).toUpperCase();
$output = '' + $initials + '';
}
// Creates full output for row
var $row_output =
'