Merge branch 'dev' into secfix

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

查看文件

@ -1,4 +1,4 @@
<?php
<?php
require_once './src/Label/vendor/autoload.php';
use Cloudlog\Label\PDF_Label;
@ -12,7 +12,7 @@ class Labels extends CI_Controller {
|--------------------------------------------------------------------------
| Controller: Labels
|--------------------------------------------------------------------------
|
|
| This Controller handles all things Labels, creating, editing and printing
|
|
@ -31,8 +31,8 @@ class Labels extends CI_Controller {
|--------------------------------------------------------------------------
| Function: index
|--------------------------------------------------------------------------
|
| Nothing fancy just shows the main display of how many labels are waiting
|
| Nothing fancy just shows the main display of how many labels are waiting
| to be printed per station profile.
|
*/
@ -60,7 +60,7 @@ class Labels extends CI_Controller {
|--------------------------------------------------------------------------
| Function: create
|--------------------------------------------------------------------------
|
|
| Shows the form used to create a label type.
|
*/
@ -79,7 +79,7 @@ class Labels extends CI_Controller {
$this->load->view('interface_assets/footer');
}
else
{
{
$this->load->model('labels_model');
$this->labels_model->addLabel();
@ -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
@ -119,16 +119,16 @@ class Labels extends CI_Controller {
try {
if ($label) {
$pdf = new PDF_Label(array(
'paper-size' => $label->paper_type,
'metric' => $label->metric,
'marginLeft' => $label->marginleft,
'marginTop' => $label->margintop,
'NX' => $label->nx,
'NY' => $label->ny,
'SpaceX' => $label->spacex,
'SpaceY' => $label->spacey,
'width' => $label->width,
'height' => $label->height,
'paper-size' => $label->paper_type,
'metric' => $label->metric,
'marginLeft' => $label->marginleft,
'marginTop' => $label->margintop,
'NX' => $label->nx,
'NY' => $label->ny,
'SpaceX' => $label->spacex,
'SpaceY' => $label->spacey,
'width' => $label->width,
'height' => $label->height,
'font-size' => $label->font_size
));
} else {
@ -137,7 +137,7 @@ class Labels extends CI_Controller {
echo json_encode(array('message' => 'You need to create a label and set it to be used for print.'));
return;
} else {
$this->session->set_flashdata('error', 'You need to create a label and set it to be used for print.');
$this->session->set_flashdata('error', 'You need to create a label and set it to be used for print.');
redirect('labels');
}
}
@ -147,7 +147,7 @@ class Labels extends CI_Controller {
echo json_encode(array('message' => 'Something went wrong! The label could not be generated. Check label size and font size.'));
return;
} else {
$this->session->set_flashdata('error', 'Something went wrong! The label could not be generated. Check label size and font size.');
$this->session->set_flashdata('error', 'Something went wrong! The label could not be generated. Check label size and font size.');
redirect('labels');
}
}
@ -165,30 +165,41 @@ 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!');
$this->session->set_flashdata('message', '0 QSOs found for print!');
redirect('labels');
}
$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";
@ -273,14 +296,14 @@ class Labels extends CI_Controller {
public function updateLabel($id) {
$this->load->model('labels_model');
$this->labels_model->updateLabel($id);
$this->session->set_flashdata('message', 'Label was saved.');
$this->session->set_flashdata('message', 'Label was saved.');
redirect('labels');
}
public function delete($id) {
$this->load->model('labels_model');
$this->labels_model->deleteLabel($id);
$this->session->set_flashdata('warning', 'Label was deleted.');
$this->session->set_flashdata('warning', 'Label was deleted.');
redirect('labels');
}
@ -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'));

查看文件

@ -27,7 +27,7 @@
<div class="card-body">
<a href="<?php echo site_url('labels/create'); ?>" class="btn btn-outline-primary btn-sm">Create New Label Type</a>
<?php if ($labels) {
echo '<br/><br/>';?>
@ -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>
@ -105,4 +105,4 @@
</div>
</div>
</div>
</div>

查看文件

@ -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>

查看文件

@ -2,7 +2,7 @@ $('.labeltable').on('click', 'input[type="checkbox"]', function() {
var clickedlabelid = $(this).closest('tr').attr("class");
clickedlabelid = clickedlabelid.match(/\d+/)[0];
saveDefault(clickedlabelid);
$('input:checkbox').not(this).prop('checked', false);
$('input:checkbox').not(this).prop('checked', false);
});
function saveDefault(id) {
@ -13,4 +13,29 @@ function saveDefault(id) {
success: function (html) {
}
});
}
}
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();
}
}]
});
}
});
}