Added optional Grid and Call-Line to label

pull/2375/head
int2001 2023-08-05 05:49:12 +00:00
rodzic 22fba830a4
commit 4ec2a03c33
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DFB1C13CD2DB037B
2 zmienionych plików z 24 dodań i 18 usunięć

Wyświetl plik

@ -133,27 +133,29 @@ class Labels extends CI_Controller {
public function printids() { public function printids() {
$ids = xss_clean(json_decode($this->input->post('id'))); $ids = xss_clean(json_decode($this->input->post('id')));
$offset = xss_clean($this->input->post('startat')); $offset = xss_clean($this->input->post('startat'));
$grid = xss_clean($this->input->post('grid') ?? 0);
$this->load->model('labels_model'); $this->load->model('labels_model');
$result = $this->labels_model->export_printrequestedids($ids); $result = $this->labels_model->export_printrequestedids($ids);
$this->prepareLabel($result, true, $offset); $this->prepareLabel($result, true, $offset, $grid);
} }
public function print($station_id) { public function print($station_id) {
$clean_id = xss_clean($station_id); $clean_id = xss_clean($station_id);
$offset = xss_clean($this->input->post('startat')); $offset = xss_clean($this->input->post('startat'));
$grid = xss_clean($this->input->post('grid') ?? 0);
$this->load->model('stations'); $this->load->model('stations');
if ($this->stations->check_station_is_accessible($station_id)) { if ($this->stations->check_station_is_accessible($station_id)) {
$this->load->model('labels_model'); $this->load->model('labels_model');
$result = $this->labels_model->export_printrequested($clean_id); $result = $this->labels_model->export_printrequested($clean_id);
$this->prepareLabel($result, false, $offset); $this->prepareLabel($result, false, $offset, $grid);
} else { } else {
redirect('labels'); redirect('labels');
} }
} }
function prepareLabel($qsos, $jscall = false, $offset = 1) { function prepareLabel($qsos, $jscall = false, $offset = 1, $grid = false) {
$this->load->model('labels_model'); $this->load->model('labels_model');
$label = $this->labels_model->getDefaultLabel(); $label = $this->labels_model->getDefaultLabel();
@ -229,9 +231,9 @@ class Labels extends CI_Controller {
if ($qsos->num_rows() > 0) { if ($qsos->num_rows() > 0) {
if ($label->qsos == 1) { if ($label->qsos == 1) {
$this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation); $this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset, $ptype->orientation, $grid);
} else { } else {
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation); $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset, $ptype->orientation, $grid);
} }
} else { } else {
$this->session->set_flashdata('message', '0 QSOs found for print!'); $this->session->set_flashdata('message', '0 QSOs found for print!');
@ -240,7 +242,7 @@ class Labels extends CI_Controller {
$pdf->Output(); $pdf->Output();
} }
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation) { function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $grid) {
$text = ''; $text = '';
$current_callsign = ''; $current_callsign = '';
$current_sat = ''; $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_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))) { // ((($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)) { 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 = []; $qso_data = [];
} }
$current_callsign = $qso->COL_CALL; $current_callsign = $qso->COL_CALL;
@ -275,11 +277,12 @@ class Labels extends CI_Controller {
'sat' => $qso->COL_SAT_NAME, 'sat' => $qso->COL_SAT_NAME,
'sat_mode' => $this->pretty_sat_mode($qso->COL_SAT_MODE ?? ''), 'sat_mode' => $this->pretty_sat_mode($qso->COL_SAT_MODE ?? ''),
'sat_band_rx' => ($qso->COL_BAND_RX ?? ''), '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)) { 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 // 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 ?? '')); 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 = []; $tableData = [];
$count_qso = 0; $count_qso = 0;
@ -307,7 +310,7 @@ class Labels extends CI_Controller {
if($count_qso == $qso_per_label){ 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 $tableData = []; // reset the data
$count_qso = 0; // reset the counter $count_qso = 0; // reset the counter
} }
@ -315,18 +318,17 @@ class Labels extends CI_Controller {
} }
// generate label for remaining QSOs // generate label for remaining QSOs
if($count_qso > 0){ 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 $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 = new \AsciiTable\Builder();
$builder->addRows($tableData); $builder->addRows($tableData);
$text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with ";
$text .= $current_callsign; $text .= $current_callsign."\n";
$text .= "\n"; $text .= $builder->renderTable();
$text .= $builder->renderTable();
if($qso['sat'] != "") { if($qso['sat'] != "") {
if (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] !== '')) { if (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] !== '')) {
$text .= "\n".'Satellite: '.$qso['sat'].' Band RX: '.$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 .= "\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"; $text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";
$pdf->Add_Label($text,$orientation); $pdf->Add_Label($text,$orientation);
} }

Wyświetl plik

@ -1,4 +1,6 @@
<form method="post" action="<?php echo site_url('labels/print/'.$stationid) ?>" class="form-inline"> <form method="post" action="<?php echo site_url('labels/print/'.$stationid) ?>" class="form-inline">
<input class="form-control input-group-sm" type="checkbox" id="grid" name="grid" value="1">
Include Grid?
<input class="form-control input-group-sm" type="number" id="startat" name="startat" value="1"> <input class="form-control input-group-sm" type="number" id="startat" name="startat" value="1">
<button type="submit" id="button1id" name="button1id" class="btn btn-primary ld-ext-right">Print</button> <button type="submit" id="button1id" name="button1id" class="btn btn-primary ld-ext-right">Print</button>
</form> </form>