Mode and period has been added.

这个提交包含在:
Andreas 2020-10-08 11:45:41 +02:00
父节点 20dc1caa27
当前提交 dd200871cc
共有 4 个文件被更改,包括 196 次插入51 次删除

查看文件

@ -20,6 +20,10 @@ class Accumulated extends CI_Controller {
$data['worked_bands'] = $this->Accumulate_model->get_worked_bands(); $data['worked_bands'] = $this->Accumulate_model->get_worked_bands();
$this->load->model('modes');
$data['modes'] = $this->modes->active();
$this->load->view('interface_assets/header', $data); $this->load->view('interface_assets/header', $data);
$this->load->view('accumulate/index'); $this->load->view('accumulate/index');
$this->load->view('interface_assets/footer'); $this->load->view('interface_assets/footer');
@ -33,9 +37,11 @@ class Accumulated extends CI_Controller {
$this->load->model('accumulate_model'); $this->load->model('accumulate_model');
$band = $this->input->post('Band'); $band = $this->input->post('Band');
$award = $this->input->post('Award'); $award = $this->input->post('Award');
$mode = $this->input->post('Mode');
$period = $this->input->post('Period');
// get data // get data
$data = $this->accumulate_model->get_accumulated_data($band, $award); $data = $this->accumulate_model->get_accumulated_data($band, $award, $mode, $period);
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($data); echo json_encode($data);
} }

查看文件

@ -9,24 +9,34 @@ class Accumulate_model extends CI_Model
parent::__construct(); parent::__construct();
} }
function get_accumulated_data($band, $award) { function get_accumulated_data($band, $award, $mode, $period) {
$CI =& get_instance(); $CI =& get_instance();
$CI->load->model('Stations'); $CI->load->model('Stations');
$station_id = $CI->Stations->find_active(); $station_id = $CI->Stations->find_active();
switch ($award) { switch ($award) {
case 'dxcc': $result = $this->get_accumulated_dxcc($band, $station_id); break; case 'dxcc': $result = $this->get_accumulated_dxcc($band, $mode, $period, $station_id); break;
case 'was': $result = $this->get_accumulated_was($band, $station_id); break; case 'was': $result = $this->get_accumulated_was($band, $mode, $period, $station_id); break;
case 'iota': $result = $this->get_accumulated_iota($band, $station_id); break; case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $station_id); break;
case 'waz': $result = $this->get_accumulated_waz($band, $station_id); break; case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $station_id); break;
} }
return $result; return $result;
} }
function get_accumulated_dxcc($band, $station_id) { function get_accumulated_dxcc($band, $mode, $period, $station_id) {
$sql = "SELECT year(col_time_on) as year, if ($period == "year") {
(select count(distinct b.col_dxcc) from " . $this->config->item('table_name') . " as b where year(col_time_on) <= year and b.station_id = ". $station_id; $sql = "SELECT year(col_time_on) as year,
(select count(distinct b.col_dxcc) from " .
$this->config->item('table_name') .
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
}
else if ($period == "month") {
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
(select count(distinct b.col_dxcc) from " .
$this->config->item('table_name') .
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
}
if ($band != 'All') { if ($band != 'All') {
if ($band == 'SAT') { if ($band == 'SAT') {
@ -37,6 +47,10 @@ class Accumulate_model extends CI_Model
} }
} }
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .=") total from " . $this->config->item('table_name') . " as a $sql .=") total from " . $this->config->item('table_name') . " as a
where a.station_id = ". $station_id; where a.station_id = ". $station_id;
@ -49,17 +63,37 @@ class Accumulate_model extends CI_Model
} }
} }
$sql .= " group by year(a.col_time_on) if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
if ($period == "year") {
$sql .= " group by year(a.col_time_on)
order by year(a.col_time_on)"; order by year(a.col_time_on)";
}
else if ($period == "month") {
$sql .= " group by date_format(a.col_time_on, '%Y%m')
order by date_format(a.col_time_on, '%Y%m')";
}
$query = $this->db->query($sql); $query = $this->db->query($sql);
return $query->result(); return $query->result();
} }
function get_accumulated_was($band, $station_id) { function get_accumulated_was($band, $mode, $period, $station_id) {
$sql = "SELECT year(col_time_on) as year, if ($period == "year") {
(select count(distinct b.col_state) from " . $this->config->item('table_name') . " as b where year(col_time_on) <= year and b.station_id = ". $station_id; $sql = "SELECT year(col_time_on) as year,
(select count(distinct b.col_state) from " .
$this->config->item('table_name') .
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
}
else if ($period == "month") {
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
(select count(distinct b.col_state) from " .
$this->config->item('table_name') .
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
}
if ($band != 'All') { if ($band != 'All') {
if ($band == 'SAT') { if ($band == 'SAT') {
@ -70,6 +104,10 @@ class Accumulate_model extends CI_Model
} }
} }
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= " and COL_DXCC in ('291', '6', '110')"; $sql .= " and COL_DXCC in ('291', '6', '110')";
$sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')"; $sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')";
@ -85,20 +123,40 @@ class Accumulate_model extends CI_Model
} }
} }
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= " and COL_DXCC in ('291', '6', '110')"; $sql .= " and COL_DXCC in ('291', '6', '110')";
$sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')"; $sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')";
$sql .= " group by year(a.col_time_on) if ($period == "year") {
$sql .= " group by year(a.col_time_on)
order by year(a.col_time_on)"; order by year(a.col_time_on)";
}
else if ($period == "month") {
$sql .= " group by date_format(a.col_time_on, '%Y%m')
order by date_format(a.col_time_on, '%Y%m')";
}
$query = $this->db->query($sql); $query = $this->db->query($sql);
return $query->result(); return $query->result();
} }
function get_accumulated_iota($band, $station_id) { function get_accumulated_iota($band, $mode, $period, $station_id) {
$sql = "SELECT year(col_time_on) as year, if ($period == "year") {
(select count(distinct b.col_iota) from " . $this->config->item('table_name') . " as b where year(col_time_on) <= year and b.station_id = ". $station_id; $sql = "SELECT year(col_time_on) as year,
(select count(distinct b.col_iota) from " .
$this->config->item('table_name') .
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
}
else if ($period == "month") {
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
(select count(distinct b.col_iota) from " .
$this->config->item('table_name') .
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
}
if ($band != 'All') { if ($band != 'All') {
if ($band == 'SAT') { if ($band == 'SAT') {
@ -109,6 +167,10 @@ class Accumulate_model extends CI_Model
} }
} }
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .=") total from " . $this->config->item('table_name') . " as a $sql .=") total from " . $this->config->item('table_name') . " as a
where a.station_id = ". $station_id; where a.station_id = ". $station_id;
@ -121,17 +183,37 @@ class Accumulate_model extends CI_Model
} }
} }
$sql .= " group by year(a.col_time_on) if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
if ($period == "year") {
$sql .= " group by year(a.col_time_on)
order by year(a.col_time_on)"; order by year(a.col_time_on)";
}
else if ($period == "month") {
$sql .= " group by date_format(a.col_time_on, '%Y%m')
order by date_format(a.col_time_on, '%Y%m')";
}
$query = $this->db->query($sql); $query = $this->db->query($sql);
return $query->result(); return $query->result();
} }
function get_accumulated_waz($band, $station_id) { function get_accumulated_waz($band, $mode, $period, $station_id) {
$sql = "SELECT year(col_time_on) as year, if ($period == "year") {
(select count(distinct b.col_cqz) from " . $this->config->item('table_name') . " as b where year(col_time_on) <= year and b.station_id = ". $station_id; $sql = "SELECT year(col_time_on) as year,
(select count(distinct b.col_cqz) from " .
$this->config->item('table_name') .
" as b where year(col_time_on) <= year and b.station_id = ". $station_id;
}
else if ($period == "month") {
$sql = "SELECT date_format(col_time_on, '%Y%m') as year,
(select count(distinct b.col_cqz) from " .
$this->config->item('table_name') .
" as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id;
}
if ($band != 'All') { if ($band != 'All') {
if ($band == 'SAT') { if ($band == 'SAT') {
@ -142,6 +224,10 @@ class Accumulate_model extends CI_Model
} }
} }
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .=") total from " . $this->config->item('table_name') . " as a $sql .=") total from " . $this->config->item('table_name') . " as a
where a.station_id = ". $station_id; where a.station_id = ". $station_id;
@ -154,8 +240,18 @@ class Accumulate_model extends CI_Model
} }
} }
$sql .= " group by year(a.col_time_on) if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
if ($period == "year") {
$sql .= " group by year(a.col_time_on)
order by year(a.col_time_on)"; order by year(a.col_time_on)";
}
else if ($period == "month") {
$sql .= " group by date_format(a.col_time_on, '%Y%m')
order by date_format(a.col_time_on, '%Y%m')";
}
$query = $this->db->query($sql); $query = $this->db->query($sql);

查看文件

@ -6,7 +6,7 @@
<!-- Select Basic --> <!-- Select Basic -->
<div class="form-group row"> <div class="form-group row">
<label class="col-md-1 control-label" for="band">Band</label> <label class="col-md-1 control-label" for="band">Band</label>
<div class="col-md-2"> <div class="col-md-3">
<select id="band" name="band" class="form-control custom-select"> <select id="band" name="band" class="form-control custom-select">
<option value="All">All</option> <option value="All">All</option>
<?php foreach($worked_bands as $band) { <?php foreach($worked_bands as $band) {
@ -14,31 +14,68 @@
} ?> } ?>
</select> </select>
</div> </div>
<label class="col-md-1 control-label" for="mode">Mode</label>
<div class="col-md-3">
<select id="mode" name="mode" class="form-control custom-select">
<option value="All">All</option>
<?php
foreach($modes->result() as $mode){
if ($mode->submode == null) {
printf("<option value=\"%s\">%s</option>", $mode->mode, $mode->mode);
} else {
printf("<option value=\"%s\">&rArr; %s</option>", $mode->submode, $mode->submode);
}
}
?>
</select>
</div>
</div> </div>
<div class="form-group">
<div class="form-check"> <div class="form-group row">
<input class="form-check-input" type="radio" name="awardradio" id="dxcc" value="dxcc" checked>
<label class="form-check-label" for="dxcc"> <label class="col-md-1 control-label" for="radio">Award</label>
DX Century Club (DXCC) <div class="col-md-3">
</label> <div class="form-check">
</div> <input class="form-check-input" type="radio" name="awardradio" id="dxcc" value="dxcc" checked>
<div class="form-check"> <label class="form-check-label" for="dxcc">
<input class="form-check-input" type="radio" name="awardradio" id="was" value="was"> DX Century Club (DXCC)
<label class="form-check-label" for="was"> </label>
Worked all states (WAS) </div>
</label> <div class="form-check">
</div> <input class="form-check-input" type="radio" name="awardradio" id="was" value="was">
<div class="form-check"> <label class="form-check-label" for="was">
<input class="form-check-input" type="radio" name="awardradio" id="iota" value="iota"> Worked all states (WAS)
<label class="form-check-label" for="iota"> </label>
Islands on the air (IOTA) </div>
</label> <div class="form-check">
</div> <input class="form-check-input" type="radio" name="awardradio" id="iota" value="iota">
<div class="form-check"> <label class="form-check-label" for="iota">
<input class="form-check-input" type="radio" name="awardradio" id="waz" value="waz"> Islands on the air (IOTA)
<label class="form-check-label" for="waz"> </label>
Worked all zones (WAZ) </div>
</label> <div class="form-check">
<input class="form-check-input" type="radio" name="awardradio" id="waz" value="waz">
<label class="form-check-label" for="waz">
Worked all zones (WAZ)
</label>
</div>
</div>
<label class="col-md-1 control-label" for="radio">Period</label>
<div class="col-md-3">
<div class="form-check">
<input class="form-check-input" type="radio" name="periodradio" id="yearly" value="year" checked>
<label class="form-check-label" for="yearly">
Yearly
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="periodradio" id="monthly" value="month">
<label class="form-check-label" for="monthly">
Monthly
</label>
</div>
</div> </div>
</div> </div>

查看文件

@ -1803,10 +1803,12 @@ $(document).ready(function(){
var baseURL= "<?php echo base_url();?>"; var baseURL= "<?php echo base_url();?>";
var award = form.awardradio.value; var award = form.awardradio.value;
var mode = form.mode.value;
var period = form.periodradio.value;
$.ajax({ $.ajax({
url: baseURL+'index.php/accumulated/get_accumulated_data', url: baseURL+'index.php/accumulated/get_accumulated_data',
type: 'post', type: 'post',
data: {'Band': form.band.value, 'Award': award}, data: {'Band': form.band.value, 'Award': award, 'Mode': mode, 'Period': period},
success: function(data) { success: function(data) {
// used for switching award text in the table and the chart // used for switching award text in the table and the chart
switch(award) { switch(award) {
@ -1816,7 +1818,11 @@ $(document).ready(function(){
case 'waz': var awardtext = "CQ zones"; break; case 'waz': var awardtext = "CQ zones"; break;
} }
// removing the old chart so that it will not interefere when loading chart again var periodtext = 'Year';
if (period == 'month') {
periodtext += ' + month';
}
// removing the old chart so that it will not interfere when loading chart again
$("#accumulateContainer").empty(); $("#accumulateContainer").empty();
$("#accumulateContainer").append("<canvas id=\"myChartAccumulate\" width=\"400\" height=\"150\"></canvas><div id=\"accumulateTable\"></div>"); $("#accumulateContainer").append("<canvas id=\"myChartAccumulate\" width=\"400\" height=\"150\"></canvas><div id=\"accumulateTable\"></div>");
@ -1824,7 +1830,7 @@ $(document).ready(function(){
$("#accumulateTable").append('<table class="accutable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>' + $("#accumulateTable").append('<table class="accutable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>' +
'<tr>' + '<tr>' +
'<td>#</td>' + '<td>#</td>' +
'<td>Year</td>' + '<td>' + periodtext + '</td>' +
'<td>Accumulated # of ' + awardtext + ' worked </td>'+ '<td>Accumulated # of ' + awardtext + ' worked </td>'+
'</tr>' + '</tr>' +
'</thead>' + '</thead>' +
@ -1863,7 +1869,7 @@ $(document).ready(function(){
data: { data: {
labels: labels, labels: labels,
datasets: [{ datasets: [{
label: 'Accumulated number of ' + awardtext + ' worked each year', label: 'Accumulated number of ' + awardtext + ' worked each ' + period,
data: dataDxcc, data: dataDxcc,
backgroundColor: 'rgba(54, 162, 235, 0.2)', backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)', borderColor: 'rgba(54, 162, 235, 1)',