Grid worked before now checks based on type SAT or band/mode

pull/425/head
Peter Goodhall 2019-08-16 12:25:31 +01:00
rodzic 06297e76e5
commit 0739790943
2 zmienionych plików z 26 dodań i 15 usunięć

Wyświetl plik

@ -53,7 +53,7 @@ class Logbook extends CI_Controller {
}
function json($callsign)
function json($callsign, $type, $band, $mode)
{
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
@ -89,7 +89,7 @@ class Logbook extends CI_Controller {
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
$return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign);
$return['bearing'] = $this->bearing($return['callsign_qra'], $this->config->item('measurement_base'));
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
if ($return['callsign_qra'] != "") {
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
@ -138,7 +138,7 @@ class Logbook extends CI_Controller {
if ($return['callsign_qra'] != "") {
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
}
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
}
$return['bearing'] = $this->bearing($return['callsign_qra'], $this->config->item('measurement_base'));
@ -147,11 +147,21 @@ class Logbook extends CI_Controller {
return;
}
function worked_grid_before($gridsquare)
function worked_grid_before($gridsquare, $type, $band, $mode)
{
if (strlen($gridsquare) < 4)
return false;
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');
}
$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
@ -374,17 +384,7 @@ class Logbook extends CI_Controller {
}
}
// Find DXCC
function find_dxcc($callsign) {
// Live lookup against Clublogs API
$url = "https://secure.clublog.org/dxcc?call=".$callsign."&api=a11c3235cd74b88212ce726857056939d52372bd&full=1";
$json = file_get_contents($url);
$data = json_decode($json, TRUE);
// echo ucfirst(strtolower($data['Name']));
return $data;
}
/*
* Provide a dxcc search, returning results json encoded

Wyświetl plik

@ -259,7 +259,18 @@ $(document).ready(function(){
/* Find and populate DXCC */
$('.callsign-suggest').hide();
$.getJSON('logbook/json/' + $(this).val().toUpperCase(), function(result)
if($("#sat_name").val() != ""){
var sat_type = "SAT";
var json_band = "0";
var json_mode = "0";
} else {
var sat_type = "0";
var json_band = $("#band").val();
var json_mode = $("#mode").val();
}
$.getJSON('logbook/json/' + $(this).val().toUpperCase() + '/' + sat_type + '/' + json_band + '/' + json_mode, function(result)
{
//$('#country').val(result); lotw_info
if(result.dxcc.entity != undefined) {