mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-23 10:08:38 +00:00
[Advanced Logbook] Added dialog to set label offset when printing labels
This commit is contained in:
parent
f4feaea23b
commit
e3789ae1be
@ -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) {
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
4
application/views/logbookadvanced/startatform.php
Normal file
4
application/views/logbookadvanced/startatform.php
Normal file
@ -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>
|
@ -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);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user