Merge pull request #643 from AndreasK79/accumulated_stats
New feaure: Accumulated stats for DXCC, WAS, IOTA or WAZ
这个提交包含在:
		
						当前提交
						76691aaa6d
					
				
					共有  5 个文件被更改,包括 591 次插入 和 6 次删除
				
			
		|  | @ -0,0 +1,49 @@ | ||||||
|  | <?php | ||||||
|  | defined('BASEPATH') OR exit('No direct script access allowed'); | ||||||
|  | 
 | ||||||
|  | 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'); } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function index() | ||||||
|  |     { | ||||||
|  |         // Render Page
 | ||||||
|  |         $data['page_title'] = "Accumulated statistics"; | ||||||
|  | 
 | ||||||
|  |         $this->load->model('Accumulate_model'); | ||||||
|  | 
 | ||||||
|  |         $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'); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /* | ||||||
|  |      * Used for ajax-call in javascript to fetch the data and insert into table and chart | ||||||
|  |      */ | ||||||
|  |     public function get_accumulated_data(){ | ||||||
|  |         //load model
 | ||||||
|  |         $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, $mode, $period); | ||||||
|  |         header('Content-Type: application/json'); | ||||||
|  |         echo json_encode($data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -0,0 +1,314 @@ | ||||||
|  | <?php | ||||||
|  | if (!defined('BASEPATH')) exit('No direct script access allowed'); | ||||||
|  | 
 | ||||||
|  | class Accumulate_model extends CI_Model | ||||||
|  | { | ||||||
|  |     function __construct() | ||||||
|  |     { | ||||||
|  |         // Call the Model constructor
 | ||||||
|  |         parent::__construct(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     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, $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, $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') { | ||||||
|  |                 $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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $sql .=") total  from " . $this->config->item('table_name') . " as a
 | ||||||
|  |                       where a.station_id = ". $station_id;
 | ||||||
|  | 
 | ||||||
|  |         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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         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, $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') { | ||||||
|  |                 $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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $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 .=") total  from " . $this->config->item('table_name') . " as a
 | ||||||
|  |                       where a.station_id = ". $station_id;
 | ||||||
|  | 
 | ||||||
|  |         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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $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')"; | ||||||
|  | 
 | ||||||
|  |         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, $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') { | ||||||
|  |                 $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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $sql .=") total  from " . $this->config->item('table_name') . " as a
 | ||||||
|  |                       where a.station_id = ". $station_id;
 | ||||||
|  | 
 | ||||||
|  |         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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         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, $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') { | ||||||
|  |                 $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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $sql .=") total  from " . $this->config->item('table_name') . " as a
 | ||||||
|  |                       where a.station_id = ". $station_id;
 | ||||||
|  | 
 | ||||||
|  |         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 . "'"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         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_worked_bands() { | ||||||
|  |         $CI =& get_instance(); | ||||||
|  |         $CI->load->model('Stations'); | ||||||
|  |         $station_id = $CI->Stations->find_active(); | ||||||
|  | 
 | ||||||
|  |         $data = $this->db->query( | ||||||
|  |             "SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE != \"SAT\"" | ||||||
|  |         ); | ||||||
|  |         $worked_slots = array(); | ||||||
|  |         foreach ($data->result() as $row) { | ||||||
|  |             array_push($worked_slots, $row->COL_BAND); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $SAT_data = $this->db->query( | ||||||
|  |             "SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE = \"SAT\"" | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         foreach ($SAT_data->result() as $row) { | ||||||
|  |             array_push($worked_slots, strtoupper($row->COL_PROP_MODE)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // bring worked-slots in order of defined $bandslots
 | ||||||
|  |         $results = array(); | ||||||
|  |         foreach (array_keys($this->bandslots) as $slot) { | ||||||
|  |             if (in_array($slot, $worked_slots)) { | ||||||
|  |                 array_push($results, $slot); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return $results; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public $bandslots = array("160m" => 0, | ||||||
|  |         "80m" => 0, | ||||||
|  |         "60m" => 0, | ||||||
|  |         "40m" => 0, | ||||||
|  |         "30m" => 0, | ||||||
|  |         "20m" => 0, | ||||||
|  |         "17m" => 0, | ||||||
|  |         "15m" => 0, | ||||||
|  |         "12m" => 0, | ||||||
|  |         "10m" => 0, | ||||||
|  |         "6m" => 0, | ||||||
|  |         "4m" => 0, | ||||||
|  |         "2m" => 0, | ||||||
|  |         "70cm" => 0, | ||||||
|  |         "23cm" => 0, | ||||||
|  |         "13cm" => 0, | ||||||
|  |         "9cm" => 0, | ||||||
|  |         "6cm" => 0, | ||||||
|  |         "3cm" => 0, | ||||||
|  |         "1.25cm" => 0, | ||||||
|  |         "SAT" => 0, | ||||||
|  |     ); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,99 @@ | ||||||
|  | <div class="container"> | ||||||
|  |     <h2><?php echo $page_title; ?></h1>
 | ||||||
|  | 
 | ||||||
|  |         <form class="form"> | ||||||
|  | 
 | ||||||
|  |                 <!-- Select Basic --> | ||||||
|  |                 <div class="form-group row"> | ||||||
|  |                     <label class="col-md-1 control-label" for="band">Band</label> | ||||||
|  |                     <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) { | ||||||
|  |                                 echo '<option value="' . $band . '">' . $band . '</option>'."\n"; | ||||||
|  |                             } ?>
 | ||||||
|  |                         </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 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> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |                 <!-- Button (Double) --> | ||||||
|  |                 <div class="form-group row"> | ||||||
|  |                     <div class="col-md-10"> | ||||||
|  |                         <button id="button1id" type="button" name="button1id" class="btn btn-success btn-primary ld-ext-right" onclick="accumulatePlot(this.form)">Show<div class="ld ld-ring ld-spin"></div></button> | ||||||
|  |                     </div> | ||||||
|  |                 </div> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         </form> | ||||||
|  | 
 | ||||||
|  |         <div id="accumulateContainer"> | ||||||
|  |         <canvas id="myChartAccumulate" width="400" height="150"></canvas> | ||||||
|  |         <div id="accumulateTable"></div> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  | </div> | ||||||
|  | 
 | ||||||
|  | @ -31,9 +31,7 @@ | ||||||
|     <script src="<?php echo base_url() ;?>assets/js/sections/notes.js"></script> |     <script src="<?php echo base_url() ;?>assets/js/sections/notes.js"></script> | ||||||
| <?php } ?>
 | <?php } ?>
 | ||||||
| 
 | 
 | ||||||
| <?php if ($this->uri->segment(1) == "awards") { ?>
 |  | ||||||
|     <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/datatables.min.js"></script> |     <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/datatables.min.js"></script> | ||||||
| <?php } ?>
 |  | ||||||
| 
 | 
 | ||||||
| <?php if ($this->uri->segment(1) == "search" && $this->uri->segment(2) == "filter") { ?>
 | <?php if ($this->uri->segment(1) == "search" && $this->uri->segment(2) == "filter") { ?>
 | ||||||
| 
 | 
 | ||||||
|  | @ -1791,6 +1789,131 @@ $(document).ready(function(){ | ||||||
|         </script> |         </script> | ||||||
|         <?php } ?>
 |         <?php } ?>
 | ||||||
| 
 | 
 | ||||||
|  | <?php if ($this->uri->segment(1) == "accumulated") { ?>
 | ||||||
|  |     <script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script> | ||||||
|  |     <script> | ||||||
|  |         function accumulatePlot(form) { | ||||||
|  |             $(".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 background = $('body').css( "background-color"); | ||||||
|  |             var color = 'grey'; | ||||||
|  |             if (background != ('rgb(255, 255, 255)')) { | ||||||
|  |                 color = 'white'; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             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, 'Mode': mode, 'Period': period}, | ||||||
|  |                 success: function(data) { | ||||||
|  |                     // used for switching award text in the table and the chart
 | ||||||
|  |                     switch(award) { | ||||||
|  |                         case 'dxcc': var awardtext = "DXCC\'s"; break; | ||||||
|  |                         case 'was':  var awardtext = "states";break; | ||||||
|  |                         case 'iota': var awardtext = "IOTA\'s";break; | ||||||
|  |                         case 'waz':  var awardtext = "CQ zones"; break; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     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>"); | ||||||
|  | 
 | ||||||
|  |                     // 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>Accumulated # of ' + awardtext + ' worked </td>'+ | ||||||
|  |                         '</tr>' + | ||||||
|  |                         '</thead>' + | ||||||
|  |                         '<tbody></tbody></table>'); | ||||||
|  |                     var labels = []; | ||||||
|  |                     var dataDxcc = []; | ||||||
|  | 
 | ||||||
|  |                     var $myTable = $('.accutable'); | ||||||
|  |                     var i = 1; | ||||||
|  | 
 | ||||||
|  |                     // building the rows in the table
 | ||||||
|  |                     var rowElements = data.map(function ( row ) { | ||||||
|  | 
 | ||||||
|  |                         var $row = $('<tr></tr>'); | ||||||
|  | 
 | ||||||
|  |                         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); | ||||||
|  | 
 | ||||||
|  |                         return $row; | ||||||
|  |                     }); | ||||||
|  | 
 | ||||||
|  |                     // finally inserting the rows
 | ||||||
|  |                     $myTable.append(rowElements); | ||||||
|  | 
 | ||||||
|  |                     $.each(data, function(){ | ||||||
|  |                         labels.push(this.year); | ||||||
|  |                         dataDxcc.push(this.total); | ||||||
|  |                     }); | ||||||
|  | 
 | ||||||
|  |                     var ctx = document.getElementById("myChartAccumulate").getContext('2d'); | ||||||
|  |                     var myChart = new Chart(ctx, { | ||||||
|  |                         type: 'bar', | ||||||
|  |                         data: { | ||||||
|  |                             labels: labels, | ||||||
|  |                             datasets: [{ | ||||||
|  |                                 label: 'Accumulated number of ' + awardtext + ' worked each ' + period, | ||||||
|  |                                 data: dataDxcc, | ||||||
|  |                                 backgroundColor: 'rgba(54, 162, 235, 0.2)', | ||||||
|  |                                 borderColor: 'rgba(54, 162, 235, 1)', | ||||||
|  |                                 borderWidth: 2, | ||||||
|  |                             }] | ||||||
|  |                         }, | ||||||
|  |                         options: { | ||||||
|  |                             scales: { | ||||||
|  |                                 yAxes: [{ | ||||||
|  |                                     ticks: { | ||||||
|  |                                         beginAtZero:true, | ||||||
|  |                                         fontColor: color | ||||||
|  |                                     } | ||||||
|  |                                 }], | ||||||
|  |                                 xAxes: [{ | ||||||
|  |                                     ticks: { | ||||||
|  |                                         fontColor: color | ||||||
|  |                                     } | ||||||
|  |                                 }] | ||||||
|  |                             }, | ||||||
|  |                             legend: { | ||||||
|  |                                 labels: { | ||||||
|  |                                     fontColor: color, | ||||||
|  |                                 } | ||||||
|  |                             }, | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                     $(".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 | ||||||
|  |                     }); | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     </script> | ||||||
|  | <?php } ?>
 | ||||||
| 
 | 
 | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|  |  | ||||||
|  | @ -28,16 +28,14 @@ | ||||||
| 	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/plugins/quill/quill.snow.css" /> | 	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/plugins/quill/quill.snow.css" /> | ||||||
| 	<?php } ?>
 | 	<?php } ?>
 | ||||||
| 
 | 
 | ||||||
| 	<?php if ($this->uri->segment(1) == "qrz") { ?>
 | 	<?php if ($this->uri->segment(1) == "qrz" || $this->uri->segment(1) == "accumulated") { ?>
 | ||||||
| 	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/loading.min.css" /> | 	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/loading.min.css" /> | ||||||
| 	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/ldbtn.min.css" /> | 	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/ldbtn.min.css" /> | ||||||
| 	<?php } ?>
 | 	<?php } ?>
 | ||||||
| 
 | 
 | ||||||
|     <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/js/bootstrapdialog/css/bootstrap-dialog.min.css" /> |     <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/js/bootstrapdialog/css/bootstrap-dialog.min.css" /> | ||||||
| 
 | 
 | ||||||
|       <?php if ($this->uri->segment(1) == "awards") { ?>
 |  | ||||||
|   <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/datatables.min.css"/> |   <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/datatables.min.css"/> | ||||||
|       <?php } ?>
 |  | ||||||
| 
 | 
 | ||||||
|  	<?php if ($this->uri->segment(1) == "adif") { ?>
 |  	<?php if ($this->uri->segment(1) == "adif") { ?>
 | ||||||
|   	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/datepicker.css" /> |   	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/datepicker.css" /> | ||||||
|  | @ -86,6 +84,8 @@ | ||||||
|                     <a class="dropdown-item" href="<?php echo site_url('dayswithqso');?>" title="Dayswithqso">Days with QSOs</a> |                     <a class="dropdown-item" href="<?php echo site_url('dayswithqso');?>" title="Dayswithqso">Days with QSOs</a> | ||||||
|                     <div class="dropdown-divider"></div> |                     <div class="dropdown-divider"></div> | ||||||
|                     <a class="dropdown-item" href="<?php echo site_url('timeline');?>" title="Dxcctimeline">DXCC Timeline</a> |                     <a class="dropdown-item" href="<?php echo site_url('timeline');?>" title="Dxcctimeline">DXCC Timeline</a> | ||||||
|  |                     <div class="dropdown-divider"></div> | ||||||
|  |                     <a class="dropdown-item" href="<?php echo site_url('accumulated');?>" title="Dxcctimeline">Accumulated statistics</a> | ||||||
| 				</div> | 				</div> | ||||||
|         	</li> |         	</li> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用