diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php index 1357ce16..a173da5d 100644 --- a/application/models/Gridsquares_model.php +++ b/application/models/Gridsquares_model.php @@ -31,7 +31,7 @@ class Gridsquares_model extends CI_Model { $CI =& get_instance(); $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - + return $this->db->query('SELECT COL_VUCC_GRIDS, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_VUCC_GRIDS != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y") AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'); } @@ -58,7 +58,7 @@ class Gridsquares_model extends CI_Model { .$station_id.'" AND COL_GRIDSQUARE != ""'; if ($band != 'All') { $sql .= ' AND COL_BAND = "' . $band - .'" + .'" AND COL_PROP_MODE != "SAT" AND COL_PROP_MODE != "INTERNET" AND COL_PROP_MODE != "ECH" @@ -80,7 +80,7 @@ class Gridsquares_model extends CI_Model { .$station_id.'" AND COL_GRIDSQUARE != ""'; if ($band != 'All') { $sql .= ' AND COL_BAND = "' . $band - .'" + .'" AND COL_PROP_MODE != "SAT" AND COL_PROP_MODE != "INTERNET" AND COL_PROP_MODE != "ECH" @@ -99,15 +99,14 @@ class Gridsquares_model extends CI_Model { $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE FROM ' + $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' .$this->config->item('table_name') - .' WHERE station_id = "' - .$station_id.'" AND COL_GRIDSQUARE LIKE "%' - .$gridsquare.'%"'; + .' WHERE station_id = "' . $station_id . '" ' + . ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")'; if ($band != 'All') { $sql .= ' AND COL_BAND = "' . $band - .'" + .'" AND COL_PROP_MODE != "SAT" AND COL_PROP_MODE != "INTERNET" AND COL_PROP_MODE != "ECH" @@ -126,7 +125,13 @@ class Gridsquares_model extends CI_Model { $CI->load->model('Stations'); $station_id = $CI->Stations->find_active(); - $result = $this->db->query('SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_SAT_NAME, COL_GRIDSQUARE FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" AND COL_PROP_MODE = "SAT"'); + $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_SAT_NAME, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' . + $this->config->item('table_name'). + ' WHERE station_id = "'.$station_id. '"' . + ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")'. + ' AND COL_PROP_MODE = "SAT"'; + + $result = $this->db->query($sql); //print_r($result); return json_encode($result->result()); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 64045a65..3aa436d1 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1042,7 +1042,7 @@ class Logbook_model extends CI_Model { $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); $this->db->where("station_id", $station_id); - + if($band != "All" && $band != "SAT") { $this->db->where("COL_BAND", $band); @@ -2086,9 +2086,8 @@ class Logbook_model extends CI_Model { * Check the dxxc_prefixes table and return (dxcc, country) */ public function check_dxcc_table($call, $date){ - $len = strlen($call); - $dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`') + $dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`') ->where('call', $call) ->where('(start <= ', $date) ->or_where('start is null)', NULL, false) @@ -2096,12 +2095,19 @@ class Logbook_model extends CI_Model { ->or_where('end is null)', NULL, false) ->get('dxcc_exceptions'); - if ($dxcc_exceptions->num_rows() > 0){ - $row = $dxcc_exceptions->row_array(); - return array($row['adif'], $row['entity'], $row['cqz']); - } - // query the table, removing a character from the right until a match - for ($i = $len; $i > 0; $i--){ + if ($dxcc_exceptions->num_rows() > 0){ + $row = $dxcc_exceptions->row_array(); + return array($row['adif'], $row['entity'], $row['cqz']); + } + + if (preg_match('/(^KG4)[A-Z09]{3,}/', $call)) { // KG4/ and KG4 5 char calls are Guantanamo Bay. If 6 char, it is USA + $call = "K"; + } + + $len = strlen($call); + + // query the table, removing a character from the right until a match + for ($i = $len; $i > 0; $i--){ //printf("searching for %s\n", substr($call, 0, $i)); $dxcc_result = $this->db->select('`call`, `entity`, `adif`, `cqz`') ->where('call', substr($call, 0, $i)) @@ -2124,41 +2130,47 @@ class Logbook_model extends CI_Model { } public function dxcc_lookup($call, $date){ - $len = strlen($call); - $dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`') - ->where('call', $call) - ->where('(start <= CURDATE()') - ->or_where('start is null', NULL, false) - ->where('end >= CURDATE()') - ->or_where('end is null)', NULL, false) - ->get('dxcc_exceptions'); + $dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`') + ->where('call', $call) + ->where('(start <= CURDATE()') + ->or_where('start is null', NULL, false) + ->where('end >= CURDATE()') + ->or_where('end is null)', NULL, false) + ->get('dxcc_exceptions'); - if ($dxcc_exceptions->num_rows() > 0){ - $row = $dxcc_exceptions->row_array(); - return $row; - } else { - // query the table, removing a character from the right until a match - for ($i = $len; $i > 0; $i--){ - //printf("searching for %s\n", substr($call, 0, $i)); - $dxcc_result = $this->db->select('*') - ->where('call', substr($call, 0, $i)) - ->where('(start <= ', $date) - ->or_where("start is null)", NULL, false) - ->where('(end >= ', $date) - ->or_where("end is null)", NULL, false) - ->get('dxcc_prefixes'); + if ($dxcc_exceptions->num_rows() > 0){ + $row = $dxcc_exceptions->row_array(); + return $row; + } else { - //$dxcc_result = $this->db->query("select `call`, `entity`, `adif` from dxcc_prefixes where `call` = '".substr($call, 0, $i) ."'"); - //print $this->db->last_query(); + if (preg_match('/(^KG4)[A-Z09]{3,}/', $call)) { // KG4/ and KG4 5 char calls are Guantanamo Bay. If 6 char, it is USA + $call = "K"; + } - if ($dxcc_result->num_rows() > 0){ - $row = $dxcc_result->row_array(); - return $row; - } - } - } + $len = strlen($call); + + // query the table, removing a character from the right until a match + for ($i = $len; $i > 0; $i--){ + //printf("searching for %s\n", substr($call, 0, $i)); + $dxcc_result = $this->db->select('*') + ->where('call', substr($call, 0, $i)) + ->where('(start <= ', $date) + ->or_where("start is null)", NULL, false) + ->where('(end >= ', $date) + ->or_where("end is null)", NULL, false) + ->get('dxcc_prefixes'); + + //$dxcc_result = $this->db->query("select `call`, `entity`, `adif` from dxcc_prefixes where `call` = '".substr($call, 0, $i) ."'"); + //print $this->db->last_query(); + + if ($dxcc_result->num_rows() > 0){ + $row = $dxcc_result->row_array(); + return $row; + } + } + } return array("Not Found", "Not Found"); } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 799f2d7a..be883106 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -827,9 +827,9 @@ $(document).ready(function(){ $.each( data, function( i, item ) { console.log(item.COL_CALL + item.COL_SAT_NAME); if(item.COL_SAT_NAME != undefined) { - items.push( "