danh123 Posted April 17, 2013 Share Posted April 17, 2013 Hello, I currently have a php inventory program running on a nitix server (linux) but I'm trying to move it all over to a windows 7 pro machine running wamp. I got pretty everything else to work fine but for the label printing. I have already enabled lpr. This works on linux: function label_print($label) { $Printer = ics_select('Employee, Printer', 'Address', "EmployeeId=$_SESSION[ICS_UserId] and LabelPrinter=PrinterId"); $pipe = popen("rlpr -H$Printer[Address]", "w"); fwrite($pipe, $label); pclose($pipe); } How do I get this to work on windows or is it not possible and if so, what are my options? Thanks! Dan Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 18, 2013 Share Posted April 18, 2013 Is $label a file resource when it is passed? Is ics_select() your own function? What does it do? popen() should be returning a resource with the (error) message from your command. Print out the result to see that message. Quote Link to comment Share on other sites More sharing options...
danh123 Posted April 18, 2013 Author Share Posted April 18, 2013 Please bare with me here. What I know about php is self taught and very basic. I didn't write the code myself but I just tweak the code where I can and when needed. The mysql database is called ics. There is a table called Printer which stores all the label printers info (unique id, name and ip address of every eltron/zebra printer attached to a print server). Each employee that prints labels selects the label printer they want to print to and the printer unique id is stored in the Employee table. I'm not getting any errors. I get the label printed response but the label just doesn't print. By my understanding, rlpr is not a recognized statement by windows? Here is the code from each file that has to do with the labels. stockline.php require 'ics.php'; require 'html.php'; require 'label.inc'; else if ( $_GET['print_label'] ) { label_print(label_part($_GET['StockId'])); html_status("Printed Label for Control #$_GET[StockId]"); $PartNumber = $_SESSION['ICS_PartNumber']; html.php // html_button() generates a "button" as a small HTML table. function html_button($url, $label) { ?> <table border="1" cellspacing="0" cellpadding="3"><tr class="menu"> <th><a class="menu" href="<?php echo $url; ?>"><?php echo $label; ?></a></th> </tr></table> <?php } ?> label.inc /* label.inc This file contains four label template functions: label_part($StockId), label_receiving($StockId, $Copies), label_shipping_address($SalesOrderId, $InvoiceId), label_shipping_part($SalesOrderId, $SOItemId, $qty) and one helper function: label_print($label) */ function label_print($label) { $Printer = ics_select('Employee, Printer', 'Address', "EmployeeId=$_SESSION[ICS_UserId] and LabelPrinter=PrinterId"); $pipe = popen("rlpr -H$Printer[Address]", "w"); fwrite($pipe, $label); pclose($pipe); } below in this file is the code that constructs the label with the information from mysql but I don't think any of that is the issue because it works fine on linux. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 18, 2013 Share Posted April 18, 2013 Assuming label_part() returns a file resource, the only problem I can guess is that you don't have rlpr installed on the windows machine. That certainly isn't a native function. Windows DOES have the native function, print: Prints a text file. PRINT [/D:device] [[drive:][path]filename[...]] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.