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

(-)a/opac/opac-reserve.pl (-4 / +11 lines)
Lines 24-30 use CGI qw ( -utf8 ); Link Here
24
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
25
use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
25
use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
26
use C4::Circulation qw( GetBranchItemRule GetTransfers );
26
use C4::Circulation qw( GetBranchItemRule GetTransfers );
27
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch IsAvailableForItemLevelRequest );
27
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
28
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
28
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
29
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
29
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
30
use C4::Output qw( output_html_with_http_headers );
30
use C4::Output qw( output_html_with_http_headers );
Lines 470-475 foreach my $biblioNum (@biblionumbers) { Link Here
470
    $biblioLoopIter{itemLoop} = [];
470
    $biblioLoopIter{itemLoop} = [];
471
    my $numCopiesAvailable = 0;
471
    my $numCopiesAvailable = 0;
472
    my $numCopiesOPACAvailable = 0;
472
    my $numCopiesOPACAvailable = 0;
473
    # iterating through all items first to check if any of them available
474
    # to pass this value further inside down to IsAvailableForItemLevelRequest to
475
    # it's complicated logic to analyse.
476
    # (before this loop was inside that sub loop so it was O(n^2) )
477
    my $items_any_available;
478
    $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioNum, patron => $patron }) if $patron;
473
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
479
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
474
        my $itemNum = $itemInfo->{itemnumber};
480
        my $itemNum = $itemInfo->{itemnumber};
475
        my $item = $visible_items->{$itemNum};
481
        my $item = $visible_items->{$itemNum};
Lines 557-565 foreach my $biblioNum (@biblionumbers) { Link Here
557
        my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
563
        my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
558
564
559
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
565
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
566
        # items_any_available defined outside of the current loop,
567
        # so we avoiding loop inside IsAvailableForItemLevelRequest:
560
        $policy_holdallowed &&=
568
        $policy_holdallowed &&=
561
            IsAvailableForItemLevelRequest($item, $patron) &&
569
            CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK' &&
562
            CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
570
            IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available);
563
571
564
        if ($policy_holdallowed) {
572
        if ($policy_holdallowed) {
565
            my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
573
            my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
566
- 

Return to bug 29685