mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
prettier
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Accumulated extends CI_Controller {
|
||||
class Accumulated extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
if (!$this->user_model->authorize(2)) {
|
||||
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
|
||||
redirect('dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
@@ -32,7 +36,8 @@ class Accumulated extends CI_Controller {
|
||||
/*
|
||||
* Used for ajax-call in javascript to fetch the data and insert into table and chart
|
||||
*/
|
||||
public function get_accumulated_data(){
|
||||
public function get_accumulated_data()
|
||||
{
|
||||
//load model
|
||||
$this->load->model('accumulate_model');
|
||||
$band = $this->input->post('Band');
|
||||
@@ -45,5 +50,4 @@ class Accumulated extends CI_Controller {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,31 +3,40 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Accumulate_model extends CI_Model
|
||||
{
|
||||
function get_accumulated_data($band, $award, $mode, $period) {
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
function get_accumulated_data($band, $award, $mode, $period)
|
||||
{
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
$location_list = "'" . implode("','", $logbooks_locations_array) . "'";
|
||||
|
||||
switch ($award) {
|
||||
case 'dxcc': $result = $this->get_accumulated_dxcc($band, $mode, $period, $location_list); break;
|
||||
case 'was': $result = $this->get_accumulated_was($band, $mode, $period, $location_list); break;
|
||||
case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $location_list); break;
|
||||
case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $location_list); break;
|
||||
case 'dxcc':
|
||||
$result = $this->get_accumulated_dxcc($band, $mode, $period, $location_list);
|
||||
break;
|
||||
case 'was':
|
||||
$result = $this->get_accumulated_was($band, $mode, $period, $location_list);
|
||||
break;
|
||||
case 'iota':
|
||||
$result = $this->get_accumulated_iota($band, $mode, $period, $location_list);
|
||||
break;
|
||||
case 'waz':
|
||||
$result = $this->get_accumulated_waz($band, $mode, $period, $location_list);
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_accumulated_dxcc($band, $mode, $period, $location_list) {
|
||||
function get_accumulated_dxcc($band, $mode, $period, $location_list)
|
||||
{
|
||||
if ($period == "year") {
|
||||
$sql = "select year(thcv.col_time_on) year";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql = "select date_format(col_time_on, '%Y-%m') year";
|
||||
}
|
||||
|
||||
@@ -39,14 +48,13 @@ class Accumulate_model extends CI_Model
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= "year(col_time_on)";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= "date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
|
||||
$sql .= " year, col_dxcc
|
||||
from " . $this->config->item('table_name') .
|
||||
" where col_dxcc > 0 and station_id in (". $location_list . ")";
|
||||
from " . $this->config->item('table_name') .
|
||||
" where col_dxcc > 0 and station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -57,47 +65,45 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
|
||||
$sql .= " and col_dxcc = x.col_dxcc";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and station_id in (". $location_list . "))
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
} else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
|
||||
$sql .= " and col_dxcc = x.col_dxcc";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and station_id in (" . $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
|
||||
$sql .= " where thcv.col_dxcc > 0";
|
||||
|
||||
if ($band != 'All') {
|
||||
@@ -110,17 +116,15 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and station_id in (". $location_list . ")";
|
||||
|
||||
$sql .= " and station_id in (" . $location_list . ")";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " group by year(thcv.col_time_on), y.tot
|
||||
order by year(thcv.col_time_on)";
|
||||
}
|
||||
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= " group by date_format(col_time_on, '%Y-%m'), y.tot
|
||||
order by date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
@@ -130,7 +134,8 @@ class Accumulate_model extends CI_Model
|
||||
return $this->count_and_add_accumulated_total($query->result());
|
||||
}
|
||||
|
||||
function count_and_add_accumulated_total($array) {
|
||||
function count_and_add_accumulated_total($array)
|
||||
{
|
||||
$counter = 0;
|
||||
for ($i = 0; $i < count($array); $i++) {
|
||||
$array[$i]->total = $array[$i]->tot + $counter;
|
||||
@@ -139,11 +144,11 @@ class Accumulate_model extends CI_Model
|
||||
return $array;
|
||||
}
|
||||
|
||||
function get_accumulated_was($band, $mode, $period, $location_list) {
|
||||
function get_accumulated_was($band, $mode, $period, $location_list)
|
||||
{
|
||||
if ($period == "year") {
|
||||
$sql = "select year(thcv.col_time_on) year";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql = "select date_format(col_time_on, '%Y-%m') year";
|
||||
}
|
||||
|
||||
@@ -155,14 +160,13 @@ class Accumulate_model extends CI_Model
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= "year(col_time_on)";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= "date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
|
||||
$sql .= " year, col_state
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (". $location_list . ")";
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -173,35 +177,6 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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 .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
|
||||
$sql .= " and col_state = x.col_state";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
@@ -209,18 +184,17 @@ class Accumulate_model extends CI_Model
|
||||
$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 station_id in (". $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
} else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
$sql .= " where station_id in (". $location_list . ")";
|
||||
|
||||
$sql .= " and col_state = x.col_state";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -232,15 +206,41 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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 .= " and station_id in (" . $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
} else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
$sql .= " where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " group by year(thcv.col_time_on), y.tot
|
||||
order by year(thcv.col_time_on)";
|
||||
}
|
||||
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= " group by date_format(col_time_on, '%Y-%m'), y.tot
|
||||
order by date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
@@ -250,11 +250,11 @@ class Accumulate_model extends CI_Model
|
||||
return $this->count_and_add_accumulated_total($query->result());
|
||||
}
|
||||
|
||||
function get_accumulated_iota($band, $mode, $period, $location_list) {
|
||||
function get_accumulated_iota($band, $mode, $period, $location_list)
|
||||
{
|
||||
if ($period == "year") {
|
||||
$sql = "select year(thcv.col_time_on) year";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql = "select date_format(col_time_on, '%Y-%m') year";
|
||||
}
|
||||
|
||||
@@ -266,14 +266,13 @@ class Accumulate_model extends CI_Model
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= "year(col_time_on)";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= "date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
|
||||
$sql .= " year, col_iota
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (". $location_list . ")";
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -284,48 +283,21 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
|
||||
$sql .= " and col_iota = x.col_iota";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and station_id in (". $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
} else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
$sql .= " where station_id in (". $location_list . ")";
|
||||
|
||||
$sql .= " and col_iota = x.col_iota";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -337,15 +309,38 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
|
||||
$sql .= " and station_id in (" . $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
} else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
$sql .= " where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " group by year(thcv.col_time_on), y.tot
|
||||
order by year(thcv.col_time_on)";
|
||||
}
|
||||
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= " group by date_format(col_time_on, '%Y-%m'), y.tot
|
||||
order by date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
@@ -355,11 +350,11 @@ class Accumulate_model extends CI_Model
|
||||
return $this->count_and_add_accumulated_total($query->result());
|
||||
}
|
||||
|
||||
function get_accumulated_waz($band, $mode, $period, $location_list) {
|
||||
function get_accumulated_waz($band, $mode, $period, $location_list)
|
||||
{
|
||||
if ($period == "year") {
|
||||
$sql = "select year(thcv.col_time_on) year";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql = "select date_format(col_time_on, '%Y-%m') year";
|
||||
}
|
||||
|
||||
@@ -371,14 +366,13 @@ class Accumulate_model extends CI_Model
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= "year(col_time_on)";
|
||||
}
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= "date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
|
||||
$sql .= " year, col_cqz
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (". $location_list . ")";
|
||||
from " . $this->config->item('table_name') .
|
||||
" where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -389,48 +383,21 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
|
||||
$sql .= " and col_cqz = x.col_cqz";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
$sql .= " and station_id in (". $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
$sql .= " order by year
|
||||
) x
|
||||
where not exists (select 1 from " . $this->config->item('table_name') . " where";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
$sql .= " year(col_time_on) < year";;
|
||||
} else if ($period == "month") {
|
||||
$sql .= " date_format(col_time_on, '%Y-%m') < year";;
|
||||
}
|
||||
else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
$sql .= " where station_id in (". $location_list . ")";
|
||||
|
||||
$sql .= " and col_cqz = x.col_cqz";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
@@ -442,15 +409,38 @@ class Accumulate_model extends CI_Model
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
|
||||
$sql .= " and station_id in (" . $location_list . "))
|
||||
group by year
|
||||
order by year";
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " ) y on year(thcv.col_time_on) = y.year";
|
||||
} else if ($period == "month") {
|
||||
$sql .= " ) y on date_format(col_time_on, '%Y-%m') = y.year";
|
||||
}
|
||||
|
||||
$sql .= " where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
|
||||
}
|
||||
|
||||
if ($period == "year") {
|
||||
$sql .= " group by year(thcv.col_time_on), y.tot
|
||||
order by year(thcv.col_time_on)";
|
||||
}
|
||||
|
||||
else if ($period == "month") {
|
||||
} else if ($period == "month") {
|
||||
$sql .= " group by date_format(col_time_on, '%Y-%m'), y.tot
|
||||
order by date_format(col_time_on, '%Y-%m')";
|
||||
}
|
||||
@@ -459,4 +449,4 @@ class Accumulate_model extends CI_Model
|
||||
|
||||
return $this->count_and_add_accumulated_total($query->result());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,90 @@
|
||||
function accumulatePlot(form) {
|
||||
$(".ld-ext-right").addClass('running');
|
||||
$(".ld-ext-right").prop('disabled', true);
|
||||
$(".ld-ext-right").addClass("running");
|
||||
$(".ld-ext-right").prop("disabled", true);
|
||||
|
||||
// using this to change color of legend and label according to background color
|
||||
var color = ifDarkModeThemeReturn('white', 'grey');
|
||||
var color = ifDarkModeThemeReturn("white", "grey");
|
||||
|
||||
var award = form.awardradio.value;
|
||||
var mode = form.mode.value;
|
||||
var period = form.periodradio.value;
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/accumulated/get_accumulated_data',
|
||||
type: 'post',
|
||||
data: { 'Band': form.band.value, 'Award': award, 'Mode': mode, 'Period': period },
|
||||
url: base_url + "index.php/accumulated/get_accumulated_data",
|
||||
type: "post",
|
||||
data: {
|
||||
Band: form.band.value,
|
||||
Award: award,
|
||||
Mode: mode,
|
||||
Period: period,
|
||||
},
|
||||
success: function (data) {
|
||||
if (!$.trim(data)) {
|
||||
$("#accumulateContainer").empty();
|
||||
$("#accumulateContainer").append('<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>');
|
||||
$(".ld-ext-right").removeClass('running');
|
||||
$(".ld-ext-right").prop('disabled', false);
|
||||
}
|
||||
else {
|
||||
$("#accumulateContainer").append(
|
||||
'<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>'
|
||||
);
|
||||
$(".ld-ext-right").removeClass("running");
|
||||
$(".ld-ext-right").prop("disabled", false);
|
||||
} else {
|
||||
// used for switching award text in the table and the chart
|
||||
switch (award) {
|
||||
case 'dxcc': var awardtext = lang_statistics_accumulated_worked_dxcc; break;
|
||||
case 'was': var awardtext = lang_statistics_accumulated_worked_states; break;
|
||||
case 'iota': var awardtext = lang_statistics_accumulated_worked_iota; break;
|
||||
case 'waz': var awardtext = lang_statistics_accumulated_worked_cqzone; break;
|
||||
case "dxcc":
|
||||
var awardtext = lang_statistics_accumulated_worked_dxcc;
|
||||
break;
|
||||
case "was":
|
||||
var awardtext =
|
||||
lang_statistics_accumulated_worked_states;
|
||||
break;
|
||||
case "iota":
|
||||
var awardtext = lang_statistics_accumulated_worked_iota;
|
||||
break;
|
||||
case "waz":
|
||||
var awardtext =
|
||||
lang_statistics_accumulated_worked_cqzone;
|
||||
break;
|
||||
}
|
||||
|
||||
var periodtext = lang_general_word_year;
|
||||
if (period == 'month') {
|
||||
periodtext = lang_general_word_year + ' + ' + lang_general_word_month;
|
||||
if (period == "month") {
|
||||
periodtext =
|
||||
lang_general_word_year +
|
||||
" + " +
|
||||
lang_general_word_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>");
|
||||
$("#accumulateContainer").append(
|
||||
'<canvas id="myChartAccumulate" width="400" height="150"></canvas><div id="accumulateTable"></div>'
|
||||
);
|
||||
|
||||
// appending table to hold the data
|
||||
$("#accumulateTable").append('<table style="width:100%" class="accutable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>' +
|
||||
'<tr>' +
|
||||
'<td>#</td>' +
|
||||
'<td>' + periodtext + '</td>' +
|
||||
'<td>' + awardtext + '</td>' +
|
||||
'</tr>' +
|
||||
'</thead>' +
|
||||
'<tbody></tbody></table>');
|
||||
$("#accumulateTable").append(
|
||||
'<table style="width:100%" class="accutable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>' +
|
||||
"<tr>" +
|
||||
"<td>#</td>" +
|
||||
"<td>" +
|
||||
periodtext +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
awardtext +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
"</thead>" +
|
||||
"<tbody></tbody></table>"
|
||||
);
|
||||
var labels = [];
|
||||
var dataDxcc = [];
|
||||
|
||||
var $myTable = $('.accutable');
|
||||
var $myTable = $(".accutable");
|
||||
var i = 1;
|
||||
|
||||
// building the rows in the table
|
||||
var rowElements = data.map(function (row) {
|
||||
var $row = $("<tr></tr>");
|
||||
|
||||
var $row = $('<tr></tr>');
|
||||
|
||||
var $iterator = $('<td></td>').html(i++);
|
||||
var $type = $('<td></td>').html(row.year);
|
||||
var $content = $('<td></td>').html(row.total);
|
||||
var $iterator = $("<td></td>").html(i++);
|
||||
var $type = $("<td></td>").html(row.year);
|
||||
var $content = $("<td></td>").html(row.total);
|
||||
|
||||
$row.append($iterator, $type, $content);
|
||||
|
||||
@@ -73,76 +99,78 @@ function accumulatePlot(form) {
|
||||
dataDxcc.push(this.total);
|
||||
});
|
||||
|
||||
var ctx = document.getElementById("myChartAccumulate").getContext('2d');
|
||||
var ctx = document
|
||||
.getElementById("myChartAccumulate")
|
||||
.getContext("2d");
|
||||
var headerperiod;
|
||||
if (period == 'year') {
|
||||
if (period == "year") {
|
||||
headerperiod = lang_general_word_yearly;
|
||||
} else if (period == 'month') {
|
||||
} else if (period == "month") {
|
||||
headerperiod = lang_general_word_monthly;
|
||||
} else {
|
||||
headerperiod = 'n/a';
|
||||
headerperiod = "n/a";
|
||||
}
|
||||
var myChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: awardtext + ' (' + headerperiod + ')',
|
||||
data: dataDxcc,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 2,
|
||||
color: color
|
||||
}]
|
||||
datasets: [
|
||||
{
|
||||
label: awardtext + " (" + headerperiod + ")",
|
||||
data: dataDxcc,
|
||||
backgroundColor: "rgba(54, 162, 235, 0.2)",
|
||||
borderColor: "rgba(54, 162, 235, 1)",
|
||||
borderWidth: 2,
|
||||
color: color,
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
color: color
|
||||
}
|
||||
color: color,
|
||||
},
|
||||
},
|
||||
x: {
|
||||
ticks: {
|
||||
color: color
|
||||
}
|
||||
}
|
||||
color: color,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
labels: {
|
||||
color: color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
color: color,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
$(".ld-ext-right").removeClass('running');
|
||||
$(".ld-ext-right").prop('disabled', false);
|
||||
$('.accutable').DataTable({
|
||||
$(".ld-ext-right").removeClass("running");
|
||||
$(".ld-ext-right").prop("disabled", false);
|
||||
$(".accutable").DataTable({
|
||||
responsive: false,
|
||||
ordering: false,
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
"language": {
|
||||
scrollY: "400px",
|
||||
scrollCollapse: true,
|
||||
paging: false,
|
||||
scrollX: true,
|
||||
language: {
|
||||
url: getDataTablesLanguageUrl(),
|
||||
},
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'csv'
|
||||
]
|
||||
dom: "Bfrtip",
|
||||
buttons: ["csv"],
|
||||
});
|
||||
|
||||
// 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)')) {
|
||||
if (background != "rgb(255, 255, 255)") {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user