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 _can_pickup_at |
557 |
|
558 |
$item->_can_pickup_at({ 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 and |
574 |
are pickup_locations |
575 |
|
576 |
If checking only one library please use $item->can_be_transferred. |
577 |
|
578 |
=cut |
579 |
|
580 |
sub _can_pickup_at { |
581 |
my ($self, $params ) = @_; |
582 |
|
583 |
my $to = $params->{to}; |
584 |
my $from = $params->{from}; |
585 |
$from = defined $from ? $from->branchcode : $self->holdingbranch; |
586 |
|
587 |
my @pickup_locations; |
588 |
my @destination_codes; |
589 |
foreach my $lib (@$to){ |
590 |
next unless $lib->pickup_location; |
591 |
push @destination_codes, $lib->branchcode; |
592 |
push @pickup_locations, $lib; |
593 |
} |
594 |
|
595 |
return \@pickup_locations unless C4::Context->preference('UseBranchTransferLimits'); |
596 |
|
597 |
my $limittype = C4::Context->preference('BranchTransferLimitsType'); |
598 |
my $limiter = $limittype eq 'itemtype' ? $self->effective_itemtype : $self->ccode; |
599 |
|
600 |
my @cant_transfer; |
601 |
my $limits = Koha::Item::Transfer::Limits->search({ |
602 |
fromBranch => $from, |
603 |
$limittype => $limiter |
604 |
}); |
605 |
my @limits = $limits->get_column('toBranch'); |
606 |
return \@pickup_locations unless @limits; |
607 |
|
608 |
my @can_transfer = Koha::Libraries->search({ |
609 |
pickup_location => 1, |
610 |
branchcode => { |
611 |
-in => \@destination_codes, |
612 |
-not_in => \@limits, |
613 |
} |
614 |
}); |
615 |
return \@can_transfer; |
553 |
} |
616 |
} |
554 |
|
617 |
|
555 |
=head3 pickup_locations |
618 |
=head3 pickup_locations |
Lines 596-609
sub pickup_locations {
Link Here
|
596 |
})->as_list; |
659 |
})->as_list; |
597 |
} |
660 |
} |
598 |
|
661 |
|
599 |
my @pickup_locations; |
662 |
my $pickup_locations = $self->_can_pickup_at({ |
600 |
foreach my $library (@libs) { |
663 |
to => \@libs |
601 |
if ($library->pickup_location && $self->can_be_transferred({ to => $library })) { |
664 |
}); |
602 |
push @pickup_locations, $library; |
|
|
603 |
} |
604 |
} |
605 |
|
665 |
|
606 |
return \@pickup_locations; |
666 |
return $pickup_locations; |
607 |
} |
667 |
} |
608 |
|
668 |
|
609 |
=head3 article_request_type |
669 |
=head3 article_request_type |
610 |
- |
|
|