X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FPrint.pm;h=c0b37c8a12f992db66fe525536773d52f94e90d0;hb=90d13965d321d12cf2984a18c4bbcdde210526ab;hp=26b388317ee0f999b79a3c6efe8d9c7540043b93;hpb=3b07c5bf30e1243f93f9e52e8764c8eaf0a9cbaf;p=koha_gimpoz diff --git a/C4/Print.pm b/C4/Print.pm index 26b388317e..c0b37c8a12 100644 --- a/C4/Print.pm +++ b/C4/Print.pm @@ -1,120 +1,133 @@ -package C4::Print; #asummes C4/Print.pm +package C4::Print; + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -require Exporter; -#use C4::InterfaceCDK; - -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - -# set the version for version checking -$VERSION = 0.01; - -@ISA = qw(Exporter); -@EXPORT = qw(&remoteprint &printreserve); -%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], - -# your exported package globals go here, -# as well as any optionally exported functions - -@EXPORT_OK = qw($Var1 %Hashit); - - -# non-exported package globals go here -use vars qw(@more $stuff); - -# initalize package globals, first exported ones - -my $Var1 = ''; -my %Hashit = (); - - -# then the others (which are still accessible as $Some::Module::stuff) -my $stuff = ''; -my @more = (); - -# all file-scoped lexicals must be created before -# the functions below that use them. - -# file-private lexicals go here -my $priv_var = ''; -my %secret_hash = (); - -# here's a file-private function as a closure, -# callable as &$priv_func; it cannot be prototyped. -my $priv_func = sub { - # stuff goes here. - }; - -# make all your functions, whether exported or not; - -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 "") { - open (PRINTER,">/tmp/kohaiss"); - } else { - open(PRINTER, "| lpr -P $queue") or die "Couldn't write to 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"); +#use warnings; FIXME - Bug 2505 +use C4::Context; + +use vars qw($VERSION @ISA @EXPORT); + +BEGIN { + # set the version for version checking + $VERSION = 3.01; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw(&printslip); } -sub printreserve { - my($env,$resrec,$rbordata,$itemdata)=@_; - my $file=time; - my $queue = $env->{'queue'}; - #if ($queue eq "") { - 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); - } - close PRINTER; - #system("lpr /tmp/$file"); +=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 + +=cut + +=for comment + 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 +=cut + +=head2 printslip + + &printslip($slip) + +print a slip for the given $borrowernumber and $branchcode + +=cut + +sub printslip ($) { + my ($slip) = @_; + + return unless ( C4::Context->boolean_preference('printcirculationslips') ); + +# 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 $slip; + 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