Bug 40504

Summary: ILL requests should have ability to assign staff to manage
Product: Koha Reporter: Esther Melander <esther.melander>
Component: ILLAssignee: Pedro Amorim <pedro.amorim>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew.auld, jeremy.evans, lisette, martin.renvoize, pedro.amorim, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Crowdfunding goal: 0
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 40504: Preparation: Abstract 'managed by' functionality from suggestions
Bug 40504: Preparation: Add empty_table_settings option to patron_search_js
Bug 40504: Preparation: Disambiguation of .clear_search
Bug 40504: Add ill/users API endpoint
Bug 40504: dbic
Bug 40504: Add 'managedby' to illrequests
Bug 40504: UI improvements
Bug 40504: Auto functionality:
Bug 40504: atomicupdate
Bug 40504: Add tests
Bug 40504: atomicupdate
Bug 40504: Add tests
Bug 40504: Preparation: Abstract 'managed by' functionality from suggestions
Bug 40504: Preparation: Add empty_table_settings option to patron_search_js
Bug 40504: Preparation: Disambiguation of .clear_search
Bug 40504: Add ill/users API endpoint
Bug 40504: dbic
Bug 40504: Add 'managedby' to illrequests
Bug 40504: UI improvements
Bug 40504: Auto functionality:
Bug 40504: Add tests
Bug 40504: atomicupdate
Bug 40504: (QA follow-up): Add 'managed by' filter
Bug 40504: (QA follow-up): Add 'managed by' filter
Bug 40504: (QA follow-up): Add 'managed by' filter
Bug 40504: [DONT PUSH] dbic

Description Esther Melander 2025-07-24 19:15:20 UTC
It would be nice if staff could be assigned to manage a request. This is something available for purchase suggestions and it would be nice for ILL requests as well. It would be especially helpful for large consortia that have to manage lots of requests.
Comment 1 Pedro Amorim 2025-10-15 13:32:31 UTC
Created attachment 187906 [details] [review]
Bug 40504: Preparation: Abstract 'managed by' functionality from suggestions

Move 'managed by' and 'restore previous manager' form and show
functionality to reusable .inc files
Comment 2 Pedro Amorim 2025-10-15 13:32:33 UTC
Created attachment 187907 [details] [review]
Bug 40504: Preparation: Add empty_table_settings option to patron_search_js

This is required for ILL 'select manager' functionality, as table_settings are already defined there and the user modal table will pick that up unless explicitly stated to not use it, thus empty_table_settings
Comment 3 Pedro Amorim 2025-10-15 13:32:36 UTC
Created attachment 187908 [details] [review]
Bug 40504: Preparation: Disambiguation of .clear_search

This is required, or clicking 'Clear' on the ILL patron search modal will trigger this event listener and cause a JS error, as the 'regular' ILL table is not shown/initialized when editing an ILL request
Comment 4 Pedro Amorim 2025-10-15 13:32:38 UTC
Created attachment 187909 [details] [review]
Bug 40504: Add ill/users API endpoint

Required to get users filtered by 'ill' permission for patron search modal

prove t/db_dependent/api/v1/ill_users.t
Comment 5 Pedro Amorim 2025-10-15 13:32:40 UTC Comment hidden (obsolete)
Comment 6 Pedro Amorim 2025-10-15 13:32:42 UTC
Created attachment 187911 [details] [review]
Bug 40504: Add 'managedby' to illrequests

This also includes a 'manager' accessor which returns the Koha::Patron
object
Comment 7 Pedro Amorim 2025-10-15 13:32:45 UTC
Created attachment 187912 [details] [review]
Bug 40504: UI improvements

This turns the 'Select manager' and 'Restore manager' actions to proper buttons, well aligned in where they are displayed. The 'Select manager' functionality in the suggestions table page is also updated to make use of the same reusable button block
Comment 8 Pedro Amorim 2025-10-15 13:32:48 UTC
Created attachment 187913 [details] [review]
Bug 40504: Auto functionality:

- The staff member who creates a new ILL request is automatically assigned as its manager.
- No manager is assigned to ILL requests made by users without 'ill' permission e.g. patrons using the OPAC.
- When an ILL request without a manager has its status changed, the staff member making the change is automatically assigned as its manager e.g. by clicking 'confirm' or 'revert request'.
- It is possible to manually update a request's manager by clicking the 'Edit request' toolbar button when viewing a request. The patron search modal, 'select manager' button and all its functionality is shared with the 'select manager' present in the suggestions module. This means that when editing an ILL request, the 'managedby' defaults to the staff member editing the request, unless 'Keep existing manager' is clicked, like it happens in suggestions.
- This is fully core built, all backends will automatically hook into this functionality, because:
-- Automatic 'managedby' happen on status change, regardless of backend
-- All requests have access to 'edit request' page, regardless of backend
- Only if a logged in staff member exists does the auto set manager. If no staff member is found, nothing happens e.g. an ILL request status
was changed by a CLI command / cronjob
Comment 9 Pedro Amorim 2025-10-15 13:32:50 UTC
Created attachment 187914 [details] [review]
Bug 40504: atomicupdate
Comment 10 Pedro Amorim 2025-10-15 13:32:53 UTC
Created attachment 187915 [details] [review]
Bug 40504: Add tests

Test plan, ktd, apply patches:
1) Enable ILLModule
2) Create a new ILL request, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard
3) Set a 'type', add a cardnumber e.g. '23529000035676', and a library. Click 'Submit'.
4) Notice the new 'Managed by' field entry on the 'Manage request' page. This should be assigned to your logged in user.
5) Click 'Edit request' from the top toolbar
6) Notice the new 'Managed by' form entry. Click 'Select manager' and click 'Search'. Only the 'koha' user should be returned.
7) Notice the message at the top 'Only staff with superlibrarian or ILL permissions are returned in the search results'.
8) Let's give 'ill' permissions to Edna Acosta, visit:
<staff_url>/cgi-bin/koha/members/member-flags.pl?member=5
9) Search for 'ill' permission (Search for 'interlibrary' on the top right search bar) and set 'ill' permission to Edna Acosta. Save.
10) Repeat 6). Notice that now when you use the patron search modal Edna Acosta is also returned. Select Edna. Click 'Submit' to edit the request.
11) Edit again. Notice the 'Managed by' is showing 'You', with the message 'Previously was Edna Acosta'. This is the desired behavior mimicked from Suggestions i.e. the staff member that is editing the request details is assumed to becomes it's manager by default. The staff member must click 'Keep existing manager' if they want to submit changes without changing the request's manager. Test buttons, save, verify that it all works.
12) Visit the ILL list table:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl
13) Click 'columns' and pick 'Managed by'. Notice it shows correctly with the link to the patron and sorting also works.
14) Create a new user without permissions (OPAC only user)
15) Access the OPAC ILL and login as that user (preferably on a different browser session as we'll want to access the staff UI as staff member again), visit:
<opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard
16) Pick a type and click 'Create'
17) Repeat 12) Notice the newly created request from OPAC is 'Managed by': Nobody. This is intentional as that request still needs to be assigned to a staff member.

Suggestions testing:
1) This testing is also important as the existing suggestions 'Managed by' functionality has been abstracted to be utilized by both the suggestions and ILL module.
2) Access suggestions, visit:
<staff_url>/cgi-bin/koha/suggestion/suggestion.pl
3) Click 'New purchase suggestion'. Notice the select manager button is also there. Click it and click 'search'. On the modal, the following message should show 'Only staff with superlibrarian or full suggestions permissions are returned in the search results' and the patrons shown should reflect that.
4) Do the same exercises here as we just did for the ILL module, i.e. create a staff member with permission 'suggestions.suggestions_manage' and ensure that shows on the modal, assign that patron as manager, edit again, verify that it defaults to 'You' and that the 'Keep existing manager' button works as before.
5) Finally, test the suggestions list table, repeat 2) and notice the 'Update manager' action at the bottom, test that that works just as well, by checking a few suggestions boxes, selecting a manager to your selection and clicking the 'Submit' button under it.

Run tests:
prove t/db_dependent/Koha/ILL/Request.t
prove t/db_dependent/api/v1/ill_users.t
Comment 11 Pedro Amorim 2025-10-23 14:49:54 UTC
Created attachment 188365 [details] [review]
Bug 40504: atomicupdate
Comment 12 OpenFifth Sandboxes 2025-10-29 16:02:15 UTC
Created attachment 188563 [details] [review]
Bug 40504: Add tests

Test plan, ktd, apply patches:
1) Enable ILLModule
2) Create a new ILL request, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard
3) Set a 'type', add a cardnumber e.g. '23529000035676', and a library. Click 'Submit'.
4) Notice the new 'Managed by' field entry on the 'Manage request' page. This should be assigned to your logged in user.
5) Click 'Edit request' from the top toolbar
6) Notice the new 'Managed by' form entry. Click 'Select manager' and click 'Search'. Only the 'koha' user should be returned.
7) Notice the message at the top 'Only staff with superlibrarian or ILL permissions are returned in the search results'.
8) Let's give 'ill' permissions to Edna Acosta, visit:
<staff_url>/cgi-bin/koha/members/member-flags.pl?member=5
9) Search for 'ill' permission (Search for 'interlibrary' on the top right search bar) and set 'ill' permission to Edna Acosta. Save.
10) Repeat 6). Notice that now when you use the patron search modal Edna Acosta is also returned. Select Edna. Click 'Submit' to edit the request.
11) Edit again. Notice the 'Managed by' is showing 'You', with the message 'Previously was Edna Acosta'. This is the desired behavior mimicked from Suggestions i.e. the staff member that is editing the request details is assumed to becomes it's manager by default. The staff member must click 'Keep existing manager' if they want to submit changes without changing the request's manager. Test buttons, save, verify that it all works.
12) Visit the ILL list table:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl
13) Click 'columns' and pick 'Managed by'. Notice it shows correctly with the link to the patron and sorting also works.
14) Create a new user without permissions (OPAC only user)
15) Access the OPAC ILL and login as that user (preferably on a different browser session as we'll want to access the staff UI as staff member again), visit:
<opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard
16) Pick a type and click 'Create'
17) Repeat 12) Notice the newly created request from OPAC is 'Managed by': Nobody. This is intentional as that request still needs to be assigned to a staff member.

Suggestions testing:
1) This testing is also important as the existing suggestions 'Managed by' functionality has been abstracted to be utilized by both the suggestions and ILL module.
2) Access suggestions, visit:
<staff_url>/cgi-bin/koha/suggestion/suggestion.pl
3) Click 'New purchase suggestion'. Notice the select manager button is also there. Click it and click 'search'. On the modal, the following message should show 'Only staff with superlibrarian or full suggestions permissions are returned in the search results' and the patrons shown should reflect that.
4) Do the same exercises here as we just did for the ILL module, i.e. create a staff member with permission 'suggestions.suggestions_manage' and ensure that shows on the modal, assign that patron as manager, edit again, verify that it defaults to 'You' and that the 'Keep existing manager' button works as before.
5) Finally, test the suggestions list table, repeat 2) and notice the 'Update manager' action at the bottom, test that that works just as well, by checking a few suggestions boxes, selecting a manager to your selection and clicking the 'Submit' button under it.

Run tests:
prove t/db_dependent/Koha/ILL/Request.t
prove t/db_dependent/api/v1/ill_users.t

Signed-off-by: Pedro <pedro.amorim@openfifth.co.uk>
Comment 13 Jeremy Evans 2025-10-29 16:04:24 UTC
I have tested this on a sandbox and it is working as expected.
Comment 14 Pedro Amorim 2025-10-29 16:22:16 UTC
Created attachment 188565 [details] [review]
Bug 40504: Preparation: Abstract 'managed by' functionality from suggestions

Move 'managed by' and 'restore previous manager' form and show
functionality to reusable .inc files

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 15 Pedro Amorim 2025-10-29 16:22:18 UTC
Created attachment 188566 [details] [review]
Bug 40504: Preparation: Add empty_table_settings option to patron_search_js

This is required for ILL 'select manager' functionality, as table_settings are already defined there and the user modal table will pick that up unless explicitly stated to not use it, thus empty_table_settings

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 16 Pedro Amorim 2025-10-29 16:22:20 UTC
Created attachment 188567 [details] [review]
Bug 40504: Preparation: Disambiguation of .clear_search

This is required, or clicking 'Clear' on the ILL patron search modal will trigger this event listener and cause a JS error, as the 'regular' ILL table is not shown/initialized when editing an ILL request

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 17 Pedro Amorim 2025-10-29 16:22:23 UTC
Created attachment 188568 [details] [review]
Bug 40504: Add ill/users API endpoint

Required to get users filtered by 'ill' permission for patron search modal

prove t/db_dependent/api/v1/ill_users.t

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 18 Pedro Amorim 2025-10-29 16:22:25 UTC Comment hidden (obsolete)
Comment 19 Pedro Amorim 2025-10-29 16:22:27 UTC
Created attachment 188570 [details] [review]
Bug 40504: Add 'managedby' to illrequests

This also includes a 'manager' accessor which returns the Koha::Patron
object

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 20 Pedro Amorim 2025-10-29 16:22:30 UTC
Created attachment 188571 [details] [review]
Bug 40504: UI improvements

This turns the 'Select manager' and 'Restore manager' actions to proper buttons, well aligned in where they are displayed. The 'Select manager' functionality in the suggestions table page is also updated to make use of the same reusable button block

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 21 Pedro Amorim 2025-10-29 16:22:33 UTC
Created attachment 188572 [details] [review]
Bug 40504: Auto functionality:

- The staff member who creates a new ILL request is automatically assigned as its manager.
- No manager is assigned to ILL requests made by users without 'ill' permission e.g. patrons using the OPAC.
- When an ILL request without a manager has its status changed, the staff member making the change is automatically assigned as its manager e.g. by clicking 'confirm' or 'revert request'.
- It is possible to manually update a request's manager by clicking the 'Edit request' toolbar button when viewing a request. The patron search modal, 'select manager' button and all its functionality is shared with the 'select manager' present in the suggestions module. This means that when editing an ILL request, the 'managedby' defaults to the staff member editing the request, unless 'Keep existing manager' is clicked, like it happens in suggestions.
- This is fully core built, all backends will automatically hook into this functionality, because:
-- Automatic 'managedby' happen on status change, regardless of backend
-- All requests have access to 'edit request' page, regardless of backend
- Only if a logged in staff member exists does the auto set manager. If no staff member is found, nothing happens e.g. an ILL request status
was changed by a CLI command / cronjob

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 22 Pedro Amorim 2025-10-29 16:22:35 UTC
Created attachment 188573 [details] [review]
Bug 40504: Add tests

Test plan, ktd, apply patches:
1) Enable ILLModule
2) Create a new ILL request, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard
3) Set a 'type', add a cardnumber e.g. '23529000035676', and a library. Click 'Submit'.
4) Notice the new 'Managed by' field entry on the 'Manage request' page. This should be assigned to your logged in user.
5) Click 'Edit request' from the top toolbar
6) Notice the new 'Managed by' form entry. Click 'Select manager' and click 'Search'. Only the 'koha' user should be returned.
7) Notice the message at the top 'Only staff with superlibrarian or ILL permissions are returned in the search results'.
8) Let's give 'ill' permissions to Edna Acosta, visit:
<staff_url>/cgi-bin/koha/members/member-flags.pl?member=5
9) Search for 'ill' permission (Search for 'interlibrary' on the top right search bar) and set 'ill' permission to Edna Acosta. Save.
10) Repeat 6). Notice that now when you use the patron search modal Edna Acosta is also returned. Select Edna. Click 'Submit' to edit the request.
11) Edit again. Notice the 'Managed by' is showing 'You', with the message 'Previously was Edna Acosta'. This is the desired behavior mimicked from Suggestions i.e. the staff member that is editing the request details is assumed to becomes it's manager by default. The staff member must click 'Keep existing manager' if they want to submit changes without changing the request's manager. Test buttons, save, verify that it all works.
12) Visit the ILL list table:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl
13) Click 'columns' and pick 'Managed by'. Notice it shows correctly with the link to the patron and sorting also works.
14) Create a new user without permissions (OPAC only user)
15) Access the OPAC ILL and login as that user (preferably on a different browser session as we'll want to access the staff UI as staff member again), visit:
<opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard
16) Pick a type and click 'Create'
17) Repeat 12) Notice the newly created request from OPAC is 'Managed by': Nobody. This is intentional as that request still needs to be assigned to a staff member.

Suggestions testing:
1) This testing is also important as the existing suggestions 'Managed by' functionality has been abstracted to be utilized by both the suggestions and ILL module.
2) Access suggestions, visit:
<staff_url>/cgi-bin/koha/suggestion/suggestion.pl
3) Click 'New purchase suggestion'. Notice the select manager button is also there. Click it and click 'search'. On the modal, the following message should show 'Only staff with superlibrarian or full suggestions permissions are returned in the search results' and the patrons shown should reflect that.
4) Do the same exercises here as we just did for the ILL module, i.e. create a staff member with permission 'suggestions.suggestions_manage' and ensure that shows on the modal, assign that patron as manager, edit again, verify that it defaults to 'You' and that the 'Keep existing manager' button works as before.
5) Finally, test the suggestions list table, repeat 2) and notice the 'Update manager' action at the bottom, test that that works just as well, by checking a few suggestions boxes, selecting a manager to your selection and clicking the 'Submit' button under it.

Run tests:
prove t/db_dependent/Koha/ILL/Request.t
prove t/db_dependent/api/v1/ill_users.t

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 23 Pedro Amorim 2025-10-29 16:22:38 UTC
Created attachment 188574 [details] [review]
Bug 40504: atomicupdate

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 24 Pedro Amorim 2025-10-30 11:18:41 UTC Comment hidden (obsolete)
Comment 25 Pedro Amorim 2025-10-30 11:20:54 UTC
Created attachment 188625 [details] [review]
Bug 40504: (QA follow-up): Add 'managed by' filter

This adds a 'Managed by:' filter input on the left side filters.
Comment 26 Pedro Amorim 2025-11-03 14:17:30 UTC
Created attachment 188935 [details] [review]
Bug 40504: (QA follow-up): Add 'managed by' filter

This adds a 'Managed by:' filter input on the left side filters.

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Comment 27 Pedro Amorim 2025-11-03 14:22:00 UTC
Created attachment 188936 [details] [review]
Bug 40504: [DONT PUSH] dbic