Lines 383-407
sub pickup_locations {
Link Here
|
383 |
my ( $self, $params ) = @_; |
383 |
my ( $self, $params ) = @_; |
384 |
|
384 |
|
385 |
Koha::Exceptions::MissingParameter->throw( parameter => 'patron' ) |
385 |
Koha::Exceptions::MissingParameter->throw( parameter => 'patron' ) |
386 |
unless exists $params->{patron}; |
386 |
unless exists $params->{patron}; |
387 |
|
387 |
|
388 |
my $patron = $params->{patron}; |
388 |
my $patron = $params->{patron}; |
389 |
|
389 |
|
390 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
390 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
391 |
my @pickup_locations; |
391 |
my @pickup_locations; |
|
|
392 |
my $location_items; |
392 |
foreach my $item ( $self->items->as_list ) { |
393 |
foreach my $item ( $self->items->as_list ) { |
393 |
my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", |
394 |
my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", |
394 |
$item->itype,$item->homebranch,$item->holdingbranch,$item->ccode || "",$patron->branchcode||"" ; |
395 |
$item->itype, $item->homebranch, $item->holdingbranch, $item->ccode || "", $patron->branchcode || ""; |
395 |
my $item_pickup_locations = $memory_cache->get_from_cache( $cache_key ); |
396 |
my $item_pickup_locations = $memory_cache->get_from_cache($cache_key); |
396 |
unless( $item_pickup_locations ){ |
397 |
unless ($item_pickup_locations) { |
397 |
@{ $item_pickup_locations } = $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; |
398 |
@{$item_pickup_locations} = |
398 |
$memory_cache->set_in_cache( $cache_key, $item_pickup_locations ); |
399 |
$item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; |
|
|
400 |
$memory_cache->set_in_cache( $cache_key, $item_pickup_locations ); |
401 |
} |
402 |
push @pickup_locations, @{$item_pickup_locations}; |
403 |
for my $location (@{$item_pickup_locations}) { |
404 |
push @{ $location_items->{$location} }, $item->itemnumber; |
399 |
} |
405 |
} |
400 |
push @pickup_locations, @{ $item_pickup_locations } |
|
|
401 |
} |
406 |
} |
402 |
|
407 |
|
403 |
return Koha::Libraries->search( |
408 |
my $resultSet = |
404 |
{ branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } ); |
409 |
Koha::Libraries->search( { branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } ); |
|
|
410 |
|
411 |
$resultSet->{_pickup_location_items} = $location_items; |
412 |
|
413 |
return $resultSet; |
405 |
} |
414 |
} |
406 |
|
415 |
|
407 |
=head3 hidden_in_opac |
416 |
=head3 hidden_in_opac |