diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index cd405b62..5a829f50 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -557,6 +557,108 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer',$footerData); } + public function ffma() { + $data['page_title']= lang('menu_ffma'); + + $this->load->model('bands'); + $this->load->model('ffma_model'); + $this->load->model('stations'); + + $data['homegrid']= explode(',', $this->stations->find_gridsquare()); + + $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_worked']= lang('gridsquares_gridsquares_worked'); + $data['gridsquares_gridsquares_lotw']= lang('gridsquares_gridsquares_lotw'); + $data['gridsquares_gridsquares_paper']= lang('gridsquares_gridsquares_paper'); + + $footerData = []; + $footerData['scripts']= [ + 'assets/js/leaflet/geocoding.js', + 'assets/js/leaflet/L.MaidenheadColouredGridmasterMap.js', + 'assets/js/sections/ffma.js?' + ]; + + $this->load->view('interface_assets/header',$data); + $this->load->view('awards/ffma/index'); + $this->load->view('interface_assets/footer',$footerData); + } + + public function getFfmaGridsjs() { + $this->load->model('ffma_model'); + + $array_grid_4char = array(); + $array_grid_4char_lotw = array(); + $array_grid_4char_paper = array(); + + $grid_4char = ""; + $grid_4char_lotw = ""; + + $query = $this->ffma_model->get_lotw(); + if ($query && $query->num_rows() > 0) { + foreach ($query->result() as $row) { + $grid_4char_lotw = strtoupper(substr($row->GRID_SQUARES,0,4)); + if(!in_array($grid_4char_lotw, $array_grid_4char_lotw)){ + array_push($array_grid_4char_lotw, $grid_4char_lotw); + } + } + } + + $query = $this->ffma_model->get_paper(); + if ($query && $query->num_rows() > 0) { + foreach ($query->result() as $row) { + $grid_4char_paper = strtoupper(substr($row->GRID_SQUARES,0,4)); + if(!in_array($grid_4char_paper, $array_grid_4char_paper)){ + array_push($array_grid_4char_paper, $grid_4char_paper); + } + } + } + + $query = $this->ffma_model->get_worked(); + if ($query && $query->num_rows() > 0) { + foreach ($query->result() as $row) { + $grid_four = strtoupper(substr($row->GRID_SQUARES,0,4)); + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + } + } + + $vucc_grids = $this->ffma_model->get_vucc_lotw(); + foreach($vucc_grids as $key) { + $grid_four_lotw = strtoupper(substr($key,0,4)); + if(!in_array($grid_four_lotw, $array_grid_4char_lotw)){ + array_push($array_grid_4char_lotw, $grid_four_lotw); + } + } + + $vucc_grids = $this->ffma_model->get_vucc_paper(); + foreach($vucc_grids as $key) { + $grid_four_paper = strtoupper(substr($key,0,4)); + if(!in_array($grid_four_paper, $array_grid_4char_paper)){ + array_push($array_grid_4char_paper, $grid_four_paper); + } + } + + $vucc_grids = $this->ffma_model->get_vucc_worked(); + foreach($vucc_grids as $key) { + $grid_four = strtoupper(substr($key,0,4)); + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + } + + $data['grid_4char_lotw'] = ($array_grid_4char_lotw); + $data['grid_4char_paper'] = ($array_grid_4char_paper); + $data['grid_4char'] = ($array_grid_4char); + + header('Content-Type: application/json'); + echo json_encode($data); + } + public function getGridmasterGridsjs() { $this->load->model('gridmaster_model'); @@ -592,7 +694,7 @@ class Awards extends CI_Controller { foreach ($query->result() as $row) { $grid_four = strtoupper(substr($row->GRID_SQUARES,0,4)); if(!in_array($grid_four, $array_grid_4char)){ - array_push($array_grid_4char, $grid_four); + array_push($array_grid_4char, $grid_four); } } } diff --git a/application/language/english/menu_lang.php b/application/language/english/menu_lang.php index 52a06af3..224bcbb3 100644 --- a/application/language/english/menu_lang.php +++ b/application/language/english/menu_lang.php @@ -37,6 +37,7 @@ $lang['menu_awards'] = 'Awards'; $lang['menu_cq'] = 'CQ'; $lang['menu_dok'] = 'DOK'; $lang['menu_dxcc'] = 'DXCC'; +$lang['menu_ffma'] = 'Fred Fish Memorial Award'; $lang['menu_iota'] = 'IOTA'; $lang['menu_pota'] = 'POTA'; $lang['menu_sig'] = 'SIG'; diff --git a/application/models/Ffma_model.php b/application/models/Ffma_model.php new file mode 100644 index 00000000..d9ae6cbd --- /dev/null +++ b/application/models/Ffma_model.php @@ -0,0 +1,189 @@ +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 substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES FROM ' + .$this->config->item('table_name') + .' WHERE station_id in ('.$location_list.')' + ." and COL_LOTW_QSL_RCVD = 'Y'" + ." and COL_BAND = '6M'" + .' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->us_grids).'\')'; + return $this->db->query($sql); + } + + function get_paper() { + $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 substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES FROM ' + .$this->config->item('table_name') + .' WHERE station_id in ('.$location_list.')' + ." and COL_QSL_RCVD = 'Y'" + ." and COL_BAND = '6M'" + .' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->us_grids).'\')'; + return $this->db->query($sql); + } + + function get_worked() { + $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 substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES FROM ' + .$this->config->item('table_name') + .' WHERE station_id in ('.$location_list.')' + ." and COL_BAND = '6M'" + .' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->us_grids).'\')'; + return $this->db->query($sql); + } + + function get_vucc_lotw() { + $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 as VUCC_GRIDS FROM ' + .$this->config->item('table_name') + .' WHERE station_id in ('.$location_list.')' + ." and COL_LOTW_QSL_RCVD = 'Y'" + ." and COL_VUCC_GRIDS != ''" + ." and COL_VUCC_GRIDS IS NOT NULL" + ." and COL_BAND = '6M'"; + $query = $this->db->query($sql); + $vucc_grids = []; + foreach ($query->result() as $row) { + $grids = explode(',', $row->VUCC_GRIDS); + foreach ($grids as $grid) { + if (in_array(substr($grid, 0, 4), $this->us_grids)) { + if (!in_array(substr($grid, 0, 4), $vucc_grids)) { + $vucc_grids[] = substr($grid, 0, 4); + } + } + } + } + return $vucc_grids; + } + + function get_vucc_paper() { + $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 as VUCC_GRIDS FROM ' + .$this->config->item('table_name') + .' WHERE station_id in ('.$location_list.')' + ." and COL_QSL_RCVD = 'Y'" + ." and COL_VUCC_GRIDS != ''" + ." and COL_VUCC_GRIDS IS NOT NULL" + ." and COL_BAND = '6M'"; + $query = $this->db->query($sql); + $vucc_grids = []; + foreach ($query->result() as $row) { + $grids = explode(',', $row->VUCC_GRIDS); + foreach ($grids as $grid) { + if (in_array(substr($grid, 0, 4), $this->us_grids)) { + if (!in_array(substr($grid, 0, 4), $vucc_grids)) { + $vucc_grids[] = substr($grid, 0, 4); + } + } + } + } + return $vucc_grids; + } + + function get_vucc_worked() { + $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 as VUCC_GRIDS FROM ' + .$this->config->item('table_name') + .' WHERE station_id in ('.$location_list.')' + ." and COL_VUCC_GRIDS != ''" + ." and COL_VUCC_GRIDS IS NOT NULL" + ." and COL_BAND = '6M'"; + $query = $this->db->query($sql); + $vucc_grids = []; + foreach ($query->result() as $row) { + $grids = explode(',', $row->VUCC_GRIDS); + foreach ($grids as $grid) { + if (in_array(substr($grid, 0, 4), $this->us_grids)) { + if (!in_array(substr($grid, 0, 4), $vucc_grids)) { + $vucc_grids[] = substr($grid, 0, 4); + } + } + } + } + return $vucc_grids; + } + +} diff --git a/application/views/awards/ffma/index.php b/application/views/awards/ffma/index.php new file mode 100644 index 00000000..6caed124 --- /dev/null +++ b/application/views/awards/ffma/index.php @@ -0,0 +1,84 @@ + + + +