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; |