From 084ed6e32271cdfc1116e3c7c7f0d93e4cc15a5b Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 31 May 2024 21:12:04 +0000 Subject: [PATCH] Bug 37004: Add branchcode as HTML class to each grouped result in search results To test: 1. Apply patch and restart_all 2. Do a catalog search that returns results. 3. Using the browsers dev tools inscpet the page and look for the 'available_items_loop_items' class in the 'Location column'. 4. Each child
  • element should have a class that is the branchcode. 5. Make sure that branchcode is correct. 6. Change the StaffSearchResultsDisplayBranch system preference. Make sure that each branchcode is still correct. 7. Change the system preference 'noItemTypeImages' to 'Dont show'. 8. Make sure the branchcode is still correct. 9. Checkout an item that would show up in these search results. 10. Do steps 3-8 again excpet this time look for the HTML element 'onloan_items_loop_items'. 11. Put some items in transfer that would show up in these search resultss. 12. Do steps 3-8 again excpet this time look for the HTML element 'other_items_loop_items'. Signed-off-by: David Nind Signed-off-by: Katrin Fischer --- C4/Search.pm | 6 +++++- .../intranet-tmpl/prog/en/modules/catalogue/results.tt | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index ea70377373..ca8e79ab0f 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1842,13 +1842,14 @@ sub searchResults { my $hbranch = C4::Context->preference('StaffSearchResultsDisplayBranch'); my $otherbranch = $hbranch eq 'homebranch' ? 'holdingbranch' : 'homebranch'; - # set item's branch name, use HomeOrHoldingBranch syspref first, fall back to the other one if ($item->{$hbranch}) { $item->{'branchname'} = $branches{$item->{$hbranch}}; + $item->{'branchcode'} = $item->{$hbranch}; } elsif ($item->{$otherbranch}) { # Last resort $item->{'branchname'} = $branches{$item->{$otherbranch}}; + $item->{'branchcode'} = $item->{$otherbranch}; } my $prefix = @@ -1867,6 +1868,7 @@ sub searchResults { $onloan_items->{$key}->{due_date} = $item->{onloan}; $onloan_items->{$key}->{count}++ if $item->{$hbranch}; $onloan_items->{$key}->{branchname} = $item->{branchname}; + $onloan_items->{$key}->{branchcode} = $item->{branchcode}; $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber}; $onloan_items->{$key}->{description} = $item->{description}; @@ -1964,6 +1966,7 @@ sub searchResults { foreach (qw(withdrawn itemlost damaged branchname itemcallnumber)) { $other_items->{$key}->{$_} = $item->{$_}; } + $other_items->{$key}->{branchcode} = $item->{branchcode}; $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0; $other_items->{$key}->{recalled} = ($recallstatus) ? 1 : 0; $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0; @@ -1981,6 +1984,7 @@ sub searchResults { foreach (qw(branchname itemcallnumber description)) { $available_items->{$prefix}->{$_} = $item->{$_}; } + $available_items->{$prefix}->{branchcode} = $item->{branchcode}; $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} ); $available_items->{$prefix}->{collectioncode} = GetAuthorisedValueDesc('','',$item->{ccode},'','','CCODE'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 17765ebe5d..137f6cf16e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -632,10 +632,10 @@
      [% FOREACH items_loo IN SEARCH_RESULT.${items_loop} %] [% IF item_level_itypes && !noItemTypeImages && items_loo.imageurl %] -
    • +
    • [% items_loo.description | html %] [% ELSE %] -
    • +
    • [% END %] [% IF ( items_loo.branchname ) %] [% items_loo.branchname | html %] -- 2.39.5