Bugzilla – Attachment 177784 Details for
Bug 37883
Add a filter for staff search results to filter by library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37883: Add logged in branch available, other, and onloan counts
Bug-37883-Add-logged-in-branch-available-other-and.patch (text/plain), 8.99 KB, created by
Lucas Gass (lukeg)
on 2025-02-11 20:55:32 UTC
(
hide
)
Description:
Bug 37883: Add logged in branch available, other, and onloan counts
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-02-11 20:55:32 UTC
Size:
8.99 KB
patch
obsolete
>From 1c87c80075609aa8550616b9a2081e708bb90098 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 10 Sep 2024 15:38:16 +0000 >Subject: [PATCH] Bug 37883: Add logged in branch available, other, and onloan > counts > >Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> >--- > C4/Search.pm | 95 ++++++++++++++++++++++++++++++---------------------- > 1 file changed, 55 insertions(+), 40 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 6ae9ddcc8d5..ffc95b23394 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1686,7 +1686,8 @@ sub searchResults { > > # set stuff for XSLT processing here once, not later again for every record we retrieved > >- my $userenv = C4::Context->userenv; >+ my $userenv = C4::Context->userenv; >+ my $userenv_branch = $userenv->{'branch'}; > my $logged_in_user = > ( defined $userenv and $userenv->{number} ) > ? Koha::Patrons->find( $userenv->{number} ) >@@ -1784,23 +1785,26 @@ sub searchResults { > my $onloan_items; > my $other_items; > >- my $ordered_count = 0; >- my $available_count = 0; >- my $onloan_count = 0; >- my $longoverdue_count = 0; >- my $other_count = 0; >- my $withdrawn_count = 0; >- my $itemlost_count = 0; >- my $hideatopac_count = 0; >- my $itembinding_count = 0; >- my $itemdamaged_count = 0; >- my $item_in_transit_count = 0; >- my $item_onhold_count = 0; >- my $notforloan_count = 0; >- my $item_recalled_count = 0; >- my $items_count = scalar(@fields); >- my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults'); >- my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; >+ my $ordered_count = 0; >+ my $available_count = 0; >+ my $branch_available_count = 0; >+ my $onloan_count = 0; >+ my $branch_onloan_count = 0; >+ my $longoverdue_count = 0; >+ my $other_count = 0; >+ my $branch_other_count = 0; >+ my $withdrawn_count = 0; >+ my $itemlost_count = 0; >+ my $hideatopac_count = 0; >+ my $itembinding_count = 0; >+ my $itemdamaged_count = 0; >+ my $item_in_transit_count = 0; >+ my $item_onhold_count = 0; >+ my $notforloan_count = 0; >+ my $item_recalled_count = 0; >+ my $items_count = scalar(@fields); >+ my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults'); >+ my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; > my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref > > # loop through every item >@@ -1857,8 +1861,10 @@ sub searchResults { > and !( $patron_category_hide_lost_items and $item->{itemlost} ) ) > { > $onloan_count++; >+ $branch_onloan_count++ if $item->{'branchcode'} eq $userenv_branch; > my $key = $prefix . $item->{onloan} . $item->{barcode}; >- $onloan_items->{$key}->{due_date} = $item->{onloan}; >+ $onloan_items->{$key}->{branchonloancount} = $branch_onloan_count; >+ $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}; >@@ -1965,15 +1971,16 @@ sub searchResults { > . ( $item->{notforloan} // q{} ); > > $other_count++; >- >+ $branch_other_count++ if $item->{branchcode} eq $userenv_branch; > my $key = $prefix . $item->{status}; > 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; >+ $other_items->{$key}->{branchothercount} = $branch_other_count; >+ $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; > $other_items->{$key}->{notforloan} = > GetAuthorisedValueDesc( '', '', $item->{notforloan}, '', '', $notforloan_authorised_value ) > if $notforloan_authorised_value and $item->{notforloan}; >@@ -1991,12 +1998,14 @@ sub searchResults { > # item is available > else { > $available_count++; >+ $branch_available_count++ if $item->{branchcode} eq $userenv_branch; > $available_items->{$prefix}->{count}++ if $item->{$hbranch}; > foreach (qw(branchname itemcallnumber description)) { > $available_items->{$prefix}->{$_} = $item->{$_}; > } >- $available_items->{$prefix}->{branchcode} = $item->{branchcode}; >- $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } >+ $available_items->{$prefix}->{branchavailablecount} = $branch_available_count; >+ $available_items->{$prefix}->{branchcode} = $item->{branchcode}; >+ $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } > if $item->{location}; > $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( > $search_context->{'interface'}, >@@ -2057,7 +2066,7 @@ sub searchResults { > } > ); > } >- >+ my $branch_count = $branch_available_count + $branch_onloan_count + $branch_other_count || 0; > my $biblio_object = Koha::Biblios->find( $oldbiblio->{biblionumber} ); > $oldbiblio->{biblio_object} = $biblio_object; > $oldbiblio->{coins} = eval { $biblio_object->get_coins } >@@ -2081,19 +2090,25 @@ sub searchResults { > $oldbiblio->{onloan_items_loop} = \@onloan_items_loop; > $oldbiblio->{other_items_loop} = \@other_items_loop; > $oldbiblio->{availablecount} = $available_count; >- $oldbiblio->{availableplural} = 1 if $available_count > 1; >- $oldbiblio->{onloancount} = $onloan_count; >- $oldbiblio->{onloanplural} = 1 if $onloan_count > 1; >- $oldbiblio->{othercount} = $other_count; >- $oldbiblio->{otherplural} = 1 if $other_count > 1; >- $oldbiblio->{withdrawncount} = $withdrawn_count; >- $oldbiblio->{itemlostcount} = $itemlost_count; >- $oldbiblio->{damagedcount} = $itemdamaged_count; >- $oldbiblio->{intransitcount} = $item_in_transit_count; >- $oldbiblio->{onholdcount} = $item_onhold_count; >- $oldbiblio->{recalledcount} = $item_recalled_count; >- $oldbiblio->{orderedcount} = $ordered_count; >- $oldbiblio->{notforloancount} = $notforloan_count; >+ >+ $oldbiblio->{branchavailablecount} = $branch_available_count || 0; >+ $oldbiblio->{branchonloancount} = $branch_onloan_count || 0; >+ $oldbiblio->{branchothercount} = $branch_other_count || 0; >+ $oldbiblio->{branchtotalcount} = $branch_count || 0; >+ >+ $oldbiblio->{availableplural} = 1 if $available_count > 1; >+ $oldbiblio->{onloancount} = $onloan_count; >+ $oldbiblio->{onloanplural} = 1 if $onloan_count > 1; >+ $oldbiblio->{othercount} = $other_count; >+ $oldbiblio->{otherplural} = 1 if $other_count > 1; >+ $oldbiblio->{withdrawncount} = $withdrawn_count; >+ $oldbiblio->{itemlostcount} = $itemlost_count; >+ $oldbiblio->{damagedcount} = $itemdamaged_count; >+ $oldbiblio->{intransitcount} = $item_in_transit_count; >+ $oldbiblio->{onholdcount} = $item_onhold_count; >+ $oldbiblio->{recalledcount} = $item_recalled_count; >+ $oldbiblio->{orderedcount} = $ordered_count; >+ $oldbiblio->{notforloancount} = $notforloan_count; > > if ( C4::Context->preference("AlternateHoldingsField") && $items_count == 0 ) { > my $fieldspec = C4::Context->preference("AlternateHoldingsField"); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37883
:
171256
|
171257
|
171261
|
171286
|
171287
|
171289
|
171291
|
171406
|
171407
|
171408
|
171409
|
171410
|
171411
|
176697
|
177306
|
177784
|
177785
|
177786
|
177787
|
177788
|
177789
|
177790
|
177791
|
178772
|
178773
|
178774
|
178775
|
178776
|
178777