Add some flexibility to compose QSL labels

This commit is contained in:
cats-shadow
2025-02-10 14:15:45 +03:00
parent 49202167d1
commit 814d5b5fd1
3 changed files with 56 additions and 16 deletions

View File

@@ -143,11 +143,13 @@ class Labels extends CI_Controller {
$offset = xss_clean($this->input->post('startat'));
$grid = $this->input->post('grid') === "true" ? 1 : 0;
$via = $this->input->post('via') === "true" ? 1 : 0;
$qslmsg = $this->input->post('qslmsg') === "true" ? 1 : 0;
$tnxmsg = $this->input->post('tnxmsg') === "true" ? 1 : 0;
$reference = $this->input->post('reference') == "true" ? 1 : 0;
$this->load->model('labels_model');
$result = $this->labels_model->export_printrequestedids($ids);
$this->prepareLabel($result, true, $offset, $grid, $via, $reference);
$this->prepareLabel($result, true, $offset, $grid, $via, $reference, $qslmsg, $tnxmsg);
}
public function print($station_id) {
@@ -155,19 +157,21 @@ class Labels extends CI_Controller {
$offset = xss_clean($this->input->post('startat'));
$grid = xss_clean($this->input->post('grid') ?? 0);
$via = xss_clean($this->input->post('via') ?? 0);
$qslmsg = xss_clean($this->input->post('qslmsg') ?? 0);
$tnxmsg = xss_clean($this->input->post('tnxmsg') ?? 0);
$reference = xss_clean($this->input->post('reference') ?? 0);
$this->load->model('stations');
if ($this->stations->check_station_is_accessible($station_id)) {
$this->load->model('labels_model');
$result = $this->labels_model->export_printrequested($clean_id);
$this->prepareLabel($result, false, $offset, $grid, $via, $reference);
$this->prepareLabel($result, false, $offset, $grid, $via, $reference, $qslmsg, $tnxmsg);
} else {
redirect('labels');
}
}
function prepareLabel($qsos, $jscall = false, $offset = 1, $grid = false, $via = false, $reference = false) {
function prepareLabel($qsos, $jscall = false, $offset = 1, $grid = false, $via = false, $reference = false, $qslmsg = false, $tnxmsg = true) {
$this->load->model('labels_model');
$label = $this->labels_model->getDefaultLabel();
@@ -243,9 +247,9 @@ class Labels extends CI_Controller {
if ($qsos->num_rows() > 0) {
if ($label->qsos == 1) {
$this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation, $grid, $via, $reference);
$this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation, $grid, $via, $reference, $qslmsg, $tnxmsg);
} else {
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation, $grid, $via, $reference);
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation, $grid, $via, $reference, $qslmsg, $tnxmsg);
}
} else {
$this->session->set_flashdata('message', __('0 QSOs found for print!'));
@@ -254,7 +258,7 @@ class Labels extends CI_Controller {
$pdf->Output();
}
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $grid, $via, $reference) {
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $grid, $via, $reference, $qslmsg, $tnxmsg) {
$text = '';
$current_callsign = '';
$current_sat = '';
@@ -271,7 +275,7 @@ class Labels extends CI_Controller {
( ($qso->COL_BAND_RX !== $current_sat_bandrx) && ($this->pretty_sat_mode($qso->COL_SAT_MODE) !== '')) ) {
// ((($qso->COL_SAT_NAME ?? '' !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) && ($qso->COL_SAT_NAME ?? '' !== '') && ($col->COL_BAND_RX ?? '' !== $current_sat_bandrx))) {
if (!empty($qso_data)) {
$this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via, $reference);
$this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via, $reference, $qslmsg, $tnxmsg);
$qso_data = [];
}
$current_callsign = $qso->COL_CALL;
@@ -303,7 +307,7 @@ class Labels extends CI_Controller {
];
}
if (!empty($qso_data)) {
$this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via, $reference);
$this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via, $reference, $qslmsg, $tnxmsg);
}
}
// New begin
@@ -311,7 +315,7 @@ class Labels extends CI_Controller {
return(strlen($sat_mode ?? '') == 2 ? (strtoupper($sat_mode[0]).'/'.strtoupper($sat_mode[1])) : strtoupper($sat_mode ?? ''));
}
function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label,$orientation, $grid, $via, $reference) {
function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label,$orientation, $grid, $via, $reference, $qslmsg, $tnxmsg) {
$tableData = [];
$count_qso = 0;
@@ -331,7 +335,7 @@ class Labels extends CI_Controller {
if($count_qso == $qso_per_label){
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via, $reference);
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via, $reference, $qslmsg, $tnxmsg);
$tableData = []; // reset the data
$count_qso = 0; // reset the counter
}
@@ -339,12 +343,12 @@ class Labels extends CI_Controller {
}
// generate label for remaining QSOs
if($count_qso > 0){
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via, $reference);
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via, $reference, $qslmsg, $tnxmsg);
$preliminaryData = []; // reset the data
}
}
function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation,$grid=true, $via=false, $reference = false){
function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation,$grid=true, $via=false, $reference = false, $qslmsg = false, $tnxmsg = true){
$builder = new \AsciiTable\Builder();
$builder->addRows($tableData);
$toradio = "To Radio: ";
@@ -379,10 +383,22 @@ class Labels extends CI_Controller {
if (!empty($qso['wwff'])) { $ref_text .= "WWFF:".$qso['wwff']; $ref_avail = true;}
if ($ref_avail == true) {$text .= $ref_text."\n";}
}
if (!empty($qso['qslmsg'])) { $text .= $qso['qslmsg'];}
else {
$text .= "Thanks for the QSO".($numofqsos>1 ? 's' : '');
$text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";}
if ($qslmsg) {
if (!empty($qso['qslmsg'])) { $text .= $qso['qslmsg']."\n";}
}
if ($tnxmsg) {
$text .= "Thanks for the QSO".($numofqsos>1 ? 's' : '');
$text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";
}
// if (!empty($qso['qslmsg'])) { $text .= $qso['qslmsg'];}
// else {
// $text .= "Thanks for the QSO".($numofqsos>1 ? 's' : '');
// $text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";
// }
$pdf->Add_Label($text,$orientation); }

View File

@@ -18,6 +18,18 @@
<input class="form-check-input" type="checkbox" name="via" id="via">
</div>
</div>
<div class="mb-3 row">
<label for="qslmsg"><?= __("Include QSLMSG (if filled)?"); ?></label>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="qslmsg" id="qslmsg">
</div>
</div>
<div class="mb-3 row">
<label for="tnxmsg"><?= __("Include TNX message?"); ?></label>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="tnxmsg" id="tnxmsg" checked>
</div>
</div>
<div class="mb-3 row">
<label for="startat"><?= __("Start printing at?"); ?></label>
<div class="d-flex align-items-center">

View File

@@ -17,6 +17,18 @@
<input class="form-check-input" type="checkbox" name="via" id="via">
</div>
</div>
<div class="mb-3 row">
<label for="qslmsg"><?= __("Include QSLMSG"); ?></label>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="qslmsg" id="qslmsg">
</div>
</div>
<div class="mb-3 row">
<label for="tnxmsg"><?= __("Include TNX message"); ?></label>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="tnxmsg" id="tnxmsg" checked>
</div>
</div>
<div class="mb-3 row">
<label for="startat"><?= __("Start printing at?"); ?></label>
<div class="d-flex align-items-center">