Merge pull request #2399 from AndreasK79/qslprint_checkboxes

[QSLPrint] Added checkboxes for multiselect
pull/2401/head
Peter Goodhall 2023-08-10 22:25:22 +01:00 zatwierdzone przez GitHub
commit 9fb96a8d0d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 99 dodań i 5 usunięć

Wyświetl plik

@ -13,9 +13,10 @@ if (empty($station_id)) {
}
if ($qsos->result() != NULL) {
echo '<table style="width:100%" class="table table-sm table-bordered table-hover table-striped table-condensed">
echo '<table style="width:100%" class="table table-sm table-bordered table-hover table-striped table-condensed qslprint">
<thead>
<tr>
<th style=\'text-align: center\'><div class="form-check" style="margin-top: -1.5em"><input class="form-check-input" type="checkbox" id="checkBoxAll" /></div></th>
<th style=\'text-align: center\'>'.lang('gen_hamradio_callsign').'</th>
<th style=\'text-align: center\'>' . lang('general_word_date') . '</th>
<th style=\'text-align: center\'>'. lang('general_word_time') .'</th>
@ -25,7 +26,7 @@ if ($qsos->result() != NULL) {
<th style=\'text-align: center\'>' . lang('gen_hamradio_station') . '</th>
<th style=\'text-align: center\'>Sent method</th>
<th style=\'text-align: center\'>Mark as sent</th>
<th style=\'text-align: center\'>Delete</th>
<th style=\'text-align: center\'>Remove</th>
<th style=\'text-align: center\'>QSO List</th>
</tr>
</thead><tbody>';
@ -41,6 +42,7 @@ if ($qsos->result() != NULL) {
foreach ($qsos->result() as $qsl) {
echo '<tr id="qslprint_'.$qsl->COL_PRIMARY_KEY.'">';
echo '<td style=\'text-align: center\'><div class="form-check"><input class="form-check-input" type="checkbox" /></div></td>';
echo '<td style=\'text-align: center\'>' . $qsl->COL_CALL . '</td>';
echo '<td style=\'text-align: center\'>'; $timestamp = strtotime($qsl->COL_TIME_ON); echo date($custom_date_format, $timestamp); echo '</td>';
echo '<td style=\'text-align: center\'>'; $timestamp = strtotime($qsl->COL_TIME_ON); echo date('H:i', $timestamp); echo '</td>';
@ -57,11 +59,15 @@ if ($qsos->result() != NULL) {
echo '</tbody></table>';
?>
<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></p>
<p><button onclick="markSelectedQsos();" title="Mark selected QSOs as printed" class="btn btn-success markallprinted">Mark selected QSOs as printed</button>
<p><a href="<?php echo site_url('qslprint/exportadif/' . $station_id); ?>" title="Export ADIF" class="btn btn-primary">Export requested QSLs to ADIF-file</a></p>
<button onclick="removeSelectedQsos();" title="Remove seleced QSOS from print queue" class="btn btn-danger removeall">Remove selected QSOs from the queue</button></p>
<p><a href="<?php echo site_url('qslprint/qsl_printed/' . $station_id); ?>" title="Mark QSLs as printed" class="btn btn-primary">Mark requested QSLs as sent</a></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>
<a href="<?php echo site_url('qslprint/exportadif/' . $station_id); ?>" title="Export ADIF" class="btn btn-primary">Export requested QSLs to ADIF-file</a>
<a href="<?php echo site_url('qslprint/qsl_printed/' . $station_id); ?>" title="Mark QSLs as printed" class="btn btn-primary">Mark requested QSLs as sent</a></p>
<?php
} else {

Wyświetl plik

@ -126,3 +126,91 @@ function mark_qsl_sent(id, method) {
}
});
}
$('#checkBoxAll').change(function (event) {
if (this.checked) {
$('.qslprint tbody tr').each(function (i) {
$(this).closest('tr').addClass('activeRow');
$(this).closest('tr').find("input[type=checkbox]").prop("checked", true);
});
} else {
$('.qslprint tbody tr').each(function (i) {
$(this).closest('tr').removeClass('activeRow');
$(this).closest('tr').find("input[type=checkbox]").prop("checked", false);
});
}
});
$('.qslprint').on('click', 'input[type="checkbox"]', function() {
if ($(this).is(":checked")) {
$(this).closest('tr').addClass('activeRow');
} else {
$(this).closest('tr').removeClass('activeRow');
}
});
function markSelectedQsos() {
var elements = $('.qslprint tbody input:checked');
var nElements = elements.length;
if (nElements == 0) {
return;
}
$('.markallprinted').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);
});
$.ajax({
url: base_url + 'index.php/logbookadvanced/update_qsl',
type: 'post',
data: {'id': JSON.stringify(id_list, null, 2),
'sent' : 'Y',
'method' : 'B'
},
success: function(data) {
if (data !== []) {
$.each(data, function(k, v) {
$("#qslprint_"+this.qsoID).remove();
});
}
$('.markallprinted').prop("disabled", false);
}
});
}
function removeSelectedQsos() {
var elements = $('.qslprint tbody input:checked');
var nElements = elements.length;
if (nElements == 0) {
return;
}
$('.removeall').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);
});
$.ajax({
url: base_url + 'index.php/logbookadvanced/update_qsl',
type: 'post',
data: {'id': JSON.stringify(id_list, null, 2),
'sent' : 'N',
'method' : ''
},
success: function(data) {
if (data !== []) {
$.each(data, function(k, v) {
$("#qslprint_"+this.qsoID).remove();
});
}
$('.removeall').prop("disabled", false);
}
});
}