Are we getting sick of merging yet? Not me!
[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);
22   
23 # set the version for version checking
24 $VERSION = 0.01;
25     
26 @ISA = qw(Exporter);
27 @EXPORT = qw(&getgroups &groupmembers);
28
29 sub getgroups {
30     my ($env) = @_;
31     my %groups;
32     my $dbh=&C4Connect;  
33     my $sth=$dbh->prepare("select distinct groupshortname,grouplongname from borrowergroups");
34     $sth->execute;
35     while (my ($short, $long)=$sth->fetchrow) {
36         $groups{$short}=$long;
37     }
38     $dbh->disconnect;
39     return (\%groups);
40 }
41
42 sub groupmembers {
43     my ($env, $group) = @_;
44     my @members;
45     my $dbh=&C4Connect;
46     my $q_group=$dbh->quote($group);
47     my $sth=$dbh->prepare("select borrowernumber from borrowergroups where groupshortname=$q_group");
48     $sth->execute;
49     while (my ($borrowernumber) = $sth->fetchrow) {
50         my ($patron, $flags) = getpatroninformation($env, $borrowernumber);
51         my $currentissues=currentissues($env, $patron);
52         $patron->{'currentissues'}=$currentissues;
53         push (@members, $patron);
54     }
55     return (\@members);
56 }
57
58
59 END { }       # module clean-up code here (global destructor)