Commit Graph

60143 Commits

Author SHA1 Message Date
Andrew Fuerste Henry fcc2e2afce
Bug 39781: Allow limiting of custom message notices by library
To test
The following should work with either email or SMS notices sent from the Add Message button in a patron record
1 - create a notice in module Patrons (custom message) for all libraries
2 - create a notice in module Patrons (custom message) for Centerville
3 - while logged in at Centerville, confirm you can see and enqueue your all libraries message
4 - while logged in at Centerville, confirm you can see but cannot successfully enqueue your Centerville message
5 - while logged in at Fairfield, confirm you can see but cannot successfully enqueue your Centerville message

6 - apply patch, restart_all

7 - while logged in at Fairfield, confirm you can see and enqueue your all libraries message
8 - while logged in at Fairfield, confirm you cannot see your Centerville message
9 - while logged in at Centervielle, confirm you can see and enqueue your Centerville message

Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 3a1bd59197)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:49:51 +00:00
Jacob O'Mara 99aedfb2db
Bug 42083: DBRev 25.11.02.005
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:49:31 +00:00
Martin Renvoize 3c4eed5429
Bug 42083: (QA follow-up) Simplify atomicupdate migration loop
Replace the O(n²) accumulate-and-re-insert pattern with a simple
per-row execute inside the while loop.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 8eec766b5a)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:47:34 +00:00
Andrew Fuerste Henry 8a53f076d3
Bug 42083: Implement distinct permissions
To test:
1 - have an staff account with 'send_messages_to_borrowers' permission but not top level 'borrowers' permission
2 - have a value in SMSSendDriver system preference
3 - log in under your staff account and confirm you can send both email and SMS messages from the Add Message button on a patron record

4 - apply patch, updatedatabase, restart_all

5 - confirm your staff account now has 'send_messages_to_borrowers_email' permission rather than 'send_messages_to_borrowers'
6 - confirm your staff account can now only send email messages from the Add Message button on a patron record
7 - add 'send_messages_to_borrowers_sms' permission to your staff account
8 - confirm your staff account can now send both email and sms messages from the Add Message button on a patron record
9 - remove 'send_messages_to_borrowers_email' from your staff account
10 - confirm your staff account can now only send sms messages from the Add Message button on a patron record

Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 3dd4691076)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:47:34 +00:00
Andrew Fuerste Henry 743e3d9baa
Bug 42083: atomicupdate for permissions
Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 6b51873f9c)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:47:33 +00:00
Andrew Fuerste Henry 7619d9e412
Bug 42083: Create distinct permissions
Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 153a18d603)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:47:32 +00:00
Owen Leonard 9d94593eb7
Bug 41040: (follow-up) Move JS to global JS file
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 16caf3cc6b)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:15:45 +00:00
Owen Leonard 43427026a4
Bug 41040: (follow-up) Tooltip text change and remove unnecessary class
- I think "Please enter a card number or name" sounds friendlier
- We don't add a "btn-primary" class to these buttons

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 44bec3f9f3)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:15:42 +00:00
Kyle M Hall 2b66724bd4
Bug 41040: Use tooltip for message instead of alert
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3c403e2331)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:15:37 +00:00
Kyle M Hall 302a6ae497
Bug 41040: Prevent form submission if no filters have been selected
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4fe4809518)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:15:33 +00:00
Kyle M Hall e83e2259f7
Bug 41040: Empty patron search from the header should not trigger a patron search
If the "arrow" button on the patron search is clicked with no value in
the textbox, it redirects to members/members-home.pl and performs a
search with no value automatically. It makes more send for it to behave
as the "Patrons" link in the navbar that directs to members-home.pl
where the librarian can then perform a more advanced search.

Test Plan:
1) Click the "Search patrons" link on the header, then the arrow button
2) Note an empty patron search is performed immediately
3) Apply this patch
4) Restart all the things!
5) Repeat step 1
6) Note a paton search is no longer triggered automatically

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 222e3161cc)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:15:30 +00:00
Slava Shishkin eead3468c1
Bug 41055: add missing accesskey attribute for print button
This commit adds the missing accesskey attribute to the print button in the circulation template.

Test plan:
1. Try to checkout an item that is waiting for pickup.
2. Try to print the checkout receipt using the alt+shift+p keyboard shortcut.
3. Verify that nothing happens when using the shortcut.
4. After applying this commit, try the same steps again.
5. Verify that the print button now works with the alt+shift+p keyboard shortcut.

Sponsored-by: Koha-Suomi Oy

Signed-off-by: Slava Shishkin <slavashishkin@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit fe51e9c881)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:13:59 +00:00
Martin Renvoize f5efbf8091
Bug 41679: Fix overlapping modals when hold conflicts with stock rotation transfer
When checking in an item that has both a hold and a stock rotation
repatriation transfer, both modals would appear simultaneously,
overlapping each other and making it impossible to interact with
either one properly.

This occurred because:
1. The hold modal showed when 'waiting' was set
2. The transfer modal condition checked for 'reserved' but not 'waiting'
3. Both modals had the "block" class, causing simultaneous display

This patch ensures holds take precedence over stock rotation transfers
by adding a check for the 'waiting' flag to the transfer modal condition.

When a hold is found, only the hold modal displays. The stock rotation
transfer can be handled at a subsequent check-in, which is appropriate
since holds are patron-facing and time-sensitive, while stock rotation
is an internal process that can be deferred.

Test plan:
1. Enable StockRotation system preference
2. Navigate to Cataloging->Stock rotation
3. Click '+ New rota' and fill out with any values
4. Click 'Manage->stages' for the Rota
5. Add a stage for Centerville for 1 day, and Midway for 1 day
6. Return to rotas
7. Click Manage->items for the rota
8. Add an item
9. Return to rotas
10. Click 'Activate'
11. On the command line run the stock rotation job:
    perl misc/cronjobs/stockrotation.pl -x
12. There should be one item for initiation
13. Run it again, there should be one stationary item
14. Place an item specific hold for the item, for pickup at Midway
15. Check the item in at Centerville, confirm transfer
16. Check the item in at Midway, confirm hold
17. Run the stock rotation job again:
    perl misc/cronjobs/stockrotation.pl -x
18. There should be one item for repatriation
19. Check in the item again at Midway
20. Before patch: Two overlapping modals appear (hold + transfer)
21. After patch: Only the hold modal appears
22. Confirm the hold - no transfer modal should appear
23. The stock rotation transfer will be handled at the next check-in

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit fe791731b4)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 13:12:04 +00:00
Jan Kissig d0998535f9
Bug 41120: Fix broken Add data provider functionality
Clicking on New data provider in the ERM eUsage section will not work, when a data provider was shown before.

Test plan:

prequisites:
- activate the ERM module system preference.
- this is for ktd

a) go to /cgi-bin/koha/erm/eusage/usage_data_providers
b) add a new data provider, dummy data is sufficient
c) submit the new provider and on the following screen click close to return to the provider list
d) click on 'Add data provider' (open web dev tools will display an error)

e) apply patch
f) run 'yarn js:build'
f) do a hard refresh in the browser
g) on provider list click your created provider
h) close it via 'close' to return to the provider list
d) click on 'Add data provider' should work now

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 18c18175ca)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 12:33:49 +00:00
Olli Kautonen f6aa530c07
Bug 40154: prevent deletion of items with holds
This patch prevents deletion of items that have item level holds on
them.

Test plan:
1. Create an item level hold.
2. Delete the item using alternative A or B:
   A. Open the biblios Detail-view -> From the toolbar, open
      "Edit"-dropdown menu -> Manage items -> Delete the item that has
      an item level hold attached to it from "Actions"-dropdown menu
   B. Open the biblios Detail-view -> Select the item that has an item
      level hold attached to it -> Click "Delete selected items" ->
      Confirm deletion
3. Notice that the item is deleted without any warning and the item
   level hold has disappeared.
4. Apply this patch.
5. Repeat steps 1-3.
6. Notice that the item cannot be deleted and a warning is shown.
7. prove t/db_dependent/Koha/Item.t
8. Run the REST API tests: prove t/db_dependent/api/v1/items.t

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9445ffc9aa)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 12:32:24 +00:00
Kyle M Hall 439634e580
Bug 33782: (QA follow-up) Fix qa issues
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 556bd55543)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 12:05:03 +00:00
Tomás Cohen Arazi 38a547ae9d
Bug 33782: (follow-up) Remove code duplication in OAuth client
This patch eliminates duplicated patron search logic in the
_get_data_and_patron method by extracting it into a dedicated
helper method _find_patron_by_matchpoint.

Changes:
- Extract duplicated patron search logic (8 lines removed)
- Add _find_patron_by_matchpoint helper method
- Improve code maintainability and readability
- No functional changes - behavior preserved

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Auth/Client/OAuth.t
=> SUCCESS: Tests pass! OAuth client tests work correctly
  k$ prove t/db_dependent/api/v1/oauth.t
=> SUCCESS: Tests pass! OAuth API integration works
3. Confirm OAuth authentication still works in browser
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 13e8f6105a)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 12:04:59 +00:00
Tomás Cohen Arazi b8626ffbd3
Bug 33782: Add unit tests for Koha::Auth::Client::OAuth
This patch adds comprehensive unit tests for the OAuth authentication
client, specifically covering the _get_data_and_patron method which
handles JWT token processing and UserInfo endpoint integration.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Auth/Client/OAuth.t
=> SUCCESS: Tests pass!
3. Tests cover:
   - JWT id_token processing and patron matching
   - UserInfo endpoint calls and data merging
   - Non-existent user scenarios
   - Combined JWT + UserInfo data sources
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4ff2eb3469)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 12:04:48 +00:00
Slava Shishkin 93c2f7bd41
Bug 41458: Pass a valid GID to Net::Server for SIP
When starting SIP, Koha passes an incorrect value to the
Net::Server "group" parameter, which can generate an
error in the logs":
  Couldn't become gid "<uid>": Operation not permitted

This change ensures that a valid numeric GID is passed instead.

Test plan:
1. Enter KTD shell.
2. To reproduce the error: sudo groupmod -g 8001 kohadev-koha
3. Restart SIP: sudo koha-sip --restart kohadev
4. Check SIP logs:
     /var/log/koha/kohadev/sip-output.log
5. Observe the error:
     Couldn't become gid "<uid>": Operation not permitted
6. Apply this patch.
7. Repeat steps 2 to 4.
8. Verify that the "Couldn't become gid" error is no longer logged.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit b16ff5a8a0)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:58:36 +00:00
Paul Derscheid 02e5298c6b
Bug 41798: (QA follow-up) Add missing html filter
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4950884e17)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:55:11 +00:00
Martin Renvoize 3a4a9418f2
Bug 41798: Fix FTP passive mode not saving and add display indicator
The FTP passive mode setting was not being saved due to a typo in the
parameter name ('passiv' instead of 'passive'). This fixes the typo
and adds display of passive mode status in the transports table.

Test plan:
1. Go to Administration > File transports
2. Click "New file transport"
3. Fill in the name (e.g., "Test FTP")
4. Change Transport to "FTP"
5. Set Passive mode to "Enabled (Recommended)"
6. Fill in required fields (host, username, etc.) and save
7. Edit the transport you just created
8. Verify Passive mode is still set to "Enabled" (not reverted to Disabled)
9. Return to the file transports list
10. Verify the Transport column shows "FTP (passive)" for this transport
11. Edit the transport and change Passive mode to "Disabled"
12. Save and return to the list
13. Verify the Transport column now shows just "FTP" (without the passive indicator)

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a92e6ef8ea)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:55:08 +00:00
Lucas Gass c54fd99db6
Bug 40134: (RM follow-up) Tidy commit
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4858768f9a)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:44:51 +00:00
Martin Renvoize 5a04483d45
Bug 40134: Add Cypress tests for booking improvements
This patch adds end-to-end Cypress tests for the booking modal improvements,
including smart window maximization and server-side optimal item selection.

New Tests:

1. "should successfully submit an 'Any item' booking with server-side optimal item selection"
   - Tests the complete "any item" booking workflow
   - Selects itemtype and "Any item" option (item_id = 0)
   - Submits booking form
   - Verifies modal closes without errors
   - Validates booking created in database
   - Confirms item was assigned by server
   - Verifies server-side optimal selection completed
   - Test status: PASSING

2. "should maximize booking window by dynamically reducing available items during overlaps"
   - Creates 4 items with strategic booking patterns
   - Tests "never re-add items to pool" algorithm
   - Validates 5 scenarios:
     a) Full window when all items available
     b) Reduced window when Item 1 becomes unavailable
     c) Further reduction when Items 1&2 unavailable
     d) Minimal window with Items 1,2,3 unavailable
     e) No availability when all items booked
   - Demonstrates smart window maximization
   - Test status: PASSING

3. "should handle edit mode date initialization correctly"
   - Tests fix for edit mode race condition
   - Verifies dates populate correctly when editing booking
   - Ensures itemtype is set before date initialization
   - Tests that flatpickr dates are set properly
   - Test status: PASSING

Updated Tests:

- "should successfully submit a booking"
  * Updated to use day+5 start date (accounts for 3-day lead period)
  * Ensures test doesn't fail on past-date constraint

- Updated test comments and log messages to reflect server-side selection
  * Changed from "client-side selectOptimalItem()" references
  * Updated to "server-side optimal item selection"
  * Clarified that server performs the optimal selection

Test Coverage:
- End-to-end "any item" booking submission
- Smart window maximization algorithm
- Edit mode date initialization
- Server-side optimal selection validation
- Database verification of assigned items
- Modal interaction and form submission

Test plan:
1. Start KTD environment
2. Ensure Cypress is installed: yarn install
3. Run: npx cypress run --spec "t/cypress/integration/Circulation/bookingsModalBasic_spec.ts"
4. Verify all 11 tests pass
5. Optionally run in interactive mode: npx cypress open

Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9360ed6157)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:44:45 +00:00
Martin Renvoize 5d6aadb853
Bug 40134: Implement client-side improvements for bookings
This patch implements client-side improvements for the bookings modal,
including smart window maximization and hybrid submission logic that
delegates optimal item selection to the server.

Smart Window Maximization:
- Implements "never re-add items to pool" algorithm
- Dynamic item pool reduction based on availability
- isDateDisabledForItemtype() calculates available dates
- isDateInMaximumWindow() validates end dates against item pool
- Provides real-time calendar feedback to users

Hybrid Submission Logic:
For "any item" bookings, the client now uses a smart hybrid approach:
1. Filters items by selected itemtype
2. Checks availability for the booking period
3. If 0 items available: Shows error (no suitable item)
4. If 1 item available: Sends item_id (optimization - skips server)
5. If 2+ items available: Sends itemtype_id (delegates to server)

This minimizes server round-trips while delegating complex optimal
selection logic to the server when multiple choices exist.

Test plan:
1. Navigate to biblio detail page with bookable items
2. Click "Place booking" and select patron/pickup location
3. Select itemtype (not specific item) - "any item" mode
4. Select start date - verify end dates are maximized
5. Verify calendar disables dates when no items available
6. Submit booking - verify it succeeds
7. Check that optimal item was selected (server-side)
8. Test edit mode with "any item" selection
9. Verify both create and edit use same logic

Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 39fadd016a)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:44:30 +00:00
Martin Renvoize a935b93ee1
Bug 40134: Add unit tests for optimal item selection
This patch adds unit tests for the server-side optimal item selection
functionality.

t/db_dependent/Koha/Booking.t:
- Added subtest for _select_optimal_item() method (7 tests)
  * Tests with no items (returns undef)
  * Tests with single item (returns that item)
  * Tests with multiple items (selects item with longest future availability)
  * Tests optimal selection across items with different booking patterns
  * Tests handling of cancelled bookings (ignored in selection)
  * Tests iterator reset after selection
- Added subtest for _assign_item_for_booking() with itemtype filtering (6 tests)
  * Tests booking without item_id or itemtype_id (selects any available)
  * Tests booking with itemtype_id (filters by type)
  * Tests optimal selection within filtered itemtype
  * Tests exception when no items of specified type available
- Added integration test for full optimal selection workflow (5 tests)
  * Creates 3 items with different future booking patterns
  * Verifies items selected in optimal order (B→C→A)
  * Demonstrates preservation of constrained resources
  * Validates complete algorithm chain
  * Tests booking failure when all items exhausted

t/db_dependent/api/v1/bookings.t:
- Added subtest for itemtype_id parameter validation (16 tests)
  * Tests successful booking creation with itemtype_id
  * Tests that item is automatically assigned
  * Tests validation: cannot specify both item_id and itemtype_id
  * Tests validation: must specify either item_id or itemtype_id
  * Tests clash detection with itemtype-based bookings
- Fixed duplicate booking_id test to use different dates
  * Prevents clash detection from masking duplicate ID constraint
- Updated test count from 3 to 8 subtests in Booking.t
- Updated test count to match actual assertions (16 not 18)

Test Coverage:
- Internal method testing: _select_optimal_item()
- Integration testing: _assign_item_for_booking()
- API endpoint testing: add() with itemtype_id
- End-to-end workflow validation
- Edge cases: empty sets, single items, ties, cancelled bookings

Test plan:
1. prove t/db_dependent/Koha/Booking.t
2. prove t/db_dependent/api/v1/bookings.t
3. Verify all tests pass

Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a6766a9e80)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:44:26 +00:00
Martin Renvoize 53b59294f9
Bug 40134: Implement optimal item selection for 'any item' bookings
This patch implements an algorithm for selecting the item that would
leave the largest gap after the proposed booking to maximize the
opportunity for future bookings.

Key Changes:

Koha::Booking:
- Added set_itemtype_filter() method for transient itemtype parameter
- Added _select_optimal_item() method using single aggregated query
  * Groups bookings by item_id with MIN(start_date)
  * Selects items with no future bookings (optimal)
  * Among items with bookings, selects one with latest next booking
  * O(1) complexity - single database query with GROUP BY
- Updated _assign_item_for_booking() to use optimal selection
  * Filters by itemtype when itemtype_id is provided
  * Replaces previous random selection (RAND())

API Changes:
- Added itemtype_id parameter support to add() endpoint
- Added itemtype_id parameter support to update() endpoint
- Validates exactly one of item_id or itemtype_id is provided
- itemtype_id is transient - not persisted to database
- Extracted and applied via set_itemtype_filter() before store()

Architecture:
- itemtype_id is NOT a database column (transient only)
- Used as selection criterion, then discarded

Test plan:
1. Apply patch and restart services
2. Create "any item" booking via staff interface
3. Verify item with longest future availability is selected
4. Test via API with itemtype_id parameter
5. Verify itemtype_id is not persisted to database
6. Run t/db_dependent/Koha/Booking.t
7. Run t/db_dependent/api/v1/bookings.t

Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c7fa646929)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:44:01 +00:00
Jonathan Druart 61116073ae
Bug 41747: Tidy js/ill-availability.js
xt/js_tidy.t does not check all files every run (it's using the incremental runs).
Something happened (node version changed?) and this is triggered because bug 41512 modified those files

Test plan:
0. Do not apply this patch
1. KOHA_CI_INCREMENTAL_RUNS=1 prove xt/js_tidy.t
=> fail
2. Apply this patch
3. Run prove again
=> pass

4. Run prove without the env var set
=> pass (i.e. there are no other JS files not tidy)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 080f5a2497)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:36:30 +00:00
Andrew Fuerste Henry 0fc8efac47
Bug 41588: Normalize spaces in 856$u links
To test:
1 - add 856$u " www.cheese.com" to a record
2 - confirm link does not work from results or details in either staff interface or OPAC
3 - add 856$u "www.cheese.com " to a record
4 - confirm link does not work from results or details in either staff interface or OPAC
7 - apply patch, restart_all
8 - reload pages, confirm both links work in results and details in staff interface and OPAC

Optional final step: have some cheese as a treat

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c58989fc51)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:30:34 +00:00
Chloe Zermatten 366d685d7d
Bug 41701: DBRev 25.11.02.005
Signed-off-by: Chloe Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:22:10 +00:00
Owen Leonard 1bc195001f
Bug 41701: Fix definition of OAI-PMH:DeletedRecord preference in sysprefs.sql
This patch updates the definition of the OAI-PMH:DeletedRecord
preference in sysprefs.sql, correcting the switched options and
explanation columns.

To test, apply the patch and run updatedatabase. Check that the database
has been updated correctly:

SELECT `options`, `explanation` FROM `systempreferences` WHERE
`variable` = 'OAI-PMH:DeletedRecord';

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit eb69c7a735)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:14:36 +00:00
Kyle M Hall 2d009dbfd7
Bug 37402: (follow-up) Zero pad the hour automatically on blur
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c2b7f2ddb2)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:08:45 +00:00
Owen Leonard 9c0e3fd5a8
Bug 37402: (follow-up) Add standard 'required' attributes and labels
This patch also moves time format hint into a standard <div
class="hint">. The hour format has been corrected from hhmm to HH:MM.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5a8a8ffd57)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:08:40 +00:00
adam.styles 72587be68c
Bug 37402: Applying scheduler form UI changes to ensure correct form state fail
Also adding form place holder and label update to better inform users

1. login to koha instance
2. navigate to reports module
3. create a small quick test report or use an existing small test report
4. select 'schedule' from toolbar above main sql window
5. once redirected to task scheduler UI, choose 'tommorow' in drop down
   'date' field.
6. enter 'test@local.com' in 'email' field
7. enter no value in the 'time' field
8. press 'save'.

Result - PASS:
- No  'Failed to add scheduled task' error state occurs, and the correct
  time require error state does occur
- Form does not attempt submit as it identifies the required time field
  data is missing
- Addition time field place holder information is provided and time
  field label also offer time format information to user

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 38c3c56045)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 11:06:43 +00:00
Baptiste Wojtkowski e064a51736
Bug 41420: Fix referrer in parcel.tt
Test plan:

Steps to reproduce :
1 - Go to http://localhost:8081/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=1&basketno=1 and fill in a new item.
2 - Visit http://localhost:8081/cgi-bin/koha/acqui/parcels.pl?booksellerid=1, type an invoice name and validate. Inspect both "Cancel order" and "Cancel order and catalog record". Notice the link in "Cancel order is broken"
3 - Apply patch
4 - Repeat 3 and notice the referrer is well formed.

For a reason I ignore, it does not seem to have an impact on main, but
on the 24.11 I tested, if you click on cancel order, after confirming
the deletion and clicking on "ok", you will be asked again to confirm,
    however the deletion has been performed

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e1ef80682a)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>
2026-03-23 10:36:20 +00:00
Jacob O'Mara 4fd7dba8eb
Bug 36466: DBRev 25.11.02.004
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 10:10:28 +00:00
Hammat Wele a79a7b4808
Bug 36466: (follow-up) Use NULL for blank planned and published dates instead of today
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 2e3325a680)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 10:03:40 +00:00
Hammat Wele 6dc82ebb74
Bug 36466: (follow-up) Adding atomicupdate file to fix 0000-00-00 in serial table
WNC amended patch - tidied

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 085c27e41b)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 10:02:51 +00:00
Hammat Wele 9c543fb471
Bug 36466: Incorrect date value stored when 'Published on' or 'Expected on' are empty
When we edit a serial and we leave the date fields ('Published on' or 'Expected on') empty incorrect date are saved in the database 0000-00-00
instade of current date and we get Error 500

to reproduce
1. Connect to staff interface
2. Go to Serials and create a new subscription
3. Click on Serial collection in the left menu (and note the
   Subscription numnber)
4. Select a serial to edit and Click on «Edit serials»
5. In the Serial edition form, delete «Published on > and « Expected on
   » dates and save
    ----> Error 500 page is displayed
6. Check the value of «Published on > and « Expected on » dates  in the
   database
   select planneddate,publisheddate from serial where subscriptionid=<Subscription numnber in step 3>;
    ------> planneddate publisheddate have «0000-00-00» value
7. Apply the patch
8. run ./installer/data/mysql/updatedatabase.pl
9. repeat step 2, 3, 4, 5, 6
   ----->  Error 500 page is no more displayed
   -----> «Published on » and « Expected on » field have NULL as value

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit cbdd895dbf)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 10:02:36 +00:00
Owen Leonard 7e29271c88
Bug 41764: ISSN hidden input missing from Z39.50 search form navigation
This patch modifies the Acquisitions and Cataloging Z39.50 search forms
so that the pagination form includes a hidden ISSN input. This is
necessary for the form to submit the same search parameters each time
the user requests a new page of results.

To test, apply the patch and go to Acquisitions.

- Search for a vendor, and create a basket if necessary.
- Add to the basket and choose "From an external source."
- In the "ISSN" field, enter a partial ISSN number, e.g. 0361, and
  search.
- At the bottom of the search results, click the "Next page" button.
- The second page of results should load correctly. At the top of the
  table of results it should say "You searched for: ISSN: 0361"
- Perform the same test in Cataloging:
  - Cataloging -> New from Z39.50/SRU

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5b8756f7b2)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:57:29 +00:00
Baptiste 4692be4252
Bug 40960: Print notification only if selected type is impossible
Test plan (ktd):
1 - Have henry acevedo have no mail and set messaging preference "Hold filled to sms"
2 - Have edna acosta have not messaging preference
3 - Place an hold on two books for edna acosta and henry acevedo, check in both books and select the button to fill the hold
4 - Check in notices and see that both received a notice
5 - Apply tests and run tests -> they should fail
6 - Apply patch, run rest -> they should pass
7 - Unfill both holds and fill them back. Henry should keep receiving notices while Edna should not anymore.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c800ea71de)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:56:14 +00:00
Baptiste 0185fb75cf
Bug 40960: Fix unit tests
Two unit tests have been moved/replaced to fit the desired behaviour

- "patron notified when item set to waiting" -> does not fit the desired behaviour.
  The desired behaviour for mails/sms is already tested
  The desired behaviour for prints is changed to "patron not notified if
  no messaging preference is specified"
- "patron not notified a second time (bug 11445)" -> Moved into
  _koha_notify_reserve tests

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ed42880f3d)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:55:46 +00:00
Lucas Gass 651e4f7db6
Bug 41475: Make hostitemnumbers an array ref
To test:

1. Set 'EasyAnalyticalRecords' to 'Show'.
2. Find or create a parent record that has at least 2 items on it. Note the itemnumbers and the framework.
3. Edit that framework so you can add a 773$0, 773$9, and 773$t
4. Find or create a child record.
5. Make at least 2 773 entries on the child record. Add the biblionumber of the host record to the 773$0.
6. In each entry for the 773$9 add one of the itemnumbers from the host record.
7. For the 773$t and the biblio title of the host record.
8. Save.
9. Now attempt to put a hold on the child record.
10. 500 error:
11. APPLY PATCH and restart_all
12. Try placing the hold again, this time it succeeds.

Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d2a3fe93f2)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:54:25 +00:00
Emmi Takkinen 918307ae13
Bug 41431: Use correct data-attribute to fetch existing circulation rule note
If you click Edit on a line with a note, the note field is not displayed
in the editing line and is blanked upon save (i.e., the note is lost,
even if you made no edits on the note). Value of the note is stored to
data-attribute which was changed to use Bootstraps own data-attribute.
So now the value must be fetched with keyword "bsContent" instead of
just "content".

To test:
1. Add note for a circulation rule.
2. Edit the rule.
=> Note that notes value is not displayed in editing row.
3. Apply this patch.
4. Edit rule again.
=> Note that notes value is now displayed as expected.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c27f4e54ac)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:53:11 +00:00
Marcel de Rooy 4e49aa5e36
Bug 19690: Change comments in IsAvailableForItemLevelRequest
The term 'If any unavailable' is not very clear but it is also
very hard to find something short and better.

A next available hold is possible when at least one item is
unavailable (checked out, on order, waiting/transit hold).
A item level hold is possible when the specific item is
unavailable.

Test plan:
Read the patch. The code did not change.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 56410f9c90)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:51:54 +00:00
Tomás Cohen Arazi 4bf3d8544c
Bug 41617: Remove extra spaces breaking CSV formatting
This patch removes extra spaces breaking CSV parsing in tools like Excel.

To test:
1. Perform an item search selecting the CSV option
2. Open the CSV with a TEXT EDITOR of your choice
=> FAIL: Notice the extra spaces after the commas (those used as separators, no the ones within the double quotes)
3. Apply this patch
4. Repeat 1-2
=> SUCCESS: No extra spaces!
5. Sign off :-D

Note: On the first attempt you can open the file on Excel if you have it and notice things are not aligned.
Note2: Using double quotes on all fields regardless of the context works for most parsers, but is not correct CSV. Will deal with it on a separate bug.

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit b7ab84f560)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:50:31 +00:00
Andrew Fuerste Henry d67fe1e462
Bug 41752: label concactfirstname and contactname as Guarantor first name and Guarantor surname
This change impacts the display of patron fields listed in system preferences:
BorrowerMandatoryField
BorrowerUnwantedField
PatronSelfModificationBorrowerUnwantedField
PatronSelfRegistrationBorrowerMandatoryField
PatronSelfRegistrationBorrowerUnwantedField

To test:
1 - confirm that the sysprefs listed above include "Alternate contact: First name (contactfirstname)" and "Alternate contact: Surname (contactname)"
2 - confirm that toggling the display of these fields hides/shows the Guarantor first name and Guarantor surname fields in a patron record
3 - apply patch, restart_all
4 - confirm that sysprefs now show "Guarantor first name (contactfirstname)" and "Guarnator surname (contactname)"
5 - confirm toggling the display of these fields still hides/shows the correct fields in a patron record in the staff client, in self-ref, and in OPAC self-modification

Signed-off-by: Anneli Österman <anneli.osterman@koha-suomi.fi>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit cc68988bce)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:47:34 +00:00
Ayoub Glizi-Vicioso 0db7e18645
Bug 41689: Make patron message labels translatable
To Test:

BEFORE APPLYING PATCH:
1- Go to any patron account > Add message
2- Add a message for: "Staff - Internal note"
3- Add a second message for: "OPAC - [NAME OF THE PATRON SELECTED]"

4- Add any language (I'll use french-Canada, fr-CA, in this case):
From your koha instance, enter on the command line:
./misc/translator/translate install fr-CA

5- Go to Administration > System preferences > enter language
6- Make sure to check 'Français (fr-CA)' box from the 'StaffInterfaceLanguages'preference and save.

7- Go back to the specific patron in which you added the messages
8- Switch language to 'Français' (bottom left corner)

9- Notice that:
--> 'OPAC' is still the same (Since we spell OPAC the same way in both english and french. However, it might not be the case in other languages).
--> 'Staff note' is not translated.

10- apply patch

AFTER APPLYING PATCH:

11 - From you koha instance, enter on the command line:

./misc/translator/translate update fr-CA

./misc/translator/translate install fr-CA

12- Reload patron's page

13- Notice that 'Staff note' is now translated
** You should see this output: 'Note interne'

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 707a208e16)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:44:57 +00:00
David Cook bc0bfb8470
Bug 34879: Remove unused file from Koha
This change removes the "catalogue/getitem-ajax.pl"
which appears to be an unused file in Koha.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit cb040b07f0)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:36:26 +00:00
Lucas Gass 3714b6c6b7
Bug 41422: Fix I18N issue with FilterSearchResultsByLoggedInBranch
To test:
1. Apply patch
2. Search fof the FilterSearchResultsByLoggedInBranch system preference and set it to 'Do'.
3. Do a catalog search and notice the 'Show local items only' button above the "Location" column.
4. Click it to show information ( in that column ) that is only related to the branch you are currently logged in at.
5. In the same result set have some items that are checked out, withdrawn, lost, damaged, and notforlaon.
6. Play more with the search results and ensure everything is accurate.
7. Set the FilterSearchResultsByLoggedInBranch system preference to 'Don't' and confirm that there is no button to filter by branch anymore.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 27f4bb4c9d)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-23 09:11:08 +00:00
Martin Renvoize 93f2e16007
Bug 41268: (QA follow-up) Apply same simplification to remaining operations
This follow-up applies the same variable-based simplification pattern
to the remaining operations in smart-rules.pl:

- cud-set-branch-defaults: 2 code paths reduced to 1
- cud-add-branch-cat: 4 code paths reduced to 1
- cud-add-open-article-requests-limit: 4 code paths reduced to 1
- cud-del-open-article-requests-limit: 4 code paths reduced to 1
- cud-add-branch-item: 4 code paths reduced to 1

Note: cud-delete-branch-cat was NOT simplified because it contains
additional business logic (setting itemtype rules only when deleting
the default categorycode), which is not simply a matter of converting
'*' to undef.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 1f51dab88e)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-03-16 13:23:10 +00:00