From fa9d8e54c2fd2db729a4b16b40583d808109550a Mon Sep 17 00:00:00 2001 From: bob_lyon Date: Tue, 6 Jun 2006 22:48:00 +0000 Subject: [PATCH] Merging katipo changes... Modified getbranches so you can pass it a branch type and it will only return branches of that type --- C4/Koha.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 63d1f71b57..7dd57e87a6 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -36,8 +36,6 @@ C4::Koha - Perl Module containing convenience functions for Koha scripts use C4::Koha; - $date = slashifyDate("01-01-2002") - =head1 DESCRIPTION Koha.pm provides many functions for Koha scripts. @@ -120,6 +118,7 @@ foreach my $thisbranch (sort keys %$branches) { sub getbranches { # returns a reference to a hash of references to branches... + my ($type) = @_; my %branches; my $dbh = C4::Context->dbh; my $sth; @@ -134,7 +133,12 @@ sub getbranches { $sth->execute; while (my $branch=$sth->fetchrow_hashref) { my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?"); - $nsth->execute($branch->{'branchcode'}); + if ($type){ + $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ? and categorycode = ?"); + $nsth->execute($branch->{'branchcode'},$type); + } else { + $nsth->execute($branch->{'branchcode'}); + } while (my ($cat) = $nsth->fetchrow_array) { # FIXME - This seems wrong. It ought to be # $branch->{categorycodes}{$cat} = 1; @@ -147,7 +151,13 @@ sub getbranches { # that aren't fields in the "branches" table. $branch->{$cat} = 1; } - $branches{$branch->{'branchcode'}}=$branch; + if ($type) { + $branches{$branch->{'branchcode'}}=$branch; + } + } + if (!$type){ + $branches{$branch->{'branchcode'}}=$branch; + } } return (\%branches); } -- 2.20.1