diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 2aa640f0..527c05b7 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -53,6 +53,14 @@ class Logbook extends CI_Controller { } + function jsonentity($adif) { + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } + + $return['dxcc'] = $this->getentity($adif); + echo json_encode($return, JSON_PRETTY_PRINT); + } + function json($callsign, $type, $band, $mode) { $this->load->model('user_model'); @@ -547,6 +555,13 @@ class Logbook extends CI_Controller { return $ans; } + function getentity($adif) { + $this->load->model("logbook_model"); + + $entity = $this->logbook_model->get_entity($adif); + return $entity; + } + /* return station bearing */ function searchbearing($locator) { diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index a4773623..d2e70c6d 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -23,6 +23,7 @@ class QSO extends CI_Controller { $data['stations'] = $this->stations->all(); $data['radios'] = $this->cat->radios(); $data['query'] = $this->logbook_model->last_custom('5'); + $data['dxcc'] = $this->logbook_model->fetchDxcc(); $this->load->library('form_validation'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 0b60e9cb..36e52204 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -56,7 +56,7 @@ class Logbook_model extends CI_Model { } } else { - $dxcc_id = $this->input->post('dxcc_id'); + $dxcc_id = $this->input->post('dxcc_id'); } // Create array with QSO Data @@ -1184,7 +1184,8 @@ class Logbook_model extends CI_Model { if (isset($record['call'])){ if ($dxccAdif != NULL) { if (isset($record['dxcc'])) { - $dxcc = array($record['dxcc'], $this->get_entity($record['dxcc'])); + $entity = $this->get_entity($record['dxcc']); + $dxcc = array($record['dxcc'], $entity['name']); } else { $dxcc = NULL; } @@ -1705,12 +1706,12 @@ class Logbook_model extends CI_Model { } public function get_entity($dxcc){ - $sql = "select name from dxcc_entities where adif = " . $dxcc; + $sql = "select name, cqz, lat, `long` from dxcc_entities where adif = " . $dxcc; $query = $this->db->query($sql); if ($query->result() > 0){ $row = $query->row_array(); - return $row['name']; + return $row; } return ''; } @@ -1810,6 +1811,15 @@ class Logbook_model extends CI_Model { return 0; } + + function fetchDxcc() { + $sql = "select adif, prefix, name, date(end) Enddate, date(start) Startdate from dxcc_entities"; + + $sql .= ' order by prefix'; + $query = $this->db->query($sql); + + return $query->result(); + } } @@ -1820,4 +1830,6 @@ function validateADIFDate($date, $format = 'Ymd') } + + ?> diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 8cf40678..1b51519b 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -413,6 +413,29 @@ $(document).on('keypress',function(e) { } }); + $('#dxcc_id').on('change', function() { + $.getJSON('logbook/jsonentity/' + $(this).val(), function (result) { + if (result.dxcc.name != undefined) { + + $('#country').val(convert_case(result.dxcc.name)); + $('#cqz').val(convert_case(result.dxcc.cqz)); + + $('#callsign_info').removeClass("badge-secondary"); + $('#callsign_info').removeClass("badge-success"); + $('#callsign_info').removeClass("badge-danger"); + $('#callsign_info').attr('title', ''); + $('#callsign_info').text(convert_case(result.dxcc.name)); + + // Set Map to Lat/Long + markers.clearLayers(); + var marker = L.marker([result.dxcc.lat, result.dxcc.long]); + mymap.panTo([result.dxcc.lat, result.dxcc.long], 8); + + markers.addLayer(marker).addTo(mymap); + } + }); + }); + $("#callsign").focusout(function() { if ($(this).val().length >= 3) { @@ -530,6 +553,7 @@ $(document).on('keypress',function(e) { $('#dxcc_id').val(result.dxcc.adif); $('#cqz').val(result.dxcc.cqz); + $('#ituz').val(result.dxcc.ituz); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index b8817bcc..e339cb09 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -6,8 +6,6 @@