Lines 365-389
sub pickup_locations {
Link Here
|
365 |
my ( $self, $params ) = @_; |
365 |
my ( $self, $params ) = @_; |
366 |
|
366 |
|
367 |
Koha::Exceptions::MissingParameter->throw( parameter => 'patron' ) |
367 |
Koha::Exceptions::MissingParameter->throw( parameter => 'patron' ) |
368 |
unless exists $params->{patron}; |
368 |
unless exists $params->{patron}; |
369 |
|
369 |
|
370 |
my $patron = $params->{patron}; |
370 |
my $patron = $params->{patron}; |
371 |
|
371 |
|
372 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
372 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
373 |
my @pickup_locations; |
373 |
my @pickup_locations; |
|
|
374 |
my $location_items; |
374 |
foreach my $item ( $self->items->as_list ) { |
375 |
foreach my $item ( $self->items->as_list ) { |
375 |
my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", |
376 |
my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", |
376 |
$item->itype,$item->homebranch,$item->holdingbranch,$item->ccode || "",$patron->branchcode||"" ; |
377 |
$item->itype, $item->homebranch, $item->holdingbranch, $item->ccode || "", $patron->branchcode || ""; |
377 |
my $item_pickup_locations = $memory_cache->get_from_cache( $cache_key ); |
378 |
my $item_pickup_locations = $memory_cache->get_from_cache($cache_key); |
378 |
unless( $item_pickup_locations ){ |
379 |
unless ($item_pickup_locations) { |
379 |
@{ $item_pickup_locations } = $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; |
380 |
@{$item_pickup_locations} = |
380 |
$memory_cache->set_in_cache( $cache_key, $item_pickup_locations ); |
381 |
$item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; |
|
|
382 |
$memory_cache->set_in_cache( $cache_key, $item_pickup_locations ); |
383 |
} |
384 |
push @pickup_locations, @{$item_pickup_locations}; |
385 |
for my $location (@{$item_pickup_locations}) { |
386 |
push @{ $location_items->{$location} }, $item->itemnumber; |
381 |
} |
387 |
} |
382 |
push @pickup_locations, @{ $item_pickup_locations } |
|
|
383 |
} |
388 |
} |
384 |
|
389 |
|
385 |
return Koha::Libraries->search( |
390 |
my $resultSet = |
386 |
{ branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } ); |
391 |
Koha::Libraries->search( { branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } ); |
|
|
392 |
|
393 |
$resultSet->{_pickup_location_items} = $location_items; |
394 |
|
395 |
return $resultSet; |
387 |
} |
396 |
} |
388 |
|
397 |
|
389 |
=head3 hidden_in_opac |
398 |
=head3 hidden_in_opac |