From 93c31e53b260bc725ccbc6b4d14b5a27661b3bc6 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Tue, 7 May 2024 18:22:52 +0200
Subject: [PATCH 1/3] Adif export can now use filter for adif export
---
application/controllers/Logbookadvanced.php | 14 ++++-
application/models/Logbookadvanced_model.php | 17 ++++--
application/views/logbookadvanced/index.php | 12 ++--
assets/js/sections/logbookadvanced.js | 62 ++++++++++++--------
assets/js/sections/logbookadvanced_map.js | 12 ++--
5 files changed, 73 insertions(+), 44 deletions(-)
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index 89a356453..c431c32ed 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -201,6 +201,16 @@ 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');
+ $data['qsos'] = $this->logbookadvanced_model->getSearchResult($postdata);
+
+ $this->load->view('adif/data/exportall', $data);
+ }
+
function update_qsl() {
$this->load->model('logbookadvanced_model');
@@ -306,7 +316,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 +357,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..625d2827c 100644
--- a/application/models/Logbookadvanced_model.php
+++ b/application/models/Logbookadvanced_model.php
@@ -222,7 +222,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
@@ -239,10 +239,17 @@ class Logbookadvanced_model extends CI_Model {
ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc
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 +257,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..05338cb03 100644
--- a/application/views/logbookadvanced/index.php
+++ b/application/views/logbookadvanced/index.php
@@ -139,7 +139,7 @@ $options = json_decode($options);
-
-
+
' . htmlentities($orbit) . ''."\n";
@@ -157,7 +157,7 @@ $options = json_decode($options);
-
+
@@ -310,7 +310,7 @@ $options = json_decode($options);
-
+
@@ -401,11 +401,13 @@ $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,
From 051963da962231293a27958d47a74ef7562ce00c Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Wed, 8 May 2024 09:53:53 +0200
Subject: [PATCH 2/3] Removed 7.5k and 10k. Slows down everything too much
---
application/views/logbookadvanced/index.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php
index 05338cb03..a05b1f72b 100644
--- a/application/views/logbookadvanced/index.php
+++ b/application/views/logbookadvanced/index.php
@@ -406,8 +406,6 @@ $options = json_decode($options);
-
-
From 3225de066123e79424fa0a7a97c242f57cb63288 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Wed, 8 May 2024 10:49:13 +0200
Subject: [PATCH 3/3] Now exports ALL qsos with the given filters
---
application/controllers/Logbookadvanced.php | 1 +
application/models/Logbookadvanced_model.php | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index c431c32ed..20bb51841 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -206,6 +206,7 @@ class Logbookadvanced extends CI_Controller {
$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);
diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php
index 625d2827c..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 = '';
@@ -237,7 +241,7 @@ class Logbookadvanced_model extends CI_Model {
$where
$where2
ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc
- LIMIT $limit
+ $limit
";
return $this->db->query($sql, $binding);