Bug 35211

Summary: Make it possible to split holdings tab using library groups in intranet
Product: Koha Reporter: Kati Sillgren <kati.sillgren>
Component: Staff interfaceAssignee: Eric Garcia <cubingguy714>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew, carthur, george, gmcharlt, hattara, jzairo, lucas
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 40342    
Attachments: Bug 35211: Add group_holdings tab to Holdings table
Bug 35211: Add group_holdings tab to Holdings table
Bug 35211: Add group_holdings tab to Holdings table
Bug 35211: Add group_holdings tab to Holdings table
Bug 35211: Add group_holdings tab to Holdings table
Bug 35211: Separate group holdings
Bug 35211: Add group_holdings tab to Holdings table
Bug 35211: Separate group holdings
Bug 35211: Separate group holdings into individual tabs
Bug 35211: Separate group holdings into individual tabs
Bug 35211: Reordered tabs in Holdings Table and fixed group tabnames
Bug 35211: Reordered tabs in Holdings Table and fixed group tabnames
empty group tab
Bug 35211: Removed local items from group tabs and removed group items from other holdings tab
Bug 35211: Fixed count on logged in holdings
Bug 35211: Set SeparateHoldingsByGroup to separate based on SeparateHoldingsBranch syspref

Description Kati Sillgren 2023-11-01 09:38:46 UTC
Make it possible to add new tab to record’s detail page/holdings table by using library groups.

Library groups are made here: admin/library_groups.pl
Comment 1 Kati Sillgren 2023-11-07 06:21:08 UTC
Tab is shown automatically according to the library where Koha-user is logged in, and library is included to the library group (search group).
Comment 2 Jessie Zairo 2024-09-12 15:00:18 UTC
+1 this would be helpful for large systems, consortiums, and library networks to breakdown multi-branch systems and see whats available.
Comment 3 Eric Garcia 2025-06-06 16:50:32 UTC
Created attachment 183075 [details] [review]
Bug 35211: Add group_holdings tab to Holdings table

Current status: ASSIGNED
Comment 4 Eric Garcia 2025-06-09 18:40:02 UTC
Created attachment 183099 [details] [review]
Bug 35211: Add group_holdings tab to Holdings table
Comment 5 Eric Garcia 2025-06-10 16:36:56 UTC
Created attachment 183143 [details] [review]
Bug 35211: Add group_holdings tab to Holdings table

Add new system preference 'SeparateHoldingsByGroup'
Adds new tab to Group Holdings to Holdings table.
Separates holdings by library group.
Comment 6 Eric Garcia 2025-06-10 17:16:21 UTC
Created attachment 183144 [details] [review]
Bug 35211: Add group_holdings tab to Holdings table

Add new system preference 'SeparateHoldingsByGroup'
Adds new tab to Group Holdings to Holdings table.
Separates holdings by library group.

Test Plan:
  1. Apply patch, restart_all
  2. Koha Administration -> System preferences ->  SeparateHoldingsByGroup
  3. Separate items display into two tabs and Separate holdings by library group.
  4. Save preference changes
  5. Koha Administration -> Library groups
  6. Create a library group and add check the 'Use for staff search groups' box.
  7. Add libraries to the new group including your logged in branch.
  8. Do a catalog search.
  9. Click on an item that libraries in your group own.
  10. Notice a new tab called Group Holdings that contains only the libraries in your group

  11. Return to Koha Administration -> System preferences SeparateHoldingsByGroup
  12. Don't separate holdings by library group
  13. Return to the item you search for and notice the tab has been removed.
Comment 7 Lucas Gass (lukeg) 2025-06-10 22:15:05 UTC
I found a few problems here: 

1. There is a problem with the atomicupdate:
	ERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''variable','value','options','explanation','type')
	            VALUES ('Separ...' at line 1 at /kohadevbox/koha/C4/Installer.pm line 825

2. The "Group holdings" do not seem to include the logged in branch's holdings 

3. If there are more than one groups everything gets grouped together under the single tab "Group holdings". In my opinion there should be a separate tab for every group that the logged in library is a part of.
Comment 8 Eric Garcia 2025-06-23 15:25:31 UTC
Created attachment 183420 [details] [review]
Bug 35211: Add group_holdings tab to Holdings table

Add new system preference 'SeparateHoldingsByGroup'
Adds new tab to Group Holdings to Holdings table.
Separates holdings by library group.

Test Plan:
  1. Apply patch, restart_all
  2. Koha Administration -> System preferences ->  SeparateHoldingsByGroup
  3. Separate items display into two tabs and Separate holdings by library group.
  4. Save preference changes
  5. Koha Administration -> Library groups
  6. Create a library group and add check the 'Use for staff search groups' box.
  7. Add libraries to the new group including your logged in branch.
  8. Do a catalog search.
  9. Click on an item that libraries in your group own.
  10. Notice a new tab called Group Holdings that contains only the libraries in your group

  11. Return to Koha Administration -> System preferences SeparateHoldingsByGroup
  12. Don't separate holdings by library group
  13. Return to the item you search for and notice the tab has been removed.
Comment 9 Eric Garcia 2025-06-27 15:26:02 UTC
Created attachment 183615 [details] [review]
Bug 35211: Separate group holdings
Comment 10 Eric Garcia 2025-06-30 15:15:13 UTC
Created attachment 183642 [details] [review]
Bug 35211: Add group_holdings tab to Holdings table

Add new system preference 'SeparateHoldingsByGroup'
Adds new tab to Group Holdings to Holdings table.
Separates holdings by library group.

Test Plan:
  1. Apply patch, restart_all
  2. Koha Administration -> System preferences ->  SeparateHoldingsByGroup
  3. Separate items display into two tabs and Separate holdings by library group.
  4. Save preference changes
  5. Koha Administration -> Library groups
  6. Create a library group and add check the 'Use for staff search groups' box.
  7. Add libraries to the new group including your logged in branch.
  8. Do a catalog search.
  9. Click on an item that libraries in your group own.
  10. Notice a new tab called Group Holdings that contains only the libraries in your group

  11. Return to Koha Administration -> System preferences SeparateHoldingsByGroup
  12. Don't separate holdings by library group
  13. Return to the item you search for and notice the tab has been removed.
Comment 11 Eric Garcia 2025-06-30 15:15:16 UTC
Created attachment 183643 [details] [review]
Bug 35211: Separate group holdings
Comment 12 Eric Garcia 2025-07-09 15:05:13 UTC
Created attachment 183901 [details] [review]
Bug 35211: Separate group holdings into individual tabs

Added SeparateHoldingsByGroup system preference
Adds new tabs to Holdings table if preference is enabled
Separates by library groups
Comment 13 Eric Garcia 2025-07-10 14:41:01 UTC
Created attachment 183945 [details] [review]
Bug 35211: Separate group holdings into individual tabs

Added SeparateHoldingsByGroup system preference
Adds new tabs to Holdings table if preference is enabled
Separates by library groups

Test Plan:
1. Apply patch, restart_all, updatedatabase
2. Koha Administration -> System preferences -> SeparateHoldingsByGroup
3. Change to "Separate holdings by library group in subsequent tabs..." and Save
4. Koha Administration -> Library Groups
5. Create multiple library groups and check the 'Use for staff search groups' box.
6. Add your logged in library to each group and other libraries to each group.
7. Do catalog searches where the location of the item is a library in a library group
8. Notice tabs in the Holdings table for each library group if it contains a library that has the item
Comment 14 Andrew Fuerste-Henry 2025-07-10 15:40:27 UTC
This orders the holdings tabs as Local / Other / Group. I think Local / Group / Other would make more sense, organizationally.

You've labeled the group holdings tab with "[Group title] - Group". This would be more consistent if the label were "[Group title] holdings".

We should add the same functionality in the OPAC, which has a separate OpacSeparateHoldings syspref. That could be a separate bug, but might make sense to cover here if it's more of less a copy/paste.
Comment 15 Eric Garcia 2025-07-10 16:03:02 UTC
Created attachment 183949 [details] [review]
Bug 35211: Reordered tabs in Holdings Table and fixed group tabnames
Comment 16 Eric Garcia 2025-07-10 16:04:10 UTC
(In reply to Andrew Fuerste-Henry from comment #14)

> We should add the same functionality in the OPAC, which has a separate
> OpacSeparateHoldings syspref. That could be a separate bug, but might make
> sense to cover here if it's more of less a copy/paste.

I think it should be a separate bug, might be more than a copy/paste
Comment 17 Eric Garcia 2025-07-10 16:48:55 UTC
Created attachment 183950 [details] [review]
Bug 35211: Reordered tabs in Holdings Table and fixed group tabnames
Comment 18 Andrew Fuerste-Henry 2025-07-10 17:50:34 UTC
Created attachment 183966 [details]
empty group tab

Thanks for those changes! Two more issues:
1 - Set SeparateHoldings="Don't separate" and SeparateHoldingsByGroup="Separate." See attached screenshot; the group holdings tab appears and shows an accurate count of record on the tab, but contains no items

2 - With both sysprefs set to Separate, items repeat between tabs -- the Group tab repeats the item held locally and the Other tab repeats the non-local group items. Items should show in only one tab -- local items in the local tab, non-local group items in the Group tab, non-local & non-group items in the Other tab
Comment 19 Eric Garcia 2025-07-10 18:54:32 UTC
Created attachment 183967 [details] [review]
Bug 35211: Removed local items from group tabs and removed group items from other holdings tab

Fixed the issues with tabs.

I cannot replicate the issue in the attached screenshot. What steps did you take?
Comment 20 Andrew Fuerste-Henry 2025-07-10 19:41:33 UTC
(In reply to Eric Garcia from comment #19)
> I cannot replicate the issue in the attached screenshot. What steps did you
> take?

- apply patch, updatedatabase, reset_all
- log in at default branch, Centerville
- go to bib 344 (E Street Shuffle, 3 items)
- add 3 items to bib 344 with homebranch of Fairfield, Fairview, Franklin, respectively. holdingbranch remains Centerville
- go to Admin, Groups. Create a group, check "Use for staff search groups", add Fairfield, Fairview, and Franklin to the group
- in sysprefs, set SeparateHoldings="Don't Separate", SeparateHoldingsBranch="home library", SeparateHoldingsByGroup="Separate"
- set your logged-in-branch to Fairfield
- load bib 344
Comment 21 Eric Garcia 2025-07-10 19:54:35 UTC
Created attachment 183968 [details] [review]
Bug 35211: Fixed count on logged in holdings
Comment 22 Andrew Fuerste-Henry 2025-07-11 12:59:32 UTC
(In reply to Eric Garcia from comment #21)
> Created attachment 183968 [details] [review] [review]
> Bug 35211: Fixed count on logged in holdings

I'm seeing some odd behavior now. Testing with the same setup described above (6 items on bib 344, group of F libraries). 

With: SeparateHoldings = Separate, 
SeparateHoldingsByGroup = Separate, 
SeparateHoldingsBranch = Home, 
logged in at Fairfield: 
I don't get a group holdings tab, just local and Other. The two non-local group items are not displayed at all

With: SeparateHoldings = Separate, 
SeparateHoldingsByGroup = Separate, 
SeparateHoldingsBranch = Holding, 
logged in at Fairfield:
No local tab, no group tab. There is not a tab selected at page load. The Other holdings tab shows a count of 4 but actually lists all 6 items.

With apologies for being slow to think of this, but I don't think SeparateHoldingsByGroup can be coded to always go by homebranch; it should also follow SeparateHoldingsBranch. That further suggests these three sysprefs should get grouped together and rephrased a bit. Maybe:

[Don't separate/Separate] items held by the user's logged-in library into the first tab of the items display.
[Don't separate/Separate] items held by other libraries in a staff search group with the user's logged-in library into the next tab of the items display.
The final tab will contain all other items.
Use the items' [holding library/homelibrary] for determining these groupings.
Comment 23 Eric Garcia 2025-07-11 16:07:23 UTC
Created attachment 184016 [details] [review]
Bug 35211: Set SeparateHoldingsByGroup to separate based on SeparateHoldingsBranch syspref