Merge pull request #1245 from AndreasK79/contests_activate_deactivate_all
[Contests] Added buttons for activate/deactivate all
这个提交包含在:
当前提交
76d9e639b0
共有 4 个文件被更改,包括 109 次插入 和 22 次删除
|
|
@ -134,4 +134,20 @@ class Contesting extends CI_Controller {
|
||||||
echo json_encode(array('message' => 'OK'));
|
echo json_encode(array('message' => 'OK'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deactivateall() {
|
||||||
|
$this->load->model('Contesting_model');
|
||||||
|
$this->Contesting_model->deactivateall();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode(array('message' => 'OK'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activateall() {
|
||||||
|
$this->load->model('Contesting_model');
|
||||||
|
$this->Contesting_model->activateall();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode(array('message' => 'OK'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,4 +122,24 @@ class Contesting_model extends CI_Model {
|
||||||
$this->db->where('id', $id);
|
$this->db->where('id', $id);
|
||||||
$this->db->update('contest', $data);
|
$this->db->update('contest', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activateall() {
|
||||||
|
$data = array(
|
||||||
|
'active' => '1',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->update('contest', $data);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivateall() {
|
||||||
|
$data = array(
|
||||||
|
'active' => '0',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->update('contest', $data);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@
|
||||||
<table>
|
<table>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<p><button onclick="createContestDialog();" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> Add a Contest</button></p>
|
<p>
|
||||||
|
<button onclick="createContestDialog();" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> Add a Contest</button>
|
||||||
|
<button onclick="activateAllContests();" class="btn btn-primary btn-sm">Activate All</button>
|
||||||
|
<button onclick="deactivateAllContests();" class="btn btn-primary btn-sm">Deactivate All </button>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,10 @@ function createContest(form) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/create',
|
url: base_url + 'index.php/contesting/create',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'name': form.contestname.value,
|
data: {
|
||||||
'adifname': form.adifcontestname.value},
|
'name': form.contestname.value,
|
||||||
|
'adifname': form.adifcontestname.value
|
||||||
|
},
|
||||||
success: function (html) {
|
success: function (html) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +96,8 @@ function deleteContest(id, contest) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url + 'index.php/contesting/delete',
|
url: base_url + 'index.php/contesting/delete',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'id': id
|
data: {
|
||||||
|
'id': id
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$(".contest_" + id).parent("tr:first").remove(); // removes mode from table
|
$(".contest_" + id).parent("tr:first").remove(); // removes mode from table
|
||||||
|
|
@ -104,3 +107,47 @@ function deleteContest(id, contest) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activateAllContests() {
|
||||||
|
BootstrapDialog.confirm({
|
||||||
|
title: 'DANGER',
|
||||||
|
message: 'Warning! Are you sure you want to activate all contests?',
|
||||||
|
type: BootstrapDialog.TYPE_DANGER,
|
||||||
|
closable: true,
|
||||||
|
draggable: true,
|
||||||
|
btnOKClass: 'btn-danger',
|
||||||
|
callback: function (result) {
|
||||||
|
if (result) {
|
||||||
|
$.ajax({
|
||||||
|
url: base_url + 'index.php/contesting/activateall',
|
||||||
|
type: 'post',
|
||||||
|
success: function (data) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivateAllContests() {
|
||||||
|
BootstrapDialog.confirm({
|
||||||
|
title: 'DANGER',
|
||||||
|
message: 'Warning! Are you sure you want to deactivate all contests?',
|
||||||
|
type: BootstrapDialog.TYPE_DANGER,
|
||||||
|
closable: true,
|
||||||
|
draggable: true,
|
||||||
|
btnOKClass: 'btn-danger',
|
||||||
|
callback: function (result) {
|
||||||
|
if (result) {
|
||||||
|
$.ajax({
|
||||||
|
url: base_url + 'index.php/contesting/deactivateall',
|
||||||
|
type: 'post',
|
||||||
|
success: function (data) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
正在加载…
在新工单中引用