From 920db14214ea123c6dd1472f171a580c339e3a5f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 8 Feb 2013 11:14:17 -0500 Subject: [PATCH] Bug 9575 - Serious Holds Problem with IndependantBranches Test plan: 1) Disable IndependantBranches 2) Place 3 holds on a record with 3 different pickup locations 3) Enable IndependantBranches 4) Refresh the holds page for that record, all the holds show now show a pickup location of the logged in branch 5) Modify the order of the holds 6) Disable IndependantBranches 7) Refresh the holds, verify the holds all now have a pickup location of the logged in branch 8) Apply the patch 9) Repeat steps 1-3 10) Refresh the holds page for that record, all the holds should now show the correct pickup branch, but it cannot be changed as IndependantBranches is enabled. --- C4/Branch.pm | 14 +++++++++----- reserve/request.pl | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index fe67e0c..d55ba97 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -102,21 +102,24 @@ Create a branch selector with the following code. =cut sub GetBranches { - my ($onlymine)=@_; + my ($onlymine,$onlythis)=@_; # returns a reference to a hash of references to ALL branches... my %branches; my $dbh = C4::Context->dbh; my $sth; my $query="SELECT * FROM branches"; my @bind_parameters; - if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){ + if ($onlythis){ $query .= ' WHERE branchcode = ? '; - push @bind_parameters, C4::Context->userenv->{branch}; + push @bind_parameters, $onlythis; } + elsif ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){ + $query .= ' WHERE branchcode = ? '; + push @bind_parameters, C4::Context->userenv->{branch}; + } $query.=" ORDER BY branchname"; $sth = $dbh->prepare($query); $sth->execute( @bind_parameters ); - my $nsth = $dbh->prepare( "SELECT categorycode FROM branchrelations WHERE branchcode = ?" ); # prepare once, outside while loop @@ -158,7 +161,8 @@ sub mybranch { sub GetBranchesLoop { # since this is what most pages want anyway my $branch = @_ ? shift : mybranch(); # optional first argument is branchcode of "my branch", if preselection is wanted. my $onlymine = @_ ? shift : onlymine(); - my $branches = GetBranches($onlymine); + my $onlythis = shift; + my $branches = GetBranches($onlymine, $onlythis); my @loop; foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches ) { push @loop, { diff --git a/reserve/request.pl b/reserve/request.pl index 506d5fa..b1af156 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -579,7 +579,8 @@ foreach my $biblionumber (@biblionumbers) { $reserve{'barcode'} = $res->{'barcode'}; $reserve{'priority'} = $res->{'priority'}; $reserve{'lowestPriority'} = $res->{'lowestPriority'}; - $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'}); + my $only_this_branch = C4::Context->preference('IndependantBranches') ? $res->{'branchcode'} : undef; + $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'}, undef, $only_this_branch); $reserve{'optionloop'} = \@optionloop; $reserve{'suspend'} = $res->{'suspend'}; $reserve{'suspend_until'} = $res->{'suspend_until'}; -- 1.7.2.5