diff --git a/application/controllers/Timeline.php b/application/controllers/Timeline.php index cb99c636..879df97b 100644 --- a/application/controllers/Timeline.php +++ b/application/controllers/Timeline.php @@ -14,7 +14,7 @@ class Timeline extends CI_Controller { public function index() { // Render Page - $data['page_title'] = "DXCC Timeline"; + $data['page_title'] = "Timeline"; $this->load->model('Timeline_model'); @@ -25,9 +25,28 @@ class Timeline extends CI_Controller { $band = 'All'; } - $data['dxcc_timeline_array'] = $this->Timeline_model->get_dxcc_timeline($band); + if ($this->input->post('mode') != NULL) { // Band is not set when page first loads. + $mode = $this->input->post('mode'); + } + else { + $mode = 'All'; + } + + if ($this->input->post('awardradio') != NULL) { // Band is not set when page first loads. + $award = $this->input->post('awardradio'); + } + else { + $award = 'dxcc'; + } + + $this->load->model('modes'); + + $data['modes'] = $this->modes->active(); + + $data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award); $data['worked_bands'] = $this->Timeline_model->get_worked_bands(); $data['bandselect'] = $band; + $data['modeselect'] = $mode; $this->load->view('interface_assets/header', $data); $this->load->view('timeline/index'); @@ -37,14 +56,29 @@ class Timeline extends CI_Controller { public function details() { $this->load->model('logbook_model'); - $adif = str_replace('"', "", $this->input->post("Adif")); - $country = $this->logbook_model->get_entity($adif); - $band = str_replace('"', "", $this->input->post("Band")); - $data['results'] = $this->logbook_model->timeline_qso_details($adif, $band); + $querystring = str_replace('"', "", $this->input->post("Querystring")); - // Render Page - $data['page_title'] = "Log View - DXCC"; - $data['filter'] = "country ". $country['name']; + $band = str_replace('"', "", $this->input->post("Band")); + $mode = str_replace('"', "", $this->input->post("Mode")); + $type = str_replace('"', "", $this->input->post("Type")); + $data['results'] = $this->logbook_model->timeline_qso_details($querystring, $band, $mode, $type); + + + switch($type) { + case 'dxcc': $country = $this->logbook_model->get_entity($querystring); + $data['page_title'] = "Log View - DXCC"; + $data['filter'] = "country ". $country['name']; + break; + case 'was' : $data['page_title'] = "Log View - WAS"; + $data['filter'] = "state ". $querystring; + break; + case 'iota': $data['page_title'] = "Log View - IOTA"; + $data['filter'] = "iota ". $querystring; + break; + case 'waz' : $data['page_title'] = "Log View - WAZ"; + $data['filter'] = "CQ zone ". $querystring; + break; + } if ($band != "All") { $data['filter'] .= " and " . $band; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 53464389..b1b57b25 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -278,7 +278,7 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } - public function timeline_qso_details($adif, $band){ + public function timeline_qso_details($querystring, $band, $mode, $type){ $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); @@ -292,8 +292,18 @@ class Logbook_model extends CI_Model { } } + if ($mode != 'All') { + $this->db->where('col_mode', $mode); + } + $this->db->where('station_id', $station_id); - $this->db->where('COL_DXCC', $adif); + + switch($type) { + case 'dxcc': $this->db->where('COL_DXCC', $querystring); break; + case 'was': $this->db->where('COL_STATE', $querystring); break; + case 'iota': $this->db->where('COL_IOTA', $querystring); break; + case 'waz': $this->db->where('COL_CQZ', $querystring); break; + } return $this->db->get($this->config->item('table_name')); } diff --git a/application/models/Timeline_model.php b/application/models/Timeline_model.php index 7ce479ca..4730f457 100644 --- a/application/models/Timeline_model.php +++ b/application/models/Timeline_model.php @@ -9,12 +9,22 @@ class Timeline_model extends CI_Model parent::__construct(); } - function get_dxcc_timeline($band) - { + function get_timeline($band, $mode, $award) { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); + switch ($award) { + case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $station_id); break; + case 'was': $result = $this->get_timeline_was($band, $mode, $station_id); break; + case 'iota': $result = $this->get_timeline_iota($band, $mode, $station_id); break; + case 'waz': $result = $this->get_timeline_waz($band, $mode, $station_id); break; + } + + return $result; + } + + public function get_timeline_dxcc($band, $mode, $station_id) { $sql = "select min(date(COL_TIME_ON)) date, prefix, col_country, end, adif from " .$this->config->item('table_name'). " thcv join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif @@ -30,6 +40,10 @@ class Timeline_model extends CI_Model } } + if ($mode != 'All') { + $sql .= " and col_mode ='" . $mode . "'"; + } + $sql .= " group by col_dxcc, col_country order by date desc"; @@ -38,6 +52,91 @@ class Timeline_model extends CI_Model return $query->result(); } + public function get_timeline_was($band, $mode, $station_id) { + $sql = "select min(date(COL_TIME_ON)) date, col_state from " + .$this->config->item('table_name'). " thcv + where 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 .= " group by col_state + order by date desc"; + + $query = $this->db->query($sql); + + return $query->result(); + } + + public function get_timeline_iota($band, $mode, $station_id) { + $sql = "select min(date(COL_TIME_ON)) date, col_iota, name, prefix from " + .$this->config->item('table_name'). " thcv + join iota on thcv.col_iota = iota.tag + where 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_iota <> '' group by col_iota + order by date desc"; + + $query = $this->db->query($sql); + + return $query->result(); + } + + public function get_timeline_waz($band, $mode, $station_id) { + $sql = "select min(date(COL_TIME_ON)) date, col_cqz from " + .$this->config->item('table_name'). " thcv + where 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_cqz <> '' group by col_cqz + order by date desc"; + + $query = $this->db->query($sql); + + return $query->result(); + } + public $bandslots = array("160m" => 0, "80m" => 0, "60m" => 0, diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index d0af4c4e..fda640c4 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1903,13 +1903,15 @@ $(document).ready(function(){ $(".buttons-csv").css("color", "white"); } - function displayTimelineContacts(adif, band) { + function displayTimelineContacts(querystring, band, mode, type) { var baseURL= ""; $.ajax({ url: baseURL + 'index.php/timeline/details', type: 'post', - data: {'Adif': adif, - 'Band': band + data: {'Querystring': querystring, + 'Band': band, + 'Mode': mode, + 'Type': type }, success: function(html) { BootstrapDialog.show({ diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index d7125e90..e04e46f9 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -84,9 +84,9 @@
Days with QSOs - DXCC Timeline + Timeline - Accumulated statistics + Accumulated statistics Timeplotter diff --git a/application/views/timeline/details.php b/application/views/timeline/details.php index d5e85065..ca67ad2c 100644 --- a/application/views/timeline/details.php +++ b/application/views/timeline/details.php @@ -1,7 +1,4 @@