X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FPrint.pm;h=12aa107db92a0339f6cdb558dd4a6a53f16855a8;hb=6ca9b8f037f5ba87c26fd9379589505950ebfd13;hp=4ff242cecb6b9b2f6f2dee1b918f28444faf70ca;hpb=b195ac3625dc5a6cf6e25b44215b6b81d2291197;p=koha.git diff --git a/C4/Print.pm b/C4/Print.pm index 4ff242cecb..12aa107db9 100644 --- a/C4/Print.pm +++ b/C4/Print.pm @@ -1,5 +1,4 @@ -package C4::Print; #assumes C4/Print.pm - +package C4::Print; # Copyright 2000-2002 Katipo Communications # @@ -14,76 +13,92 @@ package C4::Print; #assumes C4/Print.pm # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -require Exporter; -#use C4::InterfaceCDK; +#use warnings; FIXME - Bug 2505 +use C4::Context; use vars qw($VERSION @ISA @EXPORT); -# set the version for version checking -$VERSION = 0.01; - -@ISA = qw(Exporter); -@EXPORT = qw(&remoteprint &printreserve &printslip); - -sub remoteprint { - my ($env,$items,$borrower)=@_; - #open (FILE,">/tmp/olwen"); - #print FILE "queue $env->{'queue'}"; - #close FILE; - #debug_msg($env,"In print"); - my $file=time; - my $queue = $env->{'queue'}; - if ($queue eq "" || $queue eq 'nulllp') { - open (PRINTER,">/tmp/kohaiss"); - } else { - open(PRINTER, "| lpr -P $queue") or die "Couldn't write to queue:$queue!\n"; - } -# print $queue; - #open (FILE,">/tmp/$file"); - my $i=0; - my $brdata = $env->{'brdata'}; - print PRINTER "Horowhenua Library Trust\r\n"; -# print PRINTER "$brdata->{'branchname'}\r\n"; - print PRINTER "Phone: 368-1953\r\n"; - print PRINTER "Fax: 367-9218\r\n"; - print PRINTER "Email: renewals\@library.org.nz\r\n\r\n\r\n"; - print PRINTER "$borrower->{'cardnumber'}\r\n"; - print PRINTER "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n"; - while ($items->[$i]){ -# print $i; - my $itemdata = $items->[$i]; - print PRINTER "$i $itemdata->{'title'}\r\n"; - print PRINTER "$itemdata->{'barcode'}"; - print PRINTER " "x15; - print PRINTER "$itemdata->{'date_due'}\r\n"; - $i++; - } - print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; - if ($env->{'printtype'} eq "docket"){ - #print chr(27).chr(105); - } - close PRINTER; - #system("lpr /tmp/$file"); +BEGIN { + # set the version for version checking + $VERSION = 3.07.00.049; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw(&NetworkPrint); } +=head1 NAME + +C4::Print - Koha module dealing with printing + +=head1 SYNOPSIS + + use C4::Print; + +=head1 DESCRIPTION + +The functions in this module handle sending text to a printer. + +=head1 FUNCTIONS + +=head2 NetworkPrint + + &NetworkPrint($text) + +Queue some text for printing on the selected branch printer + +=cut -sub printslip { - my($env, $slip)=@_; - 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"; - } - print PRINTER $slip; - close PRINTER; +sub NetworkPrint { + my ($text) = @_; + +# FIXME - It'd be nifty if this could generate pretty PostScript. + + my $queue = ''; + + # FIXME - If 'queue' is undefined or empty, then presumably it should + # mean "use the default queue", whatever the default is. Presumably + # the default depends on the physical location of the machine. + # FIXME - Perhaps "print to file" should be a supported option. Just + # set the queue to "file" (or " file", if real queues aren't allowed + # to have spaces in them). Or perhaps if $queue eq "" and + # $env->{file} ne "", then that should mean "print to $env->{file}". + if ( $queue eq "" || $queue eq 'nulllp' ) { + return; + #open( PRINTER, ">/tmp/kohaiss" ); + } + else { + + # FIXME - This assumes that 'lpr' exists, and works as expected. + # This is a reasonable assumption, but only because every other + # printing package has a wrapper script called 'lpr'. It'd still + # be better to be able to customize this. + open( PRINTER, "| lpr -P $queue > /dev/null" ) + or die "Couldn't write to queue:$queue!\n"; + } + + # print $queue; + #open (FILE,">/tmp/$file"); + print PRINTER $text; + print PRINTER "\r\n" x 7 ; + close PRINTER; + + #system("lpr /tmp/$file"); } -END { } # module clean-up code here (global destructor) - - +1; +__END__ + +=head1 AUTHOR + +Koha Development Team + +=head1 SEE ALSO + +C4::Circulation::Circ2(3) + +=cut