Merged with arensb-context branch: use C4::Context->dbh instead of
[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 # FIXME - This package is only used in groups.pl, which in turn is
25 # never used. Presumably this module is therefore obsolete.
26
27 use strict;
28 require Exporter;
29 use DBI;
30 use C4::Context;
31 use C4::Circulation::Circ2;
32 #use C4::Accounts;
33 #use C4::InterfaceCDK;
34 #use C4::Circulation::Main;
35 #use C4::Format;
36 #use C4::Circulation::Renewals;
37 #use C4::Scan;
38 use C4::Stats;
39 #use C4::Search;
40 #use C4::Print;
41
42 use vars qw($VERSION @ISA @EXPORT);
43   
44 # set the version for version checking
45 $VERSION = 0.01;
46     
47 @ISA = qw(Exporter);
48 @EXPORT = qw(&getgroups &groupmembers);
49
50 sub getgroups {
51     my ($env) = @_;
52     my %groups;
53     my $dbh = C4::Context->dbh;
54     my $sth=$dbh->prepare("select distinct groupshortname,grouplongname from borrowergroups");
55     $sth->execute;
56     while (my ($short, $long)=$sth->fetchrow) {
57         $groups{$short}=$long;
58     }
59     return (\%groups);
60 }
61
62 sub groupmembers {
63     my ($env, $group) = @_;
64     my @members;
65     my $dbh = C4::Context->dbh;
66     my $q_group=$dbh->quote($group);
67     my $sth=$dbh->prepare("select borrowernumber from borrowergroups where groupshortname=$q_group");
68     $sth->execute;
69     while (my ($borrowernumber) = $sth->fetchrow) {
70         my ($patron, $flags) = getpatroninformation($env, $borrowernumber);
71         my $currentissues=currentissues($env, $patron);
72         $patron->{'currentissues'}=$currentissues;
73         push (@members, $patron);
74     }
75     return (\@members);
76 }
77
78
79 END { }       # module clean-up code here (global destructor)