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
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #use warnings; FIXME - Bug 2505
25 use C4
::Dates
qw(format_date);
27 use vars
qw($VERSION @ISA @EXPORT);
30 # set the version for version checking
34 @EXPORT = qw(&remoteprint &printreserve &printslip);
39 C4::Print - Koha module dealing with printing
47 The functions in this module handle sending text to a printer.
53 &remoteprint($items, $borrower);
55 Prints the list of items in C<$items> to a printer.
57 C<$borrower> is a reference-to-hash giving information about a patron.
58 This may be gotten from C<&GetMemberDetails>. The patron's name
59 will be printed in the output.
61 C<$items> is a reference-to-list, where each element is a
62 reference-to-hash describing a borrowed item. C<$items> may be gotten
63 from C<&GetBorrowerIssues>.
67 # FIXME - It'd be nifty if this could generate pretty PostScript.
68 sub remoteprint
($$) {
69 my ($items, $borrower) = @_;
72 unless ( C4
::Context
->boolean_preference('printcirculationslips') );
75 # FIXME - If 'queue' is undefined or empty, then presumably it should
76 # mean "use the default queue", whatever the default is. Presumably
77 # the default depends on the physical location of the machine.
78 # FIXME - Perhaps "print to file" should be a supported option. Just
79 # set the queue to "file" (or " file", if real queues aren't allowed
80 # to have spaces in them). Or perhaps if $queue eq "" and
81 # $env->{file} ne "", then that should mean "print to $env->{file}".
82 if ( $queue eq "" || $queue eq 'nulllp' ) {
83 open( PRINTER
, ">/tmp/kohaiss" );
87 # FIXME - This assumes that 'lpr' exists, and works as expected.
88 # This is a reasonable assumption, but only because every other
89 # printing package has a wrapper script called 'lpr'. It'd still
90 # be better to be able to customize this.
91 open( PRINTER
, "| lpr -P $queue > /dev/null" )
92 or die "Couldn't write to queue:$queue!\n";
96 #open (FILE,">/tmp/$file");
98 # FIXME - This is HLT-specific. Put this stuff in a customizable
99 # site-specific file somewhere.
100 print PRINTER
"Horowhenua Library Trust\r\n";
101 print PRINTER
"Phone: 368-1953\r\n";
102 print PRINTER
"Fax: 367-9218\r\n";
103 print PRINTER
"Email: renewals\@library.org.nz\r\n\r\n\r\n";
104 print PRINTER
"$borrower->{'cardnumber'}\r\n";
106 "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
108 # FIXME - Use for ($i = 0; $items->[$i]; $i++)
109 # Or better yet, foreach $item (@{$items})
110 while ( $items->[$i] ) {
113 my $itemdata = $items->[$i];
115 # FIXME - This is just begging for a Perl format.
116 print PRINTER
"$i $itemdata->{'title'}\r\n";
117 print PRINTER
"$itemdata->{'barcode'}";
118 print PRINTER
" " x
15;
119 print PRINTER
"$itemdata->{'date_due'}\r\n";
122 print PRINTER
"\r\n" x
7 ;
125 #system("lpr /tmp/$file");
129 my ( $branchname, $bordata, $itemdata ) = @_;
131 (return) unless ( C4
::Context
->boolean_preference('printreserveslips') );
132 if ( $printer eq "" || $printer eq 'nulllp' ) {
133 open( PRINTER
, ">>/tmp/kohares" )
134 or die "Could not write to /tmp/kohares";
137 open( PRINTER
, "| lpr -P $printer >/dev/null" )
138 or die "Couldn't write to queue:$!\n";
140 my @da = localtime();
141 my $todaysdate = "$da[2]:$da[1] " . C4
::Dates
->today();
143 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147 $itemdata->{'title'} ($itemdata->{'author'})
148 barcode: $itemdata->{'barcode'}
150 COLLECT AT: $branchname
153 $bordata->{'surname'}, $bordata->{'firstname'}
154 card number: $bordata->{'cardnumber'}
155 Phone: $bordata->{'phone'}
156 $bordata->{'streetaddress'}
159 $bordata->{'emailaddress'}
162 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171 &printslip($borrowernumber)
173 print a slip for the given $borrowernumber
179 my $borrowernumber = shift;
180 my $borrower = GetMemberDetails
($borrowernumber);
181 my $issueslist = GetPendingIssues
($borrowernumber);
182 foreach my $it (@
$issueslist){
183 $it->{'date_due'}=format_date
($it->{'date_due'});
185 my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @
$issueslist;
186 remoteprint
(\
@issues, $borrower );
189 END { } # module clean-up code here (global destructor)
196 Koha Development Team <http://koha-community.org/>
200 C4::Circulation::Circ2(3)