From 22e74b55e434b620b532909c156ebda53688ad48 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 22 Mar 2022 17:41:03 +0100 Subject: [PATCH] Add table for (VUCC) gridsquare activators top list Squashed commit of the following: commit 1091c0321e49b37f29d2997ff28051f137efc53f Author: phl0 Date: Tue Mar 22 17:31:08 2022 +0100 Also take VUCC_GRIDS into account commit c396e87c78e659c98c86ebf96ce21ba9a34203d0 Author: phl0 Date: Thu Jan 27 23:19:39 2022 +0100 Add ShowQSO function for detailed view commit 52d3ef9b60de6a82c9239e6be387aa35050db203 Author: phl0 Date: Thu Jan 27 20:59:58 2022 +0100 Distinguish between LEO and GEO in SAT selection commit 019d1d71bf3f06abbd38c65b0278c52c785bf407 Author: phl0 Date: Thu Jan 27 19:57:48 2022 +0100 Make sure mincount is numeric commit 3802f9269d7e6bae7891e814909bd364afbfdf73 Author: phl0 Date: Thu Jan 27 00:37:35 2022 +0100 Implement optional minimin grid count commit d206f2429d2bbaab1336c2266e7036e2ea77718d Author: phl0 Date: Wed Jan 26 23:21:55 2022 +0100 Add table showing gridsquare activators --- application/controllers/Activators.php | 75 ++++++++++ application/models/Activators_model.php | 117 ++++++++++++++++ application/models/Logbook_model.php | 26 ++++ application/views/activators/details.php | 4 + application/views/activators/index.php | 130 ++++++++++++++++++ application/views/interface_assets/footer.php | 69 +++++++++- application/views/interface_assets/header.php | 2 + 7 files changed, 422 insertions(+), 1 deletion(-) create mode 100644 application/controllers/Activators.php create mode 100644 application/models/Activators_model.php create mode 100644 application/views/activators/details.php create mode 100644 application/views/activators/index.php diff --git a/application/controllers/Activators.php b/application/controllers/Activators.php new file mode 100644 index 00000000..6c66d542 --- /dev/null +++ b/application/controllers/Activators.php @@ -0,0 +1,75 @@ +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'] = "Gridsquare Activators"; + + $this->load->model('Activators_model'); + + if ($this->input->post('band') != NULL) { // Band is not set when page first loads. + $band = $this->input->post('band'); + } + else { + $band = 'All'; + } + + $this->load->model('bands'); + + $data['worked_bands'] = $this->bands->get_worked_bands(); + $data['maxactivatedgrids'] = $this->Activators_model->get_max_activated_grids(); + $data['activators_array'] = $this->Activators_model->get_activators($band, $this->input->post('mincount'), $this->input->post('leogeo')); + $data['activators_vucc_array'] = $this->Activators_model->get_activators_vucc($band, $this->input->post('leogeo')); + $data['bandselect'] = $band; + + $this->load->view('interface_assets/header', $data); + $this->load->view('activators/index'); + $this->load->view('interface_assets/footer'); + } + + public function details() { + $this->load->model('logbook_model'); + + $call = str_replace('"', "", $this->input->post("Callsign")); + $band = str_replace('"', "", $this->input->post("Band")); + $leogeo = str_replace('"', "", $this->input->post("LeoGeo")); + $data['results'] = $this->logbook_model->activator_details($call, $band, $leogeo); + $data['filter'] = "Call ".$call; + switch($band) { + case 'All': $data['page_title'] = "Log View All Bands"; + $data['filter'] .= " and Band All"; + break; + case 'SAT': $data['page_title'] = "Log View SAT"; + $data['filter'] .= " and Band SAT"; + break; + default: $data['page_title'] = "Log View Band"; + $data['filter'] .= " and Band ".$band; + break; + } + if ($band == "SAT") { + switch($leogeo) { + case 'both': $data['filter'] .= " and GEO/LEO"; + break; + case 'leo': $data['filter'] .= " and LEO"; + break; + case 'geo': $data['filter'] .= " and GEO"; + break; + } + } + + + $this->load->view('activators/details', $data); + } + +} diff --git a/application/models/Activators_model.php b/application/models/Activators_model.php new file mode 100644 index 00000000..283b00b8 --- /dev/null +++ b/application/models/Activators_model.php @@ -0,0 +1,117 @@ +load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if ($mincount == '' || $mincount == 0 || ! is_numeric($mincount)) { + $mincount = 2; + } + + if (!$logbooks_locations_array) { + return null; + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $sql = "select COL_CALL as `call`, COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count`, GROUP_CONCAT(DISTINCT SUBSTR(`COL_GRIDSQUARE`,1,4) ORDER BY `COL_GRIDSQUARE` SEPARATOR ', ') AS `grids` from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; + if ($band != 'All') { + if ($band == 'SAT') { + switch ($leogeo) { + case 'both' : + $sql .= " and col_prop_mode ='" . $band . "'"; + break; + case 'leo' : + $sql .= " and col_prop_mode = '" . $band . "'"; + $sql .= " and col_sat_name != 'QO-100'"; + break; + case 'geo' : + $sql .= " and col_prop_mode = '" . $band . "'"; + $sql .= " and col_sat_name = 'QO-100'"; + break; + default : + $sql .= " and col_prop_mode ='" . $band . "'"; + break; + } + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and COL_BAND ='" . $band . "'"; + } + } + $sql .= " AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` HAVING `count` >= ".$mincount." ORDER BY `count` DESC;"; + + $query = $this->db->query($sql); + + return $query->result(); + } + + function get_activators_vucc($band, $leogeo) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(REGEXP_REPLACE(COL_VUCC_GRIDS, '([A-Z]{2}[0-9]{2})[A-Z]{2}', '$1')) AS `vucc_grids` FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; + if ($band != 'All') { + if ($band == 'SAT') { + switch ($leogeo) { + case 'both' : + $sql .= " and col_prop_mode ='" . $band . "'"; + break; + case 'leo' : + $sql .= " and col_prop_mode = '" . $band . "'"; + $sql .= " and col_sat_name != 'QO-100'"; + break; + case 'geo' : + $sql .= " and col_prop_mode = '" . $band . "'"; + $sql .= " and col_sat_name = 'QO-100'"; + break; + default : + $sql .= " and col_prop_mode ='" . $band . "'"; + break; + } + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and COL_BAND ='" . $band . "'"; + } + } + $sql .= " AND COL_VUCC_GRIDS != '' GROUP BY COL_CALL;"; + + $query = $this->db->query($sql); + + return $query->result(); + } + function get_max_activated_grids() { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return array(); + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + // Get max no of activated grids of single operator + $data = $this->db->query( + "select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from TABLE_HRD_CONTACTS_V01 WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" + ); + foreach($data->result() as $row){ + $max = $row->count; + } + + return $max; + } + +} diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 9881efb9..9625118c 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -392,6 +392,32 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } + public function activator_details($call, $band, $leogeo){ + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $this->db->where('COL_CALL', $call); + if ($band != 'All') { + if ($band == 'SAT') { + $this->db->where('col_prop_mode', $band); + switch ($leogeo) { + case 'leo' : $this->db->where('COL_SAT_NAME !=', 'QO-100'); + break; + case 'geo': $this->db->where('COL_SAT_NAME', 'QO-100'); + break; + } + } else { + $this->db->where('COL_PROP_MODE !=', 'SAT'); + $this->db->where('col_band', $band); + } + } + + $this->db->where_in('station_id', $logbooks_locations_array); + + return $this->db->get($this->config->item('table_name')); + } + public function get_callsigns($callsign){ $this->db->select('COL_CALL'); $this->db->distinct(); diff --git a/application/views/activators/details.php b/application/views/activators/details.php new file mode 100644 index 00000000..ca67ad2c --- /dev/null +++ b/application/views/activators/details.php @@ -0,0 +1,4 @@ +
+
Filtering on
+ + load->view('view_log/partial/log_ajax') ?> diff --git a/application/views/activators/index.php b/application/views/activators/index.php new file mode 100644 index 00000000..68a13b4f --- /dev/null +++ b/application/views/activators/index.php @@ -0,0 +1,130 @@ +
+

+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + ?> + call] = $line->vucc_grids; + } + } + if ($activators_array) { + + $result = write_activators($activators_array, $vucc_grids, $custom_date_format, $this->input->post('band'), $this->input->post('leogeo')); + } + else { + echo ''; + } + ?> + +
+ + + + + # + Callsign + Count + Gridsquares + Show QSOs + + + '; + + $activators = array(); + foreach ($activators_array as $line) { + $call = $line->call; + $grids = $line->grids; + $count = $line->count; + if (array_key_exists($line->call, $vucc_grids)) { + $grids .= ','.$vucc_grids[$line->call]; + $grid_array = explode(',', $grids); + array_unique($grid_array, SORT_STRING); + $count = count($grid_array); + } + array_push($activators, array($count, $call, $grids)); + } + arsort($activators); + foreach ($activators as $line) { + echo ' + ' . $i++ . ' + '.$line[1].' + '.$line[0].' + '.$line[2].' + Show + '; + } + echo '
'; +} diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index a2ac10a6..8709126d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -405,7 +405,8 @@ function load_was_map() { $(document).ready(function() { $('#create_station_profile #country').val($("#dxcc_select option:selected").text()); $("#create_station_profile #dxcc_select" ).change(function() { - $('#country').val($("#dxcc_select option:selected").text()); + $('#country').val($("#dxcc_select option:selected").text()); + }); }); @@ -2029,6 +2030,72 @@ $(document).ready(function(){ } + uri->segment(1) == "activators") { ?> + + uri->segment(1) == "mode") { ?> diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index a55e6cd4..75906998 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -88,6 +88,8 @@ Activated Gridsquares + Gridsquare Activators + Distances Worked Days with QSOs