From 8b370c978315c13db77d04f142df3dbe33dd1ace Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 24 Jul 2021 14:31:16 +0200 Subject: [PATCH] [Awards] Fixed DXCC QSO details to also filter on modes. Made a generic function to display QSOs. It's now used for DXCC, WAS, IOTA, CQ, VUCC. This is also done in preparation for adding mode filter to WAS, IOTA and CQ Award. --- application/controllers/Awards.php | 71 ++------ application/models/Cq.php | 4 +- application/models/Dxcc.php | 25 +-- application/models/Iota.php | 14 +- application/models/Logbook_model.php | 108 +++++------- application/models/Was.php | 10 +- application/views/awards/vucc/band.php | 2 +- application/views/awards/was/map.php | 2 +- application/views/interface_assets/footer.php | 163 ++++-------------- 9 files changed, 119 insertions(+), 280 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index bfba2d85..e33bc816 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -140,19 +140,6 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function dxcc_details_ajax(){ - $this->load->model('logbook_model'); - - $country = str_replace('"', "", $this->input->post("Country")); - $band = str_replace('"', "", $this->input->post("Band")); - $data['results'] = $this->logbook_model->dxcc_qso_details($country, $band); - - // Render Page - $data['page_title'] = "Log View - DXCC"; - $data['filter'] = "country ".$country. " and ".$band; - $this->load->view('awards/details', $data); - } - public function vucc() { $this->load->model('vucc'); $data['worked_bands'] = $this->vucc->get_worked_bands(); @@ -195,6 +182,25 @@ class Awards extends CI_Controller { $this->load->view('awards/details', $data); } + /* + * Used to fetch QSOs from the logbook in the awards + */ + public function qso_details_ajax(){ + $this->load->model('logbook_model'); + + $searchphrase = str_replace('"', "", $this->input->post("Searchphrase")); + $band = str_replace('"', "", $this->input->post("Band")); + $mode = str_replace('"', "", $this->input->post("Mode")); + $type = $this->input->post('Type'); + + $data['results'] = $this->logbook_model->qso_details($searchphrase, $band, $mode, $type); + + // Render Page + $data['page_title'] = "Log View - " . $type; + $data['filter'] = $type . " " . $searchphrase . " and band ".$band . " and mode ".$mode; + $this->load->view('awards/details', $data); + } + /* Handles showing worked SOTAs Comment field - SOTA:# @@ -262,19 +268,6 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function cq_details_ajax(){ - $this->load->model('logbook_model'); - - $cqzone = str_replace('"', "", $this->input->post("CQZone")); - $band = str_replace('"', "", $this->input->post("Band")); - $data['results'] = $this->logbook_model->cq_qso_details($cqzone, $band); - - // Render Page - $data['page_title'] = "Log View - DXCC"; - $data['filter'] = "CQZone ".$cqzone. " and ".$band;; - $this->load->view('awards/details', $data); - } - public function was() { $this->load->model('was'); $data['worked_bands'] = $this->was->get_worked_bands(); @@ -320,19 +313,6 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function was_details_ajax() { - $this->load->model('logbook_model'); - - $state = str_replace('"', "", $this->input->post("State")); - $band = str_replace('"', "", $this->input->post("Band")); - $data['results'] = $this->logbook_model->was_qso_details($state, $band); - - // Render Page - $data['page_title'] = "Log View - WAS"; - $data['filter'] = "state ".$state. " and ".$band; - $this->load->view('awards/details', $data); - } - public function iota () { $this->load->model('iota'); $data['worked_bands'] = $this->iota->get_worked_bands(); // Used in the view for band select @@ -391,19 +371,6 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function iota_details_ajax(){ - $this->load->model('logbook_model'); - - $iota = str_replace('"', "", $this->input->post("Iota")); - $band = str_replace('"', "", $this->input->post("Band")); - $data['results'] = $this->logbook_model->iota_qso_details($iota, $band); - - // Render Page - $data['page_title'] = "Log View - IOTA"; - $data['filter'] = "iota ".$iota. " and ".$band; - $this->load->view('awards/details', $data); - } - public function counties() { $this->load->model('counties'); $data['counties_array'] = $this->counties->get_counties_array(); diff --git a/application/models/Cq.php b/application/models/Cq.php index 43cba558..a511a222 100644 --- a/application/models/Cq.php +++ b/application/models/Cq.php @@ -89,14 +89,14 @@ class CQ extends CI_Model{ if ($postdata['worked'] != NULL) { $cqBand = $this->getCQWorked($station_id, $band, $postdata); foreach ($cqBand as $line) { - $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '")\'>W
'; + $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '","All","CQZone")\'>W
'; $cqZ[$line->col_cqz]['count']++; } } if ($postdata['confirmed'] != NULL) { $cqBand = $this->getCQConfirmed($station_id, $band, $postdata); foreach ($cqBand as $line) { - $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '")\'>C
'; + $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '","All","CQZone")\'>C
'; $cqZ[$line->col_cqz]['count']++; } } diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 261550b1..5a8e712c 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -60,7 +60,7 @@ class DXCC extends CI_Model { foreach(array_keys($this->bandslots) as $slot) { if(in_array($slot, $worked_slots)) { array_push($results, $slot); - } + } } return $results; @@ -89,10 +89,10 @@ class DXCC extends CI_Model { // update stats if (!isset($results[$row->COL_COUNTRY])) - $results[$row->COL_COUNTRY] = []; + $results[$row->COL_COUNTRY] = []; if (!isset($results[$row->COL_COUNTRY][$row->COL_BAND])) - $results[$row->COL_COUNTRY][$row->COL_BAND] = 0; + $results[$row->COL_COUNTRY][$row->COL_BAND] = 0; $results[$row->COL_COUNTRY][$row->COL_BAND] += $row->cnt; } @@ -115,10 +115,10 @@ class DXCC extends CI_Model { // update stats if (!isset($results[$row->COL_COUNTRY])) - $results[$row->COL_COUNTRY] = []; + $results[$row->COL_COUNTRY] = []; if (!isset($results[$row->COL_COUNTRY][$row->COL_PROP_MODE])) - $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] = 0; + $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] = 0; $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] += $row->cnt; } @@ -203,7 +203,8 @@ class DXCC extends CI_Model { if ($postdata['worked'] != NULL) { $workedDXCC = $this->getDxccBandWorked($station_id, $band, $postdata); foreach ($workedDXCC as $wdxcc) { - $dxccMatrix[$wdxcc->dxcc][$band] = '
name).'","'. $band . '")\'>W
'; + //function displayContacts(searchphrase, band, mode, type) { + $dxccMatrix[$wdxcc->dxcc][$band] = '
name).'","'. $band . '","'. $postdata['mode'] . '","DXCC")\'>W
'; } } @@ -211,7 +212,7 @@ class DXCC extends CI_Model { if ($postdata['confirmed'] != NULL) { $confirmedDXCC = $this->getDxccBandConfirmed($station_id, $band, $postdata); foreach ($confirmedDXCC as $cdxcc) { - $dxccMatrix[$cdxcc->dxcc][$band] = '
name).'","'. $band . '")\'>C
'; + $dxccMatrix[$cdxcc->dxcc][$band] = '
name).'","'. $band . '","'. $postdata['mode'] . '","DXCC")\'>C
'; } } } @@ -317,7 +318,7 @@ class DXCC extends CI_Model { $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $sql = "select adif, prefix, name, date(end) Enddate, date(start) Startdate + $sql = "select adif, prefix, name, date(end) Enddate, date(start) Startdate from dxcc_entities"; if ($postdata['notworked'] == NULL) { @@ -357,7 +358,7 @@ class DXCC extends CI_Model { function getDxccWorked($station_id, $postdata) { $sql = "SELECT adif as dxcc FROM dxcc_entities join ( - select col_dxcc + select col_dxcc from ".$this->config->item('table_name')." thcv where station_id = " . $station_id . " and col_dxcc > 0"; @@ -414,7 +415,7 @@ class DXCC extends CI_Model { function getDxccConfirmed($station_id, $postdata) { $sql = "SELECT adif as dxcc FROM dxcc_entities join ( - select col_dxcc + select col_dxcc from ".$this->config->item('table_name')." thcv where station_id = ". $station_id . " and col_dxcc > 0"; @@ -499,7 +500,7 @@ class DXCC extends CI_Model { } return $sql; } - + /* * Function gets worked and confirmed summary on each band on the active stationprofile */ @@ -566,7 +567,7 @@ class DXCC extends CI_Model { return $query->result(); } - + function lookup_country($country) { $query = $this->db->query(' diff --git a/application/models/Iota.php b/application/models/Iota.php index 9d7a5e69..a9fa8691 100644 --- a/application/models/Iota.php +++ b/application/models/Iota.php @@ -81,7 +81,7 @@ class IOTA extends CI_Model { if ($postdata['worked'] != NULL) { $workedIota = $this->getIotaBandWorked($station_id, $band, $postdata); foreach ($workedIota as $wiota) { - $iotaMatrix[$wiota->tag][$band] = '
tag.'","'. $band . '")\'>W
'; + $iotaMatrix[$wiota->tag][$band] = '
tag.'","'. $band . '","All","IOTA")\'>W
'; } } @@ -89,7 +89,7 @@ class IOTA extends CI_Model { if ($postdata['confirmed'] != NULL) { $confirmedIota = $this->getIotaBandConfirmed($station_id, $band, $postdata); foreach ($confirmedIota as $ciota) { - $iotaMatrix[$ciota->tag][$band] = '
tag.'","'. $band . '")\'>C
'; + $iotaMatrix[$ciota->tag][$band] = '
tag.'","'. $band . '","All","IOTA")\'>C
'; } } } @@ -123,7 +123,7 @@ class IOTA extends CI_Model { } function getIotaBandConfirmed($station_id, $band, $postdata) { - $sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv join iota on thcv.col_iota = iota.tag where station_id = " . $station_id . " and thcv.col_iota is not null @@ -149,7 +149,7 @@ class IOTA extends CI_Model { } function getIotaBandWorked($station_id, $band, $postdata) { - $sql = 'SELECT distinct col_iota as tag FROM ' . $this->config->item('table_name'). ' thcv + $sql = 'SELECT distinct col_iota as tag FROM ' . $this->config->item('table_name'). ' thcv join iota on thcv.col_iota = iota.tag where station_id = ' . $station_id . ' and thcv.col_iota is not null'; @@ -207,7 +207,7 @@ class IOTA extends CI_Model { } function getIotaWorked($station_id, $postdata) { - $sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv join iota on thcv.col_iota = iota.tag where station_id = " . $station_id . " and thcv.col_iota is not null @@ -248,7 +248,7 @@ class IOTA extends CI_Model { } function getIotaConfirmed($station_id, $postdata) { - $sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv join iota on thcv.col_iota = iota.tag where station_id = " . $station_id . " and thcv.col_iota is not null @@ -375,4 +375,4 @@ class IOTA extends CI_Model { return $query->result(); } } -?> \ No newline at end of file +?> diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 2909eef4..f6d773c2 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -232,40 +232,50 @@ class Logbook_model extends CI_Model { return($row); } } + /* + * Used to fetch QSOs from the logbook in the awards + */ + public function qso_details($searchphrase, $band, $mode, $type){ + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - public function dxcc_qso_details($country, $band){ - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); + switch ($type) { + case 'DXCC': + $this->db->where('COL_COUNTRY', $searchphrase); + break; + case 'IOTA': + $this->db->where('COL_IOTA', $searchphrase); + break; + case 'VUCC': + $this->db->where("(COL_GRIDSQUARE like '%" . $searchphrase . "%' OR COL_VUCC_GRIDS like'%" . $searchphrase ."%')"); + break; + case 'CQZone': + $this->db->where('COL_CQZ', $searchphrase); + break; + case 'WAS': + $this->db->where('COL_STATE', $searchphrase); + $this->db->where_in('COL_DXCC', ['291', '6', '110']); + break; + } - $this->db->where('station_id', $station_id); - $this->db->where('COL_COUNTRY', $country); - if($band != "SAT") { - $this->db->where('COL_PROP_MODE !=', 'SAT'); - $this->db->where('COL_BAND', $band); - } else { - $this->db->where('COL_PROP_MODE', "SAT"); - } + $this->db->where('station_id', $station_id); - return $this->db->get($this->config->item('table_name')); - } + if ($band != 'All') { + if($band != "SAT") { + $this->db->where('COL_PROP_MODE !=', 'SAT'); + $this->db->where('COL_BAND', $band); + } else { + $this->db->where('COL_PROP_MODE', "SAT"); + } + } - public function iota_qso_details($iota, $band){ - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); + if ($mode != 'All') { + $this->db->where("(COL_MODE='" . $mode . "' OR COL_SUBMODE='" . $mode ."')"); + } - $this->db->where('station_id', $station_id); - $this->db->where('COL_IOTA', $iota); - if($band != "SAT") { - $this->db->where('COL_PROP_MODE !=', 'SAT'); - $this->db->where('COL_BAND', $band); - } else { - $this->db->where('COL_PROP_MODE', "SAT"); - } - - return $this->db->get($this->config->item('table_name')); - } + return $this->db->get($this->config->item('table_name')); + } public function vucc_qso_details($gridsquare, $band) { $CI =& get_instance(); @@ -288,26 +298,6 @@ class Logbook_model extends CI_Model { return $this->db->query($sql); } - public function cq_qso_details($cqzone, $band){ - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - - if ($band != 'All') { - if ($band == 'SAT') { - $this->db->where('col_prop_mode', $band); - } else if ($band != '') { - $this->db->where('col_prop_mode !=', 'SAT'); - $this->db->where('col_band', $band); - } - } - - $this->db->where('station_id', $station_id); - $this->db->where('COL_CQZ', $cqzone); - - return $this->db->get($this->config->item('table_name')); - } - public function timeline_qso_details($querystring, $band, $mode, $type){ $CI =& get_instance(); $CI->load->model('Stations'); @@ -338,26 +328,6 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } - public function was_qso_details($state, $band){ - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - - $this->db->where('station_id', $station_id); - $this->db->where('COL_STATE', $state); - $this->db->where_in('COL_DXCC', ['291', '6', '110']); - if($band != 'All') { - if($band != "SAT") { - $this->db->where('COL_PROP_MODE !=', 'SAT'); - $this->db->where('COL_BAND', $band); - } else { - $this->db->where('COL_PROP_MODE', "SAT"); - } - } - - 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/models/Was.php b/application/models/Was.php index 5a33510d..c6e76394 100644 --- a/application/models/Was.php +++ b/application/models/Was.php @@ -87,14 +87,14 @@ class was extends CI_Model { if ($postdata['worked'] != NULL) { $wasBand = $this->getWasWorked($station_id, $band, $postdata); foreach ($wasBand as $line) { - $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '")\'>W
'; + $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","All","WAS")\'>W
'; $states[$line->col_state]['count']++; } } if ($postdata['confirmed'] != NULL) { $wasBand = $this->getWasConfirmed($station_id, $band, $postdata); foreach ($wasBand as $line) { - $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '")\'>C
'; + $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","All","WAS")\'>C
'; $states[$line->col_state]['count']++; } } @@ -208,7 +208,7 @@ class was extends CI_Model { * $postdata contains data from the form, in this case Lotw or QSL are used */ function getWasWorked($station_id, $band, $postdata) { - $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv where station_id = " . $station_id; $sql .= $this->addStateToQuery(); @@ -237,7 +237,7 @@ class was extends CI_Model { * $postdata contains data from the form, in this case Lotw or QSL are used */ function getWasConfirmed($station_id, $band, $postdata) { - $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv where station_id = " . $station_id; $sql .= $this->addStateToQuery(); @@ -287,4 +287,4 @@ class was extends CI_Model { return $sql; } } -?> \ No newline at end of file +?> diff --git a/application/views/awards/vucc/band.php b/application/views/awards/vucc/band.php index 498b9272..98234b1f 100644 --- a/application/views/awards/vucc/band.php +++ b/application/views/awards/vucc/band.php @@ -23,7 +23,7 @@ foreach ($vucc_array as $vucc => $value) { // Fills the table with the data echo ' '. $i++ .' - '. $vucc .''; + '. $vucc .''; if ($type != 'worked') { echo ''. $value['qsl'] . ' diff --git a/application/views/awards/was/map.php b/application/views/awards/was/map.php index 002df5c2..77c8fc1a 100644 --- a/application/views/awards/was/map.php +++ b/application/views/awards/was/map.php @@ -135,7 +135,7 @@ 'click' : function(event, data) { - displayWasContacts(data.name,$('#band2').val()); + displayContacts(data.name,$('#band2').val(), 'All', 'WAS'); } }); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 7bc7f9a1..247fb398 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -991,33 +991,6 @@ $(document).ready(function(){ if (background != ('rgb(255, 255, 255)')) { $(".buttons-csv").css("color", "white"); } - - function displayDxccContacts(country, band) { - var baseURL = ""; - $.ajax({ - url: baseURL + 'index.php/awards/dxcc_details_ajax', - type: 'post', - data: { - 'Country': country, - 'Band': band - }, - success: function (html) { - BootstrapDialog.show({ - title: 'QSO Data', - size: BootstrapDialog.SIZE_WIDE, - cssClass: 'qso-dxcc-dialog', - nl2br: false, - message: html, - buttons: [{ - label: 'Close', - action: function (dialogItself) { - dialogItself.close(); - } - }] - }); - } - }); - } @@ -1043,32 +1016,6 @@ $(document).ready(function(){ if (background != ('rgb(255, 255, 255)')) { $(".buttons-csv").css("color", "white"); } - - function displayVuccContacts(gridsquare, band) { - var baseURL= ""; - $.ajax({ - url: baseURL + 'index.php/awards/vucc_details_ajax', - type: 'post', - data: {'Gridsquare': gridsquare, - 'Band': band - }, - success: function(html) { - BootstrapDialog.show({ - title: 'QSO Data', - size: BootstrapDialog.SIZE_WIDE, - cssClass: 'qso-vucc-dialog', - nl2br: false, - message: html, - buttons: [{ - label: 'Close', - action: function (dialogItself) { - dialogItself.close(); - } - }] - }); - } - }); - } @@ -1137,32 +1084,6 @@ $(document).ready(function(){ if (background != ('rgb(255, 255, 255)')) { $(".buttons-csv").css("color", "white"); } - - function displayIotaContacts(iota, band) { - var baseURL= ""; - $.ajax({ - url: baseURL + 'index.php/awards/iota_details_ajax', - type: 'post', - data: {'Iota': iota, - 'Band': band - }, - success: function(html) { - BootstrapDialog.show({ - title: 'QSO Data', - size: BootstrapDialog.SIZE_WIDE, - cssClass: 'qso-iota-dialog', - nl2br: false, - message: html, - buttons: [{ - label: 'Close', - action: function (dialogItself) { - dialogItself.close(); - } - }] - }); - } - }); - } @@ -1200,32 +1121,6 @@ $(document).ready(function(){ if (background != ('rgb(255, 255, 255)')) { $(".buttons-csv").css("color", "white"); } - - function displayCqContacts(cqzone, band) { - var baseURL= ""; - $.ajax({ - url: baseURL + 'index.php/awards/cq_details_ajax', - type: 'post', - data: {'CQZone': cqzone, - 'Band': band - }, - success: function(html) { - BootstrapDialog.show({ - title: 'QSO Data', - size: BootstrapDialog.SIZE_WIDE, - cssClass: 'qso-cq-dialog', - nl2br: false, - message: html, - buttons: [{ - label: 'Close', - action: function (dialogItself) { - dialogItself.close(); - } - }] - }); - } - }); - } @@ -1262,32 +1157,6 @@ $(document).ready(function(){ if (background != ('rgb(255, 255, 255)')) { $(".buttons-csv").css("color", "white"); } - - function displayWasContacts(was, band) { - var baseURL= ""; - $.ajax({ - url: baseURL + 'index.php/awards/was_details_ajax', - type: 'post', - data: {'State': was, - 'Band': band - }, - success: function(html) { - BootstrapDialog.show({ - title: 'QSO Data', - size: BootstrapDialog.SIZE_WIDE, - cssClass: 'qso-was-dialog', - nl2br: false, - message: html, - buttons: [{ - label: 'Close', - action: function (dialogItself) { - dialogItself.close(); - } - }] - }); - } - }); - } @@ -1701,6 +1570,38 @@ function deleteQsl(id) {