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
29 use vars qw($VERSION @ISA @EXPORT);
31 # set the version for version checking
32 # set the version for version checking
37 C4::Print - Koha module dealing with printing
45 The functions in this module handle sending text to a printer.
54 @EXPORT = qw(&remoteprint &printreserve &printslip);
58 &remoteprint($items, $borrower);
60 Prints the list of items in C<$items> to a printer.
62 C<$borrower> is a reference-to-hash giving information about a patron.
63 This may be gotten from C<&GetMemberDetails>. The patron's name
64 will be printed in the output.
66 C<$items> is a reference-to-list, where each element is a
67 reference-to-hash describing a borrowed item. C<$items> may be gotten
68 from C<&GetBorrowerIssues>.
72 # FIXME - It'd be nifty if this could generate pretty PostScript.
74 my ($items, $borrower ) = @_;
77 unless ( C4::Context->boolean_preference('printcirculationslips') );
80 # FIXME - If 'queue' is undefined or empty, then presumably it should
81 # mean "use the default queue", whatever the default is. Presumably
82 # the default depends on the physical location of the machine.
83 # FIXME - Perhaps "print to file" should be a supported option. Just
84 # set the queue to "file" (or " file", if real queues aren't allowed
85 # to have spaces in them). Or perhaps if $queue eq "" and
86 # $env->{file} ne "", then that should mean "print to $env->{file}".
87 if ( $queue eq "" || $queue eq 'nulllp' ) {
88 open( PRINTER, ">/tmp/kohaiss" );
92 # FIXME - This assumes that 'lpr' exists, and works as expected.
93 # This is a reasonable assumption, but only because every other
94 # printing package has a wrapper script called 'lpr'. It'd still
95 # be better to be able to customize this.
96 open( PRINTER, "| lpr -P $queue > /dev/null" )
97 or die "Couldn't write to queue:$queue!\n";
101 #open (FILE,">/tmp/$file");
103 # FIXME - This is HLT-specific. Put this stuff in a customizable
104 # site-specific file somewhere.
105 print PRINTER "Horowhenua Library Trust\r\n";
106 print PRINTER "Phone: 368-1953\r\n";
107 print PRINTER "Fax: 367-9218\r\n";
108 print PRINTER "Email: renewals\@library.org.nz\r\n\r\n\r\n";
109 print PRINTER "$borrower->{'cardnumber'}\r\n";
111 "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
113 # FIXME - Use for ($i = 0; $items->[$i]; $i++)
114 # Or better yet, foreach $item (@{$items})
115 while ( $items->[$i] ) {
118 my $itemdata = $items->[$i];
120 # FIXME - This is just begging for a Perl format.
121 print PRINTER "$i $itemdata->{'title'}\r\n";
122 print PRINTER "$itemdata->{'barcode'}";
123 print PRINTER " " x 15;
124 print PRINTER "$itemdata->{'date_due'}\r\n";
127 print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
130 #system("lpr /tmp/$file");
134 my ( $branchname, $bordata, $itemdata ) = @_;
137 (return) unless ( C4::Context->boolean_preference('printreserveslips') );
138 if ( $printer eq "" || $printer eq 'nulllp' ) {
139 open( PRINTER, ">>/tmp/kohares" );
142 open( PRINTER, "| lpr -P $printer >/dev/null" )
143 or die "Couldn't write to queue:$!\n";
145 my @da = localtime( time() );
146 my $todaysdate = "$da[2]:$da[1] $da[3]/$da[4]/$da[5]";
148 #(1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
150 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154 $itemdata->{'title'} ($itemdata->{'author'})
155 barcode: $itemdata->{'barcode'}
157 COLLECT AT: $branchname
160 $bordata->{'surname'}, $bordata->{'firstname'}
161 card number: $bordata->{'cardnumber'}
162 Phone: $bordata->{'phone'}
163 $bordata->{'streetaddress'}
166 $bordata->{'emailaddress'}
169 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178 &printslip($borrowernumber)
180 print a slip for the given $borrowernumber
186 my ( $borrowernumber ) = @_;
187 my ( $borrower, $flags ) = GetMemberDetails( $borrowernumber);
188 my ($countissues,$issueslist) = GetPendingIssues($borrowernumber);
189 foreach my $it (@$issueslist){
190 $it->{'date_due'}=format_date($it->{'date_due'});
192 my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist;
193 remoteprint(\@issues, $borrower );
196 END { } # module clean-up code here (global destructor)
205 Koha Developement team <info@koha.org>
209 C4::Circulation::Circ2(3)