diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 4ee58f47..8f5b125a 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -135,10 +135,11 @@ 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; + $awards = $this->input->post('awards') === "true" ? 1 : 0; $this->load->model('labels_model'); $result = $this->labels_model->export_printrequestedids($ids); - $this->prepareLabel($result, true, $offset, $grid, $via); + $this->prepareLabel($result, true, $offset, $grid, $via, $awards); } public function print($station_id) { @@ -146,18 +147,19 @@ 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); + $awards = xss_clean($this->input->post('awards') ?? 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); + $this->prepareLabel($result, false, $offset, $grid, $via, $awards); } else { redirect('labels'); } } - function prepareLabel($qsos, $jscall = false, $offset = 1, $grid = false, $via = false) { + function prepareLabel($qsos, $jscall = false, $offset = 1, $grid = false, $via = false, $awards = false) { $this->load->model('labels_model'); $label = $this->labels_model->getDefaultLabel(); @@ -232,11 +234,7 @@ 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); - } else { - $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation, $grid, $via); - } + $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation, $grid, $via, $awards); } else { $this->session->set_flashdata('message', '0 QSOs found for print!'); redirect('labels'); @@ -244,7 +242,7 @@ class Labels extends CI_Controller { $pdf->Output(); } - function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $grid, $via) { + function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $grid, $via, $awards) { $text = ''; $current_callsign = ''; $current_sat = ''; @@ -261,7 +259,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); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via, $awards); $qso_data = []; } $current_callsign = $qso->COL_CALL; @@ -281,19 +279,46 @@ class Labels extends CI_Controller { 'sat_mode' => $this->pretty_sat_mode($qso->COL_SAT_MODE ?? ''), 'sat_band_rx' => ($qso->COL_BAND_RX ?? ''), 'qsl_recvd' => $qso->COL_QSL_RCVD, - 'mycall' => $qso->COL_STATION_CALLSIGN + 'mycall' => $qso->COL_STATION_CALLSIGN, + 'awards' => $this->stationAwardsList($qso) ]; } if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid, $via, $awards); } } + + function stationAwardsList($station_profile) { + $awards = ""; + if (trim($station_profile->station_iota) !== '') { + $awards .= "IOTA:" . $station_profile->station_iota . " "; + } + + if (trim($station_profile->station_sota) !== '') { + $awards .= "SOTA:" . $station_profile->station_sota . " "; + } + + if (trim($station_profile->station_wwff) !== '') { + $awards .= "WWFF:" . $station_profile->station_wwff . " "; + } + + if (trim($station_profile->station_pota) !== '') { + $awards .= "POTA:" . $station_profile->station_pota . " "; + } + + if (trim($station_profile->station_sig) !== '' && trim($station_profile->station_sig_info) !== '') { + $awards .= $station_profile->station_sig . ":" . $station_profile->station_sig_info; + } + + return $awards; + } + // New begin function pretty_sat_mode($sat_mode) { 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) { + function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label,$orientation, $grid, $via, $awards) { $tableData = []; $count_qso = 0; @@ -313,7 +338,7 @@ class Labels extends CI_Controller { if($count_qso == $qso_per_label){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via, $awards); $tableData = []; // reset the data $count_qso = 0; // reset the counter } @@ -321,12 +346,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); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid, $via, $awards); $preliminaryData = []; // reset the data } } - function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation,$grid=true, $via=false){ + function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation,$grid=true, $via=false, $awards=false){ $builder = new \AsciiTable\Builder(); $builder->addRows($tableData); $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; @@ -347,6 +372,7 @@ class Labels extends CI_Controller { } $text.="\n"; if ($grid) { $text .= "My call: ".$qso['mycall']." Grid: ".$qso['mygrid']."\n"; } + if ($awards) { $text .= $qso['awards']."\n"; } $text .= "Thanks for the QSO".($numofqsos>1 ? 's' : ''); $text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL"; $pdf->Add_Label($text,$orientation); diff --git a/application/views/labels/startatform.php b/application/views/labels/startatform.php index f61d54c6..f04f5093 100644 --- a/application/views/labels/startatform.php +++ b/application/views/labels/startatform.php @@ -11,6 +11,12 @@ +
+ +
+ +
+