This is a question on printing to a Zebra printer. It is really an FTP server that takes a text file with rows of printer label strings. The labels printed fine. In PHP I open the text file to write, I pull the sql and write a row to the text file, then it iterates to another row in the while loop. But then I had to add an if/else and a 2nd function to print two labels in the case of a preferred item so I added a second function. The labels are nearly identical with only a different variable for the 2nd function.
Here is my code
while ($row = mysql_fetch_array($result)) {
$item_id=$item_id;
$description=$row['description'];
$upc=$row['upc'];
$pref_ind=$row['pref_ind'];
$pref_item_id=$row['pref_item_id'];
$print_flag=$row['print_flag'];
if ($pref_ind=='Y' || $pref_ind==''){
make_label_pref_ind($fp,$item_id,$description,$upc,$ndc);
}else{
make_label($fp,$item_id,$description,$upc,$ndc);
make_label_pref_item($fp,$pref_item,$description,$upc,$ndc);}
}//while end
fclose($fp);
Before it worked with only one function. But now if there is a preferred item they need the preferred item id on the label and one with out it. The pref_ind is a flag. If that flag is Y then only one label is written to the text file and if the flag is N then 2 labels need to be printed.
So this works as expected with the flag as Y but with the flag as N the Zebra printer skips a few spaces and doesn't get the bar code printed. THere is nothing different about the text file and how it is written to in the last function but the make_label_pref_item() function when it writes to the text file the bar code printing starts in the middle of the label instead of at the beginning.
My question is there a way to force the cursor to start at the beginning of the next
line? I don't know why it isn't. It could be the label template but it does work when I don't try to do two functions, one right after the other.
thanks,
sorry but I forgot to show you the template but all it does it write printer strings to make one label.
function make_label($fp, $item_id,$description,$upc,$ndc_uom){
$item_id= $item_id;
$description1=substr($description,0,30);
$description2=substr($description,30,30);
$upc=$upc;
$ndc_uom=$ndc_uom;
//print 1 label with with regular item id
fwrite($fp,"^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR5,5^MD10^LRN^CI0^XZ");
fwrite($fp,"^XA");
fwrite($fp,"^MMT");
fwrite($fp, "^LL0203");
fwrite($fp,"^PW457");
fwrite($fp,"^LS0");
fwrite($fp,"^FT7,121^A0N,28,28^FH\^FD$description1^FS");
fwrite($fp,"^FT7,155^A0N,28,28^FH\^FD$description2^FS");
fwrite($fp,"^BY2,3,67^FT7,72^BCN,,Y,N");
fwrite($fp,"^FD>:$item_id^FS");
fwrite($fp,"^FT6,191^A0N,28,28^FH\^FH^FDUPC:$upc^FS");
fwrite($fp,"^FT313,191^A0N,28,28^FH\^FDUOM:$ndc^FS");
fwrite($fp,"^PQ1,0,1,Y^XZ");
// fwrite($fp,"^MF");
fwrite($fp,"^PH");