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

(-)a/C4/Reserves.pm (-1 / +29 lines)
Lines 130-135 BEGIN { Link Here
130
        &ReserveSlip
130
        &ReserveSlip
131
        &ToggleSuspend
131
        &ToggleSuspend
132
        &SuspendAll
132
        &SuspendAll
133
134
        &GetReservesControlBranch
133
    );
135
    );
134
    @EXPORT_OK = qw( MergeHolds );
136
    @EXPORT_OK = qw( MergeHolds );
135
}    
137
}    
Lines 863-869 sub CheckReserves { Link Here
863
                if ( $res->{'priority'} && $res->{'priority'} < $priority ) {
865
                if ( $res->{'priority'} && $res->{'priority'} < $priority ) {
864
                    my $borrowerinfo=C4::Members::GetMember(borrowernumber => $res->{'borrowernumber'});
866
                    my $borrowerinfo=C4::Members::GetMember(borrowernumber => $res->{'borrowernumber'});
865
                    my $iteminfo=C4::Items::GetItem($itemnumber);
867
                    my $iteminfo=C4::Items::GetItem($itemnumber);
866
                    my $branch=C4::Circulation::_GetCircControlBranch($iteminfo,$borrowerinfo);
868
                    my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo );
867
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
869
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
868
                    next if ($branchitemrule->{'holdallowed'} == 0);
870
                    next if ($branchitemrule->{'holdallowed'} == 0);
869
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'}));
871
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'}));
Lines 2168-2173 sub ReserveSlip { Link Here
2168
    );
2170
    );
2169
}
2171
}
2170
2172
2173
=head2 GetReservesControlBranch
2174
2175
  my $reserves_control_branch = GetReservesControlBranch($item, $borrower);
2176
2177
  Return the branchcode to be used to determine which reserves
2178
  policy applies to a transaction.
2179
2180
  C<$iteminfos> is a hashref for an item. Only 'homebranch' is used.
2181
2182
  C<$borrower> is a hashref to borrower. Only 'branchcode' is used.
2183
2184
=cut
2185
2186
sub GetReservesControlBranch {
2187
    my ( $item, $borrower ) = @_;
2188
2189
    my $reserves_control = C4::Context->preference('ReservesControlBranch');
2190
2191
    my $branchcode =
2192
        ( $reserves_control eq 'ItemHomeLibrary' ) ? $item->{'homebranch'}
2193
      : ( $reserves_control eq 'PatronLibrary' )   ? $borrower->{'branchcode'}
2194
      :                                              undef;
2195
2196
    return $branchcode;
2197
}
2198
2171
=head1 AUTHOR
2199
=head1 AUTHOR
2172
2200
2173
Koha Development Team <http://koha-community.org/>
2201
Koha Development Team <http://koha-community.org/>
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 490-496 foreach my $biblioNum (@biblionumbers) { Link Here
490
        # If there is no loan, return and transfer, we show a checkbox.
490
        # If there is no loan, return and transfer, we show a checkbox.
491
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
491
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
492
492
493
        my $branch = ( C4::Context->preference('ReservesControlBranch') eq 'ItemHomeLibrary' ) ? $itemInfo->{'homebranch'} : $borr->{'branchcode'};
493
        my $branch = GetReservesControlBranch( $itemInfo, $borr );
494
494
495
        my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} );
495
        my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} );
496
        my $policy_holdallowed = 1;
496
        my $policy_holdallowed = 1;
(-)a/t/db_dependent/Reserves.t (-1 / +16 lines)
Lines 66-71 ok($status eq "Reserved", "CheckReserves Test 2"); Link Here
66
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
66
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
67
ok($status eq "Reserved", "CheckReserves Test 3");
67
ok($status eq "Reserved", "CheckReserves Test 3");
68
68
69
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
70
C4::Context->set_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
71
ok(
72
    'ItemHomeLib' eq GetReservesControlBranch(
73
        { homebranch => 'ItemHomeLib' },
74
        { branchcode => 'PatronHomeLib' }
75
    ), "GetReservesControlBranch returns item home branch when set to ItemHomeLibrary"
76
);
77
C4::Context->set_preference( 'ReservesControlBranch', 'PatronLibrary' );
78
ok(
79
    'PatronHomeLib' eq GetReservesControlBranch(
80
        { homebranch => 'ItemHomeLib' },
81
        { branchcode => 'PatronHomeLib' }
82
    ), "GetReservesControlBranch returns patron home branch when set to PatronLibrary"
83
);
84
C4::Context->set_preference( 'ReservesControlBranch', $ReservesControlBranch );
69
85
70
# Teardown Test---------------------
86
# Teardown Test---------------------
71
# Delete item.
87
# Delete item.
72
- 

Return to bug 10272