2019-06-26 20:11:44 +00:00
< ? php
class Gridsquares_model extends CI_Model {
2019-06-28 16:07:34 +00:00
2019-06-26 20:11:44 +00:00
function __construct ()
{
// Call the Model constructor
parent :: __construct ();
}
function get_worked_sat_squares () {
2019-09-26 11:30:40 +00:00
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
$this -> db -> where ( " station_id " , $station_id );
2020-04-02 13:59:48 +00:00
return $this -> db -> query ( 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM ' . $this -> config -> item ( 'table_name' ) . ' WHERE station_id = "' . $station_id . '" AND COL_GRIDSQUARE != "" AND COL_SAT_NAME != ""' );
2019-06-26 20:11:44 +00:00
}
2019-06-28 16:07:34 +00:00
function get_confirmed_sat_squares () {
2019-09-26 11:30:40 +00:00
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
2020-04-02 13:59:48 +00:00
return $this -> db -> query ( 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM ' . $this -> config -> item ( 'table_name' ) . ' WHERE station_id = "' . $station_id . '" AND COL_GRIDSQUARE != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")' );
2019-06-28 16:07:34 +00:00
}
function get_confirmed_sat_vucc_squares () {
2019-09-26 11:30:40 +00:00
$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")' );
2019-06-28 16:07:34 +00:00
}
2019-06-26 20:11:44 +00:00
function get_worked_sat_vucc_squares () {
2019-09-26 11:30:40 +00:00
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
2019-06-26 20:11:44 +00:00
$this -> db -> select ( 'COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME' );
2019-09-26 11:30:40 +00:00
$this -> db -> where ( " station_id " , $station_id );
2019-06-26 20:11:44 +00:00
$this -> db -> where ( 'COL_VUCC_GRIDS !=' , " " );
$this -> db -> where ( 'COL_SAT_NAME !=' , " " );
return $this -> db -> get ( $this -> config -> item ( 'table_name' ));
}
function get_band ( $band ) {
2019-09-26 11:30:40 +00:00
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
2020-04-25 06:36:44 +00:00
$sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM '
. $this -> config -> item ( 'table_name' )
. ' WHERE station_id = "'
. $station_id . '" AND COL_GRIDSQUARE != ""' ;
if ( $band != 'All' ) {
$sql .= ' AND COL_BAND = "' . $band
. ' "
2019-06-28 16:07:34 +00:00
AND COL_PROP_MODE != " SAT "
AND COL_PROP_MODE != " INTERNET "
AND COL_PROP_MODE != " ECH "
AND COL_PROP_MODE != " RPT "
2020-04-25 06:36:44 +00:00
AND COL_SAT_NAME = " " ' ;
}
return $this -> db -> query ( $sql );
2019-06-28 16:07:34 +00:00
}
function get_band_confirmed ( $band ) {
2019-09-26 11:30:40 +00:00
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
2020-04-25 06:36:44 +00:00
$sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM '
. $this -> config -> item ( 'table_name' )
. ' WHERE station_id = "'
. $station_id . '" AND COL_GRIDSQUARE != ""' ;
if ( $band != 'All' ) {
$sql .= ' AND COL_BAND = "' . $band
. ' "
2019-06-28 16:07:34 +00:00
AND COL_PROP_MODE != " SAT "
AND COL_PROP_MODE != " INTERNET "
AND COL_PROP_MODE != " ECH "
AND COL_PROP_MODE != " RPT "
2020-04-25 06:36:44 +00:00
AND COL_SAT_NAME = " " ' ;
}
$sql .= ' AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")' ;
return $this -> db -> query ( $sql );
2019-06-26 20:11:44 +00:00
}
2020-03-16 17:35:14 +00:00
function search_band ( $band , $gridsquare ) {
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
2020-04-25 06:36:44 +00:00
$sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE FROM '
. $this -> config -> item ( 'table_name' )
. ' WHERE station_id = "'
. $station_id . '" AND COL_GRIDSQUARE LIKE "%'
. $gridsquare . '%"' ;
if ( $band != 'All' ) {
$sql .= ' AND COL_BAND = "' . $band
. ' "
2020-03-16 17:35:14 +00:00
AND COL_PROP_MODE != " SAT "
AND COL_PROP_MODE != " INTERNET "
AND COL_PROP_MODE != " ECH "
AND COL_PROP_MODE != " RPT "
2020-04-25 06:36:44 +00:00
AND COL_SAT_NAME = " " ' ;
}
$result = $this -> db -> query ( $sql );
2020-03-16 17:35:14 +00:00
//print_r($result);
return json_encode ( $result -> result ());
}
function search_sat ( $gridsquare ) {
$CI =& get_instance ();
$CI -> load -> model ( 'Stations' );
$station_id = $CI -> Stations -> find_active ();
2020-04-20 19:05:00 +00:00
$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"' );
2020-03-16 17:35:14 +00:00
//print_r($result);
return json_encode ( $result -> result ());
}
2020-04-02 13:59:48 +00:00
}