diff --git a/application/controllers/Activated_grids.php b/application/controllers/Activated_grids.php new file mode 100644 index 00000000..aab6ca04 --- /dev/null +++ b/application/controllers/Activated_grids.php @@ -0,0 +1,364 @@ +load->model('logbook_model'); + $total_sat = $this->logbook_model->total_sat(); + if ($total_sat->num_rows() == 0) { + redirect('activated_grids/band/2m'); + return; + } + + $data['page_title'] = "Activated Gridsquare Map"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('activated_grids/main.php'); + $this->load->view('interface_assets/footer'); + } + + public function satellites() + { + $this->load->model('activated_grids_model'); + + $data['page_title'] = "Satellite Activated Gridsquare Map"; + + + $array_grid_2char = array(); + $array_grid_4char = array(); + $array_grid_6char = array(); + + + $array_confirmed_grid_2char = array(); + $array_confirmed_grid_4char = array(); + $array_confirmed_grid_6char = array(); + + $grid_2char = ""; + $grid_4char = ""; + $grid_6char = ""; + + $grid_2char_confirmed = ""; + $grid_4char_confirmed = ""; + $grid_6char_confirmed = ""; + + + // Get Confirmed LOTW & Paper Activated Squares (non VUCC) + $query = $this->activated_grids_model->get_activated_confirmed_sat_squares(); + + + if ($query && $query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + + /* Handle VUCC squares */ + if (strpos($row->SAT_SQUARE, ",") > 0) { + $subsquares = explode(",", $row->SAT_SQUARE); + foreach ($subsquares as &$subsquare) { + $grid_two = strtoupper(substr($subsquare,0,2)); + $grid_four = strtoupper(substr($subsquare,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_six = strtoupper(substr($subsquare,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_two, $array_grid_2char)){ + array_push($array_grid_2char, $grid_two); + } + + + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_six, $array_grid_6char)){ + array_push($array_grid_6char, $grid_six); + } + } + } + + } else { + + $grid_2char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,2)); + $grid_4char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_6char_confirmed = strtoupper(substr($row->SAT_SQUARE,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_2char_confirmed, $array_confirmed_grid_2char)){ + array_push($array_confirmed_grid_2char, $grid_2char_confirmed); + } + + + if(!in_array($grid_4char_confirmed, $array_confirmed_grid_4char)){ + array_push($array_confirmed_grid_4char, $grid_4char_confirmed); + } + + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_6char_confirmed, $array_confirmed_grid_6char)){ + array_push($array_confirmed_grid_6char, $grid_6char_confirmed); + } + } + + } + + + } + } + + // Get activated squares + $query = $this->activated_grids_model->get_activated_sat_squares(); + + if ($query && $query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + + /* Handle VUCC squares */ + if (strpos($row->SAT_SQUARE, ",") > 0) { + $subsquares = explode(",", $row->SAT_SQUARE); + foreach ($subsquares as &$subsquare) { + $grid_two = strtoupper(substr($subsquare,0,2)); + $grid_four = strtoupper(substr($subsquare,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_six = strtoupper(substr($subsquare,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_two, $array_grid_2char)){ + array_push($array_grid_2char, $grid_two); + } + + + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_six, $array_grid_6char)){ + array_push($array_grid_6char, $grid_six); + } + } + } + + } else { + + $grid_two = strtoupper(substr($row->SAT_SQUARE,0,2)); + $grid_four = strtoupper(substr($row->SAT_SQUARE,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_six = strtoupper(substr($row->SAT_SQUARE,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_two, $array_grid_2char)){ + array_push($array_grid_2char, $grid_two); + } + + + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_six, $array_grid_6char)){ + array_push($array_grid_6char, $grid_six); + } + } + + } + + + } + } + + function js_str($s) + { + return '"' . addcslashes($s, "\0..\37\"\\") . '"'; + } + + function js_array($array) + { + $temp = array_map('js_str', $array); + return '[' . implode(',', $temp) . ']'; + } + + + $data['grid_2char_confirmed'] = js_array($array_confirmed_grid_2char); + $data['grid_4char_confirmed'] = js_array($array_confirmed_grid_4char); + $data['grid_6char_confirmed'] = js_array($array_confirmed_grid_6char); + + $data['grid_2char'] = js_array($array_grid_2char); + $data['grid_4char'] = js_array($array_grid_4char); + $data['grid_6char'] = js_array($array_grid_6char); + + + $this->load->view('interface_assets/header', $data); + $this->load->view('activated_grids/index.php'); + $this->load->view('interface_assets/footer'); + } + + + public function band($band) + { + $this->load->model('activated_grids_model'); + + $data['page_title'] = strtoupper($band)." Activated Gridsquare Map"; + + $array_grid_2char = array(); + $array_grid_4char = array(); + $array_grid_6char = array(); + + $array_grid_2char_confirmed = array(); + $array_grid_4char_confirmed = array(); + $array_grid_6char_confirmed = array(); + + $grid_2char = ""; + $grid_4char = ""; + $grid_6char = ""; + + $grid_2char_confirmed = ""; + $grid_4char_confirmed = ""; + $grid_6char_confirmed = ""; + + $query = $this->activated_grids_model->get_band_confirmed($band); + + if ($query && $query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + $grid_2char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,2)); + $grid_4char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_6char_confirmed = strtoupper(substr($row->GRID_SQUARES,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){ + array_push($array_grid_2char_confirmed, $grid_2char_confirmed); + } + + if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){ + array_push($array_grid_4char_confirmed, $grid_4char_confirmed); + } + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_6char_confirmed, $array_grid_6char_confirmed)){ + array_push($array_grid_6char_confirmed, $grid_6char_confirmed); + } + } + } + } + + $query = $this->activated_grids_model->get_band($band); + + if ($query && $query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + + $grid_two = strtoupper(substr($row->GRID_SQUARES,0,2)); + $grid_four = strtoupper(substr($row->GRID_SQUARES,0,4)); + if ($this->config->item('map_6digit_grids')) { + $grid_six = strtoupper(substr($row->GRID_SQUARES,0,6)); + } + + // Check if 2 Char is in array + if(!in_array($grid_two, $array_grid_2char)){ + array_push($array_grid_2char, $grid_two); + } + + + if(!in_array($grid_four, $array_grid_4char)){ + array_push($array_grid_4char, $grid_four); + } + + + if ($this->config->item('map_6digit_grids')) { + if(!in_array($grid_six, $array_grid_6char)){ + array_push($array_grid_6char, $grid_six); + } + } + + + } + } + + function js_str($s) + { + return '"' . addcslashes($s, "\0..\37\"\\") . '"'; + } + + function js_array($array) + { + $temp = array_map('js_str', $array); + return '[' . implode(',', $temp) . ']'; + } + + $data['grid_2char_confirmed'] = js_array($array_grid_2char_confirmed); + $data['grid_4char_confirmed'] = js_array($array_grid_4char_confirmed); + $data['grid_6char_confirmed'] = js_array($array_grid_6char_confirmed); + + $data['grid_2char'] = js_array($array_grid_2char); + $data['grid_4char'] = js_array($array_grid_4char); + $data['grid_6char'] = js_array($array_grid_6char); + + $data['bands_available'] = js_array($this->config->item('bands_available')); + + $this->load->view('interface_assets/header', $data); + $this->load->view('activated_grids/index.php'); + $this->load->view('interface_assets/footer'); + } + + function search_band($band, $gridsquare){ + $this->load->model('activated_grids_model'); + header('Content-Type: application/json'); + $result = $this->activated_grids_model->search_band($band, $gridsquare); + + echo $result; + } + + function search_sat($gridsquare){ + $this->load->model('activated_grids_model'); + header('Content-Type: application/json'); + $result = $this->activated_grids_model->search_sat($gridsquare); + + echo $result; + } + + public function qso_details_ajax(){ + $this->load->model('logbook_model'); + + $searchphrase = str_replace('"', "", $this->input->post("Searchphrase")); + $band = str_replace('"', "", $this->input->post("Band")); + $mode = str_replace('"', "", $this->input->post("Mode")); + + $data['results'] = $this->logbook_model->activated_grids_qso_details($searchphrase, $band, $mode); + + // Render Page + $data['page_title'] = "Log View"; + $data['filter'] = $searchphrase . " and band ".$band . " and mode ".$mode; + $this->load->view('awards/details', $data); + } + +} diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 5c7d0d82..b3b1200a 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -14,6 +14,10 @@ class Awards extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $this->lang->load(array( + 'lotw', + 'eqsl' + )); } public function index() diff --git a/application/models/Activated_grids_model.php b/application/models/Activated_grids_model.php new file mode 100644 index 00000000..c07969ca --- /dev/null +++ b/application/models/Activated_grids_model.php @@ -0,0 +1,142 @@ +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; + } + + $sql = 'SELECT DISTINCT station_gridsquare AS SAT_SQUARE, COL_SAT_NAME FROM ' + . 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id ' + . 'WHERE station_profile.station_gridsquare != "" AND '.$this->config->item('table_name').'.COL_SAT_NAME != ""'; + + return $this->db->query($sql); + } + + function get_activated_confirmed_sat_squares() { + $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)."'"; + + $sql = 'SELECT DISTINCT station_gridsquare AS SAT_SQUARE, COL_SAT_NAME FROM ' + . 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id ' + . 'WHERE station_profile.station_gridsquare != "" AND '.$this->config->item('table_name').'.COL_SAT_NAME != "" ' + . 'AND (COL_LOTW_QSL_SENT = "Y" OR COL_QSL_SENT = "Y");'; + + return $this->db->query($sql); + } + + function get_band($band) { + $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)."'"; + + $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 ' + . 'WHERE station_profile.station_gridsquare != "" '; + + if ($band != 'All') { + $sql .= 'AND COL_BAND = "'.$band.'" ' + . 'AND COL_PROP_MODE != "SAT" ' + . 'AND COL_PROP_MODE != "INTERNET" ' + . 'AND COL_PROP_MODE != "ECH" ' + . 'AND COL_PROP_MODE != "RPT" ' + . 'AND COL_SAT_NAME = "" '; + } + + return $this->db->query($sql); + } + + function get_band_confirmed($band) { + $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)."'"; + + $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 ' + . 'WHERE station_profile.station_gridsquare != "" '; + + if ($band != 'All') { + $sql .= 'AND COL_BAND = "'.$band.'" ' + . 'AND COL_PROP_MODE != "SAT" ' + . 'AND COL_PROP_MODE != "INTERNET" ' + . 'AND COL_PROP_MODE != "ECH" ' + . 'AND COL_PROP_MODE != "RPT" ' + . 'AND COL_SAT_NAME = "" '; + } + + $sql .= ' AND (COL_LOTW_QSL_SENT = "Y" OR COL_QSL_SENT = "Y")'; + + return $this->db->query($sql); + } + + function search_band($band, $gridsquare) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $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 IN (' . $location_list . ') ' + . ' AND (COL_MY_GRIDSQUARE 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" + AND COL_PROP_MODE != "RPT" + AND COL_SAT_NAME = ""'; + } + + $result = $this->db->query($sql); + + //print_r($result); + return json_encode($result->result()); + } + + function search_sat($gridsquare) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $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 IN ('.$location_list. ')' . + ' AND (COL_MY_GRIDSQUARE 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 bcb02717..cc5e68a9 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -286,7 +286,7 @@ class Logbook_model extends CI_Model { break; } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where_in('station_id', $logbooks_locations_array); if ($band != 'All') { if($band != "SAT") { @@ -305,6 +305,35 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } + public function activated_grids_qso_details($searchphrase, $band, $mode){ + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $sql = 'SELECT COL_SOTA_REF, COL_OPERATOR, COL_IOTA, COL_VUCC_GRIDS, COL_STATE, COL_GRIDSQUARE, COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_BAND, COL_SAT_NAME, COL_MODE, COL_SUBMODE, COL_RST_SENT, '; + $sql .= 'COL_RST_RCVD, COL_STX, COL_SRX, COL_STX_STRING, COL_SRX_STRING, COL_COUNTRY, COL_QSL_SENT, COL_QSL_SENT_VIA, '; + $sql .= 'COL_QSLSDATE, COL_QSL_RCVD, COL_QSL_RCVD_VIA, COL_QSLRDATE, COL_EQSL_QSL_SENT, COL_EQSL_QSLSDATE, COL_EQSL_QSLRDATE, '; + $sql .= 'COL_EQSL_QSL_RCVD, COL_LOTW_QSL_SENT, COL_LOTW_QSLSDATE, COL_LOTW_QSL_RCVD, COL_LOTW_QSLRDATE, COL_CONTEST_ID '; + $sql .= 'FROM '.$this->config->item('table_name').' WHERE station_id IN (SELECT station_id from station_profile '; + $sql .= 'WHERE station_gridsquare LIKE "%'.$searchphrase.'%") '; + + if ($band != 'All') { + if($band != "SAT") { + $sql .= 'AND COL_PROP_MODE != "SAT" AND '; + $sql .= 'COL_BAND = "'.$band.'" '; + } else { + $sql .= 'AND COL_PROP_MODE = "SAT"'; + } + } + + if ($mode != 'All') { + $sql .= ' AND COL_MODE = "'.$mode.'" OR COL_SUBMODE="'.$mode.'"'; + } + $sql .= ' ORDER BY COL_TIME_ON DESC LIMIT 500'; + + return $this->db->query($sql); + } + public function vucc_qso_details($gridsquare, $band) { $CI =& get_instance(); $CI->load->model('logbooks_model'); diff --git a/application/views/activated_grids/index.php b/application/views/activated_grids/index.php new file mode 100644 index 00000000..a48105ac --- /dev/null +++ b/application/views/activated_grids/index.php @@ -0,0 +1,69 @@ +
+ +
+ +

+ + uri->segment(1) == "activated_grids" && $this->uri->segment(2) == "band") { ?> +
+ + +
+ + + + session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ +
+ +
+ +
+ uri->segment(2) == "satellites") { ?> + + + + uri->segment(2) == "band") { ?> + + +
+ + diff --git a/application/views/activated_grids/main.php b/application/views/activated_grids/main.php new file mode 100644 index 00000000..bb753951 --- /dev/null +++ b/application/views/activated_grids/main.php @@ -0,0 +1,18 @@ +
+ +
+ + session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +

+ + +
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 7a7bfc33..edfbea37 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1321,6 +1321,121 @@ $(document).ready(function(){ +uri->segment(1) == "activated_grids") { ?> + + + + + + uri->segment(1) == "dayswithqso") { ?> diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 44a10bf2..4ffb44dc 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -86,6 +86,8 @@ Gridsquares + Activated Gridsquares + Distances Worked Days with QSOs