Lines 285-290
sub can_be_transferred {
Link Here
|
285 |
} |
285 |
} |
286 |
|
286 |
|
287 |
|
287 |
|
|
|
288 |
=head3 validate_pickup_location |
289 |
|
290 |
$biblio->validate_pickup_location( {patron => $patron, pickup_location_id => $branchcode } ); |
291 |
|
292 |
Returns 1 if the pickup location is valid, nothing if it is not. This function is similar to, but distinct |
293 |
from pickup_locations in that it does not need to calculate all valid locations, but simply to check until |
294 |
1 item is found that validates the passed location. Rather than confusing the logic in that sub, some code |
295 |
is duplicated. |
296 |
|
297 |
=cut |
298 |
|
299 |
sub validate_pickup_location { |
300 |
my ( $self, $params ) = @_; |
301 |
|
302 |
my $patron = $params->{patron}; |
303 |
my $branchcode = $params->{pickup_location_id}; |
304 |
|
305 |
my %seen; |
306 |
foreach my $item ( $self->items->as_list ) { |
307 |
|
308 |
# The 5 variables below determine the valid locations for any item, no need to check twice |
309 |
my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", |
310 |
$item->itype, $item->homebranch, $item->holdingbranch, $item->ccode || "", $patron->branchcode || ""; |
311 |
next if $seen{$cache_key}; |
312 |
|
313 |
my @item_pickup_locations = |
314 |
$item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; |
315 |
$seen{$cache_key} = 1; |
316 |
|
317 |
return 1 if grep { $branchcode eq $_ } @item_pickup_locations; |
318 |
} |
319 |
|
320 |
return; |
321 |
} |
322 |
|
288 |
=head3 pickup_locations |
323 |
=head3 pickup_locations |
289 |
|
324 |
|
290 |
my $pickup_locations = $biblio->pickup_locations({ patron => $patron }); |
325 |
my $pickup_locations = $biblio->pickup_locations({ patron => $patron }); |