Merged with arensb-context branch: use C4::Context->dbh instead of
[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
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use strict;
25 require Exporter;
26 use DBI;
27 use C4::Context;
28 use C4::Print;
29 use C4::Format;
30 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31   
32 # set the version for version checking
33 $VERSION = 0.01;
34     
35 @ISA = qw(Exporter);
36 @EXPORT = qw(&printallissues);
37 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
38                   
39 # your exported package globals go here,
40 # as well as any optionally exported functions
41
42 @EXPORT_OK   = qw($Var1 %Hashit);
43
44
45 # non-exported package globals go here
46 use vars qw(@more $stuff);
47         
48 # initalize package globals, first exported ones
49
50 my $Var1   = '';
51 my %Hashit = ();
52                     
53 # then the others (which are still accessible as $Some::Module::stuff)
54 my $stuff  = '';
55 my @more   = ();
56         
57 # all file-scoped lexicals must be created before
58 # the functions below that use them.
59                 
60 # file-private lexicals go here
61 my $priv_var    = '';
62 my %secret_hash = ();
63                             
64 # here's a file-private function as a closure,
65 # callable as &$priv_func;  it cannot be prototyped.
66 my $priv_func = sub {
67   # stuff goes here.
68 };
69                                                     
70 # make all your functions, whether exported or not;
71
72
73 sub printallissues {
74   my ($env,$borrower)=@_;
75   my @issues;
76   my $dbh = C4::Context->dbh;
77   my $query = "select * from issues,items,biblioitems,biblio
78     where borrowernumber = '$borrower->{'borrowernumber'}' 
79     and (returndate is null)
80     and (issues.itemnumber = items.itemnumber)
81     and (items.biblioitemnumber = biblioitems.biblioitemnumber)
82     and (items.biblionumber = biblio.biblionumber) 
83     order by date_due";
84   my $sth = $dbh->prepare($query);
85   $sth->execute();
86   my $x;
87   while (my $data = $sth->fetchrow_hashref) {
88     # FIXME - This should be $issues[$x] = $data, right?
89     # Or better yet, push @issues, $data.
90     @issues[$x] =$data;
91     $x++;
92   }
93   $sth->finish();
94   remoteprint ($env,\@issues,$borrower);
95 }
96 END { }       # module clean-up code here (global destructor)