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
30 use vars qw($VERSION @ISA @EXPORT);
32 # set the version for version checking
33 # set the version for version checking
34 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
35 shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
40 C4::Print - Koha module dealing with printing
48 The functions in this module handle sending text to a printer.
57 @EXPORT = qw(&remoteprint &printreserve &printslip);
61 &remoteprint($items, $borrower);
63 Prints the list of items in C<$items> to a printer.
65 C<$borrower> is a reference-to-hash giving information about a patron.
66 This may be gotten from C<&GetMemberDetails>. The patron's name
67 will be printed in the output.
69 C<$items> is a reference-to-list, where each element is a
70 reference-to-hash describing a borrowed item. C<$items> may be gotten
71 from C<&GetBorrowerIssues>.
75 # FIXME - It'd be nifty if this could generate pretty PostScript.
77 my ($items, $borrower ) = @_;
80 unless ( C4::Context->boolean_preference('printcirculationslips') );
83 # FIXME - If 'queue' is undefined or empty, then presumably it should
84 # mean "use the default queue", whatever the default is. Presumably
85 # the default depends on the physical location of the machine.
86 # FIXME - Perhaps "print to file" should be a supported option. Just
87 # set the queue to "file" (or " file", if real queues aren't allowed
88 # to have spaces in them). Or perhaps if $queue eq "" and
89 # $env->{file} ne "", then that should mean "print to $env->{file}".
90 if ( $queue eq "" || $queue eq 'nulllp' ) {
91 open( PRINTER, ">/tmp/kohaiss" );
95 # FIXME - This assumes that 'lpr' exists, and works as expected.
96 # This is a reasonable assumption, but only because every other
97 # printing package has a wrapper script called 'lpr'. It'd still
98 # be better to be able to customize this.
99 open( PRINTER, "| lpr -P $queue > /dev/null" )
100 or die "Couldn't write to queue:$queue!\n";
104 #open (FILE,">/tmp/$file");
106 # FIXME - This is HLT-specific. Put this stuff in a customizable
107 # site-specific file somewhere.
108 print PRINTER "Horowhenua Library Trust\r\n";
109 print PRINTER "Phone: 368-1953\r\n";
110 print PRINTER "Fax: 367-9218\r\n";
111 print PRINTER "Email: renewals\@library.org.nz\r\n\r\n\r\n";
112 print PRINTER "$borrower->{'cardnumber'}\r\n";
114 "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
116 # FIXME - Use for ($i = 0; $items->[$i]; $i++)
117 # Or better yet, foreach $item (@{$items})
118 while ( $items->[$i] ) {
121 my $itemdata = $items->[$i];
123 # FIXME - This is just begging for a Perl format.
124 print PRINTER "$i $itemdata->{'title'}\r\n";
125 print PRINTER "$itemdata->{'barcode'}";
126 print PRINTER " " x 15;
127 print PRINTER "$itemdata->{'date_due'}\r\n";
130 print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
133 #system("lpr /tmp/$file");
137 my ( $branchname, $bordata, $itemdata ) = @_;
140 (return) unless ( C4::Context->boolean_preference('printreserveslips') );
141 if ( $printer eq "" || $printer eq 'nulllp' ) {
142 open( PRINTER, ">>/tmp/kohares" );
145 open( PRINTER, "| lpr -P $printer >/dev/null" )
146 or die "Couldn't write to queue:$!\n";
148 my @da = localtime( time() );
149 my $todaysdate = "$da[2]:$da[1] $da[3]/$da[4]/$da[5]";
151 #(1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
153 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157 $itemdata->{'title'} ($itemdata->{'author'})
158 barcode: $itemdata->{'barcode'}
160 COLLECT AT: $branchname
163 $bordata->{'surname'}, $bordata->{'firstname'}
164 card number: $bordata->{'cardnumber'}
165 Phone: $bordata->{'phone'}
166 $bordata->{'streetaddress'}
169 $bordata->{'emailaddress'}
172 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181 &printslip($borrowernumber)
183 print a slip for the given $borrowernumber
189 my ( $borrowernumber ) = @_;
190 my ( $borrower, $flags ) = GetMemberDetails( $borrowernumber);
191 my ($countissues,$issueslist) = GetPendingIssues($borrowernumber);
192 foreach my $it (@$issueslist){
193 $it->{'date_due'}=format_date($it->{'date_due'});
195 my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist;
196 remoteprint(\@issues, $borrower );
199 END { } # module clean-up code here (global destructor)
208 Koha Developement team <info@koha.org>
212 C4::Circulation::Circ2(3)