kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #2375 from int2001/label_grid
Added (optional) grid to label-printingpull/2377/head
commit
0af6dd2939
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
<form method="post" action="<?php echo site_url('labels/print/'.$stationid) ?>" class="form-inline">
|
||||
<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>
|
||||
<form method="post" class="col-md" action="<?php echo site_url('labels/print/'.$stationid) ?>">
|
||||
<div class="form-group row">
|
||||
<label class="my-1 mr-2 col-md-4" for="grid">Include Grid?</label>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="grid" id="grid">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="my-1 mr-2 col-md-4" for="startat">Start printing at?</label>
|
||||
<div class="form-inline">
|
||||
<input class="form-control input-group-sm" type="number" id="startat" name="startat" value="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-left">
|
||||
<button type="submit" id="button1id" name="button1id" class="btn btn-primary ld-ext-right">Print</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
<form method="post" class="form-inline">
|
||||
<input class="form-control input-group-sm" type="number" id="startat" name="startat" value="1">
|
||||
<button type="button" id="button1id" name="button1id" class="btn btn-primary ld-ext-right" onclick="printlabel();">Print</button>
|
||||
<form method="post" class="col-md">
|
||||
<div class="form-group row">
|
||||
<label class="my-1 mr-2 col-md-4" for="gridlabel">Include Grid?</label>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="gridlabel" id="gridlabel">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="my-1 mr-2 col-md-4" for="startat">Start printing at?</label>
|
||||
<div class="form-inline">
|
||||
<input class="form-control input-group-sm" type="number" id="startat" name="startat" value="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-left">
|
||||
<button type="button" id="button1id" name="button1id" class="btn btn-primary ld-ext-right" onclick="printlabel();">Print</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -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();
|
||||
|
|
Ładowanie…
Reference in New Issue