# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id$
-
use strict;
-require Exporter;
-
use C4::Context;
-use C4::Circulation::Circ2;
+use C4::Circulation;
+use C4::Members;
+use C4::Dates qw(format_date);
use vars qw($VERSION @ISA @EXPORT);
-# set the version for version checking
-# set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g;
- shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
-};
+BEGIN {
+ # set the version for version checking
+ $VERSION = 3.01;
+ require Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(&remoteprint &printreserve &printslip);
+}
=head1 NAME
=over 2
-=cut
-
-@ISA = qw(Exporter);
-@EXPORT = qw(&remoteprint &printreserve &printslip);
-
=item remoteprint
- &remoteprint($env, $items, $borrower);
+ &remoteprint($items, $borrower);
Prints the list of items in C<$items> to a printer.
-C<$env> is a reference-to-hash. C<$env-E<gt>{queue}> specifies the
-queue to print to; if it is empty or has the special value C<nulllp>,
-C<&remoteprint> will print to the file F</tmp/kohaiss>.
-
C<$borrower> is a reference-to-hash giving information about a patron.
-This may be gotten from C<&getpatroninformation>. The patron's name
+This may be gotten from C<&GetMemberDetails>. The patron's name
will be printed in the output.
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>.
+from C<&GetBorrowerIssues>.
=cut
-#'
# FIXME - It'd be nifty if this could generate pretty PostScript.
-sub remoteprint {
- my ( $env, $items, $borrower ) = @_;
+sub remoteprint ($$) {
+ my ($items, $borrower) = @_;
(return)
unless ( C4::Context->boolean_preference('printcirculationslips') );
- my $queue = $env->{'queue'};
+ my $queue = '';
# FIXME - If 'queue' is undefined or empty, then presumably it should
# mean "use the default queue", whatever the default is. Presumably
# 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.
+ # 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 "$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);
- }
+ print PRINTER "\r\n" x 7 ;
close PRINTER;
#system("lpr /tmp/$file");
}
sub printreserve {
- my ( $env, $branchname, $bordata, $itemdata ) = @_;
- my $file = time;
- my $printer = $env->{'printer'};
+ my ( $branchname, $bordata, $itemdata ) = @_;
+ my $printer = '';
(return) unless ( C4::Context->boolean_preference('printreserveslips') );
if ( $printer eq "" || $printer eq 'nulllp' ) {
- open( PRINTER, ">>/tmp/kohares" );
+ open( PRINTER, ">>/tmp/kohares" )
+ or die "Could not write to /tmp/kohares";
}
else {
open( PRINTER, "| lpr -P $printer >/dev/null" )
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 @da = localtime();
+ my $todaysdate = "$da[2]:$da[1] " . C4::Dates->today();
my $slip = <<"EOF";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Date: $todaysdate;
=item printslip
- &printslip($env, $borrowernumber)
+ &printslip($borrowernumber)
print a slip for the given $borrowernumber
=cut
#'
-sub printslip {
- my ( $env, $borrowernumber ) = @_;
- my ( $borrower, $flags ) = getpatroninformation( $env, $borrowernumber, 0 );
- $env->{'todaysissues'} = 1;
- my ($borrowerissues) = currentissues( $env, $borrower );
- $env->{'nottodaysissues'} = 1;
- $env->{'todaysissues'} = 0;
- my ($borroweriss2) = currentissues( $env, $borrower );
- $env->{'nottodaysissues'} = 0;
- my $i = 0;
- my @issues;
-
- foreach ( sort { $a <=> $b } keys %$borrowerissues ) {
- $issues[$i] = $borrowerissues->{$_};
- my $dd = $issues[$i]->{'date_due'};
-
- #convert to nz style dates
- #this should be set with some kinda config variable
- my @tempdate = split( /-/, $dd );
- $issues[$i]->{'date_due'} = "$tempdate[2]/$tempdate[1]/$tempdate[0]";
- $i++;
- }
- foreach ( sort { $a <=> $b } keys %$borroweriss2 ) {
- $issues[$i] = $borroweriss2->{$_};
- my $dd = $issues[$i]->{'date_due'};
-
- #convert to nz style dates
- #this should be set with some kinda config variable
- my @tempdate = split( /-/, $dd );
- $issues[$i]->{'date_due'} = "$tempdate[2]/$tempdate[1]/$tempdate[0]";
- $i++;
- }
- remoteprint( $env, \@issues, $borrower );
+sub printslip ($) {
+ my $borrowernumber = shift;
+ my $borrower = GetMemberDetails($borrowernumber);
+ my $issueslist = GetPendingIssues($borrowernumber);
+ foreach my $it (@$issueslist){
+ $it->{'date_due'}=format_date($it->{'date_due'});
+ }
+ my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist;
+ remoteprint(\@issues, $borrower );
}
END { } # module clean-up code here (global destructor)