mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
[QSLPrint] Added export button for selected QSOs
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
<script type="text/javascript">
|
||||
const user_callsign = "<?php echo $this->session->userdata('user_callsign') ?>";
|
||||
</script>
|
||||
<?php
|
||||
|
||||
function echo_qsl_sent_via($method) {
|
||||
@@ -66,9 +69,9 @@ if ($qsos->result() != NULL) {
|
||||
echo '</tbody></table></div>';
|
||||
?>
|
||||
|
||||
<p><button onclick="markSelectedQsos();" title="<?= __("Mark selected QSOs as printed"); ?>" class="btn btn-success markallprinted"><?= __("Mark selected QSOs as printed"); ?></button>
|
||||
|
||||
<button onclick="removeSelectedQsos();" title="<?= __("Remove selected QSOs from the queue"); ?>" class="btn btn-danger removeall"><?= __("Remove selected QSOs from the queue"); ?></button></p>
|
||||
<p><button onclick="markSelectedQsos();" title="<?= __("Mark selected QSOs as sent"); ?>" class="btn btn-success markallprinted"><?= __("Mark selected QSOs as sent"); ?></button>
|
||||
<button onclick="removeSelectedQsos();" title="<?= __("Remove selected QSOs from the queue"); ?>" class="btn btn-danger removeall"><?= __("Remove selected QSOs from the queue"); ?></button>
|
||||
<button onclick="exportSelectedQsos();" title="<?= __("Export selected QSOs to ADIF-file"); ?>" class="btn btn-primary exportselected"><?= __("Export selected QSOs to ADIF-file"); ?></button></p>
|
||||
|
||||
<p><a href="<?php echo site_url('qslprint/exportcsv/' . $station_id); ?>" title="<?= __("Export CSV-file"); ?>" class="btn btn-primary"><?= __("Export requested QSLs to CSV-file"); ?></a>
|
||||
|
||||
|
||||
@@ -244,3 +244,56 @@ function removeSelectedQsos() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function exportSelectedQsos() {
|
||||
var elements = $('.qslprint tbody input:checked');
|
||||
var nElements = elements.length;
|
||||
if (nElements == 0) {
|
||||
return;
|
||||
}
|
||||
$('.exportselected').prop("disabled", true);
|
||||
|
||||
var id_list=[];
|
||||
elements.each(function() {
|
||||
let id = $(this).first().closest('tr').attr('id');
|
||||
id = id.match(/\d/g);
|
||||
id = id.join("");
|
||||
id_list.push(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
|
||||
// Get the current date and time
|
||||
const now = new Date();
|
||||
|
||||
// Format the date and time as UTC Ymd-Hi
|
||||
const year = now.getUTCFullYear();
|
||||
const month = String(now.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-based
|
||||
const day = String(now.getUTCDate()).padStart(2, '0');
|
||||
const hours = String(now.getUTCHours()).padStart(2, '0');
|
||||
const minutes = String(now.getUTCMinutes()).padStart(2, '0');
|
||||
|
||||
// Create the formatted filename
|
||||
const filename = `${user_callsign}-${year}${month}${day}-${hours}${minutes}.adi`;
|
||||
a.download = filename;
|
||||
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));
|
||||
|
||||
$('.exportselected').prop("disabled", false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user