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

(-)a/C4/Search.pm (-6 / +18 lines)
Lines 25-31 use Lingua::Stem; Link Here
25
use C4::Search::PazPar2;
25
use C4::Search::PazPar2;
26
use XML::Simple;
26
use XML::Simple;
27
use C4::Dates qw(format_date);
27
use C4::Dates qw(format_date);
28
use C4::Members qw(GetHideLostItemsPreference);
28
use C4::Members qw(GetHideLostItemsPreference GetMember);
29
use C4::XSLT;
29
use C4::XSLT;
30
use C4::Branch;
30
use C4::Branch;
31
use C4::Reserves;    # GetReserveStatus
31
use C4::Reserves;    # GetReserveStatus
Lines 1833-1839 Format results in a form suitable for passing to the template Link Here
1833
# IMO this subroutine is pretty messy still -- it's responsible for
1833
# IMO this subroutine is pretty messy still -- it's responsible for
1834
# building the HTML output for the template
1834
# building the HTML output for the template
1835
sub searchResults {
1835
sub searchResults {
1836
    my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults ) = @_;
1836
    my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults, $borrowernumber ) = @_;
1837
    my $dbh = C4::Context->dbh;
1837
    my $dbh = C4::Context->dbh;
1838
    my @newresults;
1838
    my @newresults;
1839
1839
Lines 1863-1868 sub searchResults { Link Here
1863
    # get notforloan authorised value list (see $shelflocations  FIXME)
1863
    # get notforloan authorised value list (see $shelflocations  FIXME)
1864
    my $notforloan_authorised_value = GetAuthValCode('items.notforloan','');
1864
    my $notforloan_authorised_value = GetAuthValCode('items.notforloan','');
1865
1865
1866
    my $userenv = C4::Context->userenv;
1867
    my $hide_lost_items = GetHideLostItemsPreference($userenv->{'number'});
1868
1869
    # $borrowernumber is passed for opac search
1870
    my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
1871
1866
    #Build itemtype hash
1872
    #Build itemtype hash
1867
    #find itemtype & itemtype image
1873
    #find itemtype & itemtype image
1868
    my %itemtypes;
1874
    my %itemtypes;
Lines 2038-2050 sub searchResults { Link Here
2038
        my $onloan_count          = 0;
2044
        my $onloan_count          = 0;
2039
        my $longoverdue_count     = 0;
2045
        my $longoverdue_count     = 0;
2040
        my $other_count           = 0;
2046
        my $other_count           = 0;
2041
        my $withdrawn_count        = 0;
2047
        my $withdrawn_count       = 0;
2042
        my $itemlost_count        = 0;
2048
        my $itemlost_count        = 0;
2043
        my $hideatopac_count      = 0;
2049
        my $hideatopac_count      = 0;
2044
        my $itembinding_count     = 0;
2050
        my $itembinding_count     = 0;
2045
        my $itemdamaged_count     = 0;
2051
        my $itemdamaged_count     = 0;
2046
        my $item_in_transit_count = 0;
2052
        my $item_in_transit_count = 0;
2047
        my $can_place_holds       = 0;
2053
        my $can_place_holds       = 0;
2054
        # If no borrower no point checking issuing_rules
2055
        my $can_place_item_holds  = $borrower ? 0 : 1;
2048
        my $item_onhold_count     = 0;
2056
        my $item_onhold_count     = 0;
2049
        my $notforloan_count      = 0;
2057
        my $notforloan_count      = 0;
2050
        my $items_count           = scalar(@fields);
2058
        my $items_count           = scalar(@fields);
Lines 2091-2098 sub searchResults { Link Here
2091
2099
2092
			my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2100
			my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2093
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2101
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2094
            my $userenv = C4::Context->userenv;
2102
            if ( $item->{onloan} && !($hide_lost_items && $item->{itemlost}) ) {
2095
            if ( $item->{onloan} && !(C4::Members::GetHideLostItemsPreference($userenv->{'number'}) && $item->{itemlost}) ) {
2096
                $onloan_count++;
2103
                $onloan_count++;
2097
				my $key = $prefix . $item->{onloan} . $item->{barcode};
2104
				my $key = $prefix . $item->{onloan} . $item->{barcode};
2098
				$onloan_items->{$key}->{due_date} = format_date($item->{onloan});
2105
				$onloan_items->{$key}->{due_date} = format_date($item->{onloan});
Lines 2203-2208 sub searchResults { Link Here
2203
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2210
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2204
                }
2211
                }
2205
            }
2212
            }
2213
            # ||= because we only need one
2214
            $can_place_item_holds
2215
                ||= IsAvailableForItemLevelRequest($item, $borrower) &&
2216
                    OPACItemHoldsAllowed($item, $borrower)
2217
              if $can_place_holds && $borrower;
2206
        }    # notforloan, item level and biblioitem level
2218
        }    # notforloan, item level and biblioitem level
2207
2219
2208
        # if all items are hidden, do not show the record
2220
        # if all items are hidden, do not show the record
Lines 2237-2243 sub searchResults { Link Here
2237
                $can_place_holds = 0;
2249
                $can_place_holds = 0;
2238
            }
2250
            }
2239
        }
2251
        }
2240
        $oldbiblio->{norequests} = 1 unless $can_place_holds;
2252
        $oldbiblio->{norequests} = !($can_place_holds && $can_place_item_holds);
2241
        $oldbiblio->{itemsplural}          = 1 if $items_count > 1;
2253
        $oldbiblio->{itemsplural}          = 1 if $items_count > 1;
2242
        $oldbiblio->{items_count}          = $items_count;
2254
        $oldbiblio->{items_count}          = $items_count;
2243
        $oldbiblio->{available_items_loop} = \@available_items_loop;
2255
        $oldbiblio->{available_items_loop} = \@available_items_loop;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (-1 / +1 lines)
Lines 471-477 Link Here
471
                                                <div class="actions-menu noprint">
471
                                                <div class="actions-menu noprint">
472
                                                        [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
472
                                                        [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
473
                                                            [% UNLESS ( SEARCH_RESULT.norequests ) %]
473
                                                            [% UNLESS ( SEARCH_RESULT.norequests ) %]
474
                                                                [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && SEARCH_RESULT.holdable %]
474
                                                                [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
475
                                                                    <span class="actions"><a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a></span><!-- add back when available 0 holds in queue-->
475
                                                                    <span class="actions"><a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a></span><!-- add back when available 0 holds in queue-->
476
                                                                [% END # / IF opacuserlogin && holdable %]
476
                                                                [% END # / IF opacuserlogin && holdable %]
477
                                                            [% END # UNLESS SEARCH_RESULT.norequests %]
477
                                                            [% END # UNLESS SEARCH_RESULT.norequests %]
(-)a/opac/opac-detail.pl (-1 / +1 lines)
Lines 207-213 if ($session->param('busc')) { Link Here
207
        for (my $i=0;$i<@servers;$i++) {
207
        for (my $i=0;$i<@servers;$i++) {
208
            my $server = $servers[$i];
208
            my $server = $servers[$i];
209
            $hits = $results_hashref->{$server}->{"hits"};
209
            $hits = $results_hashref->{$server}->{"hits"};
210
            @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"});
210
            @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, $results_hashref->{$server}->{"RECORDS"}, $borrowernumber);
211
        }
211
        }
212
        return \@newresults;
212
        return \@newresults;
213
    }#searchAgain
213
    }#searchAgain
(-)a/opac/opac-search.pl (-20 / +2 lines)
Lines 42-49 use C4::Branch; # GetBranches Link Here
42
use C4::SocialData;
42
use C4::SocialData;
43
use C4::Ratings;
43
use C4::Ratings;
44
use C4::External::OverDrive;
44
use C4::External::OverDrive;
45
use C4::Members;
46
use C4::Reserves;
47
45
48
use POSIX qw(ceil floor strftime);
46
use POSIX qw(ceil floor strftime);
49
use URI::Escape;
47
use URI::Escape;
Lines 569-579 if ($@ || $error) { Link Here
569
    exit;
567
    exit;
570
}
568
}
571
569
572
my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
573
574
# At this point, each server has given us a result set
570
# At this point, each server has given us a result set
575
# now we build that set for template display
571
# now we build that set for template display
576
my %allow_onshelf_holds;
577
my @sup_results_array;
572
my @sup_results_array;
578
for (my $i=0;$i<@servers;$i++) {
573
for (my $i=0;$i<@servers;$i++) {
579
    my $server = $servers[$i];
574
    my $server = $servers[$i];
Lines 587-610 for (my $i=0;$i<@servers;$i++) { Link Here
587
                # we want as specified by $offset and $results_per_page,
582
                # we want as specified by $offset and $results_per_page,
588
                # we need to set the offset parameter of searchResults to 0
583
                # we need to set the offset parameter of searchResults to 0
589
                my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
584
                my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
590
                                                   $group->{"RECORDS"});
585
                                                   $group->{"RECORDS"}, $borrowernumber);
591
                if ($borrower) {
592
                    $_->{holdable} =
593
                        IsAvailableForItemLevelRequest($_, $borrower) &&
594
                        OPACItemHoldsAllowed($_, $borrower)
595
                      foreach @group_results;
596
                }
597
                push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
586
                push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
598
            }
587
            }
599
        } else {
588
        } else {
600
            @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
589
            @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
601
                                        $results_hashref->{$server}->{"RECORDS"});
590
                                        $results_hashref->{$server}->{"RECORDS"}, $borrowernumber);
602
            if ($borrower) {
603
                $_->{holdable} =
604
                    IsAvailableForItemLevelRequest($_, $borrower) &&
605
                    OPACItemHoldsAllowed($_, $borrower)
606
                  foreach @newresults;
607
            }
608
        }
591
        }
609
        $hits = 0 unless @newresults;
592
        $hits = 0 unless @newresults;
610
593
611
- 

Return to bug 5786