Added PODs.
[koha.git] / C4 / Print.pm
1 package C4::Print; #assumes C4/Print.pm
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20
21 use strict;
22 require Exporter;
23 #use C4::InterfaceCDK;
24
25 use vars qw($VERSION @ISA @EXPORT);
26
27 # set the version for version checking
28 $VERSION = 0.01;
29
30 @ISA = qw(Exporter);
31 @EXPORT = qw(&remoteprint &printreserve &printslip);
32
33 sub remoteprint {
34   my ($env,$items,$borrower)=@_;
35   #open (FILE,">/tmp/olwen");
36   #print FILE "queue $env->{'queue'}";
37   #close FILE;
38   #debug_msg($env,"In print");
39   my $file=time;
40   my $queue = $env->{'queue'};
41   if ($queue eq "" || $queue eq 'nulllp') {
42     open (PRINTER,">/tmp/kohaiss");
43   } else {  
44     open(PRINTER, "| lpr -P $queue") or die "Couldn't write to queue:$queue!\n";
45   }  
46 #  print $queue;
47   #open (FILE,">/tmp/$file");
48   my $i=0;
49   my $brdata = $env->{'brdata'};
50   print PRINTER "Horowhenua Library Trust\r\n";
51 #  print PRINTER "$brdata->{'branchname'}\r\n";
52   print PRINTER "Phone: 368-1953\r\n";   
53   print PRINTER "Fax:    367-9218\r\n";   
54   print PRINTER "Email:  renewals\@library.org.nz\r\n\r\n\r\n";
55   print PRINTER "$borrower->{'cardnumber'}\r\n";
56   print PRINTER "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
57   while ($items->[$i]){
58 #    print $i;
59     my $itemdata = $items->[$i];
60     print PRINTER "$i $itemdata->{'title'}\r\n";
61     print PRINTER "$itemdata->{'barcode'}";
62     print PRINTER " "x15;
63     print PRINTER "$itemdata->{'date_due'}\r\n";
64     $i++;
65   }
66   print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
67   if ($env->{'printtype'} eq "docket"){
68     #print chr(27).chr(105);
69   } 
70   close PRINTER;
71   #system("lpr /tmp/$file");
72 }
73
74
75 sub printslip {
76   my($env, $slip)=@_;
77   my $printer = $env->{'printer'};
78   if ($printer eq "" || $printer eq 'nulllp') {
79     open (PRINTER,">/tmp/kohares");
80   } else {
81     open (PRINTER, "| lpr -P $printer") or die "Couldn't write to queue:$!\n";
82   }
83   print PRINTER $slip;
84   close PRINTER;
85 }
86
87 END { }       # module clean-up code here (global destructor)
88   
89