Added PODs.
[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
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::Database;
28 use C4::Circulation::Circ2;
29 #use C4::Accounts;
30 #use C4::InterfaceCDK;
31 #use C4::Circulation::Main;
32 #use C4::Format;
33 #use C4::Circulation::Renewals;
34 #use C4::Scan;
35 use C4::Stats;
36 #use C4::Search;
37 #use C4::Print;
38
39 use vars qw($VERSION @ISA @EXPORT);
40   
41 # set the version for version checking
42 $VERSION = 0.01;
43     
44 @ISA = qw(Exporter);
45 @EXPORT = qw(&getgroups &groupmembers);
46
47 sub getgroups {
48     my ($env) = @_;
49     my %groups;
50     my $dbh=&C4Connect;  
51     my $sth=$dbh->prepare("select distinct groupshortname,grouplongname from borrowergroups");
52     $sth->execute;
53     while (my ($short, $long)=$sth->fetchrow) {
54         $groups{$short}=$long;
55     }
56     $dbh->disconnect;
57     return (\%groups);
58 }
59
60 sub groupmembers {
61     my ($env, $group) = @_;
62     my @members;
63     my $dbh=&C4Connect;
64     my $q_group=$dbh->quote($group);
65     my $sth=$dbh->prepare("select borrowernumber from borrowergroups where groupshortname=$q_group");
66     $sth->execute;
67     while (my ($borrowernumber) = $sth->fetchrow) {
68         my ($patron, $flags) = getpatroninformation($env, $borrowernumber);
69         my $currentissues=currentissues($env, $patron);
70         $patron->{'currentissues'}=$currentissues;
71         push (@members, $patron);
72     }
73     return (\@members);
74 }
75
76
77 END { }       # module clean-up code here (global destructor)