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

(-)a/C4/Reserves.pm (-4 / +19 lines)
Lines 422-430 sub CanBookBeReserved{ Link Here
422
    }
422
    }
423
423
424
    my $canReserve = { status => '' };
424
    my $canReserve = { status => '' };
425
    my $patron = Koha::Patrons->find( $borrowernumber );
425
    my $patron     = Koha::Patrons->find($borrowernumber);
426
    while ( my $item = $items->next ) {
426
    while ( my $item = $items->next ) {
427
        $canReserve = CanItemBeReserved( $patron, $item, $pickup_branchcode, $params );
427
        $canReserve = CanItemBeReserved( $patron, $item, $pickup_branchcode, $params );
428
        if ( C4::Context->interface eq 'opac' ) {
429
            my $opacitemholds = Koha::CirculationRules->get_opacitemholds_policy(
430
                {
431
                    item   => $item,
432
                    patron => $patron
433
                }
434
            ) // 'Y';
435
            return { status => 'recordHoldNotAllowed' } if $opacitemholds eq 'F';
436
            return { status => 'OK' }                   if $canReserve->{status} eq 'recordHoldsOnly';
437
        }
428
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
438
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
429
    }
439
    }
430
    return $canReserve;
440
    return $canReserve;
Lines 466-472 sub CanItemBeReserved { Link Here
466
    my ( $patron, $item, $pickup_branchcode, $params ) = @_;
476
    my ( $patron, $item, $pickup_branchcode, $params ) = @_;
467
477
468
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
478
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
469
    $CanItemBeReserved_cache_key = sprintf "Hold_CanItemBeReserved:%s:%s:%s", $patron->borrowernumber, $item->itemnumber, $pickup_branchcode || "";
479
    $CanItemBeReserved_cache_key = sprintf "Hold_CanItemBeReserved:%s:%s:%s", $patron->id, $item->itemnumber, $pickup_branchcode || "";
470
    if ( $params->{get_from_cache} ) {
480
    if ( $params->{get_from_cache} ) {
471
        my $cached = $memory_cache->get_from_cache($CanItemBeReserved_cache_key);
481
        my $cached = $memory_cache->get_from_cache($CanItemBeReserved_cache_key);
472
        return $cached if $cached;
482
        return $cached if $cached;
Lines 551-560 sub CanItemBeReserved { Link Here
551
        categorycode => $borrower->{'categorycode'},
561
        categorycode => $borrower->{'categorycode'},
552
        itemtype     => $item->effective_itemtype,
562
        itemtype     => $item->effective_itemtype,
553
        branchcode   => $reserves_control_branch,
563
        branchcode   => $reserves_control_branch,
554
        rules        => ['holds_per_record','holds_per_day']
564
        rules        => ['holds_per_record','holds_per_day','opacitemholds']
555
    });
565
    });
556
    my $holds_per_record = $rights->{holds_per_record} // 1;
566
    my $holds_per_record = $rights->{holds_per_record} // 1;
557
    my $holds_per_day    = $rights->{holds_per_day};
567
    my $holds_per_day    = $rights->{holds_per_day};
568
    my $opacitemholds    = $rights->{opacitemholds} // 'Y';
558
569
559
    if (   defined $holds_per_record && $holds_per_record ne '' ){
570
    if (   defined $holds_per_record && $holds_per_record ne '' ){
560
        if ( $holds_per_record == 0 ) {
571
        if ( $holds_per_record == 0 ) {
Lines 691-696 sub CanItemBeReserved { Link Here
691
        }
702
        }
692
    }
703
    }
693
704
705
    if ( $opacitemholds eq "N" && C4::Context->interface eq 'opac' ) {
706
        return _cache { status => "recordHoldsOnly" };
707
    }
708
694
    return _cache { status => 'OK' };
709
    return _cache { status => 'OK' };
695
}
710
}
696
711
Lines 2021-2027 sub _ShiftPriority { Link Here
2021
    $sth = $dbh->prepare( $query );
2036
    $sth = $dbh->prepare( $query );
2022
    $sth->execute( $new_priority, $biblio );
2037
    $sth->execute( $new_priority, $biblio );
2023
    while ( my $row = $sth->fetchrow_hashref ) {
2038
    while ( my $row = $sth->fetchrow_hashref ) {
2024
	$sth_update->execute( $biblio, $row->{borrowernumber}, $row->{reservedate} );
2039
       $sth_update->execute( $biblio, $row->{borrowernumber}, $row->{reservedate} );
2025
    }
2040
    }
2026
2041
2027
    return $new_priority;  # so the caller knows what priority they wind up receiving
2042
    return $new_priority;  # so the caller knows what priority they wind up receiving
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-4 / +2 lines)
Lines 157-167 Link Here
157
                                [% IF bibitemloo.forced_hold_level %]
157
                                [% IF bibitemloo.forced_hold_level %]
158
                                    <div class="alert alert-info forced_hold_level">
158
                                    <div class="alert alert-info forced_hold_level">
159
                                        [% IF bibitemloo.forced_hold_level == 'item' %]
159
                                        [% IF bibitemloo.forced_hold_level == 'item' %]
160
                                            <span>You already have at least one item level hold on this title.
160
                                            <span>All further holds must be item level.</span>
161
                                            All further holds must be item level.</span>
162
                                        [% ELSE %]
161
                                        [% ELSE %]
163
                                            <span>You already have at least one record level hold on this title.
162
                                            <span>All further holds must be record level.</span>
164
                                            All further holds must be record level.</span>
165
                                        [% END %]
163
                                        [% END %]
166
                                    </div>
164
                                    </div>
167
                                [% END %]
165
                                [% END %]
(-)a/opac/opac-reserve.pl (-15 / +26 lines)
Lines 479-499 foreach my $biblioNum (@biblionumbers) { Link Here
479
            $item_info->{hosttitle}        = Koha::Biblios->find( $item_info->{biblionumber} )->title;
479
            $item_info->{hosttitle}        = Koha::Biblios->find( $item_info->{biblionumber} )->title;
480
        }
480
        }
481
481
482
482
        my $branch = Koha::Policy::Holds->holds_control_library( $item, $patron );
483
        my $branch = Koha::Policy::Holds->holds_control_library( $item, $patron );
483
484
484
        my $policy_holdallowed =
485
        my $item_status = CanItemBeReserved( $patron, $item, undef, { get_from_cache => 1 } )->{status};
485
            CanItemBeReserved( $patron, $item, undef, { get_from_cache => 1 } )->{status} eq 'OK' &&
486
486
            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' );
487
495
488
        if ($policy_holdallowed) {
496
        if ($policy_holdallowed) {
489
            my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
497
            $numCopiesAvailable++;
490
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
498
            if ( $item_status ne 'recordHoldsOnly' ) {
491
                $item_info->{available} = 1;
492
                $numCopiesOPACAvailable++;
499
                $numCopiesOPACAvailable++;
493
                $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
500
                $item_info->{available} = 1;
494
            }
501
            }
495
            $numCopiesAvailable++;
496
497
            unless ( $can_place_hold_if_available_at_pickup ) {
502
            unless ( $can_place_hold_if_available_at_pickup ) {
498
                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 });
499
                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 543-551 foreach my $biblioNum (@biblionumbers) { Link Here
543
        }
548
        }
544
    }
549
    }
545
550
546
    my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
551
    my $record_status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
547
    $biblioLoopIter{holdable} &&= $status eq 'OK';
552
    if ($record_status eq 'recordHoldNotAllowed') {
548
    $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
    }
549
561
550
    if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
562
    if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
551
        # build the allowed item types loop
563
        # build the allowed item types loop
Lines 563-569 foreach my $biblioNum (@biblionumbers) { Link Here
563
        $biblioLoopIter{allowed_item_types} = \@item_types;
575
        $biblioLoopIter{allowed_item_types} = \@item_types;
564
    }
576
    }
565
577
566
    if ( $status eq 'recall' ) {
578
    if ( $record_status eq 'recall' ) {
567
        $biblioLoopIter{recall} = 1;
579
        $biblioLoopIter{recall} = 1;
568
    }
580
    }
569
581
Lines 623-629 if ( Link Here
623
    C4::Context->preference( 'OPACAllowHoldDateInFuture' )
635
    C4::Context->preference( 'OPACAllowHoldDateInFuture' )
624
    ) {
636
    ) {
625
    $template->param(
637
    $template->param(
626
	    reserve_in_future         => 1,
638
            reserve_in_future         => 1,
627
    );
639
    );
628
}
640
}
629
641
630
- 

Return to bug 25408