Merge branch 'dev' into secfix
这个提交包含在:
当前提交
61b55a2e3d
共有 6 个文件被更改,包括 99 次插入 和 36 次删除
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once './src/Label/vendor/autoload.php';
|
require_once './src/Label/vendor/autoload.php';
|
||||||
use Cloudlog\Label\PDF_Label;
|
use Cloudlog\Label\PDF_Label;
|
||||||
|
|
@ -12,7 +12,7 @@ class Labels extends CI_Controller {
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Controller: Labels
|
| Controller: Labels
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| This Controller handles all things Labels, creating, editing and printing
|
| This Controller handles all things Labels, creating, editing and printing
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ class Labels extends CI_Controller {
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Function: index
|
| 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.
|
| to be printed per station profile.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,7 +60,7 @@ class Labels extends CI_Controller {
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Function: create
|
| Function: create
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Shows the form used to create a label type.
|
| Shows the form used to create a label type.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
@ -79,7 +79,7 @@ class Labels extends CI_Controller {
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('interface_assets/footer');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->load->model('labels_model');
|
$this->load->model('labels_model');
|
||||||
$this->labels_model->addLabel();
|
$this->labels_model->addLabel();
|
||||||
|
|
||||||
|
|
@ -98,19 +98,19 @@ class Labels extends CI_Controller {
|
||||||
|
|
||||||
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'));
|
||||||
$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);
|
$this->prepareLabel($result, false, $offset);
|
||||||
} else {
|
} else {
|
||||||
redirect('labels');
|
redirect('labels');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareLabel($qsos, $jscall = false) {
|
function prepareLabel($qsos, $jscall = false, $offset = 1) {
|
||||||
$this->load->model('labels_model');
|
$this->load->model('labels_model');
|
||||||
$label = $this->labels_model->getDefaultLabel();
|
$label = $this->labels_model->getDefaultLabel();
|
||||||
$label->font='DejaVuSans'; // Fix font to DejaVuSans
|
$label->font='DejaVuSans'; // Fix font to DejaVuSans
|
||||||
|
|
@ -119,16 +119,16 @@ class Labels extends CI_Controller {
|
||||||
try {
|
try {
|
||||||
if ($label) {
|
if ($label) {
|
||||||
$pdf = new PDF_Label(array(
|
$pdf = new PDF_Label(array(
|
||||||
'paper-size' => $label->paper_type,
|
'paper-size' => $label->paper_type,
|
||||||
'metric' => $label->metric,
|
'metric' => $label->metric,
|
||||||
'marginLeft' => $label->marginleft,
|
'marginLeft' => $label->marginleft,
|
||||||
'marginTop' => $label->margintop,
|
'marginTop' => $label->margintop,
|
||||||
'NX' => $label->nx,
|
'NX' => $label->nx,
|
||||||
'NY' => $label->ny,
|
'NY' => $label->ny,
|
||||||
'SpaceX' => $label->spacex,
|
'SpaceX' => $label->spacex,
|
||||||
'SpaceY' => $label->spacey,
|
'SpaceY' => $label->spacey,
|
||||||
'width' => $label->width,
|
'width' => $label->width,
|
||||||
'height' => $label->height,
|
'height' => $label->height,
|
||||||
'font-size' => $label->font_size
|
'font-size' => $label->font_size
|
||||||
));
|
));
|
||||||
} else {
|
} 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.'));
|
echo json_encode(array('message' => 'You need to create a label and set it to be used for print.'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} 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');
|
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.'));
|
echo json_encode(array('message' => 'Something went wrong! The label could not be generated. Check label size and font size.'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} 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');
|
redirect('labels');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,30 +165,41 @@ 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);
|
$this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset);
|
||||||
} else {
|
} else {
|
||||||
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos);
|
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->session->set_flashdata('message', '0 QSOs found for print!');
|
$this->session->set_flashdata('message', '0 QSOs found for print!');
|
||||||
redirect('labels');
|
redirect('labels');
|
||||||
}
|
}
|
||||||
$pdf->Output();
|
$pdf->Output();
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos) {
|
function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset) {
|
||||||
$text = '';
|
$text = '';
|
||||||
$current_callsign = '';
|
$current_callsign = '';
|
||||||
$current_sat = '';
|
$current_sat = '';
|
||||||
|
$current_sat_mode = '';
|
||||||
|
$current_sat_bandrx = '';
|
||||||
$qso_data = [];
|
$qso_data = [];
|
||||||
|
if ($offset !== 1) {
|
||||||
|
for ($i = 1; $i < $offset; $i++) {
|
||||||
|
$pdf->Add_Label('');
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach($qsos as $qso) {
|
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)) {
|
if (!empty($qso_data)) {
|
||||||
$this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos);
|
$this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos);
|
||||||
$qso_data = [];
|
$qso_data = [];
|
||||||
}
|
}
|
||||||
$current_callsign = $qso->COL_CALL;
|
$current_callsign = $qso->COL_CALL;
|
||||||
$current_sat = $qso->COL_SAT_NAME;
|
$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[] = [
|
$qso_data[] = [
|
||||||
|
|
@ -198,7 +209,8 @@ class Labels extends CI_Controller {
|
||||||
'rst' => $qso->COL_RST_SENT,
|
'rst' => $qso->COL_RST_SENT,
|
||||||
'mygrid' => $qso->station_gridsquare,
|
'mygrid' => $qso->station_gridsquare,
|
||||||
'sat' => $qso->COL_SAT_NAME,
|
'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
|
'qsl_recvd' => $qso->COL_QSL_RCVD
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -207,8 +219,12 @@ class Labels extends CI_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// New begin
|
// 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) {
|
function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label) {
|
||||||
|
|
||||||
$tableData = [];
|
$tableData = [];
|
||||||
$count_qso = 0;
|
$count_qso = 0;
|
||||||
$qso=[];
|
$qso=[];
|
||||||
|
|
@ -225,6 +241,7 @@ class Labels extends CI_Controller {
|
||||||
$tableData[] = $rowData;
|
$tableData[] = $rowData;
|
||||||
$count_qso++;
|
$count_qso++;
|
||||||
|
|
||||||
|
|
||||||
if($count_qso == $qso_per_label){
|
if($count_qso == $qso_per_label){
|
||||||
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso);
|
$this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso);
|
||||||
$tableData = []; // reset the data
|
$tableData = []; // reset the data
|
||||||
|
|
@ -247,7 +264,13 @@ class Labels extends CI_Controller {
|
||||||
$text .= "\n";
|
$text .= "\n";
|
||||||
$text .= $builder->renderTable();
|
$text .= $builder->renderTable();
|
||||||
if($qso['sat'] != "") {
|
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 .= "\nThanks for the QSO".($numofqsos>1 ? 's' : '');
|
||||||
$text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";
|
$text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL";
|
||||||
|
|
@ -273,14 +296,14 @@ class Labels extends CI_Controller {
|
||||||
public function updateLabel($id) {
|
public function updateLabel($id) {
|
||||||
$this->load->model('labels_model');
|
$this->load->model('labels_model');
|
||||||
$this->labels_model->updateLabel($id);
|
$this->labels_model->updateLabel($id);
|
||||||
$this->session->set_flashdata('message', 'Label was saved.');
|
$this->session->set_flashdata('message', 'Label was saved.');
|
||||||
redirect('labels');
|
redirect('labels');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
$this->load->model('labels_model');
|
$this->load->model('labels_model');
|
||||||
$this->labels_model->deleteLabel($id);
|
$this->labels_model->deleteLabel($id);
|
||||||
$this->session->set_flashdata('warning', 'Label was deleted.');
|
$this->session->set_flashdata('warning', 'Label was deleted.');
|
||||||
redirect('labels');
|
redirect('labels');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,4 +313,8 @@ class Labels extends CI_Controller {
|
||||||
$this->labels_model->saveDefaultLabel($id);
|
$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'] = (string)$xml->Callsign->fname;
|
||||||
}
|
}
|
||||||
$data['name'] = trim($data['name']);
|
$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['city'] = (string)$xml->Callsign->addr2;
|
||||||
$data['lat'] = (string)$xml->Callsign->lat;
|
$data['lat'] = (string)$xml->Callsign->lat;
|
||||||
$data['long'] = (string)$xml->Callsign->lon;
|
$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_DXCC", "ASC");
|
||||||
$this->db->order_by("COL_CALL", "ASC");
|
$this->db->order_by("COL_CALL", "ASC");
|
||||||
$this->db->order_by("COL_SAT_NAME", "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_TIME_ON", "ASC");
|
||||||
$this->db->order_by("COL_MODE", "ASC");
|
$this->db->order_by("COL_MODE", "ASC");
|
||||||
$query = $this->db->get($this->config->item('table_name'));
|
$query = $this->db->get($this->config->item('table_name'));
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a href="<?php echo site_url('labels/create'); ?>" class="btn btn-outline-primary btn-sm">Create New Label Type</a>
|
<a href="<?php echo site_url('labels/create'); ?>" class="btn btn-outline-primary btn-sm">Create New Label Type</a>
|
||||||
|
|
||||||
|
|
||||||
<?php if ($labels) {
|
<?php if ($labels) {
|
||||||
echo '<br/><br/>';?>
|
echo '<br/><br/>';?>
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
echo '<td>' . $qso->station_gridsquare . '</td>';
|
echo '<td>' . $qso->station_gridsquare . '</td>';
|
||||||
echo '<td>' . $qso->count . '</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('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>';
|
echo '</tr>';
|
||||||
} ?>
|
} ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -105,4 +105,4 @@
|
||||||
</div>
|
</div>
|
||||||
</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");
|
var clickedlabelid = $(this).closest('tr').attr("class");
|
||||||
clickedlabelid = clickedlabelid.match(/\d+/)[0];
|
clickedlabelid = clickedlabelid.match(/\d+/)[0];
|
||||||
saveDefault(clickedlabelid);
|
saveDefault(clickedlabelid);
|
||||||
$('input:checkbox').not(this).prop('checked', false);
|
$('input:checkbox').not(this).prop('checked', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function saveDefault(id) {
|
function saveDefault(id) {
|
||||||
|
|
@ -13,4 +13,29 @@ function saveDefault(id) {
|
||||||
success: function (html) {
|
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();
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用