issues printing issue slips again
[koha.git] / C4 / Print.pm
1 package C4::Print; #asummes C4/Print.pm
2
3 use strict;
4 require Exporter;
5 #use C4::InterfaceCDK;
6
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8
9 # set the version for version checking
10 $VERSION = 0.01;
11
12 @ISA = qw(Exporter);
13 @EXPORT = qw(&remoteprint &printreserve);
14 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
15
16 # your exported package globals go here,
17 # as well as any optionally exported functions
18
19 @EXPORT_OK   = qw($Var1 %Hashit);
20
21
22 # non-exported package globals go here
23 use vars qw(@more $stuff);
24
25 # initalize package globals, first exported ones
26
27 my $Var1   = '';
28 my %Hashit = ();
29
30
31 # then the others (which are still accessible as $Some::Module::stuff)
32 my $stuff  = '';
33 my @more   = ();
34
35 # all file-scoped lexicals must be created before
36 # the functions below that use them.
37
38 # file-private lexicals go here
39 my $priv_var    = '';
40 my %secret_hash = ();
41
42 # here's a file-private function as a closure,
43 # callable as &$priv_func;  it cannot be prototyped.
44 my $priv_func = sub {
45   # stuff goes here.
46   };
47   
48 # make all your functions, whether exported or not;
49
50 sub remoteprint {
51   my ($env,$items,$borrower)=@_;
52   #open (FILE,">/tmp/olwen");
53   #print FILE "queue $env->{'queue'}";
54   #close FILE;
55   #debug_msg($env,"In print");
56   my $file=time;
57   my $queue = $env->{'queue'};
58   if ($queue eq "" || $queue eq 'nulllp') {
59     open (PRINTER,">/tmp/kohaiss");
60   } else {  
61     open(PRINTER, "| lpr -P $queue") or die "Couldn't write to queue:$queue!\n";
62   }  
63 #  print $queue;
64   #open (FILE,">/tmp/$file");
65   my $i=0;
66   my $brdata = $env->{'brdata'};
67   print PRINTER "Horowhenua Library Trust\r\n";
68 #  print PRINTER "$brdata->{'branchname'}\r\n";
69   print PRINTER "Phone: 368-1953\r\n";   
70   print PRINTER "Fax:    367-9218\r\n";   
71   print PRINTER "Email:  renewals\@library.org.nz\r\n\r\n\r\n";
72   print PRINTER "$borrower->{'cardnumber'}\r\n";
73   print PRINTER "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n";
74   while ($items->[$i]){
75 #    print $i;
76     my $itemdata = $items->[$i];
77     print PRINTER "$i $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