X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FPrint.pm;h=c0b37c8a12f992db66fe525536773d52f94e90d0;hb=bb35b608282e670e1bb07bf4cea324fc16b6ec90;hp=54dc13518a4e450c89ff38ddebc3bafa7f490a3f;hpb=d00793f8a18e58c1032eb04a5c796a08eb38d4cb;p=koha_gimpoz diff --git a/C4/Print.pm b/C4/Print.pm index 54dc13518a..c0b37c8a12 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,18 +13,23 @@ 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; +BEGIN { + # set the version for version checking + $VERSION = 3.01; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw(&printslip); +} =head1 NAME @@ -41,126 +45,86 @@ The functions in this module handle sending text to a printer. =head1 FUNCTIONS -=over 2 - =cut -@ISA = qw(Exporter); -@EXPORT = qw(&remoteprint &printslip); +=for comment + my $slip = <<"EOF"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Date: $todaysdate; -=item remoteprint +ITEM RESERVED: +$itemdata->{'title'} ($itemdata->{'author'}) +barcode: $itemdata->{'barcode'} - &remoteprint($env, $items, $borrower); +COLLECT AT: $branchname -Prints the list of items in C<$items> to a printer. +BORROWER: +$bordata->{'surname'}, $bordata->{'firstname'} +card number: $bordata->{'cardnumber'} +Phone: $bordata->{'phone'} +$bordata->{'streetaddress'} +$bordata->{'suburb'} +$bordata->{'town'} +$bordata->{'emailaddress'} -C<$env> is a reference-to-hash. C<$env-E{queue}> specifies the -queue to print to; if it is empty or has the special value C, -C<&remoteprint> will print to the file F. -C<$borrower> is a reference-to-hash giving information about a patron. -This may be gotten from C<&getpatroninformation>. The patron's name -will be printed in the output. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +EOF +=cut -C<$items> is a reference-to-list, where each element is a -reference-to-hash describing a borrowed item. C<$items> may be gotten -from C<¤tissues>. +=head2 printslip -=cut -#' -# FIXME - It'd be nifty if this could generate pretty PostScript. -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; # FIXME - Not used - my $queue = $env->{'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') { - 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") or die "Couldn't write to queue:$queue!\n"; - } -# print $queue; - #open (FILE,">/tmp/$file"); - my $i=0; - my $brdata = $env->{'brdata'}; # FIXME - Not used - # FIXME - This is HLT-specific. Put this stuff in a customizable - # site-specific file somewhere. - 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"; - # FIXME - Use for ($i = 0; $items->[$i]; $i++) - # Or better yet, foreach $item (@{$items}) - while ($items->[$i]){ -# print $i; - my $itemdata = $items->[$i]; - # FIXME - This is just begging for a Perl format. - 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"); -} + &printslip($slip) -=item printslip +print a slip for the given $borrowernumber and $branchcode - &printslip($env, $text) +=cut -Prints the string C<$text> to a printer. C<$env-E{queue}> -specifies the queue to print to. +sub printslip ($) { + my ($slip) = @_; -If C<$env-E{queue}> is empty or set to C, C<&printslip> -will print to the file F. + return unless ( C4::Context->boolean_preference('printcirculationslips') ); -=cut -#' -# FIXME - There's also a &printslip in circ/circulation.pl -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; -} +# FIXME - It'd be nifty if this could generate pretty PostScript. -END { } # module clean-up code here (global destructor) + 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"); +} 1; __END__ -=back - =head1 AUTHOR -Koha Developement team +Koha Development Team =head1 SEE ALSO