[Continents] Added band and mode filter

这个提交包含在:
Andreas 2023-02-09 12:35:30 +01:00
父节点 8b38d28122
当前提交 36de030151
共有 4 个文件被更改,包括 138 次插入55 次删除

查看文件

@ -6,6 +6,11 @@ class Continents extends CI_Controller {
{
$this->load->model('user_model');
$this->load->model('bands');
$this->load->model('logbookadvanced_model');
$data['bands'] = $this->bands->get_worked_bands();
$data['modes'] = $this->logbookadvanced_model->get_modes();
if(!$this->user_model->authorize($this->config->item('auth_mode'))) {
if($this->user_model->validate_session()) {
$this->user_model->clear_session();
@ -27,11 +32,17 @@ class Continents extends CI_Controller {
public function get_continents() {
$searchCriteria = array(
'mode' => xss_clean($this->input->post('mode')),
'band' => xss_clean($this->input->post('band')),
);
$this->load->model('logbook_model');
$continentsstats = array();
$total_continents = $this->logbook_model->total_continents();
$total_continents = $this->logbook_model->total_continents($searchCriteria);
$i = 0;
if ($total_continents) {

查看文件

@ -1631,7 +1631,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of QSOs per continent */
function total_continents() {
function total_continents($searchCriteria) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
@ -1645,6 +1645,23 @@ class Logbook_model extends CI_Model {
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_CONT is not null');
$this->db->where('COL_CONT !=', '');
if ($searchCriteria['mode'] !== '') {
$this->db->group_start();
$this->db->where('COL_MODE', $searchCriteria['mode']);
$this->db->or_where('COL_SUBMODE', $searchCriteria['mode']);
$this->db->group_end();
}
if ($searchCriteria['band'] !== '') {
if($searchCriteria['band'] != "SAT") {
$this->db->where('COL_BAND', $searchCriteria['band']);
$this->db->where('COL_PROP_MODE != "SAT"');
} else {
$this->db->where('COL_PROP_MODE', 'SAT');
}
}
$this->db->order_by('count DESC');
$this->db->group_by('COL_CONT');
$query = $this->db->get($this->config->item('table_name'));

查看文件

@ -1,38 +1,70 @@
<style>
#continentChart{
margin: 0 auto;
}
#continentChart {
margin: 0 auto;
}
</style>
<div class="container statistics">
<h2>
<?php echo $page_title; ?>
</h2>
<h2>
<?php echo $page_title; ?>
</h2>
<br>
<div hidden class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="continents-tab" data-toggle="tab" href="#continents" role="tab" aria-controls="continents" aria-selected="true">No of QSOs</a>
</li>
</ul>
</div>
<br>
<div hidden class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="continents-tab" data-toggle="tab" href="#continents" role="tab"
aria-controls="continents" aria-selected="true">No of QSOs</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade active show" id="continents" role="tabpanel" aria-labelledby="continents-tab">
<br/>
<div style="display: flex;" id="continentContainer"><div style="flex: 1;"><canvas id="continentChart" width="500" height="500"></canvas></div><div style="flex: 1;" id="continentTable">
<table style="width:100%" class="continentstable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>
<tr>
<td>#</td>
<td>Continent</td>
<td># of QSO's worked</td>
</tr>
</thead>
<tbody></tbody>
</table></div></div>
</div>
</div>
</div>
<div class="tab-pane fade active show" id="continents" role="tabpanel" aria-labelledby="continents-tab">
<br />
<form id="searchForm" name="searchForm" action="<?php echo base_url()."index.php/continents/get_continents";?>" method="post">
<div class="form-row">
<div class="form-group col-lg-2">
<label class="form-label" for="band">Band</label>
<select id="band" name="band" class="form-control form-control-sm">
<option value="">All</option>
<?php foreach($bands as $band){ ?>
<option value="<?php echo htmlentities($band);?>"><?php echo htmlspecialchars($band);?> </option>
<?php } ?>
</select>
</div>
<div class="form-group col-lg-2">
<label class="form-label" for="mode">Mode</label>
<select id="mode" name="mode" class="form-control form-control-sm">
<option value="">All</option>
<?php foreach($modes as $modeId => $mode){ ?>
<option value="<?php echo htmlspecialchars($mode);?>"><?php echo htmlspecialchars($mode);?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-lg-2 col-md-3 col-sm-3 col-xl-21">
<label>&nbsp;</label><br>
<button type="submit" class="btn btn-sm btn-primary" id="searchButton">Search</button>
<button type="reset" class="btn btn-sm btn-danger" id="resetButton">Reset</button>
</div>
</div>
</form>
<div style="display: flex;" id="continentContainer">
<div style="flex: 1;"><canvas id="continentChart" width="500" height="500"></canvas></div>
<div style="flex: 1;" id="continentTable">
<table style="width:100%" class="continentstable table table-sm table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th>#</th>
<th>Continent</th>
<th># of QSO's worked</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>

查看文件

@ -1,19 +1,49 @@
totalContinentQsos();
$(document).ready(function () {
// Needed for continentstable header fix, will be squished without
$("a[href='#continents']").on('shown.bs.tab', function(e) {
$(".continentstable").DataTable().columns.adjust();
});
// Needed for continentstable header fix, will be squished without
$("a[href='#continents']").on('shown.bs.tab', function(e) {
$(".continentstable").DataTable().columns.adjust();
$('#searchForm').submit(function (e) {
$('#searchButton').prop("disabled", true);
$.ajax({
url: this.action,
type: 'post',
data: {
mode: this.mode.value,
band: this.band.value,
},
dataType: 'json',
success: function (data) {
$('#searchButton').prop("disabled", false);
totalContinentQsos(data);
},
error: function (data) {
$('#searchButton').prop("disabled", false);
BootstrapDialog.alert({
title: 'ERROR',
message: 'An error ocurred while making the request',
type: BootstrapDialog.TYPE_DANGER,
closable: false,
draggable: false,
callback: function (result) {
}
});
},
});
return false;
});
$('#searchForm').submit();
});
function totalContinentQsos() {
function totalContinentQsos(data) {
// using this to change color of legend and label according to background color
var color = ifDarkModeThemeReturn('white', 'grey');
$.ajax({
url: base_url+'index.php/continents/get_continents',
type: 'post',
success: function (data) {
if (data.length > 0) {
$('.continentstable > tbody').empty();
$('.tabs').removeAttr('hidden');
var labels = [];
@ -47,6 +77,12 @@ function totalContinentQsos() {
});
const COLORS = ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499"]
let chartStatus = Chart.getChart("continentChart"); // <canvas> id
if (chartStatus != undefined) {
chartStatus.destroy();
}
var ctx = document.getElementById("continentChart").getContext('2d');
var myChart = new Chart(ctx, {
plugins: [ChartPieChartOutlabels],
@ -120,18 +156,5 @@ function totalContinentQsos() {
if (background != ('rgb(255, 255, 255)')) {
$(".buttons-csv").css("color", "white");
}
$('.continentstable').DataTable({
responsive: false,
ordering: false,
"scrollY": "330px",
"scrollX": true,
"ScrollCollapse": true,
"paging": false,
bFilter: false,
bInfo: false,
});
}
}
});
}