i'm trying use a Java plugin to print to raw print to a ticket printer from a browser. I've written a test program in HTML and Javascript which is working ok, but now i'm trying to transfer the code to a php script for printing tickets in a bigger app. I'm gettting this kind of error in firefox debug whenever i call a function from the app. "TypeError: qz.findPrinter is not a function".
I changed the extension on the original test program to .php from .html and i'm recieving error there too now.
Any functions from the the java begin with "qz."
Here's the plugin for reference https://code.google.com/p/jzebra/wiki/TutorialWebApplet
I figure it's something i don't know about php as it works ok as a .html file but I've included the whole script anyway. The php is running from xampp.
Thank you for you time.
<html>
<head><title>Receipt Test</title>
<script type="text/javascript" src="js/deployJava.js"></script>
<script type="text/javascript">
deployQZ();
function deployQZ() {
var attributes = {id: "qz", code:'qz.PrintApplet.class',
archive:'qz-print.jar', width:1, height:1};
var parameters = {jnlp_href: 'qz-print_jnlp.jnlp',
cache_option:'plugin', disable_logging:'false',
initial_focus:'false'};
if (deployJava.versionCheck("1.7+") == true) {}
else if (deployJava.versionCheck("1.6+") == true) {
attributes['archive'] = 'jre6/qz-print.jar';
parameters['jnlp_href'] = 'jre6/qz-print_jnlp.jnlp';
}
deployJava.runApplet(attributes, parameters, '1.5');
}
function countSpace(product, price, section) {
var spaceNeeded = (section - product.length - price.toString().length);
var spaces = "";
for(i=0; i < spaceNeeded; i++) {
spaces += " ";
}
return (product + spaces + price);
}
function findPrinter() {
// Searches for locally installed printer with "zebra" in the name
qz.findPrinter("zebra");
// Hint: Carriage Return = , New Line =
, Escape Double Quotes= \"
var ticketTime = new Date();
var singleLine = "
------------------------------------------
";
var doubleLine = "
==========================================
";
var product = ["Mirdan Tuzlama", "Suckuklu Pide" ];
var price = [8.00, 8.00];
var prodCharLength = 37;
var finCharLength = 42;
var subTotal = {name:"Subtotal", value:0};
for(i=0;i<product.length;i++) {
subTotal.value += price[i];
}
var tax = {name:"Tax", value:((20/100)*subTotal.value)};
var total = {name:"Total", value:(subTotal.value-tax.value)};
var ticketEnd = " Thank You
";
var productSec = "";
tax.value = 0 - tax.value;
for(j=0;j<product.length;j++) {
var priceloop = price[i];
productSec += (" - 1 " + countSpace(product[j], price[j],prodCharLength));
if (j<=(product.length-2)){
productSec += "
"
}
}
qz.append("
Date:" + ticketTime.getDate() + "/"
+ (ticketTime.getMonth()+1) + "/"
+ ticketTime.getFullYear()
+ "
Time:" + ticketTime.getHours() + ":"
+ ticketTime.getMinutes()
+ "
Table: B10
Ticket No:2"
//+ singleLine + " - 1 " + product1 +" 8.00
- 1 " + product1 +" 8:00"
+ singleLine + productSec
+ doubleLine + countSpace(subTotal.name, subTotal.value,finCharLength)
+ '
' + countSpace(tax.name, tax.value,finCharLength)
+ '
' + countSpace(total.name, total.value,finCharLength)
+ doubleLine + ticketEnd);
qz.print();
}
</script>
<body>
<input type="button" onClick="findPrinter()" value="Print ESCP" /><br />
</body>