From dc94d47106464207a84271c8c721938639525c9d Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 24 May 2024 20:49:18 +0200 Subject: [PATCH] formatted code --- application/controllers/Activators.php | 59 ++++++---- application/models/Activators_model.php | 140 +++++++++++------------ application/views/activators/index.php | 146 ++++++++++++------------ 3 files changed, 177 insertions(+), 168 deletions(-) diff --git a/application/controllers/Activators.php b/application/controllers/Activators.php index 6c66d5420..73d01fe96 100644 --- a/application/controllers/Activators.php +++ b/application/controllers/Activators.php @@ -1,14 +1,18 @@ 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() @@ -20,8 +24,7 @@ class Activators extends CI_Controller { if ($this->input->post('band') != NULL) { // Band is not set when page first loads. $band = $this->input->post('band'); - } - else { + } else { $band = 'All'; } @@ -38,38 +41,44 @@ class Activators extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function details() { + 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; + $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; + 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); } - } diff --git a/application/models/Activators_model.php b/application/models/Activators_model.php index a3585715d..d2e81d961 100644 --- a/application/models/Activators_model.php +++ b/application/models/Activators_model.php @@ -3,115 +3,115 @@ 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) + { + $CI = &get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->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) + { + $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; - } + 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() + { + $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 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/views/activators/index.php b/application/views/activators/index.php index bcc6041b2..8ecedd01a 100644 --- a/application/views/activators/index.php +++ b/application/views/activators/index.php @@ -3,59 +3,59 @@
-
- -
- -
-
-
- -
- -
-
-
- -
- -
- -
- -
- -
- -
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+
- session->userdata('user_date_format')) { + if ($this->session->userdata('user_date_format')) { // If Logged in and session exists $custom_date_format = $this->session->userdata('user_date_format'); } else { @@ -63,19 +63,18 @@ $custom_date_format = $this->config->item('qso_date_format'); } ?> - call] = $line->vucc_grids; - } + foreach ($activators_vucc_array as $line) { + $vucc_grids[$line->call] = $line->vucc_grids; + } } - if( $this->input->post('band') != NULL) { + if ($this->input->post('band') != NULL) { if ($activators_array) { $result = write_activators($activators_array, $vucc_grids, $custom_date_format, $this->input->post('band'), $this->input->post('leogeo')); - } - else { + } else { echo ''; } } @@ -86,12 +85,13 @@ @@ -113,16 +113,16 @@ function write_activators($activators_array, $vucc_grids, $custom_date_format, $ $grids = $line->grids; $count = $line->count; if (array_key_exists($line->call, $vucc_grids)) { - foreach(explode(',', $vucc_grids[$line->call]) as $vgrid) { - if(!strpos($grids, $vgrid)) { - $grids .= ','.$vgrid; - } - } - $grids = str_replace(' ', '', $grids); - $grid_array = explode(',', $grids); - sort($grid_array); - $count = count($grid_array); - $grids = implode(', ', $grid_array); + foreach (explode(',', $vucc_grids[$line->call]) as $vgrid) { + if (!strpos($grids, $vgrid)) { + $grids .= ',' . $vgrid; + } + } + $grids = str_replace(' ', '', $grids); + $grid_array = explode(',', $grids); + sort($grid_array); + $count = count($grid_array); + $grids = implode(', ', $grid_array); } array_push($activators, array($count, $call, $grids)); } @@ -130,11 +130,11 @@ function write_activators($activators_array, $vucc_grids, $custom_date_format, $ foreach ($activators as $line) { echo ' ' . $i++ . ' - '.$line[1].' - '.$line[0].' - '.$line[2].' - - + ' . $line[1] . ' + ' . $line[0] . ' + ' . $line[2] . ' + + '; } echo '
';