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

(-)a/C4/Reserves.pm (-4 / +13 lines)
Lines 330-335 sub CanBookBeReserved{ Link Here
330
        return { status =>'alreadypossession' };
330
        return { status =>'alreadypossession' };
331
    }
331
    }
332
332
333
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
333
    my $items;
334
    my $items;
334
    #get items linked via host records
335
    #get items linked via host records
335
    my @hostitemnumbers = get_hostitemnumbers_of($biblionumber);
336
    my @hostitemnumbers = get_hostitemnumbers_of($biblionumber);
Lines 346-355 sub CanBookBeReserved{ Link Here
346
347
347
    my $canReserve = { status => '' };
348
    my $canReserve = { status => '' };
348
    my $patron = Koha::Patrons->find( $borrowernumber );
349
    my $patron = Koha::Patrons->find( $borrowernumber );
349
    while ( my $item = $items->next ) {
350
    foreach my $itemnumber (@itemnumbers) {
350
        $canReserve = CanItemBeReserved( $patron, $item, $pickup_branchcode, $params );
351
        my $itemo = Koha::Items->find($itemnumber);
351
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
352
        unless ( $canReserve->{status} eq 'OK' ) {
353
            my $canItemBeReserved = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params );
354
            $canReserve = $canItemBeReserved
355
                # status can become 'OK' only if CanItemBeReserved && IsAvailableForItemLevelRequest
356
                if $canItemBeReserved->{status} ne 'OK' and IsAvailableForItemLevelRequest($itemo, $patron, $pickup_branchcode);
357
        }
352
    }
358
    }
359
353
    return $canReserve;
360
    return $canReserve;
354
}
361
}
355
362
Lines 381-391 sub CanBookBeReserved{ Link Here
381
=cut
388
=cut
382
389
383
sub CanItemBeReserved {
390
sub CanItemBeReserved {
384
    my ( $patron, $item, $pickup_branchcode, $params ) = @_;
391
    my ( $borrowernumber, $itemnumber, $pickup_branchcode, $params ) = @_;
385
392
386
    my $dbh = C4::Context->dbh;
393
    my $dbh = C4::Context->dbh;
387
    my $ruleitemtype;    # itemtype of the matching issuing rule
394
    my $ruleitemtype;    # itemtype of the matching issuing rule
388
    my $allowedreserves  = 0; # Total number of holds allowed across all records, default to none
395
    my $allowedreserves  = 0; # Total number of holds allowed across all records, default to none
396
    my $patron = Koha::Patrons->find($borrowernumber);
397
    my $item       = Koha::Items->find($itemnumber);
389
398
390
    # We check item branch if IndependentBranches is ON
399
    # We check item branch if IndependentBranches is ON
391
    # and canreservefromotherbranches is OFF
400
    # and canreservefromotherbranches is OFF
(-)a/C4/Search.pm (-3 / +10 lines)
Lines 1621-1627 Format results in a form suitable for passing to the template Link Here
1621
# IMO this subroutine is pretty messy still -- it's responsible for
1621
# IMO this subroutine is pretty messy still -- it's responsible for
1622
# building the HTML output for the template
1622
# building the HTML output for the template
1623
sub searchResults {
1623
sub searchResults {
1624
    my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults, $xslt_variables ) = @_;
1624
    my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults, $xslt_variables, $borrowernumber ) = @_;
1625
    my $dbh = C4::Context->dbh;
1625
    my $dbh = C4::Context->dbh;
1626
    my @newresults;
1626
    my @newresults;
1627
1627
Lines 1778-1789 sub searchResults { Link Here
1778
        my $onloan_count          = 0;
1778
        my $onloan_count          = 0;
1779
        my $longoverdue_count     = 0;
1779
        my $longoverdue_count     = 0;
1780
        my $other_count           = 0;
1780
        my $other_count           = 0;
1781
        my $withdrawn_count        = 0;
1781
        my $withdrawn_count       = 0;
1782
        my $itemlost_count        = 0;
1782
        my $itemlost_count        = 0;
1783
        my $hideatopac_count      = 0;
1783
        my $hideatopac_count      = 0;
1784
        my $itembinding_count     = 0;
1784
        my $itembinding_count     = 0;
1785
        my $itemdamaged_count     = 0;
1785
        my $itemdamaged_count     = 0;
1786
        my $item_in_transit_count = 0;
1786
        my $item_in_transit_count = 0;
1787
        my $can_place_holds       = 1;
1787
        my $item_onhold_count     = 0;
1788
        my $item_onhold_count     = 0;
1788
        my $notforloan_count      = 0;
1789
        my $notforloan_count      = 0;
1789
        my $item_recalled_count   = 0;
1790
        my $item_recalled_count   = 0;
Lines 1855-1860 sub searchResults { Link Here
1855
                if ( $item->{itemlost} ) {
1856
                if ( $item->{itemlost} ) {
1856
                    $onloan_items->{$key}->{longoverdue}++;
1857
                    $onloan_items->{$key}->{longoverdue}++;
1857
                    $longoverdue_count++;
1858
                    $longoverdue_count++;
1859
                    $can_place_holds = 0;
1858
                }
1860
                }
1859
            }
1861
            }
1860
1862
Lines 2003-2009 sub searchResults { Link Here
2003
        my $biblio_object = Koha::Biblios->find( $oldbiblio->{biblionumber} );
2005
        my $biblio_object = Koha::Biblios->find( $oldbiblio->{biblionumber} );
2004
        $oldbiblio->{biblio_object} = $biblio_object;
2006
        $oldbiblio->{biblio_object} = $biblio_object;
2005
2007
2006
        my $can_place_holds = 1;
2008
        $can_place_holds = 1;
2007
        # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
2009
        # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
2008
        if (!C4::Context->preference("item-level_itypes")) {
2010
        if (!C4::Context->preference("item-level_itypes")) {
2009
            if ($itemtype && $itemtype->{notforloan}) {
2011
            if ($itemtype && $itemtype->{notforloan}) {
Lines 2012-2017 sub searchResults { Link Here
2012
        } else {
2014
        } else {
2013
            $can_place_holds = $biblio_object->items->filter_by_for_hold()->count if $biblio_object;
2015
            $can_place_holds = $biblio_object->items->filter_by_for_hold()->count if $biblio_object;
2014
        }
2016
        }
2017
2018
        if ( $borrowernumber and $can_place_holds ) {
2019
            $can_place_holds = (C4::Reserves::CanBookBeReserved( $borrowernumber, $oldbiblio->{biblionumber} )->{status} eq 'OK');
2020
        }
2021
2015
        $oldbiblio->{norequests} = 1 unless $can_place_holds;
2022
        $oldbiblio->{norequests} = 1 unless $can_place_holds;
2016
        $oldbiblio->{items_count}          = $items_count;
2023
        $oldbiblio->{items_count}          = $items_count;
2017
        $oldbiblio->{available_items_loop} = \@available_items_loop;
2024
        $oldbiblio->{available_items_loop} = \@available_items_loop;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-1 / +1 lines)
Lines 4-10 Link Here
4
    [% UNLESS ( norequests ) %]
4
    [% UNLESS ( norequests ) %]
5
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
5
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
6
            [% IF Koha.Preference( 'OPACHoldRequests' ) == 1 %]
6
            [% IF Koha.Preference( 'OPACHoldRequests' ) == 1 %]
7
                [% IF ( ReservableItems ) %]
7
                [% IF ( CanBeReserved ) %]
8
                    <li><a class="reserve btn btn-link btn-lg" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblio.biblionumber | html %]"><i class="fa fa-fw fa-bookmark" aria-hidden="true"></i> Place hold</a></li>
8
                    <li><a class="reserve btn btn-link btn-lg" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblio.biblionumber | html %]"><i class="fa fa-fw fa-bookmark" aria-hidden="true"></i> Place hold</a></li>
9
                [% END %]
9
                [% END %]
10
            [% END %]
10
            [% END %]
(-)a/opac/opac-detail.pl (-2 / +2 lines)
Lines 258-264 if ($session->param('busc')) { Link Here
258
        for (my $i=0;$i<@servers;$i++) {
258
        for (my $i=0;$i<@servers;$i++) {
259
            my $server = $servers[$i];
259
            my $server = $servers[$i];
260
            $hits = $results_hashref->{$server}->{"hits"};
260
            $hits = $results_hashref->{$server}->{"hits"};
261
            @newresults = searchResults( $search_context, '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
261
            @newresults = searchResults( $search_context, '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"}, undef, $patron);
262
        }
262
        }
263
        return \@newresults;
263
        return \@newresults;
264
    }#searchAgain
264
    }#searchAgain
Lines 775-780 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
775
    }
775
    }
776
  }
776
  }
777
}
777
}
778
$template->param( 'CanBeReserved' => ($borrowernumber ? C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber )->{status} eq 'OK' : 1) );
778
779
779
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
780
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
780
    $template->param( ReservableItems => 1 );
781
    $template->param( ReservableItems => 1 );
781
- 

Return to bug 30556