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

(-)a/C4/Reserves.pm (-1 / +29 lines)
Lines 131-136 BEGIN { Link Here
131
        &ReserveSlip
131
        &ReserveSlip
132
        &ToggleSuspend
132
        &ToggleSuspend
133
        &SuspendAll
133
        &SuspendAll
134
135
        &GetReservesControlBranch
134
    );
136
    );
135
    @EXPORT_OK = qw( MergeHolds );
137
    @EXPORT_OK = qw( MergeHolds );
136
}    
138
}    
Lines 898-904 sub CheckReserves { Link Here
898
                if ( $res->{'priority'} && $res->{'priority'} < $priority ) {
900
                if ( $res->{'priority'} && $res->{'priority'} < $priority ) {
899
                    my $borrowerinfo=C4::Members::GetMember(borrowernumber => $res->{'borrowernumber'});
901
                    my $borrowerinfo=C4::Members::GetMember(borrowernumber => $res->{'borrowernumber'});
900
                    my $iteminfo=C4::Items::GetItem($itemnumber);
902
                    my $iteminfo=C4::Items::GetItem($itemnumber);
901
                    my $branch=C4::Circulation::_GetCircControlBranch($iteminfo,$borrowerinfo);
903
                    my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo );
902
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
904
                    my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'});
903
                    next if ($branchitemrule->{'holdallowed'} == 0);
905
                    next if ($branchitemrule->{'holdallowed'} == 0);
904
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'}));
906
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'}));
Lines 2183-2188 sub ReserveSlip { Link Here
2183
    );
2185
    );
2184
}
2186
}
2185
2187
2188
=head2 GetReservesControlBranch
2189
2190
  my $reserves_control_branch = GetReservesControlBranch($item, $borrower);
2191
2192
  Return the branchcode to be used to determine which reserves
2193
  policy applies to a transaction.
2194
2195
  C<$iteminfos> is a hashref for an item. Only 'homebranch' is used.
2196
2197
  C<$borrower> is a hashref to borrower. Only 'branchcode' is used.
2198
2199
=cut
2200
2201
sub GetReservesControlBranch {
2202
    my ( $item, $borrower ) = @_;
2203
2204
    my $reserves_control = C4::Context->preference('ReservesControlBranch');
2205
2206
    my $branchcode =
2207
        ( $reserves_control eq 'ItemHomeLibrary' ) ? $item->{'homebranch'}
2208
      : ( $reserves_control eq 'PatronLibrary' )   ? $borrower->{'branchcode'}
2209
      :                                              undef;
2210
2211
    return $branchcode;
2212
}
2213
2186
=head1 AUTHOR
2214
=head1 AUTHOR
2187
2215
2188
Koha Development Team <http://koha-community.org/>
2216
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 (-2 / +19 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 4;
5
use Test::More tests => 6;
6
use MARC::Record;
6
use MARC::Record;
7
7
8
use C4::Branch;
8
use C4::Branch;
Lines 76-78 is($status, "Reserved", "CheckReserves Test 2"); Link Here
76
76
77
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
77
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
78
is($status, "Reserved", "CheckReserves Test 3");
78
is($status, "Reserved", "CheckReserves Test 3");
79
- 
79
80
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
81
C4::Context->set_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
82
ok(
83
    'ItemHomeLib' eq GetReservesControlBranch(
84
        { homebranch => 'ItemHomeLib' },
85
        { branchcode => 'PatronHomeLib' }
86
    ), "GetReservesControlBranch returns item home branch when set to ItemHomeLibrary"
87
);
88
C4::Context->set_preference( 'ReservesControlBranch', 'PatronLibrary' );
89
ok(
90
    'PatronHomeLib' eq GetReservesControlBranch(
91
        { homebranch => 'ItemHomeLib' },
92
        { branchcode => 'PatronHomeLib' }
93
    ), "GetReservesControlBranch returns patron home branch when set to PatronLibrary"
94
);
95
C4::Context->set_preference( 'ReservesControlBranch', $ReservesControlBranch );
96

Return to bug 10272