[Modes] Added buttons for activate / activate all

这个提交包含在:
Andreas 2021-10-23 19:55:57 +02:00
父节点 76d9e639b0
当前提交 6f266567a1
共有 4 个文件被更改,包括 108 次插入21 次删除

查看文件

@ -103,4 +103,20 @@ class Mode extends CI_Controller {
echo json_encode(array('message' => 'OK'));
return;
}
public function activateall() {
$this->load->model('modes');
$this->modes->activateall();
header('Content-Type: application/json');
echo json_encode(array('message' => 'OK'));
return;
}
public function deactivateall() {
$this->load->model('modes');
$this->modes->deactivateall();
header('Content-Type: application/json');
echo json_encode(array('message' => 'OK'));
return;
}
}

查看文件

@ -102,6 +102,26 @@ class Modes extends CI_Model {
return true;
}
function activateall() {
$data = array(
'active' => '1',
);
$this->db->update('adif_modes', $data);
return true;
}
function deactivateall() {
$data = array(
'active' => '0',
);
$this->db->update('adif_modes', $data);
return true;
}
}
?>

查看文件

@ -61,6 +61,10 @@
<table>
</div>
<br/>
<p><button onclick="createModeDialog();" class="btn btn-primary"><i class="fas fa-plus"></i> Create a Mode</button></p>
<p>
<button onclick="createModeDialog();" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> Create a Mode</button>
<button onclick="activateAllModes();" class="btn btn-primary btn-sm">Activate All</button>
<button onclick="deactivateAllModes();" class="btn btn-primary btn-sm">Deactivate All </button>
</p>
</div>
</div>

查看文件

@ -35,10 +35,12 @@ function createMode(form) {
$.ajax({
url: base_url + 'index.php/mode/create',
type: 'post',
data: {'mode': form.mode.value,
data: {
'mode': form.mode.value,
'submode': form.submode.value,
'qrgmode': form.qrgmode.value,
'active': form.active.value},
'active': form.active.value
},
success: function (html) {
location.reload();
}
@ -85,7 +87,8 @@ function deleteMode(id, mode) {
$.ajax({
url: base_url + 'index.php/mode/delete',
type: 'post',
data: {'id': id
data: {
'id': id
},
success: function (data) {
$(".mode_" + id).parent("tr:first").remove(); // removes mode from table
@ -95,3 +98,47 @@ function deleteMode(id, mode) {
}
});
}
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();
}
});
}
}
});
}