From 873a0391e99262a6ea13a1cc9d9ced93fe2d557a Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:34:23 +0100 Subject: [PATCH] Fixed table info when linking locations to container --- application/controllers/Stationsetup.php | 1 + application/models/Stationsetup_model.php | 9 +++++++++ assets/js/sections/stationsetup.js | 7 ++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/application/controllers/Stationsetup.php b/application/controllers/Stationsetup.php index 43d63321c..8a67709fe 100644 --- a/application/controllers/Stationsetup.php +++ b/application/controllers/Stationsetup.php @@ -415,6 +415,7 @@ class Stationsetup extends CI_Controller { // If no link exists, create $this->stationsetup_model->create_logbook_location_link($containerid, $locationid); $data['success']=1; + $data['locationdata'] = $this->stationsetup_model->locationInfo($locationid)->result(); } else { $data['success']=0; $data['flashdata']='Error'; diff --git a/application/models/Stationsetup_model.php b/application/models/Stationsetup_model.php index 2bd6955a0..0ea88d908 100644 --- a/application/models/Stationsetup_model.php +++ b/application/models/Stationsetup_model.php @@ -147,6 +147,15 @@ class Stationsetup_model extends CI_Model { return true; } } + + function locationInfo($id) { + $userid = $this->session->userdata('user_id'); // Fallback to session-uid, if userid is omitted + $this->db->select('station_profile.station_profile_name, station_profile.station_callsign, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end'); + $this->db->where('user_id', $userid); + $this->db->where('station_id', $id); + $this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer'); + return $this->db->get('station_profile'); + } } ?> diff --git a/assets/js/sections/stationsetup.js b/assets/js/sections/stationsetup.js index b6c646f98..e626e95cd 100644 --- a/assets/js/sections/stationsetup.js +++ b/assets/js/sections/stationsetup.js @@ -530,12 +530,13 @@ function linkLocations() { success: function(data) { jdata=JSON.parse(data); if (jdata.success == 1) { + console.log(jdata); $("#StationLocationSelect").find('[value="'+ locationid +'"]').remove(); // add to table $('#station_logbooks_linked_table').append($('') - .append($('').append(locationarray[0])) - .append($('').append(locationarray[2])) - .append($('').append(locationarray[4].slice(0, -1))) + .append($('').append(jdata.locationdata[0].station_profile_name)) + .append($('').append(jdata.locationdata[0].station_callsign)) + .append($('').append(jdata.locationdata[0].station_country+(jdata.locationdata[0].dxcc_end == null ? '' : ' Deleted DXCC'))) .append($('').append('')) ) } else {