Bug 40237

Summary: Update reserves/request.pl to use Koha::Patron->can_place_holds
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: Architecture, internals, and plumbingAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: unspecified   
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:
Circulation function:
Bug Depends on: 40101    
Bug Blocks:    
Attachments: Bug 40237: Make reserve/request.pl use $patron->can_place_holds()
Bug 40237: Make reserve/request.pl use $patron->can_place_holds()

Description Martin Renvoize (ashimema) 2025-06-25 11:32:06 UTC
Bug 40101 adds the new 'can_place_holds' method to Koha::Patron, but it avoided updating this complex controller and template to utilise it.
Comment 1 Martin Renvoize (ashimema) 2025-06-25 11:40:36 UTC Comment hidden (obsolete)
Comment 2 Martin Renvoize (ashimema) 2025-06-25 13:04:44 UTC
Created attachment 183494 [details] [review]
Bug 40237: Make reserve/request.pl use $patron->can_place_holds()

This patch updates the staff interface hold placement script to use
the centralized patron hold validation method instead of duplicated
manual validation logic.

Changes:
- Replaces manual maxreserves, debt, expiration, and restriction checks
  with $patron->can_place_holds() method call
- Adds staff override support by reading override_* parameters and
  passing them to the validation method
- Updates template to iterate through validation messages array
- Enhances all "Place hold" buttons to show red "Place hold with
  overrides" buttons when AllowHoldPolicyOverride is enabled and
  validation issues exist
- Maintains backward compatibility with existing item-level override
  functionality

This consolidates patron-level hold validation logic across the
codebase and provides consistent staff override capabilities in
both OPAC and staff interfaces.

Test plan:
1. Apply patches and restart services
2. Enable system preference AllowHoldPolicyOverride
3. Create a test patron with various restrictions:
   - Set expiration date in the past
   - Add fines exceeding maxoutstanding preference
   - Mark address as bad (gonenoaddress = 1)
   - Mark card as lost (lost = 1)
   - Add a debarment/restriction
   - Create holds to exceed maxreserves preference
4. Log into staff interface and try to place holds for this patron
5. Verify validation messages appear for each restriction
6. Verify "Place hold with overrides" red buttons appear instead of normal blue buttons
7. Click override button and verify hold is placed successfully
8. Test with single holds, multi-holds, item-level holds, and group holds
9. Disable AllowHoldPolicyOverride and verify normal restriction behavior
10. Verify existing item-level override functionality still works