From e1444c2abf16b9a4fa68369a2806d3fa20364af6 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 11 Dec 2022 17:47:36 +0100 Subject: [PATCH 1/2] [IOTA Map] Added map to display IOTA's --- application/controllers/Awards.php | 66 +++++++ application/models/Iota.php | 61 ++----- application/views/awards/iota/index.php | 60 +++++++ application/views/interface_assets/footer.php | 4 + assets/js/sections/iotamap.js | 165 ++++++++++++++++++ 5 files changed, 314 insertions(+), 42 deletions(-) create mode 100644 assets/js/sections/iotamap.js diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index dabdced0..a6c24309 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -619,4 +619,70 @@ class Awards extends CI_Controller { header('Content-Type: application/json'); echo json_encode($zones); } + + /* + function iota + This displays the IOTA map + */ + public function iota_map() { + $this->load->model('iota'); + $this->load->model('bands'); + + $bands[] = $this->input->post('band'); + + $postdata['lotw'] = $this->input->post('lotw') == 0 ? NULL: 1; + $postdata['qsl'] = $this->input->post('qsl') == 0 ? NULL: 1; + $postdata['worked'] = $this->input->post('worked') == 0 ? NULL: 1; + $postdata['confirmed'] = $this->input->post('confirmed') == 0 ? NULL: 1; + $postdata['notworked'] = $this->input->post('notworked') == 0 ? NULL: 1; + $postdata['band'] = $this->input->post('band'); + $postdata['mode'] = $this->input->post('mode'); + $postdata['includedeleted'] = $this->input->post('includedeleted') == 0 ? NULL: 1; + $postdata['Africa'] = $this->input->post('Africa') == 0 ? NULL: 1; + $postdata['Asia'] = $this->input->post('Asia') == 0 ? NULL: 1; + $postdata['Europe'] = $this->input->post('Europe') == 0 ? NULL: 1; + $postdata['NorthAmerica'] = $this->input->post('NorthAmerica') == 0 ? NULL: 1; + $postdata['SouthAmerica'] = $this->input->post('SouthAmerica') == 0 ? NULL: 1; + $postdata['Oceania'] = $this->input->post('Oceania') == 0 ? NULL: 1; + $postdata['Antarctica'] = $this->input->post('Antarctica') == 0 ? NULL: 1; + + $iotalist = $this->iota->fetchIota($postdata); + + $iota_array = $this->iota->get_iota_array($iotalist, $bands, $postdata); + + $i = 0; + + foreach ($iotalist as $iota) { + $newiota[$i]['tag'] = $iota->tag; + $newiota[$i]['prefix'] = $iota->prefix; + $newiota[$i]['name'] = ucwords(strtolower($iota->name), "- (/"); + if ($iota->status == 'D') { + $newiota[$i]['name'] .= ' (deleted)'; + } + $newiota[$i]['lat1'] = $iota->lat1; + $newiota[$i]['lon1'] = $iota->lon1; + $newiota[$i]['lat2'] = $iota->lat2; + $newiota[$i]['lon2'] = $iota->lon2; + $newiota[$i++]['status'] = isset($iota_array[$iota->tag]) ? $this->returnStatus($iota_array[$iota->tag]) : 'x'; + } + + header('Content-Type: application/json'); + echo json_encode($newiota); + } + + function returnStatus($string) { + foreach ($string as $key) { + if($key != "") { + if (strpos($key, '>W<') !== false) { + return 'W'; + } + if (strpos($key, '>C<') !== false) { + return 'C'; + } + if ($key == '-') { + return '-'; + } + } + } + } } \ No newline at end of file diff --git a/application/models/Iota.php b/application/models/Iota.php index b578961f..2135c6b6 100644 --- a/application/models/Iota.php +++ b/application/models/Iota.php @@ -78,13 +78,7 @@ class IOTA extends CI_Model { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; } - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } + $sql .= $this->addBandToQuery($band); if ($postdata['includedeleted'] == NULL) { $sql .= " and coalesce(iota.status, '') <> 'D'"; @@ -107,13 +101,7 @@ class IOTA extends CI_Model { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; } - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } + $sql .= $this->addBandToQuery($band); if ($postdata['includedeleted'] == NULL) { $sql .= " and coalesce(iota.status, '') <> 'D'"; @@ -137,7 +125,7 @@ class IOTA extends CI_Model { $location_list = "'".implode("','",$logbooks_locations_array)."'"; - $sql = "select tag, name, prefix, dxccid, status from iota where 1=1"; + $sql = "select tag, name, prefix, dxccid, status, lat1, lat2, lon1, lon2 from iota where 1=1"; if ($postdata['includedeleted'] == NULL) { $sql .= " and coalesce(iota.status, '') <> 'D'"; @@ -182,27 +170,11 @@ class IOTA extends CI_Model { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; } - if ($postdata['band'] != 'All') { - if ($postdata['band'] == 'SAT') { - $sql .= " and col_prop_mode ='" . $postdata['band'] . "'"; - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $postdata['band'] . "'"; - } - } + $sql .= $this->addBandToQuery($postdata['band']); $sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y'))"; - if ($postdata['band'] != 'All') { - if ($postdata['band'] == 'SAT') { - $sql .= " and col_prop_mode ='" . $postdata['band'] . "'"; - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $postdata['band'] . "'"; - } - } + $sql .= $this->addBandToQuery($postdata['band']); if ($postdata['includedeleted'] == NULL) { $sql .= " and coalesce(iota.status, '') <> 'D'"; @@ -236,15 +208,7 @@ class IOTA extends CI_Model { $sql .= $this->addContinentsToQuery($postdata); - if ($postdata['band'] != 'All') { - if ($postdata['band'] == 'SAT') { - $sql .= " and col_prop_mode ='" . $postdata['band'] . "'"; - } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $postdata['band'] . "'"; - } - } + $sql .= $this->addBandToQuery($postdata['band']); $query = $this->db->query($sql); @@ -392,5 +356,18 @@ class IOTA extends CI_Model { return $query->result(); } + + function addBandToQuery($band) { + $sql = ''; + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + return $sql; + } } ?> diff --git a/application/views/awards/iota/index.php b/application/views/awards/iota/index.php index c6d55a7d..52bb40a1 100644 --- a/application/views/awards/iota/index.php +++ b/application/views/awards/iota/index.php @@ -1,4 +1,38 @@ + + +