diff --git a/application/controllers/Activated_gridmap.php b/application/controllers/Activated_gridmap.php new file mode 100644 index 00000000..a91edd90 --- /dev/null +++ b/application/controllers/Activated_gridmap.php @@ -0,0 +1,191 @@ +load->model('bands'); + $this->load->model('activated_gridmap_model'); + $this->load->model('stations'); + + $data['homegrid'] = explode(',', $this->stations->find_gridsquare()); + + $data['modes'] = $this->activated_gridmap_model->get_worked_modes(); + $data['bands'] = $this->bands->get_worked_bands(); + $data['sats_available'] = $this->bands->get_worked_sats(); + + $data['user_gridmap_default_band'] = $this->session->userdata('user_gridmap_default_band'); + $data['user_gridmap_confirmation'] = $this->session->userdata('user_gridmap_confirmation'); + + $data['layer'] = $this->optionslib->get_option('option_map_tile_server'); + + $data['attribution'] = $this->optionslib->get_option('option_map_tile_server_copyright'); + + $data['gridsquares_gridsquares'] = lang('gridsquares_gridsquares'); + $data['gridsquares_gridsquares_confirmed'] = lang('gridsquares_gridsquares_confirmed'); + $data['gridsquares_gridsquares_not_confirmed'] = lang('gridsquares_gridsquares_not_confirmed'); + $data['gridsquares_gridsquares_total_activated'] = lang('gridsquares_gridsquares_total_activated'); + + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/leaflet/geocoding.js', + 'assets/js/leaflet/L.MaidenheadColouredGridMap.js', + 'assets/js/sections/gridmap.js?' + ]; + + $this->load->view('interface_assets/header', $data); + $this->load->view('activated_gridmap/index'); + $this->load->view('interface_assets/footer', $footerData); + } + + public function getGridsjs() { + $band = $this->security->xss_clean($this->input->post('band')); + $mode = $this->security->xss_clean($this->input->post('mode')); + $qsl = $this->security->xss_clean($this->input->post('qsl')); + $lotw = $this->security->xss_clean($this->input->post('lotw')); + $eqsl = $this->security->xss_clean($this->input->post('eqsl')); + $sat = $this->security->xss_clean($this->input->post('sat')); + $this->load->model('activated_gridmap_model'); + + $array_grid_2char = array(); + $array_grid_4char = array(); + $array_grid_6char = array(); + + $array_grid_2char_confirmed = array(); + $array_grid_4char_confirmed = array(); + $array_grid_6char_confirmed = array(); + + $grid_2char = ""; + $grid_4char = ""; + $grid_6char = ""; + + $grid_2char_confirmed = ""; + $grid_4char_confirmed = ""; + $grid_6char_confirmed = ""; + + $query = $this->activated_gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $sat); + + if ($query && $query->num_rows() > 0) { + foreach ($query->result() as $row) { + $gridlist = explode(',', $row->GRID_SQUARES); + foreach ($gridlist as $grid) { + $grid_2char_confirmed = strtoupper(substr($grid,0,2)); + $grid_4char_confirmed = strtoupper(substr($grid,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_6char_confirmed = strtoupper(substr($grid,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){ + array_push($array_grid_2char_confirmed, $grid_2char_confirmed); + } + + if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){ + array_push($array_grid_4char_confirmed, $grid_4char_confirmed); + } + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_6char_confirmed, $array_grid_6char_confirmed)){ + array_push($array_grid_6char_confirmed, $grid_6char_confirmed); + } + } + } + } + } + + $query = $this->activated_gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $sat); + + if ($query && $query->num_rows() > 0) { + foreach ($query->result() as $row) { + + $gridlist = explode(',', $row->GRID_SQUARES); + foreach ($gridlist as $grid) { + $grid_two = strtoupper(substr($grid,0,2)); + $grid_four = strtoupper(substr($grid,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_six = strtoupper(substr($grid,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_two, $array_grid_2char)){ + array_push($array_grid_2char, $grid_two); + } + + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_six, $array_grid_6char)){ + array_push($array_grid_6char, $grid_six); + } + } + } + } + } + $query_vucc = $this->activated_gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat); + + if ($query_vucc && $query_vucc->num_rows() > 0) { + foreach ($query_vucc->result() as $row) { + + $grids = explode(",", $row->COL_VUCC_GRIDS); + + foreach($grids as $key) { + $grid_two = strtoupper(substr($key,0,2)); + $grid_four = strtoupper(substr($key,0,4)); + + // Check if 2 Char is in array + if(!in_array($grid_two, $array_grid_2char)){ + array_push($array_grid_2char, $grid_two); + } + + + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + } + } + } + + // // Confirmed Squares + $query_vucc = $this->activated_gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat); + + if ($query_vucc && $query_vucc->num_rows() > 0) { + foreach ($query_vucc->result() as $row) { + + $grids = explode(",", $row->COL_VUCC_GRIDS); + + foreach($grids as $key) { + $grid_2char_confirmed = strtoupper(substr($key,0,2)); + $grid_4char_confirmed = strtoupper(substr($key,0,4)); + + // Check if 2 Char is in array + if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){ + array_push($array_grid_2char_confirmed, $grid_2char_confirmed); + } + + + if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){ + array_push($array_grid_4char_confirmed, $grid_4char_confirmed); + } + } + } + } + + $data['grid_2char_confirmed'] = ($array_grid_2char_confirmed); + $data['grid_4char_confirmed'] = ($array_grid_4char_confirmed); + $data['grid_6char_confirmed'] = ($array_grid_6char_confirmed); + + $data['grid_2char'] = ($array_grid_2char); + $data['grid_4char'] = ($array_grid_4char); + $data['grid_6char'] = ($array_grid_6char); + + header('Content-Type: application/json'); + echo json_encode($data); + } +} diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index d11f7b86..663518e4 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -221,7 +221,8 @@ class Awards extends CI_Controller { $mode = str_replace('"', "", $this->security->xss_clean($this->input->post("Mode"))); $type = $this->security->xss_clean($this->input->post('Type')); $qsl = $this->input->post('QSL') == null ? '' : $this->security->xss_clean($this->input->post('QSL')); - $data['results'] = $this->logbook_model->qso_details($searchphrase, $band, $mode, $type, $qsl); + $searchmode = $this->input->post('searchmode') == null ? '' : $this->security->xss_clean($this->input->post('searchmode')); + $data['results'] = $this->logbook_model->qso_details($searchphrase, $band, $mode, $type, $qsl, $searchmode); // This is done because we have two different ways to get dxcc info in Cloudlog. Once is using the name (in awards), and the other one is using the ADIF DXCC. // We replace the values to make it look a bit nicer diff --git a/application/language/english/gridsquares_lang.php b/application/language/english/gridsquares_lang.php index ac6c15c3..6832be44 100644 --- a/application/language/english/gridsquares_lang.php +++ b/application/language/english/gridsquares_lang.php @@ -23,4 +23,5 @@ $lang['gridsquares_button_plot'] = 'Plot'; $lang['gridsquares_gridsquares'] = 'Gridsquares'; $lang['gridsquares_gridsquares_confirmed'] = 'Gridsquares confirmed'; $lang['gridsquares_gridsquares_not_confirmed'] = 'Gridsquares not confirmed'; -$lang['gridsquares_gridsquares_total_worked'] = 'Total gridsquares worked'; \ No newline at end of file +$lang['gridsquares_gridsquares_total_worked'] = 'Total gridsquares worked'; +$lang['gridsquares_gridsquares_total_activated'] = 'Total gridsquares activated'; diff --git a/application/language/german/gridsquares_lang.php b/application/language/german/gridsquares_lang.php index 0bf2b037..8acbb6b0 100644 --- a/application/language/german/gridsquares_lang.php +++ b/application/language/german/gridsquares_lang.php @@ -24,3 +24,4 @@ $lang['gridsquares_gridsquares'] = 'Planquadrate'; $lang['gridsquares_gridsquares_confirmed'] = 'Planquadrate bestätigt'; $lang['gridsquares_gridsquares_not_confirmed'] = 'Planquadrate nicht bestätigt'; $lang['gridsquares_gridsquares_total_worked'] = 'Summe gearbeiteter Planquadrate'; +$lang['gridsquares_gridsquares_total_activated'] = 'Summe aktivierter Planquadrate'; diff --git a/application/models/Activated_gridmap_model.php b/application/models/Activated_gridmap_model.php new file mode 100644 index 00000000..e2af78d3 --- /dev/null +++ b/application/models/Activated_gridmap_model.php @@ -0,0 +1,226 @@ +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 station_gridsquare AS GRID_SQUARES, COL_BAND FROM ' + . 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id ' + . 'WHERE station_profile.station_gridsquare != "" '; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl); + + return $this->db->query($sql); + } + + function get_band($band, $mode, $qsl, $lotw, $eqsl, $sat) { + $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 station_gridsquare AS GRID_SQUARES, COL_BAND FROM ' + . 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id ' + . 'WHERE station_profile.station_gridsquare != "" '; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + return $this->db->query($sql); + } + + function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat) { + $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_VUCC_GRIDS, COL_BAND FROM ' + .$this->config->item('table_name') + .' WHERE station_id in (' + .$location_list.') AND COL_VUCC_GRIDS != ""'; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + return null; + return $this->db->query($sql); + } + + function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat) { + $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_VUCC_GRIDS, COL_BAND FROM ' + .$this->config->item('table_name') + .' WHERE station_id in (' + .$location_list.') AND COL_VUCC_GRIDS != ""'; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + if ($sat != 'All') { + $sql .= " and col_sat_name ='" . $sat . "'"; + } + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + } + + $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl); + + return null; + return $this->db->query($sql); + } + + // Adds confirmation to query + function addQslToQuery($qsl, $lotw, $eqsl) { + $sql = ''; + if ($lotw == "true" && $qsl == "false" && $eqsl == "false") { + $sql .= " and col_lotw_qsl_sent = 'Y'"; + } + + if ($qsl == "true" && $lotw == "false" && $eqsl == "false") { + $sql .= " and col_qsl_true = 'Y'"; + } + + if ($eqsl == "true" && $lotw == "false" && $qsl == "false") { + $sql .= " and col_eqsl_qsl_sent = 'Y'"; + } + + if ($lotw == "true" && $qsl == "true" && $eqsl == "false") { + $sql .= " and (col_lotw_qsl_sent = 'Y' or col_qsl_sent = 'Y')"; + } + + if ($qsl == "true" && $lotw == "false" && $eqsl == "true") { + $sql .= " and (col_qsl_sent = 'Y' or col_eqsl_qsl_sent = 'Y')"; + } + + if ($eqsl == "true" && $lotw == "true" && $qsl == "false") { + $sql .= " and (col_eqsl_qsl_sent = 'Y' or col_lotw_qsl_sent = 'Y')"; + } + + if ($qsl == "true" && $lotw == "true" && $eqsl == "true") { + $sql .= " and (col_qsl_sent = 'Y' or col_lotw_qsl_sent = 'Y' or col_eqsl_qsl_sent = 'Y')"; + } + + if ($qsl == "false" && $lotw == "false" && $eqsl == "false") { + $sql .= " and (col_qsl_sent != 'Y' and col_lotw_qsl_sent != 'Y' and col_eqsl_qsl_sent != 'Y')"; + } + return $sql; + } + + /* + * Get's the worked modes from the log + */ + function get_worked_modes() { + $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)."'"; + + // get all worked modes from database + $data = $this->db->query( + "SELECT distinct LOWER(`COL_MODE`) as `COL_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") order by COL_MODE ASC" + ); + $results = array(); + foreach ($data->result() as $row) { + array_push($results, $row->COL_MODE); + } + + $data = $this->db->query( + "SELECT distinct LOWER(`COL_SUBMODE`) as `COL_SUBMODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") and coalesce(COL_SUBMODE, '') <> '' order by COL_SUBMODE ASC" + ); + foreach ($data->result() as $row) { + if (!in_array($row, $results)) { + array_push($results, $row->COL_SUBMODE); + } + } + + asort($results); + + return $results; + } +} diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index fd8a1852..5ccbca95 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -330,7 +330,7 @@ class Logbook_model extends CI_Model { /* * Used to fetch QSOs from the logbook in the awards */ - public function qso_details($searchphrase, $band, $mode, $type, $qsl){ + public function qso_details($searchphrase, $band, $mode, $type, $qsl, $searchmode = null){ $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -349,7 +349,11 @@ class Logbook_model extends CI_Model { $this->db->where('COL_IOTA', $searchphrase); break; case 'VUCC': - $this->db->where("(COL_GRIDSQUARE like '%" . $searchphrase . "%' OR COL_VUCC_GRIDS like'%" . $searchphrase ."%')"); + if ($searchmode == 'activated') { + $this->db->where("station_gridsquare like '%" . $searchphrase . "%'"); + } else { + $this->db->where("(COL_GRIDSQUARE like '%" . $searchphrase . "%' OR COL_VUCC_GRIDS like'%" . $searchphrase ."%')"); + } break; case 'CQZone': $this->db->where('COL_CQZ', $searchphrase); @@ -421,6 +425,8 @@ class Logbook_model extends CI_Model { } $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit(500); + return $this->db->get($this->config->item('table_name')); } diff --git a/application/views/activated_gridmap/index.php b/application/views/activated_gridmap/index.php new file mode 100644 index 00000000..8a21a551 --- /dev/null +++ b/application/views/activated_gridmap/index.php @@ -0,0 +1,150 @@ + + + +
+ +
+ +

+ +
+ + + + + + + + + + + +
+
+ '; ?> + +
+
+ '; ?> + +
+
+ '; ?> + +
+
+ + + +
+ + session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ +
+ +
+
+
+
+
Latitude:
+
+
Longitude:
+
+
Gridsquare:
+
+
Distance:
+
+
Bearing:
+
+
+ diff --git a/application/views/gridmap/index.php b/application/views/gridmap/index.php index cd6f79fe..baa60b77 100644 --- a/application/views/gridmap/index.php +++ b/application/views/gridmap/index.php @@ -136,6 +136,7 @@