Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function closePrint() {
- document.body.removeChild(this.__container__);
- }
- function setPrint() {
- this.contentWindow.__container__ = this;
- this.contentWindow.onbeforeunload = closePrint;
- this.contentWindow.onafterprint = closePrint;
- this.contentWindow.focus(); // Required for IE
- this.contentWindow.print();
- }
- function printPage(sURL) {
- var oHiddFrame = document.createElement("iframe");
- oHiddFrame.onload = setPrint;
- oHiddFrame.style.visibility = "hidden";
- oHiddFrame.style.position = "fixed";
- oHiddFrame.style.right = "0";
- oHiddFrame.style.bottom = "0";
- oHiddFrame.src = sURL;
- document.body.appendChild(oHiddFrame);
- }
- function doPrint(idlogp, setPrint) {
- setPrint = setPrint || "";
- jenisPrinter = localStorage.hasanah_printer;
- if (setPrint == "ink") jenisPrinter = "t";
- else if (setPrint == "dot") jenisPrinter = "m";
- if (jenisPrinter==="m") {
- $.post(URL_WEB + "print/lxs/PrintReceipt.php", { id: idlogp },
- function(data) {
- $('#hiddenPrintScript').html(data);
- //console.log(data);
- jsWebClientPrint.print('useDefaultPrinter=checked&printerName=' + $('#installedPrinterName').val());
- }
- );
- } else {
- // var url_print = URL_WEB + "print/ink/print.php?id=" + idlogp;
- // $("#dialog-print div").html('<iframe src="'+url_print+'" style="overflow: hidden; position: absolute; border: 0; width: 100%; height: 100%;"></iframe>');
- // show_dialog("dialog-print");
- // url = URL_WEB + "print/ink/print.php?id="+idlogp;
- window.open(URL_WEB + "print/ink/print.php?id="+idlogp,"_blank", "width=800, height=500");
- //printPage(url);
- }
- }
- function klik_ganti_printer() {
- var selectedVal = "";
- var selected = $("#div_printer input[type='radio']:checked");
- if (selected.length > 0) {
- selectedVal = selected.val();
- }
- localStorage.hasanah_printer = selectedVal;
- if (localStorage.hasanah_printer == "m") {
- $("#config-printer").hide();
- } else if (localStorage.hasanah_printer == "i") {
- $("#config-printer").show();
- }
- // close_charms();
- }
- function doPrint2(idlogp = "", setPrint) {
- if (idlogp.length == 0) {
- idlogp = "HPAYTESTPRINT";
- }
- setPrint = setPrint || "";
- jenisPrinter = localStorage.hasanah_printer;
- if (setPrint == "ink") jenisPrinter = "t";
- else if (setPrint == "dot") jenisPrinter = "m";
- if (jenisPrinter==="m") {
- $.post(URL_WEB + "print/lxs/PrintReceipt.php", { id: idlogp },
- function(data) {
- $('#hiddenPrintScript').html(data);
- //console.log(data);
- jsWebClientPrint.print('useDefaultPrinter=checked&printerName=' + $('#installedPrinterName').val());
- }
- );
- } else {
- var url_print = URL_WEB + "print/ink/print.php?id=" + idlogp;
- $("#dialog-print div").html('<iframe src="'+url_print+'" style="overflow: hidden; position: absolute; border: 0; width: 100%; height: 100%;"></iframe>');
- if (localStorage.hasanah_preview != 1) {
- setTimeout(function() {
- var dialog = $("#dialog-print").data('dialog');
- dialog.close();
- }, 1000);
- } else {
- show_dialog("dialog-print");
- }
- // url = URL_WEB + "print/ink/print.php?id="+idlogp;
- // window.open(URL_WEB + "print/ink/print.php?id="+idlogp,"_blank", "width=800, height=500");
- //printPage(url);
- }
- }
- function set_auto_print() {
- var selectedVal = "";
- var selected = $("#auto-print:checked");
- if (selected.length > 0) {
- selectedVal = selected.val();
- }
- localStorage.hasanah_auto_print = selectedVal;
- // close_charms();
- }
- function set_preview() {
- var selectedVal = "";
- var selected = $("#preview:checked");
- if (selected.length > 0) {
- selectedVal = selected.val();
- }
- localStorage.hasanah_preview = selectedVal;
- if (selectedVal != 1) {
- $("#auto-print").prop('checked', true);
- localStorage.hasanah_auto_print = 1;
- $("#auto-print").attr("disabled", true);
- } else {
- $("#auto-print").attr("disabled", false);
- }
- // close_charms();
- }
- function klik_test_printer() {
- doPrint2();
- close_charms();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement