|
Lines 550-555
sub can_be_transferred {
Link Here
|
| 550 |
$limittype => $limittype eq 'itemtype' |
550 |
$limittype => $limittype eq 'itemtype' |
| 551 |
? $self->effective_itemtype : $self->ccode |
551 |
? $self->effective_itemtype : $self->ccode |
| 552 |
})->count ? 0 : 1; |
552 |
})->count ? 0 : 1; |
|
|
553 |
|
| 554 |
} |
| 555 |
|
| 556 |
=head3 libs_can_transfer_to |
| 557 |
|
| 558 |
$item->libs_can_transfer_to({ to => $to_libraries, from => $from_library }) |
| 559 |
Checks if an item can be transferred to given libraries. |
| 560 |
|
| 561 |
This feature is controlled by two system preferences: |
| 562 |
UseBranchTransferLimits to enable / disable the feature |
| 563 |
BranchTransferLimitsType to use either an itemnumber or ccode as an identifier |
| 564 |
for setting the limitations |
| 565 |
|
| 566 |
Takes HASHref that can have the following parameters: |
| 567 |
MANDATORY PARAMETERS: |
| 568 |
$to : Array of Koha::Libraries |
| 569 |
OPTIONAL PARAMETERS: |
| 570 |
$from : Koha::Library # if not given, item holdingbranch |
| 571 |
# will be used instead |
| 572 |
|
| 573 |
Returns arry of Koha::Libraries that item can be transferred to $to_library. |
| 574 |
|
| 575 |
If checking only one library please use $item->can_be_transferred. |
| 576 |
|
| 577 |
=cut |
| 578 |
|
| 579 |
sub libs_can_transfer_to { |
| 580 |
my ($self, $params ) = @_; |
| 581 |
|
| 582 |
my $to = $params->{to}; |
| 583 |
my $from = $params->{from}; |
| 584 |
$from = defined $from ? $from->branchcode : $self->holdingbranch; |
| 585 |
|
| 586 |
return $to unless C4::Context->preference('UseBranchTransferLimits'); |
| 587 |
|
| 588 |
my $limittype = C4::Context->preference('BranchTransferLimitsType'); |
| 589 |
my $limiter = $limittype eq 'itemtype' ? $self->effective_itemtype : $self->ccode; |
| 590 |
|
| 591 |
my @destinations = map { $_->branchcode } @$to; |
| 592 |
my @cant_transfer; |
| 593 |
my $limits = Koha::Item::Transfer::Limits->search({ |
| 594 |
fromBranch => $from, |
| 595 |
$limittype => $limiter |
| 596 |
}); |
| 597 |
my @limits = $limits->get_column('toBranch'); |
| 598 |
return $to unless @limits; |
| 599 |
|
| 600 |
my @can_transfer = Koha::Libraries->search({ |
| 601 |
pickup_location => 1, |
| 602 |
branchcode => { |
| 603 |
-in => \@destinations, |
| 604 |
-not_in => \@limits, |
| 605 |
} |
| 606 |
}); |
| 607 |
return \@can_transfer; |
| 553 |
} |
608 |
} |
| 554 |
|
609 |
|
| 555 |
=head3 pickup_locations |
610 |
=head3 pickup_locations |
|
Lines 596-609
sub pickup_locations {
Link Here
|
| 596 |
})->as_list; |
651 |
})->as_list; |
| 597 |
} |
652 |
} |
| 598 |
|
653 |
|
| 599 |
my @pickup_locations; |
654 |
my $pickup_locations = $self->libs_can_transfer_to({ |
| 600 |
foreach my $library (@libs) { |
655 |
to => \@libs |
| 601 |
if ($library->pickup_location && $self->can_be_transferred({ to => $library })) { |
656 |
}); |
| 602 |
push @pickup_locations, $library; |
|
|
| 603 |
} |
| 604 |
} |
| 605 |
|
657 |
|
| 606 |
return \@pickup_locations; |
658 |
return $pickup_locations; |
| 607 |
} |
659 |
} |
| 608 |
|
660 |
|
| 609 |
=head3 article_request_type |
661 |
=head3 article_request_type |
| 610 |
- |
|
|