kopia lustrzana https://github.com/magicbug/Cloudlog
[Contests] Added buttons for activate/deactivate all
rodzic
b324aba559
commit
93b6cba00e
|
@ -134,4 +134,20 @@ class Contesting extends CI_Controller {
|
|||
echo json_encode(array('message' => 'OK'));
|
||||
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->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>
|
||||
</div>
|
||||
<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>
|
||||
|
|
|
@ -2,9 +2,9 @@ $('.contesttable').DataTable({
|
|||
"pageLength": 25,
|
||||
responsive: false,
|
||||
ordering: false,
|
||||
"scrollY": "400px",
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
@ -13,7 +13,7 @@ $('.contesttable').DataTable({
|
|||
});
|
||||
|
||||
// using this to change color of csv-button if dark mode is chosen
|
||||
var background = $('body').css( "background-color");
|
||||
var background = $('body').css("background-color");
|
||||
|
||||
if (background != ('rgb(255, 255, 255)')) {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
|
@ -23,7 +23,7 @@ function createContestDialog() {
|
|||
$.ajax({
|
||||
url: base_url + 'index.php/contesting/create',
|
||||
type: 'post',
|
||||
success: function(html) {
|
||||
success: function (html) {
|
||||
BootstrapDialog.show({
|
||||
title: 'Add Contest',
|
||||
size: BootstrapDialog.SIZE_WIDE,
|
||||
|
@ -46,9 +46,11 @@ function createContest(form) {
|
|||
$.ajax({
|
||||
url: base_url + 'index.php/contesting/create',
|
||||
type: 'post',
|
||||
data: {'name': form.contestname.value,
|
||||
'adifname': form.adifcontestname.value},
|
||||
success: function(html) {
|
||||
data: {
|
||||
'name': form.contestname.value,
|
||||
'adifname': form.adifcontestname.value
|
||||
},
|
||||
success: function (html) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
@ -59,11 +61,11 @@ function deactivateContest(contestid) {
|
|||
$.ajax({
|
||||
url: base_url + 'index.php/contesting/deactivate',
|
||||
type: 'post',
|
||||
data: {'id': contestid },
|
||||
success: function(html) {
|
||||
data: { 'id': contestid },
|
||||
success: function (html) {
|
||||
$(".contest_" + contestid).text('not active');
|
||||
$('.btn_'+contestid).html('Activate');
|
||||
$('.btn_'+contestid).attr('onclick', 'activateContest('+contestid+')')
|
||||
$('.btn_' + contestid).html('Activate');
|
||||
$('.btn_' + contestid).attr('onclick', 'activateContest(' + contestid + ')')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -72,11 +74,11 @@ function activateContest(contestid) {
|
|||
$.ajax({
|
||||
url: base_url + 'index.php/contesting/activate',
|
||||
type: 'post',
|
||||
data: {'id': contestid },
|
||||
success: function(html) {
|
||||
$('.contest_'+contestid).text('active');
|
||||
$('.btn_'+contestid).html('Deactivate');
|
||||
$('.btn_'+contestid).attr('onclick', 'deactivateContest('+contestid+')')
|
||||
data: { 'id': contestid },
|
||||
success: function (html) {
|
||||
$('.contest_' + contestid).text('active');
|
||||
$('.btn_' + contestid).html('Deactivate');
|
||||
$('.btn_' + contestid).attr('onclick', 'deactivateContest(' + contestid + ')')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -84,19 +86,20 @@ function activateContest(contestid) {
|
|||
function deleteContest(id, contest) {
|
||||
BootstrapDialog.confirm({
|
||||
title: 'DANGER',
|
||||
message: 'Warning! Are you sure you want to delete the following contest: ' + contest + '?' ,
|
||||
message: 'Warning! Are you sure you want to delete the following contest: ' + contest + '?',
|
||||
type: BootstrapDialog.TYPE_DANGER,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-danger',
|
||||
callback: function(result) {
|
||||
if(result) {
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/contesting/delete',
|
||||
type: 'post',
|
||||
data: {'id': id
|
||||
data: {
|
||||
'id': id
|
||||
},
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
$(".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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Ładowanie…
Reference in New Issue