More binding and tweaking

This commit is contained in:
Andreas Kristiansen
2024-08-15 08:37:48 +02:00
parent addafc9b2d
commit e0e08f5e06
4 changed files with 200 additions and 278 deletions

View File

@@ -783,6 +783,15 @@ class Awards extends CI_Controller {
$this->load->model('iota');
$this->load->model('modes');
$this->load->model('bands');
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$data['worked_bands'] = $this->bands->get_worked_bands('iota'); // Used in the view for band select
@@ -839,9 +848,9 @@ class Awards extends CI_Controller {
$postdata['mode'] = 'All';
}
$iotalist = $this->iota->fetchIota($postdata);
$data['iota_array'] = $this->iota->get_iota_array($iotalist, $bands, $postdata);
$data['iota_summary'] = $this->iota->get_iota_summary($bands, $postdata);
$iotalist = $this->iota->fetchIota($postdata, $location_list);
$data['iota_array'] = $this->iota->get_iota_array($iotalist, $bands, $postdata, $location_list);
$data['iota_summary'] = $this->iota->get_iota_summary($bands, $postdata, $location_list);
// Render Page
$data['page_title'] = sprintf(__("Awards - %s"), __("IOTA (Island On The Air)"));
@@ -948,17 +957,20 @@ class Awards extends CI_Controller {
$footerData = [];
$footerData['scripts']= [
'assets/js/leaflet/geocoding.js',
'assets/js/leaflet/L.MaidenheadColouredGridmasterMap.js',
'assets/js/sections/ffma.js'
'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('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$this->load->model('ffma_model');
$array_grid_4char = array();
@@ -968,7 +980,7 @@ class Awards extends CI_Controller {
$grid_4char = "";
$grid_4char_lotw = "";
$query = $this->ffma_model->get_lotw();
$query = $this->ffma_model->get_lotw($location_list);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$grid_4char_lotw = strtoupper(substr($row->GRID_SQUARES,0,4));
@@ -978,7 +990,7 @@ class Awards extends CI_Controller {
}
}
$query = $this->ffma_model->get_paper();
$query = $this->ffma_model->get_paper($location_list);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$grid_4char_paper = strtoupper(substr($row->GRID_SQUARES,0,4));
@@ -988,7 +1000,7 @@ class Awards extends CI_Controller {
}
}
$query = $this->ffma_model->get_worked();
$query = $this->ffma_model->get_worked($location_list);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$grid_four = strtoupper(substr($row->GRID_SQUARES,0,4));
@@ -998,7 +1010,7 @@ class Awards extends CI_Controller {
}
}
$vucc_grids = $this->ffma_model->get_vucc_lotw();
$vucc_grids = $this->ffma_model->get_vucc_lotw($location_list);
foreach($vucc_grids as $key) {
$grid_four_lotw = strtoupper(substr($key,0,4));
if(!in_array($grid_four_lotw, $array_grid_4char_lotw)){
@@ -1006,7 +1018,7 @@ class Awards extends CI_Controller {
}
}
$vucc_grids = $this->ffma_model->get_vucc_paper();
$vucc_grids = $this->ffma_model->get_vucc_paper($location_list);
foreach($vucc_grids as $key) {
$grid_four_paper = strtoupper(substr($key,0,4));
if(!in_array($grid_four_paper, $array_grid_4char_paper)){
@@ -1014,7 +1026,7 @@ class Awards extends CI_Controller {
}
}
$vucc_grids = $this->ffma_model->get_vucc_worked();
$vucc_grids = $this->ffma_model->get_vucc_worked($location_list);
foreach($vucc_grids as $key) {
$grid_four = strtoupper(substr($key,0,4));
if(!in_array($grid_four, $array_grid_4char)){
@@ -1033,6 +1045,9 @@ class Awards extends CI_Controller {
}
public function getGridmasterGridsjs($dxcc) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$this->load->model('gridmaster_model');
$dxcc = $this->security->xss_clean($dxcc);
@@ -1044,7 +1059,7 @@ class Awards extends CI_Controller {
$grid_4char = "";
$grid_4char_lotw = "";
$query = $this->gridmaster_model->get_lotw($dxcc);
$query = $this->gridmaster_model->get_lotw($dxcc, $location_list);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$grid_4char_lotw = strtoupper(substr($row->GRID_SQUARES,0,4));
@@ -1054,7 +1069,7 @@ class Awards extends CI_Controller {
}
}
$query = $this->gridmaster_model->get_paper($dxcc);
$query = $this->gridmaster_model->get_paper($dxcc, $location_list);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$grid_4char_paper = strtoupper(substr($row->GRID_SQUARES,0,4));
@@ -1064,7 +1079,7 @@ class Awards extends CI_Controller {
}
}
$query = $this->gridmaster_model->get_worked($dxcc);
$query = $this->gridmaster_model->get_worked($dxcc, $location_list);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$grid_four = strtoupper(substr($row->GRID_SQUARES,0,4));
@@ -1074,7 +1089,7 @@ class Awards extends CI_Controller {
}
}
$vucc_grids = $this->gridmaster_model->get_vucc_lotw($dxcc);
$vucc_grids = $this->gridmaster_model->get_vucc_lotw($dxcc, $location_list);
foreach($vucc_grids as $key) {
$grid_four_lotw = strtoupper(substr($key,0,4));
if(!in_array($grid_four_lotw, $array_grid_4char_lotw)){
@@ -1082,7 +1097,7 @@ class Awards extends CI_Controller {
}
}
$vucc_grids = $this->gridmaster_model->get_vucc_paper($dxcc);
$vucc_grids = $this->gridmaster_model->get_vucc_paper($dxcc, $location_list);
foreach($vucc_grids as $key) {
$grid_four_paper = strtoupper(substr($key,0,4));
if(!in_array($grid_four_paper, $array_grid_4char_paper)){
@@ -1090,7 +1105,7 @@ class Awards extends CI_Controller {
}
}
$vucc_grids = $this->gridmaster_model->get_vucc_worked($dxcc);
$vucc_grids = $this->gridmaster_model->get_vucc_worked($dxcc, $location_list);
foreach($vucc_grids as $key) {
$grid_four = strtoupper(substr($key,0,4));
if(!in_array($grid_four, $array_grid_4char)){
@@ -1534,6 +1549,15 @@ class Awards extends CI_Controller {
public function iota_map() {
$this->load->model('iota');
$this->load->model('bands');
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$bands[] = $this->security->xss_clean($this->input->post('band'));
@@ -1553,9 +1577,9 @@ class Awards extends CI_Controller {
$postdata['Oceania'] = $this->input->post('Oceania') == 0 ? NULL: 1;
$postdata['Antarctica'] = $this->input->post('Antarctica') == 0 ? NULL: 1;
$iotalist = $this->iota->fetchIota($postdata);
$iotalist = $this->iota->fetchIota($postdata, $location_list);
$iota_array = $this->iota->get_iota_array($iotalist, $bands, $postdata);
$iota_array = $this->iota->get_iota_array($iotalist, $bands, $postdata, $location_list);
$i = 0;

View File

@@ -3,195 +3,141 @@
class Ffma_model extends CI_Model {
private $us_grids = ['EN29', 'CN78', 'CN88', 'CN98', 'DN08', 'DN18', 'DN28', 'DN38', 'DN48', 'DN58', 'DN68', 'DN78', 'DN88', 'DN98',
'EN08', 'EN18', 'EN28', 'EN38', 'EN48', 'EN58', 'CN77', 'CN87', 'CN97', 'DN07', 'DN17', 'DN27', 'DN37', 'DN47', 'DN57', 'DN67',
'DN77', 'DN87', 'DN97', 'EN07', 'EN17', 'EN27', 'EN37', 'EN47', 'EN57', 'EN67', 'FN57', 'FN67', 'CN76', 'CN86', 'CN96', 'DN06',
'DN16', 'DN26', 'DN36', 'DN46', 'DN56', 'DN66', 'DN76', 'DN86', 'DN96', 'EN06', 'EN16', 'EN26', 'EN36', 'EN46', 'EN56', 'EN66',
'EN76', 'EN86', 'FN46', 'FN56', 'FN66', 'CN75', 'CN85', 'CN95', 'DN05', 'DN15', 'DN25', 'DN35', 'DN45', 'DN55', 'DN65', 'DN75',
'DN85', 'DN95', 'EN05', 'EN15', 'EN25', 'EN35', 'EN45', 'EN55', 'EN65', 'EN75', 'EN85', 'FN25', 'FN35', 'FN45', 'FN55', 'FN65',
'CN74', 'CN84', 'CN94', 'DN04', 'DN14', 'DN24', 'DN34', 'DN44', 'DN54', 'DN64', 'DN74', 'DN84', 'DN94', 'EN04', 'EN14', 'EN24',
'EN34', 'EN44', 'EN54', 'EN64', 'EN74', 'EN84', 'FN14', 'FN24', 'FN34', 'FN44', 'FN54', 'FN64', 'CN73', 'CN83', 'CN93', 'DN03',
'DN13', 'DN23', 'DN33', 'DN43', 'DN53', 'DN63', 'DN73', 'DN83', 'DN93', 'EN03', 'EN13', 'EN23', 'EN33', 'EN43', 'EN53', 'EN63',
'EN73', 'EN83', 'FN03', 'FN13', 'FN23', 'FN33', 'FN43', 'FN53', 'CN72', 'CN82', 'CN92', 'DN02', 'DN12', 'DN22', 'DN32', 'DN42',
'DN52', 'DN62', 'DN72', 'DN82', 'DN92', 'EN02', 'EN12', 'EN22', 'EN32', 'EN42', 'EN52', 'EN62', 'EN72', 'EN82', 'EN92', 'FN02',
'FN12', 'FN22', 'FN32', 'FN42', 'CN71', 'CN81', 'CN91', 'DN01', 'DN11', 'DN21', 'DN31', 'DN41', 'DN51', 'DN61', 'DN71', 'DN81',
'DN91', 'EN01', 'EN11', 'EN21', 'EN31', 'EN41', 'EN51', 'EN61', 'EN71', 'EN81', 'EN91', 'FN01', 'FN11', 'FN21', 'FN31', 'FN41',
'FN51', 'CN70', 'CN80', 'CN90', 'DN00', 'DN10', 'DN20', 'DN30', 'DN40', 'DN50', 'DN60', 'DN70', 'DN80', 'DN90', 'EN00', 'EN10',
'EN20', 'EN30', 'EN40', 'EN50', 'EN60', 'EN70', 'EN80', 'EN90', 'FN00', 'FN10', 'FN20', 'FN30', 'CM79', 'CM89', 'CM99', 'DM09',
'DM19', 'DM29', 'DM39', 'DM49', 'DM59', 'DM69', 'DM79', 'DM89', 'DM99', 'EM09', 'EM19', 'EM29', 'EM39', 'EM49', 'EM59', 'EM69',
'EM79', 'EM89', 'EM99', 'FM09', 'FM19', 'FM29', 'CM88', 'CM98', 'DM08', 'DM18', 'DM28', 'DM38', 'DM48', 'DM58', 'DM68', 'DM78',
'DM88', 'DM98', 'EM08', 'EM18', 'EM28', 'EM38', 'EM48', 'EM58', 'EM68', 'EM78', 'EM88', 'EM98', 'FM08', 'FM18', 'FM28', 'CM87',
'CM97', 'DM07', 'DM17', 'DM27', 'DM37', 'DM47', 'DM57', 'DM67', 'DM77', 'DM87', 'DM97', 'EM07', 'EM17', 'EM27', 'EM37', 'EM47',
'EM57', 'EM67', 'EM77', 'EM87', 'EM97', 'FM07', 'FM17', 'FM27', 'CM86', 'CM96', 'DM06', 'DM16', 'DM26', 'DM36', 'DM46', 'DM56',
'DM66', 'DM76', 'DM86', 'DM96', 'EM06', 'EM16', 'EM26', 'EM36', 'EM46', 'EM56', 'EM66', 'EM76', 'EM86', 'EM96', 'FM06', 'FM16',
'FM26', 'CM95', 'DM05', 'DM15', 'DM25', 'DM35', 'DM45', 'DM55', 'DM65', 'DM75', 'DM85', 'DM95', 'EM05', 'EM15', 'EM25', 'EM35',
'EM45', 'EM55', 'EM65', 'EM75', 'EM85', 'EM95', 'FM05', 'FM15', 'FM25', 'CM94', 'DM04', 'DM14', 'DM24', 'DM34', 'DM44', 'DM54',
'DM64', 'DM74', 'DM84', 'DM94', 'EM04', 'EM14', 'EM24', 'EM34', 'EM44', 'EM54', 'EM64', 'EM74', 'EM84', 'EM94', 'FM04', 'FM14',
'CM93', 'DM03', 'DM13', 'DM23', 'DM33', 'DM43', 'DM53', 'DM63', 'DM73', 'DM83', 'DM93', 'EM03', 'EM13', 'EM23', 'EM33', 'EM43',
'EM53', 'EM63', 'EM73', 'EM83', 'EM93', 'FM03', 'FM13', 'DM02', 'DM12', 'DM22', 'DM32', 'DM42', 'DM52', 'DM62', 'DM72', 'DM82',
'DM92', 'EM02', 'EM12', 'EM22', 'EM32', 'EM42', 'EM52', 'EM62', 'EM72', 'EM82', 'EM92', 'FM02', 'DM31', 'DM41', 'DM51', 'DM61',
'DM71', 'DM81', 'DM91', 'EM01', 'EM11', 'EM21', 'EM31', 'EM41', 'EM51', 'EM61', 'EM71', 'EM81', 'EM91', 'DM70', 'DM80', 'DM90',
'EM00', 'EM10', 'EM20', 'EM30', 'EM40', 'EM50', 'EM60', 'EM70', 'EM80', 'EM90', 'DL79', 'DL89', 'DL99', 'EL09', 'EL19', 'EL29',
'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'
'EN08', 'EN18', 'EN28', 'EN38', 'EN48', 'EN58', 'CN77', 'CN87', 'CN97', 'DN07', 'DN17', 'DN27', 'DN37', 'DN47', 'DN57', 'DN67',
'DN77', 'DN87', 'DN97', 'EN07', 'EN17', 'EN27', 'EN37', 'EN47', 'EN57', 'EN67', 'FN57', 'FN67', 'CN76', 'CN86', 'CN96', 'DN06',
'DN16', 'DN26', 'DN36', 'DN46', 'DN56', 'DN66', 'DN76', 'DN86', 'DN96', 'EN06', 'EN16', 'EN26', 'EN36', 'EN46', 'EN56', 'EN66',
'EN76', 'EN86', 'FN46', 'FN56', 'FN66', 'CN75', 'CN85', 'CN95', 'DN05', 'DN15', 'DN25', 'DN35', 'DN45', 'DN55', 'DN65', 'DN75',
'DN85', 'DN95', 'EN05', 'EN15', 'EN25', 'EN35', 'EN45', 'EN55', 'EN65', 'EN75', 'EN85', 'FN25', 'FN35', 'FN45', 'FN55', 'FN65',
'CN74', 'CN84', 'CN94', 'DN04', 'DN14', 'DN24', 'DN34', 'DN44', 'DN54', 'DN64', 'DN74', 'DN84', 'DN94', 'EN04', 'EN14', 'EN24',
'EN34', 'EN44', 'EN54', 'EN64', 'EN74', 'EN84', 'FN14', 'FN24', 'FN34', 'FN44', 'FN54', 'FN64', 'CN73', 'CN83', 'CN93', 'DN03',
'DN13', 'DN23', 'DN33', 'DN43', 'DN53', 'DN63', 'DN73', 'DN83', 'DN93', 'EN03', 'EN13', 'EN23', 'EN33', 'EN43', 'EN53', 'EN63',
'EN73', 'EN83', 'FN03', 'FN13', 'FN23', 'FN33', 'FN43', 'FN53', 'CN72', 'CN82', 'CN92', 'DN02', 'DN12', 'DN22', 'DN32', 'DN42',
'DN52', 'DN62', 'DN72', 'DN82', 'DN92', 'EN02', 'EN12', 'EN22', 'EN32', 'EN42', 'EN52', 'EN62', 'EN72', 'EN82', 'EN92', 'FN02',
'FN12', 'FN22', 'FN32', 'FN42', 'CN71', 'CN81', 'CN91', 'DN01', 'DN11', 'DN21', 'DN31', 'DN41', 'DN51', 'DN61', 'DN71', 'DN81',
'DN91', 'EN01', 'EN11', 'EN21', 'EN31', 'EN41', 'EN51', 'EN61', 'EN71', 'EN81', 'EN91', 'FN01', 'FN11', 'FN21', 'FN31', 'FN41',
'FN51', 'CN70', 'CN80', 'CN90', 'DN00', 'DN10', 'DN20', 'DN30', 'DN40', 'DN50', 'DN60', 'DN70', 'DN80', 'DN90', 'EN00', 'EN10',
'EN20', 'EN30', 'EN40', 'EN50', 'EN60', 'EN70', 'EN80', 'EN90', 'FN00', 'FN10', 'FN20', 'FN30', 'CM79', 'CM89', 'CM99', 'DM09',
'DM19', 'DM29', 'DM39', 'DM49', 'DM59', 'DM69', 'DM79', 'DM89', 'DM99', 'EM09', 'EM19', 'EM29', 'EM39', 'EM49', 'EM59', 'EM69',
'EM79', 'EM89', 'EM99', 'FM09', 'FM19', 'FM29', 'CM88', 'CM98', 'DM08', 'DM18', 'DM28', 'DM38', 'DM48', 'DM58', 'DM68', 'DM78',
'DM88', 'DM98', 'EM08', 'EM18', 'EM28', 'EM38', 'EM48', 'EM58', 'EM68', 'EM78', 'EM88', 'EM98', 'FM08', 'FM18', 'FM28', 'CM87',
'CM97', 'DM07', 'DM17', 'DM27', 'DM37', 'DM47', 'DM57', 'DM67', 'DM77', 'DM87', 'DM97', 'EM07', 'EM17', 'EM27', 'EM37', 'EM47',
'EM57', 'EM67', 'EM77', 'EM87', 'EM97', 'FM07', 'FM17', 'FM27', 'CM86', 'CM96', 'DM06', 'DM16', 'DM26', 'DM36', 'DM46', 'DM56',
'DM66', 'DM76', 'DM86', 'DM96', 'EM06', 'EM16', 'EM26', 'EM36', 'EM46', 'EM56', 'EM66', 'EM76', 'EM86', 'EM96', 'FM06', 'FM16',
'FM26', 'CM95', 'DM05', 'DM15', 'DM25', 'DM35', 'DM45', 'DM55', 'DM65', 'DM75', 'DM85', 'DM95', 'EM05', 'EM15', 'EM25', 'EM35',
'EM45', 'EM55', 'EM65', 'EM75', 'EM85', 'EM95', 'FM05', 'FM15', 'FM25', 'CM94', 'DM04', 'DM14', 'DM24', 'DM34', 'DM44', 'DM54',
'DM64', 'DM74', 'DM84', 'DM94', 'EM04', 'EM14', 'EM24', 'EM34', 'EM44', 'EM54', 'EM64', 'EM74', 'EM84', 'EM94', 'FM04', 'FM14',
'CM93', 'DM03', 'DM13', 'DM23', 'DM33', 'DM43', 'DM53', 'DM63', 'DM73', 'DM83', 'DM93', 'EM03', 'EM13', 'EM23', 'EM33', 'EM43',
'EM53', 'EM63', 'EM73', 'EM83', 'EM93', 'FM03', 'FM13', 'DM02', 'DM12', 'DM22', 'DM32', 'DM42', 'DM52', 'DM62', 'DM72', 'DM82',
'DM92', 'EM02', 'EM12', 'EM22', 'EM32', 'EM42', 'EM52', 'EM62', 'EM72', 'EM82', 'EM92', 'FM02', 'DM31', 'DM41', 'DM51', 'DM61',
'DM71', 'DM81', 'DM91', 'EM01', 'EM11', 'EM21', 'EM31', 'EM41', 'EM51', 'EM61', 'EM71', 'EM81', 'EM91', 'DM70', 'DM80', 'DM90',
'EM00', 'EM10', 'EM20', 'EM30', 'EM40', 'EM50', 'EM60', 'EM70', 'EM80', 'EM90', 'DL79', 'DL89', 'DL99', 'EL09', 'EL19', 'EL29',
'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'
];
function get_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)."'";
function get_lotw($location_list) {
$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).'\')';
.$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)."'";
function get_paper($location_list) {
$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).'\')';
.$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)."'";
function get_worked($location_list) {
$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).'\')';
.$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)."'";
function get_vucc_lotw($location_list) {
$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'";
.$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);
}
}
}
$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)."'";
function get_vucc_paper($location_list) {
$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'";
.$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);
}
}
}
$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)."'";
function get_vucc_worked($location_list) {
$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'";
.$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);
}
}
}
$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_grid_count() {
return count($this->us_grids);
return count($this->us_grids);
}
function get_grids() {
return $this->us_grids;
return $this->us_grids;
}
}

View File

@@ -62,16 +62,7 @@ class Gridmaster_model extends CI_Model {
private $lx_lon = 6;
private $lx_zoom = 8;
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'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_lotw($dxcc, $location_list) {
$sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'
@@ -81,16 +72,7 @@ class Gridmaster_model extends CI_Model {
return $this->db->query($sql);
}
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'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_paper($dxcc, $location_list) {
$sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'
@@ -100,16 +82,7 @@ class Gridmaster_model extends CI_Model {
return $this->db->query($sql);
}
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'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_worked($dxcc, $location_list) {
$sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'
@@ -118,16 +91,7 @@ class Gridmaster_model extends CI_Model {
return $this->db->query($sql);
}
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'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_vucc_lotw($dxcc, $location_list) {
$sql = 'SELECT distinct COL_VUCC_GRIDS as VUCC_GRIDS FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'
@@ -150,16 +114,7 @@ class Gridmaster_model extends CI_Model {
return $vucc_grids;
}
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'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_vucc_paper($dxcc, $location_list) {
$sql = 'SELECT distinct COL_VUCC_GRIDS as VUCC_GRIDS FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'
@@ -182,16 +137,7 @@ class Gridmaster_model extends CI_Model {
return $vucc_grids;
}
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'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_vucc_worked($dxcc, $location_list) {
$sql = 'SELECT distinct COL_VUCC_GRIDS as VUCC_GRIDS FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('.$location_list.')'

View File

@@ -5,15 +5,7 @@ class IOTA extends CI_Model {
$this->load->library('Genfunctions');
}
function get_iota_array($iotaArray, $bands, $postdata) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_iota_array($iotaArray, $bands, $postdata, $location_list) {
foreach ($bands as $band) { // Looping through bands and iota to generate the array needed for display
foreach ($iotaArray as $iota) {
$iotaMatrix[$iota->tag]['prefix'] = $iota->prefix;
@@ -68,12 +60,16 @@ class IOTA extends CI_Model {
}
function getIotaBandConfirmed($location_list, $band, $postdata) {
$binding = [];
$sql = "SELECT distinct UPPER(col_iota) as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
where station_id in (" . $location_list . ") and thcv.col_iota is not null";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
$binding[] = $postdata['mode'];
}
$sql .= $this->genfunctions->addBandToQuery($band);
@@ -85,19 +81,23 @@ class IOTA extends CI_Model {
$sql .= $this->genfunctions->addQslToQuery($postdata);
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}
function getIotaBandWorked($location_list, $band, $postdata) {
$binding = [];
$sql = 'SELECT distinct UPPER(col_iota) as tag FROM ' . $this->config->item('table_name'). ' thcv
join iota on thcv.col_iota = iota.tag
where station_id in (' . $location_list .
') and thcv.col_iota is not null';
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
$binding[] = $postdata['mode'];
}
$sql .= $this->genfunctions->addBandToQuery($band);
@@ -108,20 +108,13 @@ class IOTA extends CI_Model {
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}
function fetchIota($postdata) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function fetchIota($postdata, $location_list) {
$binding = [];
$sql = "select tag, name, prefix, dxccid, status, lat1, lat2, lon1, lon2 from iota where 1=1";
@@ -135,34 +128,41 @@ class IOTA extends CI_Model {
$sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id in (". $location_list . ") and col_iota = iota.tag";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
$binding[] = $postdata['mode'];
}
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
$sql .= " and col_prop_mode = ?";
$binding[] = $postdata['band'];
} else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $postdata['band'] . "'";
$sql .= " and col_band = ?";
$binding[] = $postdata['band'];
}
}
$sql .= ")";
}
$sql .= ' order by tag';
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}
function getIotaWorked($location_list, $postdata) {
$binding = [];
$sql = "SELECT distinct UPPER(col_iota) as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
where station_id in (" . $location_list . ") and thcv.col_iota is not null
and not exists (select 1 from ". $this->config->item('table_name') . " where station_id = ". $location_list . " and col_iota = thcv.col_iota)";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
}
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
@@ -172,24 +172,28 @@ class IOTA extends CI_Model {
}
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
}
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}
function getIotaConfirmed($location_list, $postdata) {
$binding = [];
$sql = "SELECT distinct UPPER(col_iota) as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
where station_id in (" . $location_list . ") and thcv.col_iota is not null";
$sql .= $this->genfunctions->addQslToQuery($postdata);
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
}
if ($postdata['includedeleted'] == NULL) {
@@ -201,7 +205,7 @@ class IOTA extends CI_Model {
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
$sql .= $this->genfunctions->addQslToQuery($postdata);
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}
@@ -242,16 +246,7 @@ class IOTA extends CI_Model {
/*
* Function gets worked and confirmed summary on each band on the active stationprofile
*/
function get_iota_summary($bands, $postdata) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
function get_iota_summary($bands, $postdata, $location_list) {
foreach ($bands as $band) {
$worked = $this->getSummaryByBand($band, $postdata, $location_list);
$confirmed = $this->getSummaryByBandConfirmed($band, $postdata, $location_list);
@@ -269,11 +264,14 @@ class IOTA extends CI_Model {
}
function getSummaryByBand($band, $postdata, $location_list) {
$binding = [];
$sql = "SELECT count(distinct UPPER(thcv.col_iota)) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= ' join iota on thcv.col_iota = iota.tag';
$sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
$sql .= " and thcv.col_prop_mode = ?";
$binding[] = $band;
} else if ($band == 'All') {
$this->load->model('bands');
$bandslots = $this->bands->get_worked_bands('iota');
@@ -282,25 +280,31 @@ class IOTA extends CI_Model {
$sql .= " and thcv.col_prop_mode !='SAT'";
} else {
$sql .= " and thcv.col_prop_mode !='SAT'";
$sql .= " and thcv.col_band ='" . $band . "'";
$sql .= " and thcv.col_band = ?";
$binding[] = $band;
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
$binding[] = $postdata['mode'];
}
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}
function getSummaryByBandConfirmed($band, $postdata, $location_list) {
$binding = [];
$sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= ' join iota on thcv.col_iota = iota.tag';
$sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
$sql .= " and thcv.col_prop_mode = ?";
$binding[] = $band;
} else if ($band == 'All') {
$this->load->model('bands');
$bandslots = $this->bands->get_worked_bands('iota');
@@ -309,18 +313,20 @@ class IOTA extends CI_Model {
$sql .= " and thcv.col_prop_mode !='SAT'";
} else {
$sql .= " and thcv.col_prop_mode !='SAT'";
$sql .= " and thcv.col_band ='" . $band . "'";
$sql .= " and thcv.col_band = ?";
$binding[] = $band;
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $postdata['mode'];
$binding[] = $postdata['mode'];
}
$sql .= $this->addContinentsToQuery($postdata);
$sql .= $this->genfunctions->addQslToQuery($postdata);
// log_message("Error",$sql);
$query = $this->db->query($sql);
$query = $this->db->query($sql, $binding);
return $query->result();
}