|
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 354-361
sub MapItemsToHoldRequests {
Link Here
|
| 354 |
return unless scalar(@$hold_requests) > 0; |
355 |
return unless scalar(@$hold_requests) > 0; |
| 355 |
return unless scalar(@$available_items) > 0; |
356 |
return unless scalar(@$available_items) > 0; |
| 356 |
|
357 |
|
| 357 |
my $automatic_return = C4::Context->preference("AutomaticItemReturn"); |
|
|
| 358 |
|
| 359 |
# identify item-level requests |
358 |
# identify item-level requests |
| 360 |
my %specific_items_requested = map { $_->{itemnumber} => 1 } |
359 |
my %specific_items_requested = map { $_->{itemnumber} => 1 } |
| 361 |
grep { defined($_->{itemnumber}) } |
360 |
grep { defined($_->{itemnumber}) } |
|
Lines 419-425
sub MapItemsToHoldRequests {
Link Here
|
| 419 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
418 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
| 420 |
my ($itemnumber, $holdingbranch); |
419 |
my ($itemnumber, $holdingbranch); |
| 421 |
|
420 |
|
| 422 |
my $holding_branch_items = $automatic_return ? undef : $items_by_branch{$pickup_branch}; |
421 |
my $holding_branch_items = $items_by_branch{$pickup_branch}; |
| 423 |
if ( $holding_branch_items ) { |
422 |
if ( $holding_branch_items ) { |
| 424 |
foreach my $item (@$holding_branch_items) { |
423 |
foreach my $item (@$holding_branch_items) { |
| 425 |
if ( $request->{borrowerbranch} eq $item->{homebranch} ) { |
424 |
if ( $request->{borrowerbranch} eq $item->{homebranch} ) { |
|
Lines 587-596
sub least_cost_branch {
Link Here
|
| 587 |
#$from - arrayref |
586 |
#$from - arrayref |
| 588 |
my ($to, $from, $transport_cost_matrix) = @_; |
587 |
my ($to, $from, $transport_cost_matrix) = @_; |
| 589 |
|
588 |
|
| 590 |
# Nothing really spectacular: supply to branch, a list of potential from branches |
589 |
# Nothing really spectacular: supply to branch, a list of potential from branches |
| 591 |
# and find the minimum from - to value from the transport_cost_matrix |
590 |
# and find the minimum from - to value from the transport_cost_matrix |
| 592 |
return $from->[0] if @$from == 1; |
591 |
return $from->[0] if @$from == 1; |
| 593 |
|
592 |
|
|
|
593 |
# If the pickup library is in the list of libraries to pull from, |
| 594 |
# return that library right away, it is obviously the least costly |
| 595 |
return ($to) if any { $_ eq $to } @$from; |
| 596 |
|
| 594 |
my ($least_cost, @branch); |
597 |
my ($least_cost, @branch); |
| 595 |
foreach (@$from) { |
598 |
foreach (@$from) { |
| 596 |
my $cell = $transport_cost_matrix->{$to}{$_}; |
599 |
my $cell = $transport_cost_matrix->{$to}{$_}; |