From 3d3628a1a66835b0173a2c55a14818a24094af2a Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Thu, 30 Oct 2008 00:07:40 -0500 Subject: [PATCH] Add GetBranchLoop since so many pages use exactly the same code. Signed-off-by: Galen Charlton --- C4/Branch.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/Branch.pm b/C4/Branch.pm index c09b129576..cd81368ad9 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -32,6 +32,7 @@ BEGIN { &GetBranchName &GetBranch &GetBranches + &GetBranchesLoop &GetBranchDetail &get_branchinfos_of &ModBranch @@ -132,6 +133,21 @@ sub GetBranches { return ( \%branches ); } +sub GetBranchesLoop ($$) { # since this is what most pages want anyway + my $branch = shift or return undef; + my $onlymine = shift || 0; + my $branches = GetBranches($onlymine); + my @loop; + foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { + push @loop, { + value => $_, + selected => ($_ eq $branch) ? 1 : 0, + branchname => $branches->{$_}->{branchname}, + }; + } + return \@loop; +} + =head2 GetBranchName =cut -- 2.39.5