added station profile check to bearing as well (used on change of

callsign, not on change of grid locator)
这个提交包含在:
Thomas Werzmirzowsky 2021-12-31 17:49:44 +01:00
父节点 451fd1e943
当前提交 ea1cf0141a
共有 2 个文件被更改,包括 85 次插入82 次删除

查看文件

@ -73,7 +73,7 @@ class Logbook extends CI_Controller {
echo json_encode($return, JSON_PRETTY_PRINT); echo json_encode($return, JSON_PRETTY_PRINT);
} }
function json($callsign, $type, $band, $mode) function json($callsign, $type, $band, $mode, $station_id = null)
{ {
$this->load->model('user_model'); $this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
@ -104,8 +104,6 @@ class Logbook extends CI_Controller {
$lotw_member = "not found"; $lotw_member = "not found";
} }
// Check Database for all other data // Check Database for all other data
$this->load->model('logbook_model'); $this->load->model('logbook_model');
@ -131,8 +129,7 @@ class Logbook extends CI_Controller {
{ {
if ($this->session->userdata('user_measurement_base') == NULL) { if ($this->session->userdata('user_measurement_base') == NULL) {
$measurement_base = $this->config->item('measurement_base'); $measurement_base = $this->config->item('measurement_base');
} } else {
else {
$measurement_base = $this->session->userdata('user_measurement_base'); $measurement_base = $this->session->userdata('user_measurement_base');
} }
@ -142,7 +139,7 @@ class Logbook extends CI_Controller {
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign); $return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
$return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign); $return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign);
$return['callsign_state'] = $this->logbook_model->call_state($callsign); $return['callsign_state'] = $this->logbook_model->call_state($callsign);
$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base); $return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id);
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
if ($return['callsign_qra'] != "") { if ($return['callsign_qra'] != "") {
@ -153,10 +150,8 @@ class Logbook extends CI_Controller {
return; return;
} }
$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname'));
if (isset($callbook)) if (isset($callbook))
{ {
$return['callsign_name'] = $callbook['name']; $return['callsign_name'] = $callbook['name'];
@ -177,12 +172,11 @@ class Logbook extends CI_Controller {
if ($this->session->userdata('user_measurement_base') == NULL) { if ($this->session->userdata('user_measurement_base') == NULL) {
$measurement_base = $this->config->item('measurement_base'); $measurement_base = $this->config->item('measurement_base');
} } else {
else {
$measurement_base = $this->session->userdata('user_measurement_base'); $measurement_base = $this->session->userdata('user_measurement_base');
} }
$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base); $return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id);
echo json_encode($return, JSON_PRETTY_PRINT); echo json_encode($return, JSON_PRETTY_PRINT);
@ -691,19 +685,28 @@ class Logbook extends CI_Controller {
} }
/* return station bearing */ /* return station bearing */
function bearing($locator, $unit = 'M') { function bearing($locator, $unit = 'M', $station_id = null) {
$this->load->library('Qra'); $this->load->library('Qra');
if($locator != null) { if($locator != null) {
if($this->session->userdata('user_locator') != null){ if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return "";
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator'); $mylocator = $this->session->userdata('user_locator');
} else { } else {
$mylocator = $this->config->item('locator'); $mylocator = $this->config->item('locator');
} }
$bearing = $this->qra->bearing($mylocator, $locator, $unit); $bearing = $this->qra->bearing($mylocator, $locator, $unit);
return $bearing; return $bearing;

查看文件

@ -296,7 +296,7 @@ $("#callsign").focusout(function() {
find_callsign.replace(/\//g, "-"); find_callsign.replace(/\//g, "-");
// Replace / in a callsign with - to stop urls breaking // Replace / in a callsign with - to stop urls breaking
$.getJSON('logbook/json/' + find_callsign.replace(/\//g, "-") + '/' + sat_type + '/' + json_band + '/' + json_mode, function(result) $.getJSON('logbook/json/' + find_callsign.replace(/\//g, "-") + '/' + sat_type + '/' + json_band + '/' + json_mode + '/' + $('#stationProfile').val(), function(result)
{ {
// Make sure the typed callsign and temp callsign match // Make sure the typed callsign and temp callsign match
if($('#callsign').val = temp_callsign){ if($('#callsign').val = temp_callsign){