From 367654efab705132d4dbde751909cdfad6e5256e Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:54:35 +0200 Subject: [PATCH 1/2] [Exportmap] Added lastqso --- application/controllers/Visitor.php | 14 ++++++-- application/models/Visitor_model.php | 48 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 application/models/Visitor_model.php diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index a893cee51..c08e2b407 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -409,6 +409,16 @@ class Visitor extends CI_Controller { public function exportmap() { $slug = $this->security->xss_clean($this->uri->segment(3)); + $lastqso = $this->security->xss_clean($this->uri->segment(4)); + + if ($lastqso === "lastqso") { + $this->load->model('visitor_model'); + $result = $this->visitor_model->getlastqsodate($slug)->row(); + header('Content-Type: application/json'); + echo json_encode($result->lastqso); + return; + } + $data['slug'] = $slug; $data['page_title'] = "Export Map"; @@ -418,7 +428,7 @@ class Visitor extends CI_Controller { } public function mapqsos() { - $this->load->model('logbook_model'); + $this->load->model('visitor_model'); $this->load->library('qra'); @@ -441,7 +451,7 @@ class Visitor extends CI_Controller { show_404('Unknown Public Page.'); } - $qsos = $this->logbook_model->get_qsos($qsocount, null, $logbooks_locations_array, $band); + $qsos = $this->visitor_model->get_qsos($qsocount, $logbooks_locations_array, $band); $userid = $this->stationsetup_model->public_slug_exists_userid($slug); $user_default_confirmation = $this->get_user_default_confirmation($userid); diff --git a/application/models/Visitor_model.php b/application/models/Visitor_model.php new file mode 100644 index 000000000..6a833a327 --- /dev/null +++ b/application/models/Visitor_model.php @@ -0,0 +1,48 @@ +db->select($this->config->item('table_name').'.*, station_profile.*'); + $this->db->from($this->config->item('table_name')); + + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + + if ($band != '') { + if ($band == 'SAT') { + $this->db->where($this->config->item('table_name').'.col_prop_mode', 'SAT'); + } else { + $this->db->where($this->config->item('table_name').'.col_prop_mode !="SAT"'); + $this->db->where($this->config->item('table_name').'.col_band', $band); + } + } + + $this->db->where_in($this->config->item('table_name').'.station_id', $StationLocationsArray); + $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc"); + + $this->db->limit($num); + + return $this->db->get(); + } + + function getlastqsodate ($slug) { + $this->load->model('stationsetup_model'); + $logbook_id = $this->stationsetup_model->public_slug_exists_logbook_id($slug); + $userid = $this->stationsetup_model->public_slug_exists_userid($slug); + $band = $this->user_options_model->get_options('ExportMapOptions',array('option_name'=>'band','option_key'=>$slug), $userid)->row()->option_value ?? ''; + + $sql = "select max(col_time_on) lastqso from " . $this->config->item('table_name') . + " join station_profile on station_profile.station_id = " . $this->config->item('table_name') . ".station_id where 1 = 1"; + + if ($band != '') { + if ($band == 'SAT') { + $sql .= " and " . $this->config->item('table_name') . ".col_prop_mode = 'SAT'"; + } else { + $sql .= " and " . $this->config->item('table_name') . ".col_prop_mode != 'SAT'"; + $sql .= " and " . $this->config->item('table_name') . ".col_band = '". $band . "'"; + } + } + + return $this->db->query($sql); + } +} From 949290d93a22f41ee32bae0716f54ab5c2cb8866 Mon Sep 17 00:00:00 2001 From: "Joerg (DJ7NT)" Date: Sun, 14 Apr 2024 15:21:56 +0200 Subject: [PATCH 2/2] Return named-object instead of string --- application/controllers/Visitor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index c08e2b407..810f631c6 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -415,7 +415,7 @@ class Visitor extends CI_Controller { $this->load->model('visitor_model'); $result = $this->visitor_model->getlastqsodate($slug)->row(); header('Content-Type: application/json'); - echo json_encode($result->lastqso); + echo json_encode($result); return; }