Generalize gridmaster functions

This commit is contained in:
phl0
2023-12-12 19:15:56 +01:00
parent 4050015d42
commit bfc2d50c95
6 changed files with 86 additions and 66 deletions

View File

@@ -34,8 +34,22 @@ class Gridmaster_model extends CI_Model {
'EL39', 'EL49', 'EL59', 'EL79', 'EL89', 'EL99', 'DL88', 'DL98', 'EL08', 'EL18', 'EL28', 'EL58', 'EL88', 'EL98', 'EL07', 'EL17',
'EL87', 'EL97', 'EL06', 'EL16', 'EL86', 'EL96', 'EL15', 'EL95', 'EL84', 'EL94'
];
private $us_lat = 38;
private $us_lon = -91;
private $us_zoom = 5;
function get_lotw() {
private $ja_grids = ['PL14', 'PL24', 'PL36', 'PL37', 'PL46', 'PL47', 'PL48', 'PL49', 'PL55', 'PL58', 'PM40', 'PM41', 'PM42', 'PM43',
'PM44', 'PM50', 'PM51', 'PM52', 'PM53', 'PM54', 'PM62', 'PM63', 'PM64', 'PM65', 'PM66', 'PM73', 'PM74', 'PM75', 'PM76', 'PM83',
'PM84', 'PM85', 'PM86', 'PM87', 'PM92', 'PM93', 'PM94', 'PM95', 'PM96', 'PM97', 'PM98', 'PM99', 'PN90', 'PN91', 'PN92', 'QL16',
'QL17', 'QM05', 'QM06', 'QM07', 'QM08', 'QM09', 'QM19', 'QN00', 'QN01', 'QN02', 'QN03', 'QN04', 'QN05', 'QN11', 'QN12', 'QN13',
'QN14', 'QN15', 'QN22', 'QN23', 'QN24', 'PL80', 'PM91', 'QL04', 'QL05', 'QL07', 'QL09', 'QL64', 'QM00', 'QM01', 'PL15', 'PL25',
'PL54', 'PM57', 'QN33', 'QN34', 'QN35', 'QN45'
];
private $ja_lat = 35;
private $ja_lon = 140;
private $ja_zoom = 5;
function get_lotw($dxcc) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -50,11 +64,11 @@ class Gridmaster_model extends CI_Model {
.' WHERE station_id in ('.$location_list.')'
." and COL_LOTW_QSL_RCVD = 'Y'"
." and COL_PROP_MODE = 'SAT'"
.' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->us_grids).'\')';
.' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->{$dxcc.'_grids'}).'\')';
return $this->db->query($sql);
}
function get_paper() {
function get_paper($dxcc) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -69,11 +83,11 @@ class Gridmaster_model extends CI_Model {
.' WHERE station_id in ('.$location_list.')'
." and COL_QSL_RCVD = 'Y'"
." and COL_PROP_MODE = 'SAT'"
.' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->us_grids).'\')';
.' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->{$dxcc.'_grids'}).'\')';
return $this->db->query($sql);
}
function get_worked() {
function get_worked($dxcc) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -87,11 +101,11 @@ class Gridmaster_model extends CI_Model {
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'
." and COL_PROP_MODE = 'SAT'"
.' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->us_grids).'\')';
.' AND substring(COL_GRIDSQUARE,1,4) in (\''.implode('\',\'', $this->{$dxcc.'_grids'}).'\')';
return $this->db->query($sql);
}
function get_vucc_lotw() {
function get_vucc_lotw($dxcc) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -113,7 +127,7 @@ class Gridmaster_model extends CI_Model {
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), $this->{$dxcc.'_grids'})) {
if (!in_array(substr($grid, 0, 4), $vucc_grids)) {
$vucc_grids[] = substr($grid, 0, 4);
}
@@ -123,7 +137,7 @@ class Gridmaster_model extends CI_Model {
return $vucc_grids;
}
function get_vucc_paper() {
function get_vucc_paper($dxcc) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -145,7 +159,7 @@ class Gridmaster_model extends CI_Model {
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), $this->{$dxcc.'_grids'})) {
if (!in_array(substr($grid, 0, 4), $vucc_grids)) {
$vucc_grids[] = substr($grid, 0, 4);
}
@@ -155,7 +169,7 @@ class Gridmaster_model extends CI_Model {
return $vucc_grids;
}
function get_vucc_worked() {
function get_vucc_worked($dxcc) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -176,7 +190,7 @@ class Gridmaster_model extends CI_Model {
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), $this->{$dxcc.'_grids'})) {
if (!in_array(substr($grid, 0, 4), $vucc_grids)) {
$vucc_grids[] = substr($grid, 0, 4);
}
@@ -186,4 +200,24 @@ class Gridmaster_model extends CI_Model {
return $vucc_grids;
}
function get_grid_count($dxcc) {
return count($this->{$dxcc.'_grids'});
}
function get_grids($dxcc) {
return $this->{$dxcc.'_grids'};
}
function get_lat($dxcc) {
return $this->{$dxcc.'_lat'};
}
function get_lon($dxcc) {
return $this->{$dxcc.'_lon'};
}
function get_zoom($dxcc) {
return $this->{$dxcc.'_zoom'};
}
}