3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
24 use C4
::Dates
qw(format_date);
26 use vars
qw($VERSION @ISA @EXPORT);
29 # set the version for version checking
33 @EXPORT = qw(&remoteprint &printreserve &printslip);
38 C4::Print - Koha module dealing with printing
46 The functions in this module handle sending text to a printer.
54 &remoteprint($items, $borrower);
56 Prints the list of items in C<$items> to a printer.
58 C<$borrower> is a reference-to-hash giving information about a patron.
59 This may be gotten from C<&GetMemberDetails>. The patron's name
60 will be printed in the output.
62 C<$items> is a reference-to-list, where each element is a
63 reference-to-hash describing a borrowed item. C<$items> may be gotten
64 from C<&GetBorrowerIssues>.
68 # FIXME - It'd be nifty if this could generate pretty PostScript.
69 sub remoteprint
($$) {
70 my ($items, $borrower) = @_;
73 unless ( C4
::Context
->boolean_preference('printcirculationslips') );
76 # FIXME - If 'queue' is undefined or empty, then presumably it should
77 # mean "use the default queue", whatever the default is. Presumably
78 # the default depends on the physical location of the machine.
79 # FIXME - Perhaps "print to file" should be a supported option. Just
80 # set the queue to "file" (or " file", if real queues aren't allowed
81 # to have spaces in them). Or perhaps if $queue eq "" and
82 # $env->{file} ne "", then that should mean "print to $env->{file}".
83 if ( $queue eq "" || $queue eq 'nulllp' ) {
84 open( PRINTER
, ">/tmp/kohaiss" );
88 # FIXME - This assumes that 'lpr' exists, and works as expected.
89 # This is a reasonable assumption, but only because every other
90 # printing package has a wrapper script called 'lpr'. It'd still
91 # be better to be able to customize this.
92 open( PRINTER
, "| lpr -P $queue > /dev/null" )
93 or die "Couldn't write to queue:$queue!\n";
97 #open (FILE,">/tmp/$file");
99 # FIXME - This is HLT-specific. Put this stuff in a customizable
100 # site-specific file somewhere.
101 print PRINTER
"Horowhenua Library Trust\r\n";
102 print PRINTER
"Phone: 368-1953\r\n";
103 print PRINTER
"Fax: 367-9218\r\n";
104 print PRINTER
"Email: renewals\@library.org.nz\r\n\r\n\r\n";
105 print PRINTER
"$borrower->{'cardnumber'}\r\n";
107 "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
109 # FIXME - Use for ($i = 0; $items->[$i]; $i++)
110 # Or better yet, foreach $item (@{$items})
111 while ( $items->[$i] ) {
114 my $itemdata = $items->[$i];
116 # FIXME - This is just begging for a Perl format.
117 print PRINTER
"$i $itemdata->{'title'}\r\n";
118 print PRINTER
"$itemdata->{'barcode'}";
119 print PRINTER
" " x
15;
120 print PRINTER
"$itemdata->{'date_due'}\r\n";
123 print PRINTER
"\r\n" x
7 ;
126 #system("lpr /tmp/$file");
130 my ( $branchname, $bordata, $itemdata ) = @_;
132 (return) unless ( C4
::Context
->boolean_preference('printreserveslips') );
133 if ( $printer eq "" || $printer eq 'nulllp' ) {
134 open( PRINTER
, ">>/tmp/kohares" )
135 or die "Could not write to /tmp/kohares";
138 open( PRINTER
, "| lpr -P $printer >/dev/null" )
139 or die "Couldn't write to queue:$!\n";
141 my @da = localtime();
142 my $todaysdate = "$da[2]:$da[1] " . C4
::Dates
->today();
144 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148 $itemdata->{'title'} ($itemdata->{'author'})
149 barcode: $itemdata->{'barcode'}
151 COLLECT AT: $branchname
154 $bordata->{'surname'}, $bordata->{'firstname'}
155 card number: $bordata->{'cardnumber'}
156 Phone: $bordata->{'phone'}
157 $bordata->{'streetaddress'}
160 $bordata->{'emailaddress'}
163 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172 &printslip($borrowernumber)
174 print a slip for the given $borrowernumber
180 my ( $borrowernumber ) = shift;
181 my ( $borrower ) = GetMemberDetails
( $borrowernumber);
182 my ($countissues,$issueslist) = GetPendingIssues
($borrowernumber);
183 foreach my $it (@
$issueslist){
184 $it->{'date_due'}=format_date
($it->{'date_due'});
186 my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @
$issueslist;
187 remoteprint
(\
@issues, $borrower );
190 END { } # module clean-up code here (global destructor)
199 Koha Developement team <info@koha.org>
203 C4::Circulation::Circ2(3)