Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. function closePrint() {
  2. document.body.removeChild(this.__container__);
  3. }
  4.  
  5. function setPrint() {
  6. this.contentWindow.__container__ = this;
  7. this.contentWindow.onbeforeunload = closePrint;
  8. this.contentWindow.onafterprint = closePrint;
  9. this.contentWindow.focus(); // Required for IE
  10. this.contentWindow.print();
  11. }
  12.  
  13. function printPage(sURL) {
  14. var oHiddFrame = document.createElement("iframe");
  15. oHiddFrame.onload = setPrint;
  16. oHiddFrame.style.visibility = "hidden";
  17. oHiddFrame.style.position = "fixed";
  18. oHiddFrame.style.right = "0";
  19. oHiddFrame.style.bottom = "0";
  20. oHiddFrame.src = sURL;
  21. document.body.appendChild(oHiddFrame);
  22. }
  23.  
  24. function doPrint(idlogp, setPrint) {
  25. setPrint = setPrint || "";
  26.  
  27. jenisPrinter = localStorage.hasanah_printer;
  28.  
  29. if (setPrint == "ink") jenisPrinter = "t";
  30. else if (setPrint == "dot") jenisPrinter = "m";
  31.  
  32. if (jenisPrinter==="m") {
  33.  
  34. $.post(URL_WEB + "print/lxs/PrintReceipt.php", { id: idlogp },
  35. function(data) {
  36. $('#hiddenPrintScript').html(data);
  37. //console.log(data);
  38. jsWebClientPrint.print('useDefaultPrinter=checked&printerName=' + $('#installedPrinterName').val());
  39. }
  40. );
  41. } else {
  42. // var url_print = URL_WEB + "print/ink/print.php?id=" + idlogp;
  43. // $("#dialog-print div").html('<iframe src="'+url_print+'" style="overflow: hidden; position: absolute; border: 0; width: 100%; height: 100%;"></iframe>');
  44. // show_dialog("dialog-print");
  45. // url = URL_WEB + "print/ink/print.php?id="+idlogp;
  46. window.open(URL_WEB + "print/ink/print.php?id="+idlogp,"_blank", "width=800, height=500");
  47. //printPage(url);
  48. }
  49. }
  50.  
  51. function klik_ganti_printer() {
  52. var selectedVal = "";
  53. var selected = $("#div_printer input[type='radio']:checked");
  54. if (selected.length > 0) {
  55. selectedVal = selected.val();
  56. }
  57.  
  58. localStorage.hasanah_printer = selectedVal;
  59.  
  60. if (localStorage.hasanah_printer == "m") {
  61. $("#config-printer").hide();
  62. } else if (localStorage.hasanah_printer == "i") {
  63. $("#config-printer").show();
  64. }
  65.  
  66. // close_charms();
  67. }
  68.  
  69. function doPrint2(idlogp = "", setPrint) {
  70. if (idlogp.length == 0) {
  71. idlogp = "HPAYTESTPRINT";
  72. }
  73.  
  74. setPrint = setPrint || "";
  75.  
  76. jenisPrinter = localStorage.hasanah_printer;
  77.  
  78. if (setPrint == "ink") jenisPrinter = "t";
  79. else if (setPrint == "dot") jenisPrinter = "m";
  80.  
  81. if (jenisPrinter==="m") {
  82.  
  83. $.post(URL_WEB + "print/lxs/PrintReceipt.php", { id: idlogp },
  84. function(data) {
  85. $('#hiddenPrintScript').html(data);
  86. //console.log(data);
  87. jsWebClientPrint.print('useDefaultPrinter=checked&printerName=' + $('#installedPrinterName').val());
  88. }
  89. );
  90. } else {
  91. var url_print = URL_WEB + "print/ink/print.php?id=" + idlogp;
  92. $("#dialog-print div").html('<iframe src="'+url_print+'" style="overflow: hidden; position: absolute; border: 0; width: 100%; height: 100%;"></iframe>');
  93. if (localStorage.hasanah_preview != 1) {
  94. setTimeout(function() {
  95. var dialog = $("#dialog-print").data('dialog');
  96. dialog.close();
  97. }, 1000);
  98. } else {
  99. show_dialog("dialog-print");
  100. }
  101. // url = URL_WEB + "print/ink/print.php?id="+idlogp;
  102. // window.open(URL_WEB + "print/ink/print.php?id="+idlogp,"_blank", "width=800, height=500");
  103. //printPage(url);
  104. }
  105. }
  106.  
  107. function set_auto_print() {
  108. var selectedVal = "";
  109. var selected = $("#auto-print:checked");
  110. if (selected.length > 0) {
  111. selectedVal = selected.val();
  112. }
  113. localStorage.hasanah_auto_print = selectedVal;
  114.  
  115. // close_charms();
  116. }
  117.  
  118. function set_preview() {
  119. var selectedVal = "";
  120. var selected = $("#preview:checked");
  121. if (selected.length > 0) {
  122. selectedVal = selected.val();
  123. }
  124. localStorage.hasanah_preview = selectedVal;
  125.  
  126. if (selectedVal != 1) {
  127. $("#auto-print").prop('checked', true);
  128. localStorage.hasanah_auto_print = 1;
  129. $("#auto-print").attr("disabled", true);
  130. } else {
  131. $("#auto-print").attr("disabled", false);
  132. }
  133. // close_charms();
  134. }
  135.  
  136. function klik_test_printer() {
  137. doPrint2();
  138.  
  139. close_charms();
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement