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.

Signed-off-by: Bob Bennhoff <bbennhoff@clicweb.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Kyle M Hall 2018-08-15 14:27:45 -04:00 committed by Nick Clemens
parent b028a2d1a5
commit 02d3d4a8f5

View file

@ -85,4 +85,25 @@ sub InIndependentBranchesMode {
return ( not C4::Context->preference("IndependentBranches") or C4::Context::IsSuperLibrarian );
}
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;