Lines 32-37
use C4::Biblio;
Link Here
|
32 |
use C4::Dates qw/format_date/; |
32 |
use C4::Dates qw/format_date/; |
33 |
|
33 |
|
34 |
use List::Util qw(shuffle); |
34 |
use List::Util qw(shuffle); |
|
|
35 |
use List::MoreUtils qw(any); |
35 |
use Data::Dumper; |
36 |
use Data::Dumper; |
36 |
|
37 |
|
37 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
38 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
Lines 361-368
sub MapItemsToHoldRequests {
Link Here
|
361 |
return unless scalar(@$hold_requests) > 0; |
362 |
return unless scalar(@$hold_requests) > 0; |
362 |
return unless scalar(@$available_items) > 0; |
363 |
return unless scalar(@$available_items) > 0; |
363 |
|
364 |
|
364 |
my $automatic_return = C4::Context->preference("AutomaticItemReturn"); |
|
|
365 |
|
366 |
# identify item-level requests |
365 |
# identify item-level requests |
367 |
my %specific_items_requested = map { $_->{itemnumber} => 1 } |
366 |
my %specific_items_requested = map { $_->{itemnumber} => 1 } |
368 |
grep { defined($_->{itemnumber}) } |
367 |
grep { defined($_->{itemnumber}) } |
Lines 426-432
sub MapItemsToHoldRequests {
Link Here
|
426 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
425 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
427 |
my ($itemnumber, $holdingbranch); |
426 |
my ($itemnumber, $holdingbranch); |
428 |
|
427 |
|
429 |
my $holding_branch_items = $automatic_return ? undef : $items_by_branch{$pickup_branch}; |
428 |
my $holding_branch_items = $items_by_branch{$pickup_branch}; |
430 |
if ( $holding_branch_items ) { |
429 |
if ( $holding_branch_items ) { |
431 |
foreach my $item (@$holding_branch_items) { |
430 |
foreach my $item (@$holding_branch_items) { |
432 |
if ( $request->{borrowerbranch} eq $item->{homebranch} ) { |
431 |
if ( $request->{borrowerbranch} eq $item->{homebranch} ) { |
Lines 594-603
sub least_cost_branch {
Link Here
|
594 |
#$from - arrayref |
593 |
#$from - arrayref |
595 |
my ($to, $from, $transport_cost_matrix) = @_; |
594 |
my ($to, $from, $transport_cost_matrix) = @_; |
596 |
|
595 |
|
597 |
# Nothing really spectacular: supply to branch, a list of potential from branches |
596 |
# Nothing really spectacular: supply to branch, a list of potential from branches |
598 |
# and find the minimum from - to value from the transport_cost_matrix |
597 |
# and find the minimum from - to value from the transport_cost_matrix |
599 |
return $from->[0] if @$from == 1; |
598 |
return $from->[0] if @$from == 1; |
600 |
|
599 |
|
|
|
600 |
# If the pickup library is in the list of libraries to pull from, |
601 |
# return that library right away, it is obviously the least costly |
602 |
return ($to) if any { $_ eq $to } @$from; |
603 |
|
601 |
my ($least_cost, @branch); |
604 |
my ($least_cost, @branch); |
602 |
foreach (@$from) { |
605 |
foreach (@$from) { |
603 |
my $cell = $transport_cost_matrix->{$to}{$_}; |
606 |
my $cell = $transport_cost_matrix->{$to}{$_}; |