Fixed table info when linking locations to container

This commit is contained in:
Andreas Kristiansen
2024-03-19 14:34:23 +01:00
parent 6d453b9055
commit 873a0391e9
3 changed files with 14 additions and 3 deletions

View File

@@ -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';

View File

@@ -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');
}
}
?>

View File

@@ -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($('<tr id="locationid_'+locationid+'">')
.append($('<td style="text-align: center; vertical-align: middle;">').append(locationarray[0]))
.append($('<td style="text-align: center; vertical-align: middle;">').append(locationarray[2]))
.append($('<td style="text-align: center; vertical-align: middle;">').append(locationarray[4].slice(0, -1)))
.append($('<td style="text-align: center; vertical-align: middle;">').append(jdata.locationdata[0].station_profile_name))
.append($('<td style="text-align: center; vertical-align: middle;">').append(jdata.locationdata[0].station_callsign))
.append($('<td style="text-align: center; vertical-align: middle;">').append(jdata.locationdata[0].station_country+(jdata.locationdata[0].dxcc_end == null ? '' : ' <span class="badge bg-danger">Deleted DXCC</span>')))
.append($('<td style="text-align: center; vertical-align: middle;">').append('<button class="btn btn-sm btn-danger" onclick="unLinkLocations('+containerid+','+locationid+');"><i class="fas fa-unlink"></i></button>'))
)
} else {