Added copyright statement to all .pl and .pm files
[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 sub printreserve {
75   my($env, $branchname, $bordata, $itemdata)=@_;
76   my $file=time;
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   my @da = localtime(time());
84   my $todaysdate = "$da[2]:$da[1]  $da[3]/$da[4]/$da[5]";
85
86 #(1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
87   my $slip = <<"EOF";
88 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
89 Date: $todaysdate;
90
91 ITEM RESERVED: 
92 $itemdata->{'title'} ($itemdata->{'author'})
93 barcode: $itemdata->{'barcode'}
94
95 COLLECT AT: $branchname
96
97 BORROWER:
98 $bordata->{'surname'}, $bordata->{'firstname'}
99 card number: $bordata->{'cardnumber'}
100 Phone: $bordata->{'phone'}
101 $bordata->{'streetaddress'}
102 $bordata->{'suburb'}
103 $bordata->{'town'}
104 $bordata->{'emailaddress'}
105
106
107 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108 EOF
109     print PRINTER $slip;
110   close PRINTER;
111   return $slip;
112 }
113
114 sub printslip {
115   my($env, $slip)=@_;
116   my $printer = $env->{'printer'};
117   if ($printer eq "" || $printer eq 'nulllp') {
118     open (PRINTER,">/tmp/kohares");
119   } else {
120     open (PRINTER, "| lpr -P $printer") or die "Couldn't write to queue:$!\n";
121   }
122   print PRINTER $slip;
123   close PRINTER;
124 }
125
126 END { }       # module clean-up code here (global destructor)
127   
128