diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 71a19756..fe46f901 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -58,6 +58,11 @@ class Logbook extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + $this->load->model('lotw_user'); + + $lotw_member = $this->lotw_user->check($callsign); + + $this->load->model('logbook_model'); $return = [ @@ -67,7 +72,8 @@ class Logbook extends CI_Controller { "callsign_qth" => "", "callsign_iota" => "", "bearing" => "", - "workedBefore" => false + "workedBefore" => false, + "lotw_member" => $lotw_member, ]; $return['dxcc'] = $this->dxcheck($callsign); @@ -91,6 +97,7 @@ class Logbook extends CI_Controller { return; } + if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { // Lookup using QRZ @@ -119,10 +126,12 @@ class Logbook extends CI_Controller { if (isset($callbook)) { + $return['callsign_name'] = $callbook['name']; $return['callsign_qra'] = $callbook['gridsquare']; $return['callsign_qth'] = $callbook['city']; $return['callsign_iota'] = $callbook['iota']; + $return['qsl_manager'] = $callbook['qslmgr']; if ($return['callsign_qra'] != "") { $return['latlng'] = $this->qralatlng($return['callsign_qra']); } @@ -131,6 +140,7 @@ class Logbook extends CI_Controller { $return['bearing'] = $this->bearing($return['callsign_qra']); echo json_encode($return, JSON_PRETTY_PRINT); + return; } diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 86b806b9..c85a65f2 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -301,6 +301,8 @@ class Lotw extends CI_Controller { set_time_limit(0); $this->load->model('lotw_user'); + $this->lotw_user->empty_table(); + $row = 1; if (($handle = fopen("https://lotw.arrl.org/lotw-user-activity.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { @@ -324,6 +326,9 @@ class Lotw extends CI_Controller { */ function lotw_usercheck($callsign) { $this->load->model('lotw_user'); + + + $lotw_user_result = $this->lotw_user->check($callsign); } diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 952253de..d301ffc3 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -79,6 +79,7 @@ class Qrz { $data['lat'] = (string) $xml->Callsign->lat; $data['long'] = (string) $xml->Callsign->lon; $data['iota'] = (string) $xml->Callsign->iota; + $data['qslmgr'] = (string) $xml->Callsign->qslmgr; return $data; } diff --git a/application/models/Lotw_user.php b/application/models/Lotw_user.php index 66be9158..33fae44c 100644 --- a/application/models/Lotw_user.php +++ b/application/models/Lotw_user.php @@ -9,8 +9,8 @@ class Lotw_user extends CI_Model { } - function empty_table($table) { - $this->db->empty_table($table); + function empty_table() { + $this->db->empty_table('lotw_userlist'); } function add_lotwuser($callsign, $date) { @@ -20,9 +20,18 @@ class Lotw_user extends CI_Model { 'upload_date' => $date ); - - $this->db->insert('lotw_userlist', $data); } + + function check($callsign) { + $this->db->where('callsign', $callsign); + $query = $this->db->get('lotw_userlist'); + + if ($query->num_rows() > 0) { + return "active"; + } else { + return "not found"; + } + } } ?> \ No newline at end of file diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index e2035943..f55aaa7d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -203,6 +203,7 @@ $(document).ready(function(){ $('#callsign_info').text(""); $('#locator_info').text(""); $('#country').val(""); + $('#lotw_info').text(""); $('#dxcc_id').val(""); $('#cqz').val(""); $('#name').val(""); @@ -223,9 +224,13 @@ $(document).ready(function(){ /* Find and populate DXCC */ $.getJSON('logbook/json/' + $(this).val(), function(result) { - //$('#country').val(result); + //$('#country').val(result); lotw_info $('#country').val(convert_case(result.dxcc.entity)); $('#callsign_info').text(convert_case(result.dxcc.entity)); + + if(result.lotw_member == "active") { + $('#lotw_info').text("LoTW"); + } $('#dxcc_id').val(result.dxcc.adif); $('#cqz').val(result.dxcc.cqz); @@ -243,6 +248,7 @@ $(document).ready(function(){ } markers.addLayer(marker).addTo(mymap); + /* Find Locator if the field is empty */ if($('#locator').val() == "") { @@ -272,6 +278,11 @@ $(document).ready(function(){ } /* Find Operators Name */ + if($('#qsl_via').val() == "") { + $('#qsl_via').val(result.qsl_manager); + } + + /* Find Operators Name */ if($('#name').val() == "") { $('#name').val(result.callsign_name); } diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 84b91a84..14513446 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -60,7 +60,7 @@