From 5341dc01729420ccead482bed44105ab29b5e1ef Mon Sep 17 00:00:00 2001 From: rangi Date: Fri, 16 Aug 2002 22:50:05 +0000 Subject: [PATCH] Merging across print.pm fixes bug 80 missing printslip routine --- C4/Print.pm | 72 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/C4/Print.pm b/C4/Print.pm index d8f9eb9869..184dabe42d 100644 --- a/C4/Print.pm +++ b/C4/Print.pm @@ -28,7 +28,8 @@ use vars qw($VERSION @ISA @EXPORT); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&remoteprint &printreserve); +@EXPORT = qw(&remoteprint &printreserve &printslip); + sub remoteprint { my ($env,$items,$borrower)=@_; @@ -72,32 +73,57 @@ sub remoteprint { } sub printreserve { - my($env,$resrec,$rbordata,$itemdata)=@_; + my($env, $branchname, $bordata, $itemdata)=@_; my $file=time; - my $queue = $env->{'queue'}; - #if ($queue eq "") { + my $printer = $env->{'printer'}; + if ($printer eq "" || $printer eq 'nulllp') { + open (PRINTER,">>/tmp/kohares"); + } else { + open (PRINTER, "| lpr -P $printer") or die "Couldn't write to queue:$!\n"; + } + my @da = localtime(time()); + my $todaysdate = "$da[2]:$da[1] $da[3]/$da[4]/$da[5]"; + +#(1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]); + my $slip = <<"EOF"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Date: $todaysdate; + +ITEM RESERVED: +$itemdata->{'title'} ($itemdata->{'author'}) +barcode: $itemdata->{'barcode'} + +COLLECT AT: $branchname + +BORROWER: +$bordata->{'surname'}, $bordata->{'firstname'} +card number: $bordata->{'cardnumber'} +Phone: $bordata->{'phone'} +$bordata->{'streetaddress'} +$bordata->{'suburb'} +$bordata->{'town'} +$bordata->{'emailaddress'} + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +EOF + print PRINTER $slip; + close PRINTER; + return $slip; +} + +sub printslip { + my($env, $slip)=@_; + my $printer = $env->{'printer'}; + if ($printer eq "" || $printer eq 'nulllp') { open (PRINTER,">/tmp/kohares"); - #} else { - # open (PRINTER, "| lpr -P $queue") or die "Couldn't write to queue:$!\n"; - #} - print PRINTER "Collect at $resrec->{'branchcode'}\r\n\r\n"; - print PRINTER "$rbordata->{'surname'}; $rbordata->{'firstname'}\r\n"; - print PRINTER "$rbordata->{'cardnumber'}\r\n"; - print PRINTER "Phone: $rbordata->{'phone'}\r\n"; - print PRINTER "$rbordata->{'streetaddress'}\r\n"; - print PRINTER "$rbordata->{'suburb'}\r\n"; - print PRINTER "$rbordata->{'town'}\r\n"; - print PRINTER "$rbordata->{'emailaddress'}\r\n\r\n"; - print PRINTER "$itemdata->{'barcode'}\r\n"; - print PRINTER "$itemdata->{'title'}\r\n"; - print PRINTER "$itemdata->{'author'}"; - print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; - if ($env->{'printtype'} eq "docket"){ - #print chr(27).char(105); - } + } else { + open (PRINTER, "| lpr -P $printer") or die "Couldn't write to queue:$!\n"; + } + print PRINTER $slip; close PRINTER; - #system("lpr /tmp/$file"); } + END { } # module clean-up code here (global destructor) -- 2.39.5