diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
old mode 100644
new mode 100755
index e262000d..c3ce6eb6
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -1,5 +1,6 @@
load->model('user_model');
+ if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
+
+ $this->load->model('logbook_model');
+
+ $return = [
+ "dxcc" => false,
+ "callsign_name" => "",
+ "callsign_qra" => "",
+ "callsign_qth" => "",
+ "callsign_iota" => "",
+ "bearing" => ""
+ ];
+
+ $return['dxcc'] = $this->find_dxcc($callsign);
+ $return['partial'] = $this->partial($callsign);
+
+ // Do we have local data for the Callsign?
+ if($this->logbook_model->call_name($callsign) != null)
+ {
+ $return['callsign_name'] = $this->logbook_model->call_name($callsign);
+ $return['callsign_qra'] = $this->logbook_model->call_qra($callsign);
+ $return['callsign_qth'] = $this->logbook_model->call_qth($callsign);
+ $return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
+ $return['bearing'] = $this->bearing($return['callsign_qra']);
+ echo json_encode($return, JSON_PRETTY_PRINT);
+ return;
+ }
+
+ if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null)
+ {
+ // Lookup using QRZ
+ $this->load->library('qrz');
+
+ if(!$this->session->userdata('qrz_session_key')) {
+ $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
+ $this->session->set_userdata('qrz_session_key', $qrz_session_key);
+ }
+
+ $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
+ }
+
+ if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null)
+ {
+ // Load the HamQTH library
+ $this->load->library('hamqth');
+
+ if(!$this->session->userdata('hamqth_session_key')) {
+ $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
+ $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
+ }
+
+ $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
+ }
+
+ if (isset($callbook))
+ {
+ $return['callsign_name'] = $callbook['name'];
+ $return['callsign_qra'] = $callbook['gridsquare'];
+ $return['callsign_qth'] = $callbook['city'];
+ $return['callsign_iota'] = $callbook['iota'];
+ }
+ $return['bearing'] = $this->bearing($return['callsign_qra']);
+
+ echo json_encode($return, JSON_PRETTY_PRINT);
+ return;
+ }
+
/* Used to generate maps for displaying on /logbook/ */
function qso_map() {
$this->load->model('logbook_model');
@@ -113,142 +184,11 @@ class Logbook extends CI_Controller {
$this->load->view('view_log/qso', $data);
}
- function callsign_qra($qra) {
- $this->load->model('user_model');
- if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
-
- $this->load->model('logbook_model');
-
- if($this->logbook_model->call_qra($qra)) {
- echo $this->logbook_model->call_qra($qra);
- } else {
- if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
- // Lookup using QRZ
- $this->load->library('qrz');
-
- if(!$this->session->userdata('qrz_session_key')) {
- $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
- $this->session->set_userdata('qrz_session_key', $qrz_session_key);
- }
-
- $callbook = $this->qrz->search($qra, $this->session->userdata('qrz_session_key'));
- echo $callbook['gridsquare'];
-
- } elseif ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) {
- // Load the HamQTH library
- $this->load->library('hamqth');
-
- if(!$this->session->userdata('hamqth_session_key')) {
- $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
- $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
- }
-
- $callbook = $this->hamqth->search($qra, $this->session->userdata('hamqth_session_key'));
- echo $callbook['gridsquare'];
-
- }
- }
- }
-
- function callsign_qth($callsign) {
- if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
- // Lookup using QRZ
-
- $this->load->library('qrz');
-
- if(!$this->session->userdata('qrz_session_key')) {
- $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
- $this->session->set_userdata('qrz_session_key', $qrz_session_key);
- }
-
- $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
- echo $callbook['city'];
-
- } elseif ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) {
- // Load the HamQTH library
- $this->load->library('hamqth');
-
- if(!$this->session->userdata('hamqth_session_key')) {
- $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
- $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
- }
-
- $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
- echo $callbook['city'];
-
- }
- }
-
- function callsign_iota($callsign) {
- if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
- // Lookup using QRZ
-
- $this->load->library('qrz');
-
- if(!$this->session->userdata('qrz_session_key')) {
- $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
- $this->session->set_userdata('qrz_session_key', $qrz_session_key);
- }
-
- $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
- echo $callbook['iota'];
-
- } elseif ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) {
- // Load the HamQTH library
- $this->load->library('hamqth');
-
- if(!$this->session->userdata('hamqth_session_key')) {
- $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
- $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
- }
-
- $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
- echo $callbook['iota'];
-
- }
- }
-
- function callsign_name($callsign) {
- $this->load->model('user_model');
- if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
-
- $this->load->model('logbook_model');
-
- if($this->logbook_model->call_name($callsign) != null) {
- echo $this->logbook_model->call_name($callsign);
- } else {
- if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
- // Lookup using QRZ
-
- $this->load->library('qrz');
-
- if(!$this->session->userdata('qrz_session_key')) {
- $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
- $this->session->set_userdata('qrz_session_key', $qrz_session_key);
- }
-
- $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
- echo $callbook['name'];
- } elseif ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) {
- // Load the HamQTH library
- $this->load->library('hamqth');
-
- if(!$this->session->userdata('hamqth_session_key')) {
- $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
- $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
- }
-
- $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
- echo $callbook['name'];
-
- }
- }
- }
-
function partial($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
-
+
+ $html = "";
$this->db->like('COL_CALL', $id);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->limit(16);
@@ -256,32 +196,33 @@ class Logbook extends CI_Controller {
if ($query->num_rows() > 0)
{
- echo "
QSOs Matches with ".strtoupper($id)."
";
- echo "";
- echo "";
- echo "| Date | ";
- echo "Callsign | ";
- echo "RST Sent | ";
- echo "RST Recv | ";
- echo "Band | ";
- echo "Mode | ";
- echo "
";
+ $html .= "QSOs Matches with ".strtoupper($id)."
";
+ $html .= "";
+ $html .= "";
+ $html .= "| Date | ";
+ $html .= "Callsign | ";
+ $html .= "RST Sent | ";
+ $html .= "RST Recv | ";
+ $html .= "Band | ";
+ $html .= "Mode | ";
+ $html .= "
";
foreach ($query->result() as $row)
{
- echo "";
- echo "| ".$row->COL_TIME_ON." | ";
- echo "".$row->COL_CALL." | ";
- echo "".$row->COL_RST_SENT." | ";
- echo "".$row->COL_RST_RCVD." | ";
+ $html .= "
";
+ $html .= "| ".$row->COL_TIME_ON." | ";
+ $html .= "".$row->COL_CALL." | ";
+ $html .= "".$row->COL_RST_SENT." | ";
+ $html .= "".$row->COL_RST_RCVD." | ";
if($row->COL_SAT_NAME != null) {
- echo "".$row->COL_SAT_NAME." | ";
+ $html .= "".$row->COL_SAT_NAME." | ";
} else {
- echo "".$row->COL_BAND." | ";
+ $html .= "".$row->COL_BAND." | ";
}
- echo "".$row->COL_MODE." | ";
- echo "
";
+ $html .= "".$row->COL_MODE." | ";
+ $html .= "";
}
- echo "
";
+ $html .= "
";
+ return $html;
} else {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
@@ -293,16 +234,19 @@ class Logbook extends CI_Controller {
}
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'));
- } else {
+ }
+
+ // There's no hamli integration? Disabled for now.
+ /*else {
// Lookup using hamli
$this->load->library('hamli');
$data['callsign'] = $this->hamli->callsign($id);
- }
+ }*/
$data['id'] = strtoupper($id);
- $this->load->view('search/result', $data);
+ return $this->load->view('search/result', $data, true);
}
}
@@ -363,7 +307,7 @@ class Logbook extends CI_Controller {
$data = json_decode($json, TRUE);
// echo ucfirst(strtolower($data['Name']));
- echo $json;
+ return $data;
}
/*
@@ -380,19 +324,20 @@ class Logbook extends CI_Controller {
/* return station bearing */
- function bearing() {
+ function bearing($locator) {
$this->load->library('Qra');
- if($this->uri->segment(3) != null) {
+ if($locator != null) {
if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
- $bearing = $this->qra->bearing($mylocator, $this->uri->segment(3));
+ $bearing = $this->qra->bearing($mylocator, $locator);
- echo $bearing;
+ return $bearing;
}
+ return "";
}
}
diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php
old mode 100644
new mode 100755
diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php
old mode 100644
new mode 100755
diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php
old mode 100644
new mode 100755
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
old mode 100644
new mode 100755
index e9ac3432..06b46861
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -285,46 +285,85 @@ class Logbook_model extends CI_Model {
/* Callsign QRA */
- function call_qra($callsign) {
- $this->db->select('COL_CALL, COL_GRIDSQUARE, COL_TIME_ON');
- $this->db->where('COL_CALL', $callsign);
- $where = "COL_GRIDSQUARE != \"\"";
+ function call_qra($callsign) {
+ $this->db->select('COL_CALL, COL_GRIDSQUARE, COL_TIME_ON');
+ $this->db->where('COL_CALL', $callsign);
+ $where = "COL_GRIDSQUARE != \"\"";
- $this->db->where($where);
+ $this->db->where($where);
- $this->db->order_by("COL_TIME_ON", "desc");
- $this->db->limit(1);
- $query = $this->db->get($this->config->item('table_name'));
- $callsign = "";
- if ($query->num_rows() > 0)
- {
- $data = $query->row();
- $callsign = strtoupper($data->COL_GRIDSQUARE);
- }
+ $this->db->order_by("COL_TIME_ON", "desc");
+ $this->db->limit(1);
+ $query = $this->db->get($this->config->item('table_name'));
+ $callsign = "";
+ if ($query->num_rows() > 0)
+ {
+ $data = $query->row();
+ $callsign = strtoupper($data->COL_GRIDSQUARE);
+ }
- return $callsign;
- }
+ return $callsign;
+ }
- function call_name($callsign) {
- $this->db->select('COL_CALL, COL_NAME, COL_TIME_ON');
- $this->db->where('COL_CALL', $callsign);
- $where = "COL_NAME != \"\"";
+ function call_name($callsign) {
+ $this->db->select('COL_CALL, COL_NAME, COL_TIME_ON');
+ $this->db->where('COL_CALL', $callsign);
+ $where = "COL_NAME != \"\"";
- $this->db->where($where);
+ $this->db->where($where);
- $this->db->order_by("COL_TIME_ON", "desc");
- $this->db->limit(1);
- $query = $this->db->get($this->config->item('table_name'));
- $name = "";
- if ($query->num_rows() > 0)
- {
- $data = $query->row();
- $name = $data->COL_NAME;
- }
+ $this->db->order_by("COL_TIME_ON", "desc");
+ $this->db->limit(1);
+ $query = $this->db->get($this->config->item('table_name'));
+ $name = "";
+ if ($query->num_rows() > 0)
+ {
+ $data = $query->row();
+ $name = $data->COL_NAME;
+ }
- return $name;
- }
+ return $name;
+ }
+ function call_qth($callsign) {
+ $this->db->select('COL_CALL, COL_QTH, COL_TIME_ON');
+ $this->db->where('COL_CALL', $callsign);
+ $where = "COL_QTH != \"\"";
+
+ $this->db->where($where);
+
+ $this->db->order_by("COL_TIME_ON", "desc");
+ $this->db->limit(1);
+ $query = $this->db->get($this->config->item('table_name'));
+ $name = "";
+ if ($query->num_rows() > 0)
+ {
+ $data = $query->row();
+ $name = $data->COL_QTH;
+ }
+
+ return $name;
+ }
+
+ function call_iota($callsign) {
+ $this->db->select('COL_CALL, COL_IOTA, COL_TIME_ON');
+ $this->db->where('COL_CALL', $callsign);
+ $where = "COL_IOTA != \"\"";
+
+ $this->db->where($where);
+
+ $this->db->order_by("COL_TIME_ON", "desc");
+ $this->db->limit(1);
+ $query = $this->db->get($this->config->item('table_name'));
+ $name = "";
+ if ($query->num_rows() > 0)
+ {
+ $data = $query->row();
+ $name = $data->COL_IOTA;
+ }
+
+ return $name;
+ }
/* Return QSO Info */
function qso_info($id) {
$this->db->where('COL_PRIMARY_KEY', $id);
diff --git a/application/views/qso/index.php b/application/views/qso/index.php
old mode 100644
new mode 100755
index c06e000a..18277fc8
--- a/application/views/qso/index.php
+++ b/application/views/qso/index.php
@@ -321,7 +321,7 @@
}
i=0;
- typeDelay=1000;
+ typeDelay=500;
$(document).ready(function(){
@@ -453,46 +453,35 @@
$("#callsign").keyup(delay(function(){
if ($(this).val()) {
/* Find and populate DXCC */
- $.get('logbook/find_dxcc/' + $(this).val(), function(result) {
+ $.getJSON('logbook/json/' + $(this).val(), function(result)
+ {
//$('#country').val(result);
- obj = JSON.parse(result);
- $('#country').val(convert_case(obj.Name));
- $('#dxcc_id').val(obj.DXCC);
- $('#cqz').val(obj.CQZ);
+ $('#country').val(convert_case(result.dxcc.Name));
+ $('#dxcc_id').val(result.dxcc.DXCC);
+ $('#cqz').val(result.dxcc.CQZ);
- });
-
/* Find Locator if the field is empty */
if($('#locator').val() == "") {
- $.get('logbook/callsign_qra/' + $(this).val(), function(result) {
- $('#locator').val(result);
- $('#locator_info').load("logbook/bearing/" + result).fadeIn("slow");
- });
-
+ $('#locator').val(result.callsign_qra);
+ $('#locator_info').html(result.bearing);
}
-
+
/* Find Operators Name */
if($('#name').val() == "") {
- $.get('logbook/callsign_name/' + $(this).val(), function(result) {
- $('#name').val(result);
- });
+ $('#name').val(result.callsign_name);
}
if($('#qth').val() == "") {
- $.get('logbook/callsign_qth/' + $(this).val(), function(result) {
- $('#qth').val(result);
- });
- }
-
- if($('#qth').val() == "") {
- $.get('logbook/callsign_iota/' + $(this).val(), function(result) {
- $('#iota_ref').val(result);
- });
+ $('#qth').val(result.callsign_qth);
}
- /* Find Callsign Matches */
- $('#partial_view').load("logbook/partial/" + $(this).val()).fadeIn("slow");
-
+ if($('#qth').val() == "") {
+ $('#iota_ref').val(result.callsign_iota);
+ }
+
+ /* display past QSOs */
+ $('#partial_view').html(result.partial);
+ });
} else {
/* Reset fields ... */
$('#country').val("");
@@ -502,7 +491,7 @@
$('#qth').val("");
$('#locator').val("");
$('#iota_ref').val("");
- $('#partial_view').load("logbook/partial/");
+
}
}, typeDelay));
diff --git a/sql/tables/cat.sql b/sql/tables/cat.sql
old mode 100644
new mode 100755