Merge pull request #2354 from AndreasK79/label_offset_advanced_logbook

[Advanced Logbook] Added dialog to set label offset when printing labels
pull/2355/head
Peter Goodhall 2023-08-01 10:56:58 +01:00 zatwierdzone przez GitHub
commit 57a5e2ae85
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 80 dodań i 38 usunięć

Wyświetl plik

@ -90,10 +90,11 @@ class Labels extends CI_Controller {
public function printids() {
$ids = xss_clean(json_decode($this->input->post('id')));
$offset = xss_clean($this->input->post('startat'));
$this->load->model('labels_model');
$result = $this->labels_model->export_printrequestedids($ids);
$this->prepareLabel($result, true);
$this->prepareLabel($result, true, $offset);
}
public function print($station_id) {

Wyświetl plik

@ -221,4 +221,8 @@ class Logbookadvanced extends CI_Controller {
header("Content-Type: application/json");
print json_encode($q);
}
public function startAtLabel() {
$this->load->view('logbookadvanced/startatform');
}
}

Wyświetl plik

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

Wyświetl plik

@ -464,48 +464,28 @@ $(document).ready(function () {
}
$('#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',
url: base_url + 'index.php/logbookadvanced/startAtLabel',
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);
}
$.each(id_list, function(k, v) {
unselectQsoID(this);
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();
}
}]
});
$('#printLabel').prop("disabled", false);
},
error: function (data) {
BootstrapDialog.alert({
title: 'ERROR',
message: 'Something went wrong with label print. Go to labels and check if you have defined a label, and that it is set for print!',
type: BootstrapDialog.TYPE_DANGER,
closable: false,
draggable: false,
callback: function (result) {
}
});
$.each(id_list, function(k, v) {
unselectQsoID(this);
});
$('#printLabel').prop("disabled", false);
},
}
});
});
@ -591,3 +571,56 @@ $(document).ready(function () {
$('#searchForm').submit();
});
function printlabel() {
var id_list=[];
var elements = $('#qsoList tbody input:checked');
var nElements = elements.length;
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),
'startat': $('#startat').val()
},
xhr:function(){
var xhr = new XMLHttpRequest();
xhr.responseType= 'blob'
return xhr;
},
success: function(data) {
$.each(BootstrapDialog.dialogs, function(id, dialog){
dialog.close();
});
if(data){
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
}
$.each(id_list, function(k, v) {
unselectQsoID(this);
});
$('#printLabel').prop("disabled", false);
},
error: function (data) {
BootstrapDialog.alert({
title: 'ERROR',
message: 'Something went wrong with label print. Go to labels and check if you have defined a label, and that it is set for print!',
type: BootstrapDialog.TYPE_DANGER,
closable: false,
draggable: false,
callback: function (result) {
}
});
$.each(id_list, function(k, v) {
unselectQsoID(this);
});
$('#printLabel').prop("disabled", false);
},
});
}