From 74c8851834318ceff7c634ca107ebcf587d694f4 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 2 Jul 2024 08:12:07 +0200 Subject: [PATCH] [Station setup] Shows if location belongs to active logbook --- application/controllers/Stationsetup.php | 8 ++++++++ application/models/Stations.php | 5 ++--- application/views/stationsetup/stationsetup.php | 4 +++- assets/js/sections/stationsetup.js | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/application/controllers/Stationsetup.php b/application/controllers/Stationsetup.php index 266500df4..40ef64be3 100644 --- a/application/controllers/Stationsetup.php +++ b/application/controllers/Stationsetup.php @@ -312,11 +312,19 @@ class Stationsetup extends CI_Controller { $single->station_copylog = $this->stationcopy2html($entry->station_id); $single->station_delete = $this->stationdelete2html($entry->station_id, $entry->station_profile_name, $entry->station_active); $single->station_favorite = $this->stationfavorite2html($entry->station_id, $quickswitch_enabled); + $single->station_linked = $this->stationlinked2html($entry->linked); array_push($hres,$single); } echo json_encode($hres); } + private function stationlinked2html($linked) { + if ($linked == 1) { + return ''; + } + return ''; + } + private function stationfavorite2html($id, $quickswitch_enabled) { if ($quickswitch_enabled == 'false') { return ''; diff --git a/application/models/Stations.php b/application/models/Stations.php index a5660110c..b276183ef 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -5,14 +5,13 @@ class Stations extends CI_Model { public function __construct() { } - function all_with_count() { - $this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end, count('.$this->config->item('table_name').'.station_id) as qso_total'); + $this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end, count('.$this->config->item('table_name').'.station_id) as qso_total, exists(select 1 from station_logbooks_relationship where station_location_id = station_profile.station_id and station_logbook_id = '.$this->session->userdata('active_station_logbook').') as linked'); $this->db->from('station_profile'); $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left'); $this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer'); - $this->db->group_by('station_profile.station_id'); + $this->db->group_by('station_profile.station_id'); $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); $this->db->or_where('station_profile.user_id =', NULL); return $this->db->get(); diff --git a/application/views/stationsetup/stationsetup.php b/application/views/stationsetup/stationsetup.php index 4d0b51b77..d470c6e96 100644 --- a/application/views/stationsetup/stationsetup.php +++ b/application/views/stationsetup/stationsetup.php @@ -121,6 +121,7 @@