From 20612581dccd32d644dbe619514afeb56c51662d Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Fri, 10 Feb 2017 17:05:35 +0200 Subject: [PATCH] Bug 7614: Consider transfer limits in Koha::Template::Plugin::Branches Consider transfer limits in Koha::Template::Plugin::Branches->pickup_locations. This patch modified the mentioned method to consider branch transfer limits and does not include any library in the returned list of libraries in case a branch transfer limit applies for a given book or item. To be tested in following patches. --- Koha/Template/Plugin/Branches.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 75ed8f7..cca69f0 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -78,9 +78,18 @@ sub all { sub pickup_locations { my ($self, $params) = @_; - $params->{search_params} ||= {}; - $params->{search_params}->{pickup_location} = 1; - return $self->all($params); + + my $selected = $params->{selected}; + my $libraries = Koha::Libraries->pickup_locations($params); + for my $l ( @$libraries ) { + if ( defined $selected and $l->{branchcode} eq $selected + or not defined $selected and C4::Context->userenv and $l->{branchcode} eq C4::Context->userenv->{branch} + ) { + $l->{selected} = 1; + } + } + + return $libraries; } 1; -- 1.9.1