diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 2aa640f0..38bd6694 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -53,6 +53,15 @@ 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); + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + } + function json($callsign, $type, $band, $mode) { $this->load->model('user_model'); @@ -547,6 +556,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 f122e4f8..82d1d53f 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -23,6 +23,8 @@ 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(); + $data['iota'] = $this->logbook_model->fetchIota(); $this->load->library('form_validation'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 0ceacbda..e3017983 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -62,7 +62,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 @@ -1190,7 +1190,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; } @@ -1711,12 +1712,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 ''; } @@ -1816,6 +1817,24 @@ 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(); + } + + function fetchIota() { + $sql = "select tag, name from iota"; + + $sql .= ' order by tag'; + $query = $this->db->query($sql); + + return $query->result(); + } } @@ -1826,4 +1845,6 @@ function validateADIFDate($date, $format = 'Ymd') } + + ?> diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index e5556557..b1cd656f 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -414,6 +414,76 @@ $(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)); + + changebadge(result.dxcc.name); + + // Set Map to Lat/Long it locator is not empty + if($('#locator').val() == "") { + 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); + } + } + }); + }); + + function changebadge(entityname) { + if($("#sat_name" ).val() != "") { + $.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/SAT/0/0', function(result) + { + + $('#callsign_info').removeClass("badge-secondary"); + $('#callsign_info').removeClass("badge-success"); + $('#callsign_info').removeClass("badge-danger"); + $('#callsign_info').attr('title', ''); + + if (result.workedBefore) + { + $('#callsign_info').addClass("badge-success"); + $('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); + } + else + { + $('#callsign_info').addClass("badge-danger"); + $('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); + } + }) + } else { + $.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) + { + // Reset CSS values before updating + $('#callsign_info').removeClass("badge-secondary"); + $('#callsign_info').removeClass("badge-success"); + $('#callsign_info').removeClass("badge-danger"); + $('#callsign_info').attr('title', ''); + + if (result.workedBefore) + { + $('#callsign_info').addClass("badge-success"); + $('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); + } + else + { + $('#callsign_info').addClass("badge-danger"); + $('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); + } + }) + } + } + $("#callsign").focusout(function() { if ($(this).val().length >= 3) { @@ -478,51 +548,8 @@ $(document).on('keypress',function(e) { } }) } - - - - if($("#sat_name" ).val() != "") { - //logbook/jsonlookupgrid/io77/SAT/0/0 - $.getJSON('logbook/jsonlookupdxcc/' + convert_case(result.dxcc.entity) + '/SAT/0/0', function(result) - { - - $('#callsign_info').removeClass("badge-secondary"); - $('#callsign_info').removeClass("badge-success"); - $('#callsign_info').removeClass("badge-danger"); - $('#callsign_info').attr('title', ''); - if (result.workedBefore) - { - $('#callsign_info').addClass("badge-success"); - $('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); - } - else - { - $('#callsign_info').addClass("badge-danger"); - $('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); - } - }) - } else { - $.getJSON('logbook/jsonlookupdxcc/' + convert_case(result.dxcc.entity) + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) - { - // Reset CSS values before updating - $('#callsign_info').removeClass("badge-secondary"); - $('#callsign_info').removeClass("badge-success"); - $('#callsign_info').removeClass("badge-danger"); - $('#callsign_info').attr('title', ''); - - if (result.workedBefore) - { - $('#callsign_info').addClass("badge-success"); - $('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); - } - else - { - $('#callsign_info').addClass("badge-danger"); - $('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); - } - }) - } + changebadge(result.dxcc.entity); } if(result.lotw_member == "active") { @@ -531,6 +558,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 340489f0..ea907501 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -6,8 +6,6 @@
- -
-
@@ -155,6 +152,7 @@
+
@@ -197,6 +195,29 @@
+
+ + +
+
+ + +
+
e.g: EU-005 +