Initial revision
[koha.git] / C4 / Print.pm
1
2 package C4::Print; #asummes C4/Print.pm
3
4 use strict;
5 require Exporter;
6 use C4::InterfaceCDK;
7
8 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
9
10 # set the version for version checking
11 $VERSION = 0.01;
12
13 @ISA = qw(Exporter);
14 @EXPORT = qw(&remoteprint &printreserve);
15 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
16
17 # your exported package globals go here,
18 # as well as any optionally exported functions
19
20 @EXPORT_OK   = qw($Var1 %Hashit);
21
22
23 # non-exported package globals go here
24 use vars qw(@more $stuff);
25
26 # initalize package globals, first exported ones
27
28 my $Var1   = '';
29 my %Hashit = ();
30
31
32 # then the others (which are still accessible as $Some::Module::stuff)
33 my $stuff  = '';
34 my @more   = ();
35
36 # all file-scoped lexicals must be created before
37 # the functions below that use them.
38
39 # file-private lexicals go here
40 my $priv_var    = '';
41 my %secret_hash = ();
42
43 # here's a file-private function as a closure,
44 # callable as &$priv_func;  it cannot be prototyped.
45 my $priv_func = sub {
46   # stuff goes here.
47   };
48   
49 # make all your functions, whether exported or not;
50
51 sub remoteprint {
52   my ($env,$items,$borrower)=@_;
53   #open (FILE,">/tmp/olwen");
54   #print FILE "queue $env->{'queue'}";
55   #close FILE;
56   #debug_msg($env,"In print");
57   my $file=time;
58   my $queue = $env->{'queue'};
59   if ($queue eq "") {
60     open (PRINTER,">/tmp/kohaiss");
61   } else {  
62     open(PRINTER, "| lpr -P $queue") or die "Couldn't write to queue:$!\n";
63   }  
64 #  print $queue;
65   #open (FILE,">/tmp/$file");
66   my $i=0;
67   my $brdata = $env->{'brdata'};
68   print PRINTER "Horowhenua Library Trust\r\n";
69 #  print PRINTER "$brdata->{'branchname'}\r\n";
70   print PRINTER "Phone: 368-1953\r\n";   
71   print PRINTER "Fax:    367-9218\r\n";   
72   print PRINTER "Email:  renewals\@library.org.nz\r\n\r\n\r\n";
73   print PRINTER "$borrower->{'cardnumber'}\r\n";
74   print PRINTER "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
75   while ($items->[$i]){
76     my $itemdata = $items->[$i];
77     print PRINTER "$itemdata->{'title'}\r\n";
78     print PRINTER "$itemdata->{'barcode'}";
79     print PRINTER " "x15;
80     print PRINTER "$itemdata->{'date_due'}\r\n";
81     $i++;
82   }
83   print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
84   if ($env->{'printtype'} eq "docket"){
85     #print chr(27).chr(105);
86   } 
87   close PRINTER;
88   #system("lpr /tmp/$file");
89 }
90
91 sub printreserve {
92   my($env,$resrec,$rbordata,$itemdata)=@_;
93   my $file=time;
94   my $queue = $env->{'queue'};
95   #if ($queue eq "") {
96     open (PRINTER,">/tmp/kohares");
97   #} else {
98   #  open (PRINTER, "| lpr -P $queue") or die "Couldn't write to queue:$!\n";
99   #}  
100   print PRINTER "Collect at $resrec->{'branchcode'}\r\n\r\n";
101   print PRINTER "$rbordata->{'surname'}; $rbordata->{'firstname'}\r\n";
102   print PRINTER "$rbordata->{'cardnumber'}\r\n";
103   print PRINTER "Phone: $rbordata->{'phone'}\r\n";
104   print PRINTER "$rbordata->{'streetaddress'}\r\n";
105   print PRINTER "$rbordata->{'suburb'}\r\n";
106   print PRINTER "$rbordata->{'town'}\r\n";   
107   print PRINTER "$rbordata->{'emailaddress'}\r\n\r\n";
108   print PRINTER "$itemdata->{'barcode'}\r\n";
109   print PRINTER "$itemdata->{'title'}\r\n";
110   print PRINTER "$itemdata->{'author'}";
111   print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
112   if ($env->{'printtype'} eq "docket"){ 
113     #print chr(27).char(105);
114   }  
115   close PRINTER;
116   #system("lpr /tmp/$file"); 
117 }
118 END { }       # module clean-up code here (global destructor)
119   
120