diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 89a356453..20bb51841 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -201,6 +201,17 @@ class Logbookadvanced extends CI_Controller { $this->load->view('adif/data/exportall', $data); } + function export_to_adif_params() { + $this->load->model('logbookadvanced_model'); + + $postdata = $this->input->post(); + $postdata['user_id'] = (int)$this->session->userdata('user_id'); + $postdata['qsoresults'] = 'All'; + $data['qsos'] = $this->logbookadvanced_model->getSearchResult($postdata); + + $this->load->view('adif/data/exportall', $data); + } + function update_qsl() { $this->load->model('logbookadvanced_model'); @@ -306,7 +317,7 @@ class Logbookadvanced extends CI_Controller { 'ids' => xss_clean($this->input->post('ids')) ); - $result = $this->logbookadvanced_model->searchDb($searchCriteria); + $result = $this->logbookadvanced_model->getSearchResultArray($searchCriteria); $this->prepareMappedQSos($result); } @@ -347,7 +358,7 @@ class Logbookadvanced extends CI_Controller { 'qslimages' => xss_clean($this->input->post('qslimages')), ); - $result = $this->logbookadvanced_model->searchDb($searchCriteria); + $result = $this->logbookadvanced_model->getSearchResultArray($searchCriteria); $this->prepareMappedQSos($result); } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 6d8205caa..33ef9b1ff 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -208,7 +208,11 @@ class Logbookadvanced_model extends CI_Model { $where = "AND $where"; } - $limit = $searchCriteria['qsoresults']; + $limit = ''; + + if ($searchCriteria['qsoresults'] != 'All') { + $limit = 'limit ' . $searchCriteria['qsoresults']; + } $where2 = ''; @@ -222,7 +226,7 @@ class Logbookadvanced_model extends CI_Model { } $sql = " - SELECT * + SELECT *, dxcc_entities.name AS station_country FROM " . $this->config->item('table_name') . " qsos INNER JOIN station_profile ON qsos.station_id=station_profile.station_id LEFT OUTER JOIN satellite ON qsos.COL_SAT_NAME = satellite.name @@ -237,12 +241,19 @@ class Logbookadvanced_model extends CI_Model { $where $where2 ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc - LIMIT $limit + $limit "; - $data = $this->db->query($sql, $binding); + return $this->db->query($sql, $binding); - $results = $data->result('array'); - return $results; + } + + public function getSearchResult($searchCriteria) { + return $this->searchDb($searchCriteria); + } + + public function getSearchResultArray($searchCriteria) { + $result = $this->searchDb($searchCriteria); + return $result->result('array'); } /* @@ -250,7 +261,7 @@ class Logbookadvanced_model extends CI_Model { * @return array */ public function searchQsos($searchCriteria) : array { - $results = $this->searchDb($searchCriteria); + $results = $this->getSearchResultArray($searchCriteria); $qsos = []; foreach ($results as $data) { diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php index 05351ed9c..a05b1f72b 100644 --- a/application/views/logbookadvanced/index.php +++ b/application/views/logbookadvanced/index.php @@ -139,7 +139,7 @@ $options = json_decode($options);
- @@ -310,7 +310,7 @@ $options = json_decode($options);
- +
@@ -401,7 +401,7 @@ $options = json_decode($options); - diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js index 332bb5a11..32fee112b 100644 --- a/assets/js/sections/logbookadvanced.js +++ b/assets/js/sections/logbookadvanced.js @@ -294,10 +294,10 @@ $(document).ready(function () { iota: this.iota.value, operator: this.operator.value, dxcc: this.dxcc.value, - propmode: this.selectPropagation.value, + propmode: this.propmode.value, gridsquare: this.gridsquare.value, state: this.state.value, - qsoresults: this.qsoResults.value, + qsoresults: this.qsoresults.value, sats: this.sats.value, orbits: this.orbits.value, cqzone: this.cqzone.value, @@ -306,7 +306,7 @@ $(document).ready(function () { lotwReceived: this.lotwReceived.value, eqslSent: this.eqslSent.value, eqslReceived: this.eqslReceived.value, - qslvia: $('[name="qslviainput"]').val(), + qslvia: $('[name="qslvia"]').val(), sota: this.sota.value, pota: this.pota.value, wwff: this.wwff.value, @@ -421,10 +421,7 @@ $(document).ready(function () { $('#exportAdif').click(function (event) { var elements = $('#qsoList tbody input:checked'); - var nElements = elements.length; - if (nElements == 0) { - return; - } + $('#exportAdif').prop("disabled", true); var id_list=[]; elements.each(function() { @@ -432,26 +429,39 @@ $(document).ready(function () { id_list.push(id); unselectQsoID(id); }); + xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - var a; - if (xhttp.readyState === 4 && xhttp.status === 200) { - // Trick for making downloadable link - a = document.createElement('a'); - a.href = window.URL.createObjectURL(xhttp.response); - // Give filename you wish to download - a.download = "logbook_export.adi"; - a.style.display = 'none'; - document.body.appendChild(a); - a.click(); - } - }; - // Post data to URL which handles post request - xhttp.open("POST", site_url+'/logbookadvanced/export_to_adif', true); - xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - // You should set responseType as blob for binary responses - xhttp.responseType = 'blob'; - xhttp.send("id=" + JSON.stringify(id_list, null, 2)+"&sortorder=" +$('.table').DataTable().order()); + xhttp.onreadystatechange = function() { + var a; + if (xhttp.readyState === 4 && xhttp.status === 200) { + // Trick for making downloadable link + a = document.createElement('a'); + a.href = window.URL.createObjectURL(xhttp.response); + // Give filename you wish to download + a.download = "logbook_export.adi"; + a.style.display = 'none'; + document.body.appendChild(a); + a.click(); + } + }; + + if (id_list.length > 0) { + // Post data to URL which handles post request + xhttp.open("POST", site_url+'/logbookadvanced/export_to_adif', true); + xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + // You should set responseType as blob for binary responses + xhttp.responseType = 'blob'; + xhttp.send("id=" + JSON.stringify(id_list, null, 2)+"&sortorder=" +$('.table').DataTable().order()); + } else { + + // Post data to URL which handles post request + xhttp.open("POST", site_url+'/logbookadvanced/export_to_adif_params', true); + xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + // You should set responseType as blob for binary responses + + xhttp.responseType = 'blob'; + xhttp.send($('#searchForm').serialize()); + } $('#exportAdif').prop("disabled", false); }); diff --git a/assets/js/sections/logbookadvanced_map.js b/assets/js/sections/logbookadvanced_map.js index 7b6292c70..d57278f3a 100644 --- a/assets/js/sections/logbookadvanced_map.js +++ b/assets/js/sections/logbookadvanced_map.js @@ -566,10 +566,10 @@ function loadMap(data, iconsList) { qslReceivedMethod: this.qslReceivedMethod.value, iota: form.iota.value, dxcc: form.dxcc.value, - propmode: form.selectPropagation.value, + propmode: form.propmode.value, gridsquare: form.gridsquare.value, state: form.state.value, - qsoresults: form.qsoResults.value, + qsoresults: form.qsoresults.value, sats: form.sats.value, orbits: form.orbits.value, cqzone: form.cqzone.value, @@ -577,7 +577,7 @@ function loadMap(data, iconsList) { lotwReceived: form.lotwReceived.value, eqslSent: form.eqslSent.value, eqslReceived: form.eqslReceived.value, - qslvia: $('[name="qslviainput"]').val(), + qslvia: $('[name="qslvia"]').val(), sota: form.sota.value, pota: form.pota.value, operator: form.operator.value, @@ -653,10 +653,10 @@ function loadMap(data, iconsList) { qslReceivedMethod: this.qslReceivedMethod.value, iota: form.iota.value, dxcc: form.dxcc.value, - propmode: form.selectPropagation.value, + propmode: form.propmode.value, gridsquare: form.gridsquare.value, state: form.state.value, - qsoresults: form.qsoResults.value, + qsoresults: form.qsoresults.value, sats: form.sats.value, orbits: form.orbits.value, cqzone: form.cqzone.value, @@ -664,7 +664,7 @@ function loadMap(data, iconsList) { lotwReceived: form.lotwReceived.value, eqslSent: form.eqslSent.value, eqslReceived: form.eqslReceived.value, - qslvia: $('[name="qslviainput"]').val(), + qslvia: $('[name="qslvia"]').val(), sota: form.sota.value, pota: form.pota.value, operator: form.operator.value,