diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 45ba9b4e..008ec762 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -133,27 +133,29 @@ class Labels extends CI_Controller { public function printids() { $ids = xss_clean(json_decode($this->input->post('id'))); $offset = xss_clean($this->input->post('startat')); + $grid = $this->input->post('grid') === "true" ? 1 : 0; $this->load->model('labels_model'); $result = $this->labels_model->export_printrequestedids($ids); - $this->prepareLabel($result, true, $offset); + $this->prepareLabel($result, true, $offset, $grid); } public function print($station_id) { $clean_id = xss_clean($station_id); $offset = xss_clean($this->input->post('startat')); + $grid = xss_clean($this->input->post('grid') ?? 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); + $this->prepareLabel($result, false, $offset, $grid); } else { redirect('labels'); } } - function prepareLabel($qsos, $jscall = false, $offset = 1) { + function prepareLabel($qsos, $jscall = false, $offset = 1, $grid = false) { $this->load->model('labels_model'); $label = $this->labels_model->getDefaultLabel(); @@ -229,9 +231,9 @@ class Labels extends CI_Controller { if ($qsos->num_rows() > 0) { if ($label->qsos == 1) { - $this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation); + $this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation, $grid); } else { - $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation); + $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation, $grid); } } else { $this->session->set_flashdata('message', '0 QSOs found for print!'); @@ -240,7 +242,7 @@ class Labels extends CI_Controller { $pdf->Output(); } - function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation) { + function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $grid) { $text = ''; $current_callsign = ''; $current_sat = ''; @@ -257,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); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid); $qso_data = []; } $current_callsign = $qso->COL_CALL; @@ -275,11 +277,12 @@ class Labels extends CI_Controller { 'sat' => $qso->COL_SAT_NAME, 'sat_mode' => $this->pretty_sat_mode($qso->COL_SAT_MODE ?? ''), 'sat_band_rx' => ($qso->COL_BAND_RX ?? ''), - 'qsl_recvd' => $qso->COL_QSL_RCVD + 'qsl_recvd' => $qso->COL_QSL_RCVD, + 'mycall' => $qso->COL_STATION_CALLSIGN ]; } if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $orientation, $grid); } } // New begin @@ -287,7 +290,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) { + function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label,$orientation, $grid) { $tableData = []; $count_qso = 0; @@ -307,7 +310,7 @@ class Labels extends CI_Controller { if($count_qso == $qso_per_label){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid); $tableData = []; // reset the data $count_qso = 0; // reset the counter } @@ -315,18 +318,17 @@ class Labels extends CI_Controller { } // generate label for remaining QSOs if($count_qso > 0){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso,$orientation, $grid); $preliminaryData = []; // reset the data } } - function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation){ + function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation,$grid=true){ $builder = new \AsciiTable\Builder(); $builder->addRows($tableData); - $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; - $text .= $current_callsign; - $text .= "\n"; - $text .= $builder->renderTable(); + $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; + $text .= $current_callsign."\n"; + $text .= $builder->renderTable(); if($qso['sat'] != "") { if (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] !== '')) { $text .= "\n".'Satellite: '.$qso['sat'].' Band RX: '.$qso['sat_band_rx']; @@ -336,7 +338,9 @@ class Labels extends CI_Controller { $text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.$qso['sat_mode']; } } - $text .= "\nThanks for the QSO".($numofqsos>1 ? 's' : ''); + $text.="\n"; + if ($grid) { $text .= "My call: ".$qso['mycall']." Grid: ".$qso['mygrid']."\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 15ba3b06..a9de4d26 100644 --- a/application/views/labels/startatform.php +++ b/application/views/labels/startatform.php @@ -1,4 +1,17 @@ -
- - + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
diff --git a/application/views/logbookadvanced/startatform.php b/application/views/logbookadvanced/startatform.php index 74fe356b..a2ecbca7 100644 --- a/application/views/logbookadvanced/startatform.php +++ b/application/views/logbookadvanced/startatform.php @@ -1,4 +1,17 @@ -
- - + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js index e939c4e3..02207540 100644 --- a/assets/js/sections/logbookadvanced.js +++ b/assets/js/sections/logbookadvanced.js @@ -585,7 +585,9 @@ function printlabel() { url: base_url + 'index.php/labels/printids', type: 'post', data: {'id': JSON.stringify(id_list, null, 2), - 'startat': $('#startat').val() + 'startat': $('#startat').val(), + 'grid': $('#gridlabel')[0].checked, + }, xhr:function(){ var xhr = new XMLHttpRequest();