Bug 36120: Add pickup_items to the pickup_locations response
This patch adds pickup_items as a list of itemnumbers that can be picked from the library should it be selected as a pickup location. Sponsored-by: Cuyahoga County Public Library Signed-off-by: Lisette Scheer <lisette.scheer@bywatersolutions.com> Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
e33be427bc
commit
b3fa2506cd
|
|
@ -383,25 +383,34 @@ sub pickup_locations {
|
|||
my ( $self, $params ) = @_;
|
||||
|
||||
Koha::Exceptions::MissingParameter->throw( parameter => 'patron' )
|
||||
unless exists $params->{patron};
|
||||
unless exists $params->{patron};
|
||||
|
||||
my $patron = $params->{patron};
|
||||
|
||||
my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
|
||||
my @pickup_locations;
|
||||
my $location_items;
|
||||
foreach my $item ( $self->items->as_list ) {
|
||||
my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s",
|
||||
$item->itype,$item->homebranch,$item->holdingbranch,$item->ccode || "",$patron->branchcode||"" ;
|
||||
my $item_pickup_locations = $memory_cache->get_from_cache( $cache_key );
|
||||
unless( $item_pickup_locations ){
|
||||
@{ $item_pickup_locations } = $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all;
|
||||
$memory_cache->set_in_cache( $cache_key, $item_pickup_locations );
|
||||
$item->itype, $item->homebranch, $item->holdingbranch, $item->ccode || "", $patron->branchcode || "";
|
||||
my $item_pickup_locations = $memory_cache->get_from_cache($cache_key);
|
||||
unless ($item_pickup_locations) {
|
||||
@{$item_pickup_locations} =
|
||||
$item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all;
|
||||
$memory_cache->set_in_cache( $cache_key, $item_pickup_locations );
|
||||
}
|
||||
push @pickup_locations, @{$item_pickup_locations};
|
||||
for my $location (@{$item_pickup_locations}) {
|
||||
push @{ $location_items->{$location} }, $item->itemnumber;
|
||||
}
|
||||
push @pickup_locations, @{ $item_pickup_locations }
|
||||
}
|
||||
|
||||
return Koha::Libraries->search(
|
||||
{ branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } );
|
||||
my $resultSet =
|
||||
Koha::Libraries->search( { branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } );
|
||||
|
||||
$resultSet->{_pickup_location_items} = $location_items;
|
||||
|
||||
return $resultSet;
|
||||
}
|
||||
|
||||
=head3 hidden_in_opac
|
||||
|
|
|
|||
|
|
@ -530,6 +530,7 @@ sub pickup_locations {
|
|||
my $pickup_locations = $c->objects->search($pl_set);
|
||||
@response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations};
|
||||
}
|
||||
@response = map { $_->{pickup_items} = $pl_set->{_pickup_location_items}->{ $_->{library_id} }; $_; } @response;
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
|
|
|
|||
|
|
@ -104,6 +104,13 @@ properties:
|
|||
pickup_location:
|
||||
type: boolean
|
||||
description: If the library can act as a pickup location
|
||||
pickup_items:
|
||||
type:
|
||||
- array
|
||||
- 'null'
|
||||
description: Array of items available for pickup at this library if the library is marked as a pickup location
|
||||
items:
|
||||
type: integer
|
||||
public:
|
||||
type: boolean
|
||||
description: If the library is visible to the public
|
||||
|
|
|
|||
Loading…
Reference in New Issue