Merge branch 'dev' into secfix

这个提交包含在:
Andreas Kristiansen 2023-07-30 21:40:48 +02:00 提交者 GitHub
当前提交 61b55a2e3d
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 6 个文件被更改,包括 99 次插入36 次删除

查看文件

@ -98,19 +98,19 @@ class Labels extends CI_Controller {
public function print($station_id) {
$clean_id = xss_clean($station_id);
$offset = xss_clean($this->input->post('startat'));
$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);
$this->prepareLabel($result, false, $offset);
} else {
redirect('labels');
}
}
function prepareLabel($qsos, $jscall = false) {
function prepareLabel($qsos, $jscall = false, $offset = 1) {
$this->load->model('labels_model');
$label = $this->labels_model->getDefaultLabel();
$label->font='DejaVuSans'; // Fix font to DejaVuSans
@ -165,9 +165,9 @@ class Labels extends CI_Controller {
if ($qsos->num_rows() > 0) {
if ($label->qsos == 1) {
$this->makeMultiQsoLabel($qsos->result(), $pdf,1);
$this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset);
} else {
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos);
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset);
}
} else {
$this->session->set_flashdata('message', '0 QSOs found for print!');
@ -176,19 +176,30 @@ class Labels extends CI_Controller {
$pdf->Output();
}
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos) {
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset) {
$text = '';
$current_callsign = '';
$current_sat = '';
$current_sat_mode = '';
$current_sat_bandrx = '';
$qso_data = [];
if ($offset !== 1) {
for ($i = 1; $i < $offset; $i++) {
$pdf->Add_Label('');
}
}
foreach($qsos as $qso) {
if (($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) {
if (($this->pretty_sat_mode($qso->COL_SAT_MODE) !== $current_sat_mode) || ($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign) || // Call, SAT or SAT-Mode differs?
( ($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);
$qso_data = [];
}
$current_callsign = $qso->COL_CALL;
$current_sat = $qso->COL_SAT_NAME;
$current_sat_mode = $this->pretty_sat_mode($qso->COL_SAT_MODE);
$current_sat_bandrx = $qso->COL_BAND_RX ?? '';
}
$qso_data[] = [
@ -198,7 +209,8 @@ class Labels extends CI_Controller {
'rst' => $qso->COL_RST_SENT,
'mygrid' => $qso->station_gridsquare,
'sat' => $qso->COL_SAT_NAME,
'sat_mode' => $qso->COL_SAT_MODE,
'sat_mode' => $this->pretty_sat_mode($qso->COL_SAT_MODE ?? ''),
'sat_band_rx' => ($qso->COL_BAND_RX ?? ''),
'qsl_recvd' => $qso->COL_QSL_RCVD
];
}
@ -207,8 +219,12 @@ class Labels extends CI_Controller {
}
}
// 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) {
$tableData = [];
$count_qso = 0;
$qso=[];
@ -225,6 +241,7 @@ class Labels extends CI_Controller {
$tableData[] = $rowData;
$count_qso++;
if($count_qso == $qso_per_label){
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso);
$tableData = []; // reset the data
@ -247,7 +264,13 @@ class Labels extends CI_Controller {
$text .= "\n";
$text .= $builder->renderTable();
if($qso['sat'] != "") {
$text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.(strlen($qso['sat_mode']) == 2 ? (strtoupper($qso['sat_mode'][0]).'/'.strtoupper($qso['sat_mode'][1])) : strtoupper($qso['sat_mode']));
if (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] !== '')) {
$text .= "\n".'Satellite: '.$qso['sat'].' Band RX: '.$qso['sat_band_rx'];
} elseif (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] == '')) {
$text .= "\n".'Satellite: '.$qso['sat'];
} else {
$text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.$qso['sat_mode'];
}
}
$text .= "\nThanks for the QSO".($numofqsos>1 ? 's' : '');
$text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";
@ -290,4 +313,8 @@ class Labels extends CI_Controller {
$this->labels_model->saveDefaultLabel($id);
}
public function startAtLabel() {
$data['stationid'] = xss_clean($this->input->post('stationid'));
$this->load->view('labels/startatform', $data);
}
}

查看文件

@ -82,7 +82,12 @@ class Qrz {
$data['name'] = (string)$xml->Callsign->fname;
}
$data['name'] = trim($data['name']);
$data['gridsquare'] = (string)$xml->Callsign->grid;
// Sanitise gridsquare to only allow up to 8 characters
$unclean_gridsquare = (string)$xml->Callsign->grid; // Get the gridsquare from QRZ convert to string
$clean_gridsquare = strlen($unclean_gridsquare) > 8 ? substr($unclean_gridsquare,0,8) : $unclean_gridsquare; // Trim gridsquare to 8 characters max
$data['gridsquare'] = $clean_gridsquare;
$data['city'] = (string)$xml->Callsign->addr2;
$data['lat'] = (string)$xml->Callsign->lat;
$data['long'] = (string)$xml->Callsign->lon;

查看文件

@ -125,6 +125,8 @@ class Labels_model extends CI_Model {
$this->db->order_by("COL_DXCC", "ASC");
$this->db->order_by("COL_CALL", "ASC");
$this->db->order_by("COL_SAT_NAME", "ASC");
$this->db->order_by("COL_SAT_MODE", "ASC");
$this->db->order_by("COL_BAND_RX", "ASC");
$this->db->order_by("COL_TIME_ON", "ASC");
$this->db->order_by("COL_MODE", "ASC");
$query = $this->db->get($this->config->item('table_name'));

查看文件

@ -96,7 +96,7 @@
echo '<td>' . $qso->station_gridsquare . '</td>';
echo '<td>' . $qso->count . '</td>';
echo '<td><a href="'. site_url('qslprint') . '" class="btn btn-outline-info btn-sm"><i class="fas fa-search"></i></a></td>';
echo '<td><a href="'. site_url('labels/print/' . $qso->station_id) . '" class="btn btn-outline-success btn-sm"><i class="fas fa-print"></i></a></td>';
echo '<td><button class="btn btn-outline-success btn-sm printbutton" onclick="printat('.$qso->station_id.')"><i class="fas fa-print"></i></button></td>';
echo '</tr>';
} ?>
</tbody>

查看文件

@ -0,0 +1,4 @@
<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>

查看文件

@ -14,3 +14,28 @@ function saveDefault(id) {
}
});
}
function printat(stationid) {
$.ajax({
url: base_url + 'index.php/labels/startAtLabel',
type: 'post',
data: {'stationid': stationid},
success: function (html) {
BootstrapDialog.show({
title: 'Start printing at which label?',
size: BootstrapDialog.SIZE_NORMAL,
cssClass: 'qso-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
},
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}