Bug 7614: Consider transfer limits in Koha::Template::Plugin::Branches
authorKyle M Hall <kyle@bywatersolutiosn.com>
Wed, 15 Aug 2018 18:27:45 +0000 (14:27 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 25 Jan 2019 14:46:59 +0000 (14:46 +0000)
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>
Koha/Template/Plugin/Branches.pm

index 1f50ef3..58b13d2 100644 (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;