2023-09-11 16:59:05 +02:00
< ? php
class Activated_gridmap_model extends CI_Model {
2024-05-05 23:10:02 +02:00
function get_band_confirmed ( $band , $mode , $qsl , $lotw , $eqsl , $qrz , $sat , $orbit , $propagation ) {
2024-10-12 06:05:36 +00:00
$bindings = [];
2024-05-05 23:10:02 +02:00
$this -> load -> model ( 'logbooks_model' );
$logbooks_locations_array = $this -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' ));
2023-09-11 16:59:05 +02:00
2024-04-08 15:03:32 +02:00
if ( ! $logbooks_locations_array ) {
return null ;
}
2023-09-11 16:59:05 +02:00
$location_list = " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ;
2024-04-08 15:03:32 +02:00
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN ' . $this -> config -> item ( 'table_name' ) . ' on ' . $this -> config -> item ( 'table_name' ) . '.station_id = station_profile.station_id '
. ' LEFT JOIN `satellite` on ' . $this -> config -> item ( 'table_name' ) . '.COL_SAT_NAME = satellite.name '
. 'WHERE station_profile.station_gridsquare != "" '
. 'AND station_profile.station_id in (' . $location_list . ')' ;
if ( $band != 'All' ) {
2024-10-12 06:05:36 +00:00
if ( $band == 'SAT' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $band ;
if ( $sat != 'All' && $sat != '' ) {
$sql .= " and col_sat_name = ? " ;
$bindings [] = $sat ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
$sql .= " and col_band = ? " ;
$bindings [] = $band ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
}
if ( $mode != 'All' ) {
$sql .= " and (col_mode = ? or col_submode = ?) " ;
$bindings [] = $mode ;
$bindings [] = $mode ;
}
$sql .= $this -> addOrbitToQuery ( $orbit , $bindings );
2023-09-11 16:59:05 +02:00
2024-04-08 15:03:32 +02:00
$sql .= $this -> addQslToQuery ( $qsl , $lotw , $eqsl , $qrz );
2024-10-12 06:05:36 +00:00
return $this -> db -> query ( $sql , $bindings );
2023-09-11 16:59:05 +02:00
}
2024-05-05 23:10:02 +02:00
function get_band ( $band , $mode , $qsl , $lotw , $eqsl , $qrz , $sat , $orbit , $propagation ) {
2024-10-12 06:05:36 +00:00
$bindings = [];
2024-05-05 23:10:02 +02:00
$this -> load -> model ( 'logbooks_model' );
$logbooks_locations_array = $this -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' ));
2024-04-08 15:03:32 +02:00
if ( ! $logbooks_locations_array ) {
return null ;
}
$location_list = " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ;
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN ' . $this -> config -> item ( 'table_name' ) . ' on ' . $this -> config -> item ( 'table_name' ) . '.station_id = station_profile.station_id '
. ' LEFT JOIN `satellite` on ' . $this -> config -> item ( 'table_name' ) . '.COL_SAT_NAME = satellite.name '
. 'WHERE station_profile.station_gridsquare != "" '
. 'AND station_profile.station_id in (' . $location_list . ')' ;
if ( $band != 'All' ) {
2024-10-12 06:05:36 +00:00
if ( $band == 'SAT' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $band ;
if ( $sat != 'All' && $sat != '' ) {
$sql .= " and col_sat_name = ? " ;
$bindings [] = $sat ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
$sql .= " and col_band = ? " ;
$bindings [] = $band ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
}
if ( $mode != 'All' ) {
$sql .= " and (col_mode = ? or col_submode = ?) " ;
$bindings [] = $mode ;
$bindings [] = $mode ;
}
$sql .= $this -> addOrbitToQuery ( $orbit , $bindings );
return $this -> db -> query ( $sql , $bindings );
2024-04-08 15:03:32 +02:00
}
2023-09-11 16:59:05 +02:00
2024-05-05 23:10:02 +02:00
function get_band_worked_vucc_squares ( $band , $mode , $qsl , $lotw , $eqsl , $qrz , $sat , $orbit , $propagation ) {
2024-10-12 06:05:36 +00:00
$bindings = [];
2024-05-05 23:10:02 +02:00
$this -> load -> model ( 'logbooks_model' );
$logbooks_locations_array = $this -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' ));
2023-09-11 16:59:05 +02:00
2024-04-08 15:03:32 +02:00
if ( ! $logbooks_locations_array ) {
return null ;
}
$location_list = " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ;
2023-09-11 16:59:05 +02:00
$sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM '
. $this -> config -> item ( 'table_name' )
2024-04-08 15:03:32 +02:00
. ' LEFT JOIN `satellite` on ' . $this -> config -> item ( 'table_name' ) . '.COL_SAT_NAME = satellite.name '
2023-09-11 16:59:05 +02:00
. ' WHERE station_id in ('
. $location_list . ') AND COL_VUCC_GRIDS != ""' ;
2024-04-08 15:03:32 +02:00
if ( $band != 'All' ) {
2024-10-12 06:05:36 +00:00
if ( $band == 'SAT' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $band ;
if ( $sat != 'All' && $sat != '' ) {
$sql .= " and col_sat_name = ? " ;
$bindings [] = $sat ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
$sql .= " and col_band = ? " ;
$bindings [] = $band ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
}
if ( $mode != 'All' ) {
$sql .= " and (col_mode = ? or col_submode = ?) " ;
$bindings [] = $mode ;
$bindings [] = $mode ;
}
$sql .= $this -> addOrbitToQuery ( $orbit , $bindings );
2023-09-11 16:59:05 +02:00
2024-04-08 15:03:32 +02:00
return null ;
2024-10-12 06:05:36 +00:00
return $this -> db -> query ( $sql , $bindings );
2024-04-08 15:03:32 +02:00
}
2023-09-11 16:59:05 +02:00
2024-05-05 23:10:02 +02:00
function get_band_confirmed_vucc_squares ( $band , $mode , $qsl , $lotw , $eqsl , $qrz , $sat , $orbit , $propagation ) {
2024-10-12 06:05:36 +00:00
$bindings = [];
2024-05-05 23:10:02 +02:00
$this -> load -> model ( 'logbooks_model' );
$logbooks_locations_array = $this -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' ));
2024-04-08 15:03:32 +02:00
if ( ! $logbooks_locations_array ) {
return null ;
}
2023-09-11 16:59:05 +02:00
$location_list = " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ;
$sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM '
. $this -> config -> item ( 'table_name' )
2024-04-08 15:03:32 +02:00
. ' LEFT JOIN `satellite` on ' . $this -> config -> item ( 'table_name' ) . '.COL_SAT_NAME = satellite.name '
2023-09-11 16:59:05 +02:00
. ' WHERE station_id in ('
. $location_list . ') AND COL_VUCC_GRIDS != ""' ;
2024-04-08 15:03:32 +02:00
2024-10-12 06:05:36 +00:00
2024-04-08 15:03:32 +02:00
if ( $band != 'All' ) {
2024-10-12 06:05:36 +00:00
if ( $band == 'SAT' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $band ;
if ( $sat != 'All' && $sat != '' ) {
$sql .= " and col_sat_name = ? " ;
$bindings [] = $sat ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
$sql .= " and col_band = ? " ;
$bindings [] = $band ;
}
} else {
if ( $propagation != '' ) {
$sql .= " and col_prop_mode = ? " ;
$bindings [] = $propagation ;
}
}
if ( $mode != 'All' ) {
$sql .= " and (col_mode = ? or col_submode = ?) " ;
$bindings [] = $mode ;
$bindings [] = $mode ;
}
$sql .= $this -> addOrbitToQuery ( $orbit , $bindings );
2023-09-11 16:59:05 +02:00
2023-12-08 12:51:10 +00:00
$sql .= $this -> addQslToQuery ( $qsl , $lotw , $eqsl , $qrz );
2023-09-11 16:59:05 +02:00
2024-04-08 15:03:32 +02:00
return null ;
2024-10-12 06:05:36 +00:00
return $this -> db -> query ( $sql , $bindings );
2023-09-11 16:59:05 +02:00
}
2023-12-08 12:51:10 +00:00
// Adds confirmation to query
2024-04-08 15:03:32 +02:00
function addQslToQuery ( $qsl , $lotw , $eqsl , $qrz ) {
$sql = '' ;
if ( $lotw == " true " ) {
$sql .= " or col_lotw_qsl_sent = 'Y' " ;
}
if ( $qsl == " true " ) {
$sql .= " or col_qsl_sent = 'Y' " ;
}
if ( $eqsl == " true " ) {
$sql .= " or col_eqsl_qsl_sent = 'Y' " ;
}
if ( $qrz == " true " ) {
$sql .= " or col_qrzcom_qso_upload_status = 'Y' " ;
}
if ( $sql != '' ) {
$sql = 'and (1=0 ' . $sql . ')' ;
}
return $sql ;
}
// Adds orbit type to query
2024-10-12 06:05:36 +00:00
function addOrbitToQuery ( $orbit , & $bindings ) {
2024-04-08 15:03:32 +02:00
$sql = '' ;
if ( $orbit != 'All' ) {
2024-10-12 06:05:36 +00:00
$sql .= ' AND satellite.orbit = ?' ;
$bindings [] = $orbit ;
2024-04-08 15:03:32 +02:00
}
return $sql ;
}
/*
* Get ' s the worked modes from the log
*/
2023-09-11 16:59:05 +02:00
function get_worked_modes () {
2024-05-05 23:10:02 +02:00
$this -> load -> model ( 'logbooks_model' );
$logbooks_locations_array = $this -> logbooks_model -> list_logbook_relationships ( $this -> session -> userdata ( 'active_station_logbook' ));
2024-04-08 15:03:32 +02:00
if ( ! $logbooks_locations_array ) {
return null ;
}
2023-09-11 16:59:05 +02:00
$location_list = " ' " . implode ( " ',' " , $logbooks_locations_array ) . " ' " ;
// get all worked modes from database
$data = $this -> db -> query (
" SELECT distinct LOWER(`COL_MODE`) as `COL_MODE` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id in ( " . $location_list . " ) order by COL_MODE ASC "
);
$results = array ();
foreach ( $data -> result () as $row ) {
array_push ( $results , $row -> COL_MODE );
}
$data = $this -> db -> query (
" SELECT distinct LOWER(`COL_SUBMODE`) as `COL_SUBMODE` FROM ` " . $this -> config -> item ( 'table_name' ) . " ` WHERE station_id in ( " . $location_list . " ) and coalesce(COL_SUBMODE, '') <> '' order by COL_SUBMODE ASC "
);
foreach ( $data -> result () as $row ) {
if ( ! in_array ( $row , $results )) {
array_push ( $results , $row -> COL_SUBMODE );
}
}
2024-04-08 15:03:32 +02:00
asort ( $results );
2023-09-11 16:59:05 +02:00
return $results ;
}
}