Continuing work on Z39.50 search tool. Daemon now forks up to 12 processes
[koha.git] / C4 / Circulation / Borrissues.pm
1 package C4::Circulation::Borrissues; #assumes C4/Circulation/Borrissues
2
3 #package to deal with Issues
4 #written 3/11/99 by chris@katipo.co.nz
5
6 use strict;
7 require Exporter;
8 use DBI;
9 use C4::Database;
10 use C4::Print;
11 use C4::Format;
12 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
13   
14 # set the version for version checking
15 $VERSION = 0.01;
16     
17 @ISA = qw(Exporter);
18 @EXPORT = qw(&printallissues);
19 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
20                   
21 # your exported package globals go here,
22 # as well as any optionally exported functions
23
24 @EXPORT_OK   = qw($Var1 %Hashit);
25
26
27 # non-exported package globals go here
28 use vars qw(@more $stuff);
29         
30 # initalize package globals, first exported ones
31
32 my $Var1   = '';
33 my %Hashit = ();
34                     
35 # then the others (which are still accessible as $Some::Module::stuff)
36 my $stuff  = '';
37 my @more   = ();
38         
39 # all file-scoped lexicals must be created before
40 # the functions below that use them.
41                 
42 # file-private lexicals go here
43 my $priv_var    = '';
44 my %secret_hash = ();
45                             
46 # here's a file-private function as a closure,
47 # callable as &$priv_func;  it cannot be prototyped.
48 my $priv_func = sub {
49   # stuff goes here.
50 };
51                                                     
52 # make all your functions, whether exported or not;
53
54
55 sub printallissues {
56   my ($env,$borrower)=@_;
57   my @issues;
58   my $dbh=C4Connect;
59   my $query = "select * from issues,items,biblioitems,biblio
60     where borrowernumber = '$borrower->{'borrowernumber'}' 
61     and (returndate is null)
62     and (issues.itemnumber = items.itemnumber)
63     and (items.biblioitemnumber = biblioitems.biblioitemnumber)
64     and (items.biblionumber = biblio.biblionumber) 
65     order by date_due";
66   my $sth = $dbh->prepare($query);
67   $sth->execute();
68   my $x;
69   while (my $data = $sth->fetchrow_hashref) {
70     @issues[$x] =$data;
71     $x++;
72   }
73   $sth->finish();
74   $dbh->disconnect();
75   remoteprint ($env,\@issues,$borrower);
76 }
77 END { }       # module clean-up code here (global destructor)