Merge pull request #2354 from AndreasK79/label_offset_advanced_logbook
[Advanced Logbook] Added dialog to set label offset when printing labels
这个提交包含在:
		
						当前提交
						57a5e2ae85
					
				
					共有  4 个文件被更改,包括 80 次插入 和 38 次删除
				
			
		|  | @ -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'); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -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); | ||||
| 		}, | ||||
| 	}); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		正在加载…
	
		在新工单中引用