From fad9e809c1bb844dcaa6f6b793a5b6a8b04ac82e Mon Sep 17 00:00:00 2001 From: Mason James Date: Fri, 22 Dec 2017 15:33:01 +1300 Subject: [PATCH] Bug 19870: Loaned items show as available unless logged in Content-Type: text/plain; charset="utf-8" here's a quick fix to the problem (on 17.05.00 and up) 1/ set OPACXSLTResultsDisplay = ''; 2/ log out from opac 3/ search for a title in opac, see item is available in search results 4/ check out item 5/ search for a title in opac, see item is still available?1 6/ apply patch 7/ search for an title in opac, see item is now unavailable we still need a .t/test file for resultsSearch(), but that might be a job for another day... --- C4/Search.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index fa920cf..07c8eed 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2092,11 +2092,8 @@ sub searchResults { my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; # For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item my $userenv = C4::Context->userenv; - if ( $item->{onloan} - && $userenv - && $userenv->{number} - && !( Koha::Patrons->find($userenv->{number})->category->hidelostitems && $item->{itemlost} ) ) - { + + if ( $item->{onloan} ) { $onloan_count++; my $key = $prefix . $item->{onloan} . $item->{barcode}; $onloan_items->{$key}->{due_date} = $item->{onloan}; @@ -2121,6 +2118,13 @@ sub searchResults { # items not on loan, but still unavailable ( lost, withdrawn, damaged ) else { + # skip if user logged in and has hidelostitems set, and item is lost + next if ( $userenv + && $userenv->{number} + && Koha::Patrons->find($userenv->{number})->category->hidelostitems + && $item->{itemlost} + } + $item->{notforloan}=1 if !$item->{notforloan} && $itemtypes{ C4::Context->preference("item-level_itypes")? $item->{itype}: $oldbiblio->{itemtype} }->{notforloan}; # item is on order -- 2.1.4