View | Details | Raw Unified | Return to bug 33447
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-2 / +3 lines)
Lines 258-265 sub can_be_transferred { Link Here
258
    my $pickup_locations = $biblio->pickup_locations( {patron => $patron } );
258
    my $pickup_locations = $biblio->pickup_locations( {patron => $patron } );
259
259
260
Returns a Koha::Libraries set of possible pickup locations for this biblio's items,
260
Returns a Koha::Libraries set of possible pickup locations for this biblio's items,
261
according to patron's home library (if patron is defined and holds are allowed
261
according to patron's home library and if item can be transferred to each pickup location.
262
only from hold groups) and if item can be transferred to each pickup location.
262
263
Patron is a required parameter.
263
264
264
=cut
265
=cut
265
266
(-)a/Koha/Biblios.pm (-1 / +3 lines)
Lines 40-46 Koha::Biblios - Koha Biblio object set class Link Here
40
    my $biblios = Koha::Biblios->search(...);
40
    my $biblios = Koha::Biblios->search(...);
41
    my $pickup_locations = $biblios->pickup_locations({ patron => $patron });
41
    my $pickup_locations = $biblios->pickup_locations({ patron => $patron });
42
42
43
For a given resultset, it returns all the pickup locations
43
For a given resultset, it returns all the pickup locations.
44
45
Patron is a required parameter.
44
46
45
=cut
47
=cut
46
48
(-)a/Koha/Item.pm (-5 / +6 lines)
Lines 736-760 sub can_be_transferred { Link Here
736
736
737
$pickup_locations = $item->pickup_locations( {patron => $patron } )
737
$pickup_locations = $item->pickup_locations( {patron => $patron } )
738
738
739
Returns possible pickup locations for this item, according to patron's home library (if patron is defined and holds are allowed only from hold groups)
739
Returns possible pickup locations for this item, according to patron's home library
740
and if item can be transferred to each pickup location.
740
and if item can be transferred to each pickup location.
741
741
742
Patron parameter is required.
743
742
=cut
744
=cut
743
745
744
sub pickup_locations {
746
sub pickup_locations {
745
    my ($self, $params) = @_;
747
    my ($self, $params) = @_;
746
748
747
    my $patron = $params->{patron};
749
    my $patron = $params->{patron};
750
    # FIXME We should throw an exception if not passed
748
751
749
    my $circ_control_branch =
752
    my $circ_control_branch =
750
      C4::Reserves::GetReservesControlBranch( $self->unblessed(), $patron->unblessed );
753
      C4::Reserves::GetReservesControlBranch( $self->unblessed(), $patron->unblessed );
751
    my $branchitemrule =
754
    my $branchitemrule =
752
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
755
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
753
756
754
    if(defined $patron) {
757
    return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_local_hold_group' && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} );
755
        return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_local_hold_group' && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} );
758
    return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_home_library' && $self->home_branch->branchcode ne $patron->branchcode;
756
        return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_home_library' && $self->home_branch->branchcode ne $patron->branchcode;
757
    }
758
759
759
    my $pickup_libraries = Koha::Libraries->search();
760
    my $pickup_libraries = Koha::Libraries->search();
760
    if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup') {
761
    if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup') {
(-)a/t/db_dependent/Koha/Biblios.t (-2 / +3 lines)
Lines 278-283 subtest 'pickup_locations() tests' => sub { Link Here
278
    my $item_2_1 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber });
278
    my $item_2_1 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber });
279
    my $item_2_2 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber });
279
    my $item_2_2 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber });
280
280
281
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
282
281
    my $biblios = Koha::Biblios->search(
283
    my $biblios = Koha::Biblios->search(
282
        {
284
        {
283
            biblionumber => [ $biblio_1->biblionumber, $biblio_2->biblionumber ]
285
            biblionumber => [ $biblio_1->biblionumber, $biblio_2->biblionumber ]
Lines 298-304 subtest 'pickup_locations() tests' => sub { Link Here
298
    ];
300
    ];
299
301
300
    my $pickup_locations_ids = [
302
    my $pickup_locations_ids = [
301
        $biblios->pickup_locations->_resultset->get_column('branchcode')->all
303
        $biblios->pickup_locations({ patron => $patron })->_resultset->get_column('branchcode')->all
302
    ];
304
    ];
303
305
304
    is_deeply(
306
    is_deeply(
305
- 

Return to bug 33447