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

(-)a/C4/Reserves.pm (-2 / +2 lines)
Lines 321-327 sub CanBookBeReserved{ Link Here
321
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
321
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
322
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
322
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
323
        && C4::Circulation::CheckIfIssuedToPatron( $borrowernumber, $biblionumber ) ) {
323
        && C4::Circulation::CheckIfIssuedToPatron( $borrowernumber, $biblionumber ) ) {
324
        return { status =>'itemAlreadyOnLoan' };
324
        return { status =>'alreadypossession' };
325
    }
325
    }
326
326
327
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
327
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
Lines 395-401 sub CanItemBeReserved { Link Here
395
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
395
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
396
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
396
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
397
        && C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) {
397
        && C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) {
398
        return { status =>'itemAlreadyOnLoan' };
398
        return { status =>'alreadypossession' };
399
    }
399
    }
400
400
401
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
401
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-6 / +6 lines)
Lines 200-214 Link Here
200
                                    [% IF ( bibitemloo.already_reserved ) %]
200
                                    [% IF ( bibitemloo.already_reserved ) %]
201
                                        <div class="alert alert-warning">You have already requested this title.</div>
201
                                        <div class="alert alert-warning">You have already requested this title.</div>
202
                                    [% ELSE %]
202
                                    [% ELSE %]
203
                                        [% UNLESS ( bibitemloo.bib_available ) %]
203
                                        [% IF ( bibitemloo.already_patron_possession ) %]
204
                                            <div class="alert alert-warning">There are no items that can be placed on hold.</div>
204
                                            <div class="alert alert-warning">This title cannot be requested because it's already in your possession.</div>
205
                                        [% ELSE %]
205
                                        [% ELSE %]
206
                                            [% IF ( bibitemloo.already_patron_possession ) %]
206
                                            [% UNLESS ( bibitemloo.bib_available ) %]
207
                                                <div class="alert alert-warning">This title cannot be requested because it's already in your possession.</div>
207
                                                <div class="alert">There are no items that can be placed on hold.</div>
208
                                            [% ELSE %]
208
                                            [% ELSE %]
209
                                                <div class="alert alert-warning">This title cannot be requested.</div>
209
                                                <div class="alert">This title cannot be requested.</div>
210
                                            [% END %]
210
                                            [% END %]
211
                                        [% END # / UNLESS bibitemloo.bib_available %]
211
                                        [% END # / UNLESS bibitemloo.already_patron_possession %]
212
                                    [% END # / IF bibitemloo.already_reserved %]
212
                                    [% END # / IF bibitemloo.already_reserved %]
213
                                [% END # / UNLESS bibitemloo.holdable %]
213
                                [% END # / UNLESS bibitemloo.holdable %]
214
214
(-)a/opac/opac-reserve.pl (-6 / +3 lines)
Lines 601-611 foreach my $biblioNum (@biblionumbers) { Link Here
601
        $biblioLoopIter{holdable} = undef;
601
        $biblioLoopIter{holdable} = undef;
602
        $biblioLoopIter{itemholdable} = undef;
602
        $biblioLoopIter{itemholdable} = undef;
603
    }
603
    }
604
    if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) {
605
        $biblioLoopIter{holdable} = undef;
606
        $biblioLoopIter{already_patron_possession} = 1;
607
    }
608
609
    if ( $biblioLoopIter{holdable} ) {
604
    if ( $biblioLoopIter{holdable} ) {
610
        @not_available_at = uniq @not_available_at;
605
        @not_available_at = uniq @not_available_at;
611
        $biblioLoopIter{not_available_at} = \@not_available_at ;
606
        $biblioLoopIter{not_available_at} = \@not_available_at ;
Lines 620-626 foreach my $biblioNum (@biblionumbers) { Link Here
620
        }
615
        }
621
    }
616
    }
622
617
623
    $biblioLoopIter{holdable} &&= CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
618
    my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
619
    $biblioLoopIter{holdable} &&= $status eq 'OK';
620
    $biblioLoopIter{already_patron_possession} = $status eq 'alreadypossession';
624
621
625
    # For multiple holds per record, if a patron has previously placed a hold,
622
    # For multiple holds per record, if a patron has previously placed a hold,
626
    # the patron can only place more holds of the same type. That is, if the
623
    # the patron can only place more holds of the same type. That is, if the
(-)a/reserve/request.pl (-10 / +4 lines)
Lines 314-319 foreach my $biblionumber (@biblionumbers) { Link Here
314
                $template->param( $canReserve->{status} => 1 );
314
                $template->param( $canReserve->{status} => 1 );
315
                $biblioloopiter{ $canReserve->{status} } = 1;
315
                $biblioloopiter{ $canReserve->{status} } = 1;
316
            }
316
            }
317
            elsif ( $canReserve->{status} eq 'alreadypossession' ) {
318
                $template->param( $canReserve->{status} => 1);
319
                $biblioloopiter{ $canReserve->{status} } = 1;
320
            }
317
            else {
321
            else {
318
                $biblioloopiter{ $canReserve->{status} } = 1;
322
                $biblioloopiter{ $canReserve->{status} } = 1;
319
            }
323
            }
Lines 342-357 foreach my $biblionumber (@biblionumbers) { Link Here
342
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
346
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
343
        $template->param( max_holds_for_record => $max_holds_for_record );
347
        $template->param( max_holds_for_record => $max_holds_for_record );
344
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
348
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
345
346
        { # alreadypossession
347
            # Check to see if patron is allowed to place holds on records where the
348
            # patron already has an item from that record checked out
349
            if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
350
                && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) )
351
            {
352
                $template->param( alreadypossession => 1, );
353
            }
354
        }
355
    }
349
    }
356
350
357
351
(-)a/t/db_dependent/ILSDI_Services.t (-1 / +1 lines)
Lines 424-430 subtest 'Holds test' => sub { Link Here
424
    $query->param( 'pickup_location', $origin_branch->{branchcode});
424
    $query->param( 'pickup_location', $origin_branch->{branchcode});
425
    $reply = C4::ILSDI::Services::HoldItem( $query );
425
    $reply = C4::ILSDI::Services::HoldItem( $query );
426
426
427
    is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" );
427
    is( $reply->{code}, 'alreadypossession', "Patron has issued same book" );
428
    is( $reply->{pickup_location}, undef, "No reserve placed");
428
    is( $reply->{pickup_location}, undef, "No reserve placed");
429
429
430
    $schema->storage->txn_rollback;
430
    $schema->storage->txn_rollback;
(-)a/t/db_dependent/Reserves.t (-4 / +3 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 64;
20
use Test::More tests => 65;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1169-1180 subtest 'AllowHoldOnPatronPossession test' => sub { Link Here
1169
1169
1170
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1170
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1171
                                       $item->biblionumber)->{status},
1171
                                       $item->biblionumber)->{status},
1172
       'itemAlreadyOnLoan',
1172
       'alreadypossession',
1173
       'Patron cannot place hold on a book loaned to itself');
1173
       'Patron cannot place hold on a book loaned to itself');
1174
1174
1175
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1175
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1176
                                       $item->itemnumber)->{status},
1176
                                       $item->itemnumber)->{status},
1177
       'itemAlreadyOnLoan',
1177
       'alreadypossession',
1178
       'Patron cannot place hold on an item loaned to itself');
1178
       'Patron cannot place hold on an item loaned to itself');
1179
1179
1180
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1);
1180
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1);
1181
- 

Return to bug 22806