Fixed a few warnings.
[koha.git] / C4 / Groups.pm
1 package C4::Groups;
2
3 #package to deal with Returns
4 #written 3/11/99 by olwen@katipo.co.nz
5
6 use strict;
7 require Exporter;
8 use DBI;
9 use C4::Database;
10 use C4::Circulation::Circ2;
11 #use C4::Accounts;
12 #use C4::InterfaceCDK;
13 #use C4::Circulation::Main;
14 #use C4::Format;
15 #use C4::Circulation::Renewals;
16 #use C4::Scan;
17 use C4::Stats;
18 #use C4::Search;
19 #use C4::Print;
20
21 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
22   
23 # set the version for version checking
24 $VERSION = 0.01;
25     
26 @ISA = qw(Exporter);
27 @EXPORT = qw(&getgroups &groupmembers);
28 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
29                   
30 # your exported package globals go here,
31 # as well as any optionally exported functions
32
33 @EXPORT_OK   = qw($Var1 %Hashit);
34
35
36 # non-exported package globals go here
37 #use vars qw(@more $stuff);
38         
39 # initalize package globals, first exported ones
40
41 my $Var1   = '';
42 my %Hashit = ();
43                     
44 # then the others (which are still accessible as $Some::Module::stuff)
45 my $stuff  = '';
46 my @more   = ();
47         
48 # all file-scoped lexicals must be created before
49 # the functions below that use them.
50                 
51 # file-private lexicals go here
52 my $priv_var    = '';
53 my %secret_hash = ();
54                             
55 # here's a file-private function as a closure,
56 # callable as &$priv_func;  it cannot be prototyped.
57 my $priv_func = sub {
58   # stuff goes here.
59 };
60                                                     
61 # make all your functions, whether exported or not;
62
63
64 sub getgroups {
65     my ($env) = @_;
66     my %groups;
67     my $dbh=&C4Connect;  
68     my $sth=$dbh->prepare("select distinct groupshortname,grouplongname from borrowergroups");
69     $sth->execute;
70     while (my ($short, $long)=$sth->fetchrow) {
71         $groups{$short}=$long;
72     }
73     $dbh->disconnect;
74     return (\%groups);
75 }
76
77 sub groupmembers {
78     my ($env, $group) = @_;
79     my @members;
80     my $dbh=&C4Connect;
81     my $q_group=$dbh->quote($group);
82     my $sth=$dbh->prepare("select borrowernumber from borrowergroups where groupshortname=$q_group");
83     $sth->execute;
84     while (my ($borrowernumber) = $sth->fetchrow) {
85         my ($patron, $flags) = getpatroninformation($env, $borrowernumber);
86         my $currentissues=currentissues($env, $patron);
87         $patron->{'currentissues'}=$currentissues;
88         push (@members, $patron);
89     }
90     return (\@members);
91 }
92
93
94 END { }       # module clean-up code here (global destructor)