From f1f24ee169624becfd8428bac21473b2f8bc88e6 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 21 Mar 2025 14:49:06 +0100 Subject: [PATCH] Use last worked sat for preset of flightpath selected satellite --- application/controllers/Satellite.php | 4 ++-- application/models/Satellite_model.php | 16 ++++++++++++++++ application/views/satellite/flightpath.php | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index a586c9ee9..1e2257a08 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -192,6 +192,7 @@ class Satellite extends CI_Controller { $this->load->model('stations'); $pageData['satellites'] = $this->satellite_model->get_all_satellites_with_tle(); + $data['lastworkedsat'] = $this->satellite_model->get_last_worked_sat(); $footerData = []; $footerData['scripts'] = [ @@ -207,11 +208,10 @@ class Satellite extends CI_Controller { $this->load->library('Qra'); $pageData['latlng'] = $this->qra->qra2latlong($homegrid[0]); - $data['selsat']=strtoupper($sat ?? ''); // Render Page $pageData['page_title'] = "Satellite Flightpath"; $this->load->view('interface_assets/header', $pageData); - $this->load->view('satellite/flightpath',$data); + $this->load->view('satellite/flightpath', $data); $this->load->view('interface_assets/footer', $footerData); } diff --git a/application/models/Satellite_model.php b/application/models/Satellite_model.php index c86d5afca..bec8bafef 100644 --- a/application/models/Satellite_model.php +++ b/application/models/Satellite_model.php @@ -22,6 +22,22 @@ class Satellite_model extends CI_Model { return $this->db->query($sql)->result(); } + function get_last_worked_sat() { + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; + $sql = "select COL_SAT_NAME as sat from " . $this->config->item('table_name') . + " where station_id in (" . $location_list . ")" . + "order by COL_TIME_ON DESC LIMIT 1"; + + $query = $this->db->query($sql); + $row = $query->row(); + if (isset($row)) { + return ($row->sat); + } + return null; + } + function delete($id) { // Clean ID $clean_id = $this->security->xss_clean($id); diff --git a/application/views/satellite/flightpath.php b/application/views/satellite/flightpath.php index b6f35a326..fd36cc01c 100644 --- a/application/views/satellite/flightpath.php +++ b/application/views/satellite/flightpath.php @@ -40,13 +40,12 @@ -