[Advanced Logbook] Now can print label from advanced logbook
这个提交包含在:
父节点
f13aa83254
当前提交
8dd3f290a7
共有 4 个文件被更改,包括 74 次插入 和 16 次删除
|
|
@ -87,22 +87,27 @@ class Labels extends CI_Controller {
|
|||
|
||||
}
|
||||
|
||||
public function printids() {
|
||||
$ids = xss_clean(json_decode($this->input->post('id')));
|
||||
$this->load->model('labels_model');
|
||||
$result = $this->labels_model->export_printrequestedids($ids);
|
||||
|
||||
$this->prepareLabel($result);
|
||||
}
|
||||
|
||||
public function print($station_id) {
|
||||
$clean_id = xss_clean($station_id);
|
||||
|
||||
$this->load->model('labels_model');
|
||||
$result = $this->labels_model->export_printrequested($clean_id);
|
||||
|
||||
$this->prepareLabel($result);
|
||||
}
|
||||
|
||||
function prepareLabel($qsos) {
|
||||
$this->load->model('labels_model');
|
||||
$label = $this->labels_model->getDefaultLabel();
|
||||
|
||||
// require_once('fpdf.php');
|
||||
// require('PDF_Label.php');
|
||||
// require_once APPPATH."/src/Label/PDF_Label.php";
|
||||
// require_once APPPATH."/src/Label/fpdf.php";
|
||||
|
||||
// Example of custom format
|
||||
// $pdf = new PDF_Label(array('paper-size'=>'A4', 'metric'=>'mm', 'marginLeft'=>1, 'marginTop'=>1, 'NX'=>2, 'NY'=>7, 'SpaceX'=>0, 'SpaceY'=>0, 'width'=>99, 'height'=>38, 'font-size'=>14));
|
||||
|
||||
try {
|
||||
if ($label) {
|
||||
$pdf = new PDF_Label(array(
|
||||
|
|
@ -138,12 +143,11 @@ class Labels extends CI_Controller {
|
|||
$pdf->SetFont($label->font);
|
||||
}
|
||||
|
||||
|
||||
if ($result->num_rows() > 0) {
|
||||
if ($qsos->num_rows() > 0) {
|
||||
if ($label->qsos == 1) {
|
||||
$this->makeOneQsoLabel($result->result(), $pdf);
|
||||
$this->makeOneQsoLabel($qsos->result(), $pdf);
|
||||
} else {
|
||||
$this->makeMultiQsoLabel($result->result(), $pdf, $label->qsos);
|
||||
$this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos);
|
||||
}
|
||||
} else {
|
||||
$this->session->set_flashdata('message', '0 QSOs found for print!');
|
||||
|
|
|
|||
|
|
@ -127,4 +127,16 @@ class Labels_model extends CI_Model {
|
|||
|
||||
return $query;
|
||||
}
|
||||
|
||||
function export_printrequestedids($ids) {
|
||||
$this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.name as station_country');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif');
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where_in('COL_PRIMARY_KEY', $ids);
|
||||
$this->db->order_by("COL_DXCC", "ASC");
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
|
@ -191,7 +191,10 @@
|
|||
<button type="button" class="btn btn-sm btn-success" id="sentElectronic">Sent Electronic</button>
|
||||
<button type="button" class="btn btn-sm btn-warning" id="dontSend">Not Sent</button>
|
||||
<button type="button" class="btn btn-sm btn-warning" id="notRequired">QSL Not Required</button>
|
||||
<button type="button" class="btn btn-sm btn-warning" id="receivedBureau">Received (bureau)</button>
|
||||
<button type="button" class="btn btn-sm btn-warning" id="receivedDirect">Received (direct)</button>
|
||||
<button type="button" class="btn btn-sm btn-info" id="exportAdif">Create ADIF</button>
|
||||
<button type="button" class="btn btn-sm btn-info" id="printLabel">Print Label</button>
|
||||
<button type="button" class="btn btn-sm btn-danger" id="deleteQsos">Delete</button>
|
||||
<span id="infoBox"></span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -348,6 +348,45 @@ $(document).ready(function () {
|
|||
$('#notRequired').click(function (event) {
|
||||
handleQsl('I','', 'notRequired');
|
||||
});
|
||||
$('#receivedBureau').click(function (event) {
|
||||
});
|
||||
$('#receivedDirect').click(function (event) {
|
||||
});
|
||||
|
||||
$('#printLabel').click(function (event) {
|
||||
var elements = $('#qsoList tbody input:checked');
|
||||
var nElements = elements.length;
|
||||
if (nElements == 0) {
|
||||
return;
|
||||
}
|
||||
$('#printLabel').prop("disabled", true);
|
||||
|
||||
var id_list=[];
|
||||
|
||||
elements.each(function() {
|
||||
let id = $(this).first().closest('tr').data('qsoID')
|
||||
id_list.push(id);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/labels/printids',
|
||||
type: 'post',
|
||||
data: {'id': JSON.stringify(id_list, null, 2) },
|
||||
xhr:function(){
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType= 'blob'
|
||||
return xhr;
|
||||
},
|
||||
success: function(data) {
|
||||
if(data){
|
||||
var file = new Blob([data], {type: 'application/pdf'});
|
||||
var fileURL = URL.createObjectURL(file);
|
||||
window.open(fileURL);
|
||||
}
|
||||
$('#printLabel').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#searchForm').on('reset', function(e) {
|
||||
setTimeout(function() {
|
||||
|
|
|
|||
正在加载…
在新工单中引用