From b33898abdb415c3206363a1bf978c80651fcc87b Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 23 Oct 2020 12:25:16 +0200 Subject: [PATCH] Expanded timeline with more options. --- application/controllers/Timeline.php | 52 ++++- application/models/Logbook_model.php | 14 +- application/models/Timeline_model.php | 103 ++++++++- application/views/interface_assets/footer.php | 8 +- application/views/interface_assets/header.php | 4 +- application/views/timeline/details.php | 5 +- application/views/timeline/index.php | 201 +++++++++++++++--- 7 files changed, 334 insertions(+), 53 deletions(-) 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 @@
- -

Logbook

- -

Filtering on

+
Filtering on
load->view('view_log/partial/log_ajax') ?> diff --git a/application/views/timeline/index.php b/application/views/timeline/index.php index b5500901..fc711867 100644 --- a/application/views/timeline/index.php +++ b/application/views/timeline/index.php @@ -2,23 +2,72 @@

-
- -
- -
- + +
+ +
+ +
+ + +
+ +
+
+ +
+ + +
+
+ input->post('awardradio') == 'dxcc' || $this->input->method() !== 'post') echo ' checked'?>> + +
+
+ input->post('awardradio') == 'was') echo ' checked'?>> + +
+
+ input->post('awardradio') == 'iota') echo ' checked'?>> + +
+
+ input->post('awardradio') == 'waz') echo ' checked'?>> +
+
-
@@ -26,7 +75,6 @@
-
+ + if ($timeline_array) { + switch ($this->input->post('awardradio')) { + case 'dxcc': $result = write_dxcc_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; + case 'was': $result = write_was_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; + case 'iota': $result = write_iota_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; + case 'waz': $result = write_waz_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; + } + } + else { + echo ''; + } + ?> + +
+ + # @@ -57,25 +123,98 @@ '; - foreach ($dxcc_timeline_array as $line) { - $date_as_timestamp = strtotime($line->date); - echo ' + foreach ($timeline_array as $line) { + $date_as_timestamp = strtotime($line->date); + echo ' ' . $i-- . ' ' . date($custom_date_format, $date_as_timestamp) . ' ' . $line->prefix . ' ' . $line->col_country . ' '; - if (!empty($line->end)) echo 'Yes'; - echo ' + if (!empty($line->end)) echo 'Yes'; + echo ' ' . $line->end . ' - adif . '","'. $bandselect . '")>Show + adif . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show '; - } - echo ''; } - else { - echo ''; - } - ?> + echo ''; +} - \ No newline at end of file +function write_was_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) { + $i = count($timeline_array); + echo ' + + + + + + + + + '; + + foreach ($timeline_array as $line) { + $date_as_timestamp = strtotime($line->date); + echo ' + + + + + '; + } + echo '
#DateStateShow QSOs
' . $i-- . '' . date($custom_date_format, $date_as_timestamp) . '' . $line->col_state . 'col_state . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show
'; +} + +function write_iota_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) { + $i = count($timeline_array); + echo ' + + + + + + + + + + + '; + + foreach ($timeline_array as $line) { + $date_as_timestamp = strtotime($line->date); + echo ' + + + + + + + '; + } + echo '
#DateIotaNamePrefixShow QSOs
' . $i-- . '' . date($custom_date_format, $date_as_timestamp) . '' . $line->col_iota . '' . $line->name . '' . $line->prefix . 'col_iota . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show
'; +} + +function write_waz_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) { + $i = count($timeline_array); + echo ' + + + + + + + + + '; + + foreach ($timeline_array as $line) { + $date_as_timestamp = strtotime($line->date); + echo ' + + + + + '; + } + echo '
#DateCQ ZoneShow QSOs
' . $i-- . '' . date($custom_date_format, $date_as_timestamp) . '' . $line->col_cqz . 'col_cqz . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show
'; +} \ No newline at end of file