850 lines
443 KiB
JavaScript
850 lines
443 KiB
JavaScript
|
'use strict';
|
||
|
// Class definition
|
||
|
|
||
|
var KTDatatableModal = function() {
|
||
|
|
||
|
var initDatatable = function() {
|
||
|
var el = $('#kt_datatable');
|
||
|
|
||
|
var datatable = el.KTDatatable({
|
||
|
// datasource definition
|
||
|
data: {
|
||
|
type: 'remote',
|
||
|
source: {
|
||
|
read: {
|
||
|
url: HOST_URL + '/api/datatables/demos/customers.php',
|
||
|
},
|
||
|
},
|
||
|
pageSize: 10, // display 20 records per page
|
||
|
serverPaging: true,
|
||
|
serverFiltering: false,
|
||
|
serverSorting: true,
|
||
|
},
|
||
|
|
||
|
// layout definition
|
||
|
layout: {
|
||
|
theme: 'default',
|
||
|
scroll: false,
|
||
|
height: null,
|
||
|
footer: false,
|
||
|
},
|
||
|
|
||
|
// column sorting
|
||
|
sortable: true,
|
||
|
|
||
|
pagination: true,
|
||
|
|
||
|
search: {
|
||
|
input: el.find('#kt_datatable_search_query'),
|
||
|
key: 'generalSearch'
|
||
|
},
|
||
|
|
||
|
// columns definition
|
||
|
columns: [{
|
||
|
field: 'RecordID',
|
||
|
title: '',
|
||
|
sortable: false,
|
||
|
width: 30,
|
||
|
textAlign: 'center',
|
||
|
}, {
|
||
|
field: 'FirstName',
|
||
|
title: 'First Name',
|
||
|
sortable: 'asc',
|
||
|
}, {
|
||
|
field: 'LastName',
|
||
|
title: 'Last Name',
|
||
|
}, {
|
||
|
field: 'Company',
|
||
|
title: 'Company',
|
||
|
}, {
|
||
|
field: 'Email',
|
||
|
title: 'Email',
|
||
|
}, {
|
||
|
field: 'Phone',
|
||
|
title: 'Phone',
|
||
|
}, {
|
||
|
field: 'Status',
|
||
|
title: 'Status',
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Pending',
|
||
|
'class': 'label-light-primary'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Delivered',
|
||
|
'class': ' label-light-success'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Canceled',
|
||
|
'class': ' label-light-primary'
|
||
|
},
|
||
|
4: {
|
||
|
'title': 'Success',
|
||
|
'class': ' label-light-success'
|
||
|
},
|
||
|
5: {
|
||
|
'title': 'Info',
|
||
|
'class': ' label-light-info'
|
||
|
},
|
||
|
6: {
|
||
|
'title': 'Danger',
|
||
|
'class': ' label-light-danger'
|
||
|
},
|
||
|
7: {
|
||
|
'title': 'Warning',
|
||
|
'class': ' label-light-warning'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label label-lg font-weight-bold' + status[row.Status].class + ' label-inline">' + status[row.Status].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'Type',
|
||
|
title: 'Type',
|
||
|
autoHide: false,
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Online',
|
||
|
'state': 'danger'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Retail',
|
||
|
'state': 'primary'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Direct',
|
||
|
'state': 'accent'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label label-' + status[row.Type].state + ' label-dot mr-2"></span><span class="font-weight-bold text-' + status[row.Type].state +
|
||
|
'">' +
|
||
|
status[row.Type].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'Actions',
|
||
|
width: 130,
|
||
|
title: 'Actions',
|
||
|
sortable: false,
|
||
|
overflow: 'visible',
|
||
|
textAlign: 'left',
|
||
|
autoHide: false,
|
||
|
template: function(row) {
|
||
|
return '\
|
||
|
<button data-record-id="' + row.RecordID + '" class="btn btn-sm btn-clean" title="View records">\
|
||
|
<i class="flaticon2-document"></i> Details\
|
||
|
</button>';
|
||
|
},
|
||
|
}],
|
||
|
});
|
||
|
|
||
|
var card = datatable.closest('.card');
|
||
|
|
||
|
$('#kt_datatable_search_status').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Status');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_type').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Type');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_status, #kt_datatable_search_type').selectpicker();
|
||
|
|
||
|
datatable.on('click', '[data-record-id]', function() {
|
||
|
initSubDatatable($(this).data('record-id'));
|
||
|
$('#kt_datatable_modal').modal('show');
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var initSubDatatable = function(id) {
|
||
|
var el = $('#kt_datatable_sub');
|
||
|
var datatable = el.KTDatatable({
|
||
|
data: {
|
||
|
type: 'remote',
|
||
|
source: {
|
||
|
read: {
|
||
|
url: HOST_URL + '/api/datatables/demos/orders.php',
|
||
|
params: {
|
||
|
query: {
|
||
|
generalSearch: '',
|
||
|
CustomerID: id,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
pageSize: 10,
|
||
|
serverPaging: true,
|
||
|
serverFiltering: false,
|
||
|
serverSorting: true,
|
||
|
},
|
||
|
|
||
|
// layout definition
|
||
|
layout: {
|
||
|
theme: 'default',
|
||
|
scroll: true,
|
||
|
height: 350,
|
||
|
footer: false,
|
||
|
},
|
||
|
|
||
|
search: {
|
||
|
input: el.find('#kt_datatable_search_query_2'),
|
||
|
key: 'generalSearch'
|
||
|
},
|
||
|
|
||
|
sortable: true,
|
||
|
|
||
|
// columns definition
|
||
|
columns: [{
|
||
|
field: 'RecordID',
|
||
|
title: '#',
|
||
|
sortable: false,
|
||
|
width: 30,
|
||
|
}, {
|
||
|
field: 'OrderID',
|
||
|
title: 'Order ID',
|
||
|
template: function(row) {
|
||
|
return '<span>' + row.OrderID + ' - ' + row.ShipCountry + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'ShipCountry',
|
||
|
title: 'Country',
|
||
|
width: 100,
|
||
|
}, {
|
||
|
field: 'ShipAddress',
|
||
|
title: 'Ship Address',
|
||
|
}, {
|
||
|
field: 'ShipName',
|
||
|
title: 'Ship Name',
|
||
|
autoHide: false,
|
||
|
}, {
|
||
|
field: 'TotalPayment',
|
||
|
title: 'Payment',
|
||
|
type: 'number',
|
||
|
}, {
|
||
|
field: 'Status',
|
||
|
title: 'Status',
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Pending',
|
||
|
'class': 'label-primary'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Delivered',
|
||
|
'class': ' label-success'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Canceled',
|
||
|
'class': ' label-primary'
|
||
|
},
|
||
|
4: {
|
||
|
'title': 'Success',
|
||
|
'class': ' label-success'
|
||
|
},
|
||
|
5: {
|
||
|
'title': 'Info',
|
||
|
'class': ' label-info'
|
||
|
},
|
||
|
6: {
|
||
|
'title': 'Danger',
|
||
|
'class': ' label-danger'
|
||
|
},
|
||
|
7: {
|
||
|
'title': 'Warning',
|
||
|
'class': ' label-warning'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label font-weight-bold label-lg ' + status[row.Status].class + ' label-inline label-pill">' + status[row.Status].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'Type',
|
||
|
title: 'Type',
|
||
|
autoHide: false,
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Online',
|
||
|
'state': 'danger'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Retail',
|
||
|
'state': 'primary'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Direct',
|
||
|
'state': 'accent'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label label-' + status[row.Type].state + ' label-dot"></span> <span class="font-weight-bold text-' +
|
||
|
status[row.Type].state + '">' +
|
||
|
status[row.Type].title + '</span>';
|
||
|
},
|
||
|
}],
|
||
|
});
|
||
|
|
||
|
var modal = datatable.closest('.modal');
|
||
|
|
||
|
$('#kt_datatable_search_status_2').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Status');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_type_2').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Type');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_status_2, #kt_datatable_search_type_2').selectpicker();
|
||
|
|
||
|
// fix datatable layout after modal shown
|
||
|
datatable.hide();
|
||
|
modal.on('shown.bs.modal', function() {
|
||
|
var modalContent = $(this).find('.modal-content');
|
||
|
datatable.spinnerCallback(true, modalContent);
|
||
|
datatable.spinnerCallback(false, modalContent);
|
||
|
}).on('hidden.bs.modal', function() {
|
||
|
el.KTDatatable('destroy');
|
||
|
});
|
||
|
|
||
|
datatable.on('datatable-on-layout-updated', function() {
|
||
|
datatable.show();
|
||
|
datatable.redraw();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var initDatatableModal2 = function() {
|
||
|
var dataJSONArray = JSON.parse(
|
||
|
'[{"id":1,"employee_id":"463978155-5","first_name":"Carroll","last_name":"Maharry","email":"cmaharry0@topsy.com","phone":"420-935-0970","gender":"Male","department":"Legal","address":"72460 Bunting Trail","hire_date":"3/18/2018","website":"https://gmpg.org","notes":"euismod scelerisque quam turpis adipiscing lorem vitae mattis nibh ligula nec sem duis","status":6,"type":2,"salary":"$339.37"}, {"id":2,"employee_id":"590410601-7","first_name":"Jae","last_name":"Frammingham","email":"jframmingham1@ucoz.com","phone":"377-986-0708","gender":"Male","department":"Human Resources","address":"976 Eagle Crest Junction","hire_date":"10/22/2017","website":"https://telegraph.co.uk","notes":"consequat metus sapien ut nunc vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia","status":5,"type":2,"salary":"$1568.00"}, {"id":3,"employee_id":"562079447-4","first_name":"Natalie","last_name":"Stuchberry","email":"nstuchberry2@jimdo.com","phone":"718-320-9991","gender":"Female","department":"Legal","address":"9971 Rigney Pass","hire_date":"6/1/2018","website":"http://nbcnews.com","notes":"tempus sit amet sem fusce consequat nulla nisl nunc nisl duis","status":1,"type":1,"salary":"$2014.50"}, {"id":4,"employee_id":"078485871-3","first_name":"Abran","last_name":"Ivett","email":"aivett3@pinterest.com","phone":"784-922-2482","gender":"Male","department":"Accounting","address":"9 Mesta Court","hire_date":"2/6/2018","website":"http://wikipedia.org","notes":"vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae donec pharetra","status":2,"type":1,"salary":"$1205.64"}, {"id":5,"employee_id":"048140516-X","first_name":"Viola","last_name":"Ends","email":"vends4@squarespace.com","phone":"613-457-5253","gender":"Female","department":"Research and Development","address":"2 Paget Court","hire_date":"3/16/2018","website":"https://dot.gov","notes":"id pretium iaculis diam erat fermentum justo nec condimentum neque sapien placerat ante nulla justo aliquam quis turpis eget elit","status":2,"type":2,"salary":"$1376.93"}, {"id":6,"employee_id":"115191539-4","first_name":"Marabel","last_name":"Foystone","email":"mfoystone5@example.com","phone":"731-391-3134","gender":"Female","department":"Support","address":"2498 Tennyson Way","hire_date":"5/10/2018","website":"http://booking.com","notes":"nulla suspendisse potenti cras in purus eu magna vulputate luctus cum sociis natoque penatibus et magnis","status":1,"type":1,"salary":"$1498.25"}, {"id":7,"employee_id":"053408526-1","first_name":"Maiga","last_name":"Frogley","email":"mfrogley6@flavors.me","phone":"559-339-1188","gender":"Female","department":"Legal","address":"6 Sage Circle","hire_date":"10/24/2017","website":"http://ustream.tv","notes":"in ante vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae duis faucibus accumsan odio curabitur","status":4,"type":1,"salary":"$2420.50"}, {"id":8,"employee_id":"996172199-3","first_name":"Leia","last_name":"Rapelli","email":"lrapelli7@amazonaws.com","phone":"882-958-3554","gender":"Female","department":"Training","address":"5 Bellgrove Park","hire_date":"3/11/2018","website":"https://va.gov","notes":"ullamcorper purus sit amet nulla quisque arcu libero rutrum ac lobortis vel dapibus","status":5,"type":3,"salary":"$479.73"}, {"id":9,"employee_id":"290771439-2","first_name":"Lilias","last_name":"Stollsteiner","email":"lstollsteiner8@opensource.org","phone":"725-615-6480","gender":"Female","department":"Product Management","address":"5 Shoshone Park","hire_date":"4/26/2018","website":"http://163.com","notes":"blandit nam nulla integer pede justo lacinia eget tincidunt eget tempus vel pede morbi porttitor lorem","status":6,"type":3,"salary":"$815.69"}, {"id":10,"employee_id":"475138305-1","first_name":"Chrissie","last_name":"Trenouth","email":"ctrenouth9@addtoany.com","phone":"653-550-6039","gender":"Male","department":"Product Management","address":"6753 Fulton Drive","hire_date":"4/5/2018","website":"https://nifty.com","notes":"erat nulla tempus vivamus in felis eu
|
||
|
);
|
||
|
|
||
|
var modal = $('#kt_datatable_modal_2');
|
||
|
|
||
|
var datatable = $('#kt_datatable_2').KTDatatable({
|
||
|
// datasource definition
|
||
|
data: {
|
||
|
type: 'local',
|
||
|
source: dataJSONArray,
|
||
|
pageSize: 10,
|
||
|
},
|
||
|
|
||
|
// layout definition
|
||
|
layout: {
|
||
|
scroll: true, // enable/disable datatable scroll both horizontal and vertical when needed.
|
||
|
height: 400, // datatable's body's fixed height
|
||
|
minHeight: 400,
|
||
|
footer: false, // display/hide footer
|
||
|
},
|
||
|
|
||
|
// column sorting
|
||
|
sortable: true,
|
||
|
|
||
|
pagination: true,
|
||
|
|
||
|
search: {
|
||
|
input: modal.find('#kt_datatable_search_query_3'),
|
||
|
key: 'generalSearch'
|
||
|
},
|
||
|
|
||
|
// columns definition
|
||
|
columns: [{
|
||
|
field: 'id',
|
||
|
title: '#',
|
||
|
sortable: false,
|
||
|
width: 20,
|
||
|
type: 'number',
|
||
|
selector: {
|
||
|
class: ''
|
||
|
},
|
||
|
textAlign: 'center',
|
||
|
}, {
|
||
|
field: 'employee_id',
|
||
|
title: 'Employee ID',
|
||
|
}, {
|
||
|
field: 'name',
|
||
|
title: 'Name',
|
||
|
template: function(row) {
|
||
|
return row.first_name + ' ' + row.last_name;
|
||
|
},
|
||
|
}, {
|
||
|
field: 'hire_date',
|
||
|
title: 'Hire Date',
|
||
|
type: 'date',
|
||
|
format: 'MM/DD/YYYY',
|
||
|
}, {
|
||
|
field: 'gender',
|
||
|
title: 'Gender',
|
||
|
}, {
|
||
|
field: 'status',
|
||
|
title: 'Status',
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Pending',
|
||
|
'class': 'label-light-primary'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Delivered',
|
||
|
'class': ' label-light-success'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Canceled',
|
||
|
'class': ' label-light-primary'
|
||
|
},
|
||
|
4: {
|
||
|
'title': 'Success',
|
||
|
'class': ' label-light-success'
|
||
|
},
|
||
|
5: {
|
||
|
'title': 'Info',
|
||
|
'class': ' label-light-info'
|
||
|
},
|
||
|
6: {
|
||
|
'title': 'Danger',
|
||
|
'class': ' label-light-danger'
|
||
|
},
|
||
|
7: {
|
||
|
'title': 'Warning',
|
||
|
'class': ' label-light-warning'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label font-weight-bold label-lg ' + status[row.status].class + ' label-inline">' + status[row.status].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'type',
|
||
|
title: 'Type',
|
||
|
autoHide: false,
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Online',
|
||
|
'state': 'danger'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Retail',
|
||
|
'state': 'primary'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Direct',
|
||
|
'state': 'accent'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label label-' + status[row.type].state + ' label-dot mr-2"></span><span class="font-weight-bold text-' + status[row.type].state +
|
||
|
'">' +
|
||
|
status[row.type].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'Actions',
|
||
|
title: 'Actions',
|
||
|
sortable: false,
|
||
|
width: 125,
|
||
|
overflow: 'visible',
|
||
|
autoHide: false,
|
||
|
template: function() {
|
||
|
return '\
|
||
|
<div class="dropdown dropdown-inline">\
|
||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">\
|
||
|
<span class="svg-icon svg-icon-md">\
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
||
|
<rect x="0" y="0" width="24" height="24"/>\
|
||
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>\
|
||
|
</g>\
|
||
|
</svg>\
|
||
|
</span>\
|
||
|
</a>\
|
||
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">\
|
||
|
<ul class="navi flex-column navi-hover py-2">\
|
||
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">\
|
||
|
Choose an action:\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-print"></i></span>\
|
||
|
<span class="navi-text">Print</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-copy"></i></span>\
|
||
|
<span class="navi-text">Copy</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-file-excel-o"></i></span>\
|
||
|
<span class="navi-text">Excel</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-file-text-o"></i></span>\
|
||
|
<span class="navi-text">CSV</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-file-pdf-o"></i></span>\
|
||
|
<span class="navi-text">PDF</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
</ul>\
|
||
|
</div>\
|
||
|
</div>\
|
||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" title="Edit details">\
|
||
|
<span class="svg-icon svg-icon-md">\
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
||
|
<rect x="0" y="0" width="24" height="24"/>\
|
||
|
<path d="M8,17.9148182 L8,5.96685884 C8,5.56391781 8.16211443,5.17792052 8.44982609,4.89581508 L10.965708,2.42895648 C11.5426798,1.86322723 12.4640974,1.85620921 13.0496196,2.41308426 L15.5337377,4.77566479 C15.8314604,5.0588212 16,5.45170806 16,5.86258077 L16,17.9148182 C16,18.7432453 15.3284271,19.4148182 14.5,19.4148182 L9.5,19.4148182 C8.67157288,19.4148182 8,18.7432453 8,17.9148182 Z" fill="#000000" fill-rule="nonzero"\ transform="translate(12.000000, 10.707409) rotate(-135.000000) translate(-12.000000, -10.707409) "/>\
|
||
|
<rect fill="#000000" opacity="0.3" x="5" y="20" width="15" height="2" rx="1"/>\
|
||
|
</g>\
|
||
|
</svg>\
|
||
|
</span>\
|
||
|
</a>\
|
||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon" title="Delete">\
|
||
|
<span class="svg-icon svg-icon-md">\
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
||
|
<rect x="0" y="0" width="24" height="24"/>\
|
||
|
<path d="M6,8 L6,20.5 C6,21.3284271 6.67157288,22 7.5,22 L16.5,22 C17.3284271,22 18,21.3284271 18,20.5 L18,8 L6,8 Z" fill="#000000" fill-rule="nonzero"/>\
|
||
|
<path d="M14,4.5 L14,4 C14,3.44771525 13.5522847,3 13,3 L11,3 C10.4477153,3 10,3.44771525 10,4 L10,4.5 L5.5,4.5 C5.22385763,4.5 5,4.72385763 5,5 L5,5.5 C5,5.77614237 5.22385763,6 5.5,6 L18.5,6 C18.7761424,6 19,5.77614237 19,5.5 L19,5 C19,4.72385763 18.7761424,4.5 18.5,4.5 L14,4.5 Z" fill="#000000" opacity="0.3"/>\
|
||
|
</g>\
|
||
|
</svg>\
|
||
|
</span>\
|
||
|
</a>\
|
||
|
';
|
||
|
}
|
||
|
}]
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_status_3').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Status');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_type_3').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Type');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_status_3, #kt_datatable_search_type_3').selectpicker();
|
||
|
|
||
|
// fix datatable layout after modal shown
|
||
|
datatable.hide();
|
||
|
|
||
|
var alreadyReloaded = false;
|
||
|
modal.on('shown.bs.modal', function() {
|
||
|
if (!alreadyReloaded) {
|
||
|
var modalContent = $(this).find('.modal-content');
|
||
|
datatable.spinnerCallback(true, modalContent);
|
||
|
|
||
|
datatable.reload();
|
||
|
|
||
|
datatable.on('datatable-on-layout-updated', function() {
|
||
|
datatable.show();
|
||
|
datatable.spinnerCallback(false, modalContent);
|
||
|
datatable.redraw();
|
||
|
});
|
||
|
|
||
|
alreadyReloaded = true;
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var initDatatableModal3 = function() {
|
||
|
var modal = $('#kt_datatable_modal_3');
|
||
|
|
||
|
var datatable = $('#kt_datatable_3').KTDatatable({
|
||
|
// datasource definition
|
||
|
data: {
|
||
|
type: 'remote',
|
||
|
source: {
|
||
|
read: {
|
||
|
url: HOST_URL + '/api/datatables/demos/default.php',
|
||
|
},
|
||
|
},
|
||
|
pageSize: 10, // display 20 records per page
|
||
|
serverPaging: true,
|
||
|
serverFiltering: true,
|
||
|
serverSorting: true,
|
||
|
},
|
||
|
|
||
|
// layout definition
|
||
|
layout: {
|
||
|
scroll: true, // enable/disable datatable scroll both horizontal and vertical when needed.
|
||
|
height: 400, // datatable's body's fixed height
|
||
|
minHeight: 400,
|
||
|
footer: false, // display/hide footer
|
||
|
},
|
||
|
|
||
|
// column sorting
|
||
|
sortable: true,
|
||
|
|
||
|
pagination: true,
|
||
|
|
||
|
search: {
|
||
|
input: modal.find('#kt_datatable_search_query'),
|
||
|
delay: 400,
|
||
|
key: 'generalSearch'
|
||
|
},
|
||
|
|
||
|
// columns definition
|
||
|
columns: [{
|
||
|
field: 'RecordID',
|
||
|
title: '#',
|
||
|
sortable: 'asc',
|
||
|
width: 30,
|
||
|
type: 'number',
|
||
|
selector: false,
|
||
|
textAlign: 'center',
|
||
|
}, {
|
||
|
field: 'OrderID',
|
||
|
title: 'Profile Picture',
|
||
|
template: function(data, i) {
|
||
|
var number = KTUtil.getRandomInt(1, 14);
|
||
|
var user_img = 'background-image:url(\'assets/media/users/100_' + number + '.jpg\')';
|
||
|
|
||
|
var output = '';
|
||
|
if (number > 8) {
|
||
|
output = '<div class="d-flex align-items-center">\
|
||
|
<div class="symbol symbol-40 flex-shrink-0" style="' + user_img + '">\
|
||
|
<div class="symbol-label"></div>\
|
||
|
</div>\
|
||
|
<div class="ml-2">\
|
||
|
<div class="text-dark-75 font-weight-bold line-height-sm">' + data.CompanyAgent + '</div>\
|
||
|
<a href="#" class="font-size-sm text-dark-50 text-hover-primary">' +
|
||
|
data.CompanyEmail + '</a>\
|
||
|
</div>\
|
||
|
</div>';
|
||
|
}
|
||
|
else {
|
||
|
var stateNo = KTUtil.getRandomInt(0, 7);
|
||
|
var states = [
|
||
|
'success',
|
||
|
'primary',
|
||
|
'danger',
|
||
|
'success',
|
||
|
'warning',
|
||
|
'dark',
|
||
|
'primary',
|
||
|
'info'];
|
||
|
var state = states[stateNo];
|
||
|
|
||
|
output = '<div class="d-flex align-items-center">\
|
||
|
<div class="symbol symbol-40 symbol-'+state+' flex-shrink-0">\
|
||
|
<div class="symbol-label">' + data.CompanyAgent.substring(0, 1) + '</div>\
|
||
|
</div>\
|
||
|
<div class="ml-2">\
|
||
|
<div class="text-dark-75 font-weight-bold line-height-sm">' + data.CompanyAgent + '</div>\
|
||
|
<a href="#" class="font-size-sm text-dark-50 text-hover-primary">' +
|
||
|
data.CompanyEmail + '</a>\
|
||
|
</div>\
|
||
|
</div>';
|
||
|
}
|
||
|
|
||
|
return output;
|
||
|
},
|
||
|
}, {
|
||
|
field: 'CompanyAgent',
|
||
|
title: 'Name',
|
||
|
}, {
|
||
|
field: 'ShipDate',
|
||
|
title: 'Ship Date',
|
||
|
type: 'date',
|
||
|
format: 'MM/DD/YYYY',
|
||
|
}, {
|
||
|
field: 'ShipCountry',
|
||
|
title: 'Ship Country',
|
||
|
}, {
|
||
|
field: 'Status',
|
||
|
title: 'Status',
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Pending',
|
||
|
'class': 'label-light-primary'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Delivered',
|
||
|
'class': ' label-light-success'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Canceled',
|
||
|
'class': ' label-light-primary'
|
||
|
},
|
||
|
4: {
|
||
|
'title': 'Success',
|
||
|
'class': ' label-light-success'
|
||
|
},
|
||
|
5: {
|
||
|
'title': 'Info',
|
||
|
'class': ' label-light-info'
|
||
|
},
|
||
|
6: {
|
||
|
'title': 'Danger',
|
||
|
'class': ' label-light-danger'
|
||
|
},
|
||
|
7: {
|
||
|
'title': 'Warning',
|
||
|
'class': ' label-light-warning'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label ' + status[row.Status].class + ' label-inline label-pill">' + status[row.Status].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'Type',
|
||
|
title: 'Type',
|
||
|
autoHide: false,
|
||
|
// callback function support for column rendering
|
||
|
template: function(row) {
|
||
|
var status = {
|
||
|
1: {
|
||
|
'title': 'Online',
|
||
|
'state': 'danger'
|
||
|
},
|
||
|
2: {
|
||
|
'title': 'Retail',
|
||
|
'state': 'primary'
|
||
|
},
|
||
|
3: {
|
||
|
'title': 'Direct',
|
||
|
'state': 'success'
|
||
|
},
|
||
|
};
|
||
|
return '<span class="label label-' + status[row.Type].state + ' label-dot"></span> <span class="font-weight-bold text-' + status[row.Type].state + '">' +
|
||
|
status[row.Type].title + '</span>';
|
||
|
},
|
||
|
}, {
|
||
|
field: 'Actions',
|
||
|
title: 'Actions',
|
||
|
sortable: false,
|
||
|
width: 125,
|
||
|
overflow: 'visible',
|
||
|
autoHide: false,
|
||
|
template: function() {
|
||
|
return '\
|
||
|
<div class="dropdown dropdown-inline">\
|
||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">\
|
||
|
<span class="svg-icon svg-icon-md">\
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
||
|
<rect x="0" y="0" width="24" height="24"/>\
|
||
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>\
|
||
|
</g>\
|
||
|
</svg>\
|
||
|
</span>\
|
||
|
</a>\
|
||
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">\
|
||
|
<ul class="navi flex-column navi-hover py-2">\
|
||
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">\
|
||
|
Choose an action:\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-print"></i></span>\
|
||
|
<span class="navi-text">Print</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-copy"></i></span>\
|
||
|
<span class="navi-text">Copy</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-file-excel-o"></i></span>\
|
||
|
<span class="navi-text">Excel</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-file-text-o"></i></span>\
|
||
|
<span class="navi-text">CSV</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
<li class="navi-item">\
|
||
|
<a href="#" class="navi-link">\
|
||
|
<span class="navi-icon"><i class="la la-file-pdf-o"></i></span>\
|
||
|
<span class="navi-text">PDF</span>\
|
||
|
</a>\
|
||
|
</li>\
|
||
|
</ul>\
|
||
|
</div>\
|
||
|
</div>\
|
||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" title="Edit details">\
|
||
|
<span class="svg-icon svg-icon-md">\
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
||
|
<rect x="0" y="0" width="24" height="24"/>\
|
||
|
<path d="M8,17.9148182 L8,5.96685884 C8,5.56391781 8.16211443,5.17792052 8.44982609,4.89581508 L10.965708,2.42895648 C11.5426798,1.86322723 12.4640974,1.85620921 13.0496196,2.41308426 L15.5337377,4.77566479 C15.8314604,5.0588212 16,5.45170806 16,5.86258077 L16,17.9148182 C16,18.7432453 15.3284271,19.4148182 14.5,19.4148182 L9.5,19.4148182 C8.67157288,19.4148182 8,18.7432453 8,17.9148182 Z" fill="#000000" fill-rule="nonzero"\ transform="translate(12.000000, 10.707409) rotate(-135.000000) translate(-12.000000, -10.707409) "/>\
|
||
|
<rect fill="#000000" opacity="0.3" x="5" y="20" width="15" height="2" rx="1"/>\
|
||
|
</g>\
|
||
|
</svg>\
|
||
|
</span>\
|
||
|
</a>\
|
||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon" title="Delete">\
|
||
|
<span class="svg-icon svg-icon-md">\
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
||
|
<rect x="0" y="0" width="24" height="24"/>\
|
||
|
<path d="M6,8 L6,20.5 C6,21.3284271 6.67157288,22 7.5,22 L16.5,22 C17.3284271,22 18,21.3284271 18,20.5 L18,8 L6,8 Z" fill="#000000" fill-rule="nonzero"/>\
|
||
|
<path d="M14,4.5 L14,4 C14,3.44771525 13.5522847,3 13,3 L11,3 C10.4477153,3 10,3.44771525 10,4 L10,4.5 L5.5,4.5 C5.22385763,4.5 5,4.72385763 5,5 L5,5.5 C5,5.77614237 5.22385763,6 5.5,6 L18.5,6 C18.7761424,6 19,5.77614237 19,5.5 L19,5 C19,4.72385763 18.7761424,4.5 18.5,4.5 L14,4.5 Z" fill="#000000" opacity="0.3"/>\
|
||
|
</g>\
|
||
|
</svg>\
|
||
|
</span>\
|
||
|
</a>\
|
||
|
';
|
||
|
},
|
||
|
}],
|
||
|
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_status_4').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Status');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_type_4').on('change', function() {
|
||
|
datatable.search($(this).val().toLowerCase(), 'Type');
|
||
|
});
|
||
|
|
||
|
$('#kt_datatable_search_status_4, #kt_datatable_search_type_4').selectpicker();
|
||
|
|
||
|
// fix datatable layout after modal shown
|
||
|
datatable.hide();
|
||
|
var alreadyReloaded = false;
|
||
|
modal.on('shown.bs.modal', function() {
|
||
|
if (!alreadyReloaded) {
|
||
|
var modalContent = $(this).find('.modal-content');
|
||
|
datatable.spinnerCallback(true, modalContent);
|
||
|
|
||
|
datatable.reload();
|
||
|
|
||
|
datatable.on('datatable-on-layout-updated', function() {
|
||
|
datatable.show();
|
||
|
datatable.spinnerCallback(false, modalContent);
|
||
|
datatable.redraw();
|
||
|
});
|
||
|
|
||
|
alreadyReloaded = true;
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
return {
|
||
|
// public functions
|
||
|
init: function() {
|
||
|
initDatatable();
|
||
|
initDatatableModal2();
|
||
|
initDatatableModal3();
|
||
|
}
|
||
|
};
|
||
|
}();
|
||
|
|
||
|
jQuery(document).ready(function() {
|
||
|
KTDatatableModal.init();
|
||
|
});
|