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

(-)a/C4/Reserves.pm (-1 / +15 lines)
Lines 419-424 sub CanBookBeReserved{ Link Here
419
    my $patron = Koha::Patrons->find( $borrowernumber );
419
    my $patron = Koha::Patrons->find( $borrowernumber );
420
    while ( my $item = $items->next ) {
420
    while ( my $item = $items->next ) {
421
        $canReserve = CanItemBeReserved( $patron, $item, $pickup_branchcode, $params );
421
        $canReserve = CanItemBeReserved( $patron, $item, $pickup_branchcode, $params );
422
        if ( C4::Context->interface eq 'opac' ) {
423
            my $opacitemholds = Koha::CirculationRules->get_opacitemholds_policy(
424
                {
425
                    item   => $item,
426
                    patron => $patron
427
                }
428
            ) // 'Y';
429
            return { status => 'recordHoldNotAllowed' } if $opacitemholds eq 'F';
430
            return { status => 'OK' }                   if $canReserve->{status} eq 'recordHoldsOnly';
431
        }
422
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
432
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
423
    }
433
    }
424
    return $canReserve;
434
    return $canReserve;
Lines 540-549 sub CanItemBeReserved { Link Here
540
        categorycode => $patron->categorycode,
550
        categorycode => $patron->categorycode,
541
        itemtype     => $item->effective_itemtype,
551
        itemtype     => $item->effective_itemtype,
542
        branchcode   => $reserves_control_branch,
552
        branchcode   => $reserves_control_branch,
543
        rules        => ['holds_per_record','holds_per_day']
553
        rules        => ['holds_per_record','holds_per_day', 'opacitemholds']
544
    });
554
    });
545
    my $holds_per_record = $rights->{holds_per_record} // 1;
555
    my $holds_per_record = $rights->{holds_per_record} // 1;
546
    my $holds_per_day    = $rights->{holds_per_day};
556
    my $holds_per_day    = $rights->{holds_per_day};
557
    my $opacitemholds    = $rights->{opacitemholds} // 'Y';
547
558
548
    if (   defined $holds_per_record && $holds_per_record ne '' ){
559
    if (   defined $holds_per_record && $holds_per_record ne '' ){
549
        if ( $holds_per_record == 0 ) {
560
        if ( $holds_per_record == 0 ) {
Lines 679-684 sub CanItemBeReserved { Link Here
679
            return _cache { status => 'pickupNotInHoldGroup' };
690
            return _cache { status => 'pickupNotInHoldGroup' };
680
        }
691
        }
681
    }
692
    }
693
    if ( $opacitemholds eq "N" && C4::Context->interface eq 'opac' ) {
694
        return _cache { status => "recordHoldsOnly" };
695
    }
682
696
683
    return _cache { status => 'OK' };
697
    return _cache { status => 'OK' };
684
}
698
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-4 / +2 lines)
Lines 173-183 Link Here
173
                                [% IF bibitemloo.forced_hold_level %]
173
                                [% IF bibitemloo.forced_hold_level %]
174
                                    <div class="alert alert-info forced_hold_level">
174
                                    <div class="alert alert-info forced_hold_level">
175
                                        [% IF bibitemloo.forced_hold_level == 'item' %]
175
                                        [% IF bibitemloo.forced_hold_level == 'item' %]
176
                                            <span>You already have at least one item level hold on this title.
176
                                            <span>All further holds must be item level.</span>
177
                                            All further holds must be item level.</span>
178
                                        [% ELSE %]
177
                                        [% ELSE %]
179
                                            <span>You already have at least one record level hold on this title.
178
                                            <span>All further holds must be record level.</span>
180
                                            All further holds must be record level.</span>
181
                                        [% END %]
179
                                        [% END %]
182
                                    </div>
180
                                    </div>
183
                                [% END %]
181
                                [% END %]
(-)a/opac/opac-reserve.pl (-14 / +24 lines)
Lines 482-500 foreach my $biblioNum (@biblionumbers) { Link Here
482
482
483
        my $branch = Koha::Policy::Holds->holds_control_library( $item, $patron );
483
        my $branch = Koha::Policy::Holds->holds_control_library( $item, $patron );
484
484
485
        my $policy_holdallowed =
485
        my $item_status = CanItemBeReserved( $patron, $item, undef, { get_from_cache => 1 } )->{status};
486
            CanItemBeReserved( $patron, $item, undef, { get_from_cache => 1 } )->{status} eq 'OK' &&
486
487
            IsAvailableForItemLevelRequest($item, $patron, undef);
487
        if ( $item_status eq 'recordHoldsOnly' ) {
488
            $biblioLoopIter{force_hold}        = 1;
489
            $biblioLoopIter{itemholdable}      = 0;
490
            $biblioLoopIter{forced_hold_level} = 'record';
491
        }
492
493
        my $policy_holdallowed = IsAvailableForItemLevelRequest( $item, $patron, undef )
494
            && ( $item_status eq 'OK' or $item_status eq 'recordHoldsOnly' );
488
495
489
        if ($policy_holdallowed) {
496
        if ($policy_holdallowed) {
490
            my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
497
            $numCopiesAvailable++;
491
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
498
            if ( $item_status ne 'recordHoldsOnly' ) {
492
                $item_info->{available} = 1;
493
                $numCopiesOPACAvailable++;
499
                $numCopiesOPACAvailable++;
494
                $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
500
                $item_info->{available} = 1;
495
            }
501
            }
496
            $numCopiesAvailable++;
497
498
            unless ( $can_place_hold_if_available_at_pickup ) {
502
            unless ( $can_place_hold_if_available_at_pickup ) {
499
                my $items_in_this_library = Koha::Items->search({ biblionumber => $item->biblionumber, holdingbranch => $item->holdingbranch, notforloan => 0 });
503
                my $items_in_this_library = Koha::Items->search({ biblionumber => $item->biblionumber, holdingbranch => $item->holdingbranch, notforloan => 0 });
500
                my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
504
                my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
Lines 544-552 foreach my $biblioNum (@biblionumbers) { Link Here
544
        }
548
        }
545
    }
549
    }
546
550
547
    my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
551
    my $record_status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
548
    $biblioLoopIter{holdable} &&= $status eq 'OK';
552
    if ($record_status eq 'recordHoldNotAllowed') {
549
    $biblioLoopIter{$status} = 1;
553
        $biblioLoopIter{force_hold} = 1;
554
        $biblioLoopIter{itemholdable} = 1;
555
        $biblioLoopIter{forced_hold_level} = 'item';
556
        $biblioLoopIter{holdable} &&= 1;
557
    }
558
    else {
559
        $biblioLoopIter{holdable} &&= $record_status eq 'OK';
560
    }
550
561
551
    if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
562
    if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
552
        # build the allowed item types loop
563
        # build the allowed item types loop
Lines 564-570 foreach my $biblioNum (@biblionumbers) { Link Here
564
        $biblioLoopIter{allowed_item_types} = \@item_types;
575
        $biblioLoopIter{allowed_item_types} = \@item_types;
565
    }
576
    }
566
577
567
    if ( $status eq 'recall' ) {
578
    if ( $record_status eq 'recall' ) {
568
        $biblioLoopIter{recall} = 1;
579
        $biblioLoopIter{recall} = 1;
569
    }
580
    }
570
581
571
- 

Return to bug 25408