Merge pull request #347 from AndreasK79/lba_adif_export_use_filters

Adif export can now use filters, no need to mark QSOs
This commit is contained in:
Andreas Kristiansen
2024-05-08 10:55:29 +02:00
committed by GitHub
5 changed files with 78 additions and 46 deletions

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -139,7 +139,7 @@ $options = json_decode($options);
</div>
<div hidden class="sats_dropdown mb-3 col-lg-2 col-md-2 col-sm-3 col-xl">
<label class="form-label" for="sats"><?php echo lang('general_word_satellite'); ?></label>
<select class="form-select form-select-sm" id="sats">
<select class="form-select form-select-sm" id="sats" name="sats">
<option value="All"><?php echo lang('general_word_all'); ?></option>
<?php foreach($sats as $sat) {
echo '<option value="' . htmlentities($sat) . '"' . '>' . htmlentities($sat) . '</option>'."\n";
@@ -148,7 +148,7 @@ $options = json_decode($options);
</div>
<div hidden class="orbits_dropdown mb-3 col-lg-2 col-md-2 col-sm-3 col-xl">
<label class="form-label" for="orbits"><?php echo lang('general_word_orbit'); ?></label>
<select class="form-select form-select-sm" id="orbits">
<select class="form-select form-select-sm" id="orbits" name="orbits">
<option value="All"><?php echo lang('general_word_all'); ?></option>
<?php foreach($orbits as $orbit) {
echo '<option value="' . htmlentities($orbit) . '"' . '>' . htmlentities($orbit) . '</option>'."\n";
@@ -157,7 +157,7 @@ $options = json_decode($options);
</div>
<div class="mb-3 col-lg-2 col-md-2 col-sm-3 col-xl">
<label class="form-label" for="selectPropagation"><?php echo lang('filter_general_propagation'); ?></label>
<select id="selectPropagation" name="selectPropagation" class="form-select form-select-sm">
<select id="selectPropagation" class="form-select form-select-sm" name="propmode">
<option value=""><?php echo lang('general_word_all'); ?></option>
<option value="AS">Aircraft Scatter</option>
<option value="AUR">Aurora</option>
@@ -310,7 +310,7 @@ $options = json_decode($options);
</div>
<div class="mb-3 col-lg-2 col-md-2 col-sm-3 col-xl">
<label for="qslvia"><?php echo lang('filter_qsl_via'); ?></label>
<input type="search" name="qslviainput" class="form-control form-control-sm">
<input type="search" name="qslvia" class="form-control form-control-sm">
</div>
<div class="mb-3 col-lg-2 col-md-2 col-sm-3 col-xl">
<label for="qslimages"><?php echo lang('filter_qsl_images'); ?></label>
@@ -401,7 +401,7 @@ $options = json_decode($options);
<button type="button" class="btn btn-sm btn-primary me-1" data-bs-toggle="collapse"
data-bs-target=".actionbody"><?php echo lang('filter_actions'); ?></button>
<label for="qsoResults" class="me-2"><?php echo lang('filter_results'); ?></label>
<select id="qsoResults" name="qsoResults" class="form-select form-select-sm me-2 w-auto">
<select id="qsoResults" name="qsoresults" class="form-select form-select-sm me-2 w-auto">
<option value="250">250</option>
<option value="1000">1000</option>
<option value="2500">2500</option>

View File

@@ -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);
});

View File

@@ -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,