diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
index 3182bb4e..71a19756 100755
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -70,7 +70,7 @@ class Logbook extends CI_Controller {
"workedBefore" => false
];
- $return['dxcc'] = $this->find_dxcc($callsign);
+ $return['dxcc'] = $this->dxcheck($callsign);
$return['partial'] = $this->partial($callsign);
// Do we have local data for the Callsign?
@@ -82,6 +82,11 @@ class Logbook extends CI_Controller {
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
$return['bearing'] = $this->bearing($return['callsign_qra']);
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
+
+ if ($return['callsign_qra'] != "") {
+ $return['latlng'] = $this->qralatlng($return['callsign_qra']);
+ }
+
echo json_encode($return, JSON_PRETTY_PRINT);
return;
}
@@ -118,6 +123,9 @@ class Logbook extends CI_Controller {
$return['callsign_qra'] = $callbook['gridsquare'];
$return['callsign_qth'] = $callbook['city'];
$return['callsign_iota'] = $callbook['iota'];
+ if ($return['callsign_qra'] != "") {
+ $return['latlng'] = $this->qralatlng($return['callsign_qra']);
+ }
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
}
$return['bearing'] = $this->bearing($return['callsign_qra']);
@@ -343,6 +351,15 @@ class Logbook extends CI_Controller {
print json_encode($ans);
}
+ function dxcheck($call = "", $date = "") {
+ $this->load->model("logbook_model");
+ if ($date == ''){
+ $date = date("Y-m-d");
+ }
+ $ans = $this->logbook_model->dxcc_lookup($call, $date);
+ return $ans;
+ }
+
/* return station bearing */
function searchbearing($locator) {
@@ -385,4 +402,16 @@ class Logbook extends CI_Controller {
}
return "";
}
+
+ function qralatlng($qra) {
+ $this->load->library('Qra');
+ $latlng = $this->qra->qra2latlong($qra);
+ return $latlng;
+ }
+
+ function qralatlngjson($qra) {
+ $this->load->library('Qra');
+ $latlng = $this->qra->qra2latlong($qra);
+ print json_encode($latlng);
+ }
}
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index 6f4517ec..115b92b4 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -1087,6 +1087,34 @@ class Logbook_model extends CI_Model {
return array("Not Found", "Not Found");
}
+ public function dxcc_lookup($call, $date){
+ $len = strlen($call);
+
+ // query the table, removing a character from the right until a match
+ for ($i = $len; $i > 0; $i--){
+ //printf("searching for %s\n", substr($call, 0, $i));
+ $dxcc_result = $this->db->select('*')
+ ->where('call', substr($call, 0, $i))
+ ->where('(start <= ', $date)
+ ->or_where("start = '0000-00-00'", NULL, false)
+ ->or_where("start is null)", NULL, false)
+ ->where('(end >= ', $date)
+ ->or_where("end = '0000-00-00'", NULL, false)
+ ->or_where("end is null)", NULL, false)
+ ->get('dxcc_prefixes');
+
+ //$dxcc_result = $this->db->query("select `call`, `entity`, `adif` from dxcc_prefixes where `call` = '".substr($call, 0, $i) ."'");
+ //print $this->db->last_query();
+
+ if ($dxcc_result->num_rows() > 0){
+ $row = $dxcc_result->row_array();
+ return $row;
+ }
+ }
+
+ return array("Not Found", "Not Found");
+ }
+
/*
* Same as check_dxcc_table, but the functionality is in
* a stored procedure which we call
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php
index 4203d49c..e2035943 100644
--- a/application/views/interface_assets/footer.php
+++ b/application/views/interface_assets/footer.php
@@ -110,12 +110,26 @@ $(document).ready(function(){
uri->segment(1) == "qso") { ?>
+
+
+
+