diff --git a/application/controllers/Activators.php b/application/controllers/Activators.php index 6c66d5420..13852f0af 100644 --- a/application/controllers/Activators.php +++ b/application/controllers/Activators.php @@ -1,75 +1,62 @@ load->model('user_model'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + if (!$this->user_model->authorize(2)) { + $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); + redirect('dashboard'); + } } public function index() { - // Render Page $data['page_title'] = "Gridsquare Activators"; $this->load->model('Activators_model'); if ($this->input->post('band') != NULL) { // Band is not set when page first loads. $band = $this->input->post('band'); - } - else { + } else { $band = 'All'; } + if ($this->input->post('mincount') != NULL) { // mincount is not set when page first loads. + $mincount = $this->input->post('mincount'); + } else { + $mincount = 2; + } + + if ($this->input->post('leogeo') != NULL) { // orbit is not set when page first loads. + $orbit = $this->input->post('leogeo'); + } else { + $orbit = 'both'; + } + $this->load->model('bands'); $data['worked_bands'] = $this->bands->get_worked_bands(); + $data['mincount'] = $mincount; $data['maxactivatedgrids'] = $this->Activators_model->get_max_activated_grids(); - $data['activators_array'] = $this->Activators_model->get_activators($band, $this->input->post('mincount'), $this->input->post('leogeo')); - $data['activators_vucc_array'] = $this->Activators_model->get_activators_vucc($band, $this->input->post('leogeo')); + $data['orbit'] = $orbit; + $data['activators_array'] = $this->Activators_model->get_activators($band, $mincount, $orbit); + $data['activators_vucc_array'] = $this->Activators_model->get_activators_vucc($band, $orbit); $data['bandselect'] = $band; + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/sections/activators.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/activators.js")), + ]; + $this->load->view('interface_assets/header', $data); $this->load->view('activators/index'); - $this->load->view('interface_assets/footer'); - } - - public function details() { - $this->load->model('logbook_model'); - - $call = str_replace('"', "", $this->input->post("Callsign")); - $band = str_replace('"', "", $this->input->post("Band")); - $leogeo = str_replace('"', "", $this->input->post("LeoGeo")); - $data['results'] = $this->logbook_model->activator_details($call, $band, $leogeo); - $data['filter'] = "Call ".$call; - switch($band) { - case 'All': $data['page_title'] = "Log View All Bands"; - $data['filter'] .= " and Band All"; - break; - case 'SAT': $data['page_title'] = "Log View SAT"; - $data['filter'] .= " and Band SAT"; - break; - default: $data['page_title'] = "Log View Band"; - $data['filter'] .= " and Band ".$band; - break; - } - if ($band == "SAT") { - switch($leogeo) { - case 'both': $data['filter'] .= " and GEO/LEO"; - break; - case 'leo': $data['filter'] .= " and LEO"; - break; - case 'geo': $data['filter'] .= " and GEO"; - break; - } - } - - - $this->load->view('activators/details', $data); + $this->load->view('interface_assets/footer', $footerData); } } diff --git a/application/models/Activators_model.php b/application/models/Activators_model.php index a3585715d..b863021d4 100644 --- a/application/models/Activators_model.php +++ b/application/models/Activators_model.php @@ -3,115 +3,121 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Activators_model extends CI_Model { - function get_activators($band, $mincount, $leogeo) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + function get_activators($band, $mincount, $leogeo) + { + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if ($mincount == '' || $mincount == 0 || ! is_numeric($mincount)) { + if ($mincount == '' || $mincount == 0 || !is_numeric($mincount)) { $mincount = 2; } - if (!$logbooks_locations_array) { - return null; - } + if (!$logbooks_locations_array) { + return null; + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; - $sql = "select COL_CALL as `call`, COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count`, GROUP_CONCAT(DISTINCT SUBSTR(`COL_GRIDSQUARE`,1,4) ORDER BY `COL_GRIDSQUARE` SEPARATOR ', ') AS `grids` from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; - if ($band != 'All') { - if ($band == 'SAT') { - switch ($leogeo) { - case 'both' : + $sql = "SELECT COL_CALL as `call`, + COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count`, + GROUP_CONCAT(DISTINCT SUBSTR(`COL_GRIDSQUARE`,1,4) ORDER BY `COL_GRIDSQUARE` SEPARATOR ', ') AS `grids` + FROM " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ")"; + + if ($band != 'All') { + if ($band == 'SAT') { + switch ($leogeo) { + case 'both': $sql .= " and col_prop_mode ='" . $band . "'"; break; - case 'leo' : + case 'leo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name != 'QO-100'"; break; - case 'geo' : + case 'geo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name = 'QO-100'"; break; - default : + default: $sql .= " and col_prop_mode ='" . $band . "'"; break; - } } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and COL_BAND ='" . $band . "'"; - } - } - $sql .= " AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` HAVING `count` >= ".$mincount." ORDER BY `count` DESC;"; + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and COL_BAND ='" . $band . "'"; + } + } + $sql .= " AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` HAVING `count` >= " . $mincount . " ORDER BY `count` DESC;"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - return $query->result(); - } + return $query->result(); + } - function get_activators_vucc($band, $leogeo) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + function get_activators_vucc($band, $leogeo) + { + $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; - } + if (!$logbooks_locations_array) { + return null; + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; - $sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(COL_VUCC_GRIDS) AS `vucc_grids` FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; - if ($band != 'All') { - if ($band == 'SAT') { - switch ($leogeo) { - case 'both' : + $sql = "SELECT DISTINCT COL_CALL AS `call`, + GROUP_CONCAT(COL_VUCC_GRIDS) AS `vucc_grids` FROM " . $this->config->item('table_name') . + " WHERE station_id in (" . $location_list . ")"; + + if ($band != 'All') { + if ($band == 'SAT') { + switch ($leogeo) { + case 'both': $sql .= " and col_prop_mode ='" . $band . "'"; break; - case 'leo' : + case 'leo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name != 'QO-100'"; break; - case 'geo' : + case 'geo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name = 'QO-100'"; break; - default : + default: $sql .= " and col_prop_mode ='" . $band . "'"; break; - } } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and COL_BAND ='" . $band . "'"; - } - } + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and COL_BAND ='" . $band . "'"; + } + } $sql .= " AND COL_VUCC_GRIDS != '' GROUP BY COL_CALL;"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - return $query->result(); - } - function get_max_activated_grids() { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + return $query->result(); + } + function get_max_activated_grids() + { + $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 array(); - } + if (!$logbooks_locations_array) { + return array(); + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; - // Get max no of activated grids of single operator - $data = $this->db->query( - "select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" - ); - foreach($data->result() as $row){ - $max = $row->count; - } - - return ($max ?? 0); - } + // Get max no of activated grids of single operator + $data = $this->db->query( + "SELECT COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from " . $this->config->item('table_name') . + " WHERE station_id in (" . $location_list . ") AND + `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" + ); + foreach ($data->result() as $row) { + $max = $row->count; + } + return ($max ?? 0); + } } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index bffe90cb9..55a74f3ad 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -400,6 +400,9 @@ class Logbook_model extends CI_Model { $this->db->join('satellite', 'satellite.name = '.$this->config->item('table_name').'.col_sat_name', 'left outer'); } switch ($type) { + case 'CALL': + $this->db->where('COL_CALL', $searchphrase); + break; case 'DXCC': $this->db->where('COL_COUNTRY', $searchphrase); if ($band == 'SAT' && $type == 'DXCC') { diff --git a/application/views/activators/details.php b/application/views/activators/details.php deleted file mode 100644 index 52b59c929..000000000 --- a/application/views/activators/details.php +++ /dev/null @@ -1,4 +0,0 @@ -