kopia lustrzana https://github.com/magicbug/Cloudlog
Mode and period has been added.
rodzic
20dc1caa27
commit
dd200871cc
|
@ -20,6 +20,10 @@ class Accumulated extends CI_Controller {
|
|||
|
||||
$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('accumulate/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
@ -33,9 +37,11 @@ class Accumulated extends CI_Controller {
|
|||
$this->load->model('accumulate_model');
|
||||
$band = $this->input->post('Band');
|
||||
$award = $this->input->post('Award');
|
||||
$mode = $this->input->post('Mode');
|
||||
$period = $this->input->post('Period');
|
||||
|
||||
// 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');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
|
|
@ -9,24 +9,34 @@ class Accumulate_model extends CI_Model
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
function get_accumulated_data($band, $award) {
|
||||
function get_accumulated_data($band, $award, $mode, $period) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
switch ($award) {
|
||||
case 'dxcc': $result = $this->get_accumulated_dxcc($band, $station_id); break;
|
||||
case 'was': $result = $this->get_accumulated_was($band, $station_id); break;
|
||||
case 'iota': $result = $this->get_accumulated_iota($band, $station_id); break;
|
||||
case 'waz': $result = $this->get_accumulated_waz($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, $mode, $period, $station_id); break;
|
||||
case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $station_id); break;
|
||||
case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $station_id); break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_accumulated_dxcc($band, $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;
|
||||
function get_accumulated_dxcc($band, $mode, $period, $station_id) {
|
||||
if ($period == "year") {
|
||||
$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 == '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
|
||||
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)";
|
||||
}
|
||||
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);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function get_accumulated_was($band, $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;
|
||||
function get_accumulated_was($band, $mode, $period, $station_id) {
|
||||
if ($period == "year") {
|
||||
$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 == '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_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_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)";
|
||||
}
|
||||
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);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function get_accumulated_iota($band, $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;
|
||||
function get_accumulated_iota($band, $mode, $period, $station_id) {
|
||||
if ($period == "year") {
|
||||
$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 == '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
|
||||
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)";
|
||||
}
|
||||
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);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function get_accumulated_waz($band, $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;
|
||||
function get_accumulated_waz($band, $mode, $period, $station_id) {
|
||||
if ($period == "year") {
|
||||
$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 == '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
|
||||
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)";
|
||||
}
|
||||
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);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<!-- Select Basic -->
|
||||
<div class="form-group row">
|
||||
<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">
|
||||
<option value="All">All</option>
|
||||
<?php foreach($worked_bands as $band) {
|
||||
|
@ -14,31 +14,68 @@
|
|||
} ?>
|
||||
</select>
|
||||
</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\">⇒ %s</option>", $mode->submode, $mode->submode);
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="awardradio" id="dxcc" value="dxcc" checked>
|
||||
<label class="form-check-label" for="dxcc">
|
||||
DX Century Club (DXCC)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="awardradio" id="was" value="was">
|
||||
<label class="form-check-label" for="was">
|
||||
Worked all states (WAS)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="awardradio" id="iota" value="iota">
|
||||
<label class="form-check-label" for="iota">
|
||||
Islands on the air (IOTA)
|
||||
</label>
|
||||
</div>
|
||||
<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 class="form-group row">
|
||||
|
||||
<label class="col-md-1 control-label" for="radio">Award</label>
|
||||
<div class="col-md-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="awardradio" id="dxcc" value="dxcc" checked>
|
||||
<label class="form-check-label" for="dxcc">
|
||||
DX Century Club (DXCC)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="awardradio" id="was" value="was">
|
||||
<label class="form-check-label" for="was">
|
||||
Worked all states (WAS)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="awardradio" id="iota" value="iota">
|
||||
<label class="form-check-label" for="iota">
|
||||
Islands on the air (IOTA)
|
||||
</label>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
|
|
@ -1803,10 +1803,12 @@ $(document).ready(function(){
|
|||
|
||||
var baseURL= "<?php echo base_url();?>";
|
||||
var award = form.awardradio.value;
|
||||
var mode = form.mode.value;
|
||||
var period = form.periodradio.value;
|
||||
$.ajax({
|
||||
url: baseURL+'index.php/accumulated/get_accumulated_data',
|
||||
type: 'post',
|
||||
data: {'Band': form.band.value, 'Award': award},
|
||||
data: {'Band': form.band.value, 'Award': award, 'Mode': mode, 'Period': period},
|
||||
success: function(data) {
|
||||
// used for switching award text in the table and the chart
|
||||
switch(award) {
|
||||
|
@ -1816,7 +1818,11 @@ $(document).ready(function(){
|
|||
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").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>' +
|
||||
'<tr>' +
|
||||
'<td>#</td>' +
|
||||
'<td>Year</td>' +
|
||||
'<td>' + periodtext + '</td>' +
|
||||
'<td>Accumulated # of ' + awardtext + ' worked </td>'+
|
||||
'</tr>' +
|
||||
'</thead>' +
|
||||
|
@ -1863,7 +1869,7 @@ $(document).ready(function(){
|
|||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Accumulated number of ' + awardtext + ' worked each year',
|
||||
label: 'Accumulated number of ' + awardtext + ' worked each ' + period,
|
||||
data: dataDxcc,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
|
|
Ładowanie…
Reference in New Issue