Bug 37863

Summary: Patron card batches don't detect when the patron is already in the list
Product: Koha Reporter: Adolfo Rodríguez Taboada <adolfo.rodriguez>
Component: Label/patron card printingAssignee: Adolfo Rodríguez Taboada <adolfo.rodriguez>
Status: RESOLVED FIXED QA Contact: Emily Lamancusa (emlam) <emily.lamancusa>
Severity: minor    
Priority: P5 - low CC: emily.lamancusa, fridolin.somers, jesse, lucas, martin.renvoize, phil, sukhmandeep.benipal
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.06,23.11.11
Circulation function:
Attachments: bug 37863 Fix checking if a patron is already in the list adding users to a patron card batch
bug 37863 Fix checking if a patron is already in the list adding users to a patron card batch
Bug 37863: Fix checking if a patron is already in the list adding users to a patron card batch

Description Adolfo Rodríguez Taboada 2024-09-09 07:13:33 UTC
When adding patrons to a batch from the modal the include file patron-search.inc is designed to show a success message (Patron '%s' added) or an error message (Patron '%s' is already in the list.) depending on the result of the function add_user. If add_user returned a negative number, it would show the error message. Otherwise it shows the success message. The problem is that the function add_user at the template edit_batch.tt doesn't return anything, so the system always adds the user, thus allowing to include several times the same user in the card batch.
Comment 1 Adolfo Rodríguez Taboada 2024-09-09 07:21:25 UTC
Created attachment 171170 [details] [review]
bug 37863 Fix checking if a patron is already in the list adding users to a patron card batch

If the patron is already in the card batch it won't add it and it will show an error message

Test plan:
1 Create or edit an patron card batch
2 Try adding twice or more the same patron. It will show a success message everytime and you will end up with the same patron several times in the card batch
3 Apply patch, restart services
4 Repeat step 2. The first time you click on add user, it will do it and show the success message (Patron 'Patron name' added.), but after that it won't add the user and it will display an error message (Patron 'Patron name' is already in the list.)
Comment 2 Sukhmandeep 2024-09-09 20:41:01 UTC
Created attachment 171233 [details] [review]
bug 37863 Fix checking if a patron is already in the list adding users to a patron card batch

If the patron is already in the card batch it won't add it and it will show an error message

Test plan:
1 Create or edit an patron card batch
2 Try adding twice or more the same patron. It will show a success message everytime and you will end up with the same patron several times in the card batch
3 Apply patch, restart services
4 Repeat step 2. The first time you click on add user, it will do it and show the success message (Patron 'Patron name' added.), but after that it won't add the user and it will display an error message (Patron 'Patron name' is already in the list.)

Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com>
Comment 3 Emily Lamancusa (emlam) 2024-11-01 20:00:45 UTC
Created attachment 173891 [details] [review]
Bug 37863: Fix checking if a patron is already in the list adding users to a patron card batch

If the patron is already in the card batch it won't add it and it will show an error message

Test plan:
1 Create or edit an patron card batch
2 Try adding twice or more the same patron. It will show a success message everytime and you will end up with the same patron several times in the card batch
3 Apply patch, restart services
4 Repeat step 2. The first time you click on add user, it will do it and show the success message (Patron 'Patron name' added.), but after that it won't add the user and it will display an error message (Patron 'Patron name' is already in the list.)

Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 4 Emily Lamancusa (emlam) 2024-11-01 20:07:35 UTC
This prevents accidentally double-clicking "Add" twice on the same modal. If the patron is already in the card batch from a previous operation, it doesn't prevent adding the patron a second time.

I think that's fine for now, though. The page has a "Remove duplicates" button, so if we want to change the behavior to prevent duplicates completely, that would be a larger change and should be a separate bug.

Passing QA
Comment 5 Katrin Fischer 2024-11-07 17:51:18 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 6 Lucas Gass (lukeg) 2024-12-05 22:00:40 UTC
Backported to 24.05.x for upcoming 24.05.06
Comment 7 Fridolin Somers 2024-12-18 12:20:28 UTC
Pushed to 23.11.x for 23.11.11
Comment 8 Jesse Maseto 2025-02-03 16:27:05 UTC
Not pushed to LTS. Marked Resolved.

If you feel this should be in LTS please reply with your reason.