2021-03-17 11:51:13 +00:00
|
|
|
$('.modetable').DataTable({
|
|
|
|
"pageLength": 25,
|
|
|
|
responsive: false,
|
|
|
|
ordering: false,
|
2021-10-23 17:55:57 +00:00
|
|
|
"scrollY": "500px",
|
2021-03-17 11:51:13 +00:00
|
|
|
"scrollCollapse": true,
|
2021-10-23 17:55:57 +00:00
|
|
|
"paging": false,
|
2022-08-28 18:02:07 +00:00
|
|
|
"scrollX": true,
|
2022-08-28 17:27:24 +00:00
|
|
|
initComplete: function () {
|
|
|
|
this.api()
|
2022-08-28 18:02:07 +00:00
|
|
|
.columns('.select-filter')
|
2022-08-28 17:27:24 +00:00
|
|
|
.every(function () {
|
|
|
|
var column = this;
|
|
|
|
var select = $('<select><option value=""></option></select>')
|
|
|
|
.appendTo($(column.footer()).empty())
|
|
|
|
.on('change', function () {
|
|
|
|
var val = $.fn.dataTable.util.escapeRegex($(this).val());
|
|
|
|
|
|
|
|
column.search(val ? '^' + val + '$' : '', true, false).draw();
|
|
|
|
});
|
|
|
|
|
|
|
|
column
|
|
|
|
.data()
|
|
|
|
.unique()
|
|
|
|
.sort()
|
|
|
|
.each(function (d, j) {
|
|
|
|
select.append('<option value="' + d + '">' + d + '</option>');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2021-03-17 11:51:13 +00:00
|
|
|
});
|
2022-08-28 18:02:07 +00:00
|
|
|
$($.fn.dataTable.tables(true)).DataTable().columns.adjust();
|
2021-03-17 11:51:13 +00:00
|
|
|
|
|
|
|
function createModeDialog() {
|
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/create',
|
|
|
|
type: 'post',
|
2021-10-23 17:55:57 +00:00
|
|
|
success: function (html) {
|
2021-03-17 11:51:13 +00:00
|
|
|
BootstrapDialog.show({
|
|
|
|
title: 'Create mode',
|
|
|
|
size: BootstrapDialog.SIZE_WIDE,
|
|
|
|
cssClass: 'create-mode-dialog',
|
|
|
|
nl2br: false,
|
|
|
|
message: html,
|
|
|
|
buttons: [{
|
|
|
|
label: 'Close',
|
|
|
|
action: function (dialogItself) {
|
|
|
|
dialogItself.close();
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function createMode(form) {
|
|
|
|
if (form.mode.value != '') {
|
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/create',
|
|
|
|
type: 'post',
|
2021-10-23 17:55:57 +00:00
|
|
|
data: {
|
|
|
|
'mode': form.mode.value,
|
2021-03-17 11:51:13 +00:00
|
|
|
'submode': form.submode.value,
|
|
|
|
'qrgmode': form.qrgmode.value,
|
2021-10-23 17:55:57 +00:00
|
|
|
'active': form.active.value
|
|
|
|
},
|
|
|
|
success: function (html) {
|
2021-03-17 11:51:13 +00:00
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function deactivateMode(modeid) {
|
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/deactivate',
|
|
|
|
type: 'post',
|
2021-10-23 17:55:57 +00:00
|
|
|
data: { 'id': modeid },
|
|
|
|
success: function (html) {
|
2021-03-17 11:51:13 +00:00
|
|
|
$(".mode_" + modeid).text('not active');
|
2021-10-23 17:55:57 +00:00
|
|
|
$('.btn_' + modeid).html('Activate');
|
|
|
|
$('.btn_' + modeid).attr('onclick', 'activateMode(' + modeid + ')')
|
2021-03-17 11:51:13 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function activateMode(modeid) {
|
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/activate',
|
|
|
|
type: 'post',
|
2021-10-23 17:55:57 +00:00
|
|
|
data: { 'id': modeid },
|
|
|
|
success: function (html) {
|
|
|
|
$('.mode_' + modeid).text('active');
|
|
|
|
$('.btn_' + modeid).html('Deactivate');
|
|
|
|
$('.btn_' + modeid).attr('onclick', 'deactivateMode(' + modeid + ')')
|
2021-03-17 11:51:13 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteMode(id, mode) {
|
|
|
|
BootstrapDialog.confirm({
|
|
|
|
title: 'DANGER',
|
2021-10-23 17:55:57 +00:00
|
|
|
message: 'Warning! Are you sure you want to delete the following mode: ' + mode + '?',
|
2021-03-17 11:51:13 +00:00
|
|
|
type: BootstrapDialog.TYPE_DANGER,
|
|
|
|
closable: true,
|
|
|
|
draggable: true,
|
|
|
|
btnOKClass: 'btn-danger',
|
2021-10-23 17:55:57 +00:00
|
|
|
callback: function (result) {
|
|
|
|
if (result) {
|
2021-03-17 11:51:13 +00:00
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/delete',
|
|
|
|
type: 'post',
|
2021-10-23 17:55:57 +00:00
|
|
|
data: {
|
|
|
|
'id': id
|
2021-03-17 11:51:13 +00:00
|
|
|
},
|
2021-10-23 17:55:57 +00:00
|
|
|
success: function (data) {
|
2021-03-17 11:51:13 +00:00
|
|
|
$(".mode_" + id).parent("tr:first").remove(); // removes mode from table
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-10-23 17:55:57 +00:00
|
|
|
|
|
|
|
function activateAllModes() {
|
|
|
|
BootstrapDialog.confirm({
|
|
|
|
title: 'DANGER',
|
|
|
|
message: 'Warning! Are you sure you want to activate all modes?',
|
|
|
|
type: BootstrapDialog.TYPE_DANGER,
|
|
|
|
closable: true,
|
|
|
|
draggable: true,
|
|
|
|
btnOKClass: 'btn-danger',
|
|
|
|
callback: function (result) {
|
|
|
|
if (result) {
|
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/activateall',
|
|
|
|
type: 'post',
|
|
|
|
success: function (data) {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function deactivateAllModes() {
|
|
|
|
BootstrapDialog.confirm({
|
|
|
|
title: 'DANGER',
|
|
|
|
message: 'Warning! Are you sure you want to deactivate all modes?',
|
|
|
|
type: BootstrapDialog.TYPE_DANGER,
|
|
|
|
closable: true,
|
|
|
|
draggable: true,
|
|
|
|
btnOKClass: 'btn-danger',
|
|
|
|
callback: function (result) {
|
|
|
|
if (result) {
|
|
|
|
$.ajax({
|
|
|
|
url: base_url + 'index.php/mode/deactivateall',
|
|
|
|
type: 'post',
|
|
|
|
success: function (data) {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|