Commit Graph

60155 Commits

Author SHA1 Message Date
Jacob O'Mara 1d22b73a5d
RMaint: Tidy files for xt/perltidy.t failures
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-08 16:18:08 +01:00
Jacob O'Mara 0c839bf18d
Update release notes for 25.11.03 release
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-07 15:35:27 +01:00
Jacob O'Mara c62cc0f38e
Increment version for 25.11.03 release
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-07 15:34:57 +01:00
Jonathan Druart 17b05b7d8c
Bug 42048: Add a Cypress test
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 18:31:10 +01:00
David Cook c2869ae136
Bug 42048: Build patron search description more carefully
This patch builds the patron search description more carefully
to avoid XSS

Test plan:
0. Apply the patch
1. Log into Koha and click on "Patrons"
2. Change the "Category" and "Library" to any option but "Any"
   and click "Search"
3. Type "test" into the data table "Search:" box
4. Note some text should appear on the screen similar to this content
   and format:

   Patrons found for: Anywhere: test
   Library=Centerville, Category=Board

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 18:31:10 +01:00
Jonathan Druart f8dbe45221
Bug 41594: Add Cypress tests
* Add Cypress tests to cover the 404 redirect if the pref is disabled
* Add "invoices" as possible embed option for
  /acquisitions/vendors/:vendor_id
Seems relevant as the api def for invoice if expecting for it
api/v1/swagger/definitions/invoice.yaml
* Tell insertObject how to generate an invoice and return it.
Unfortunately we don't have a direct route for that, hence the embed
on /vendors/:vendor_id

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 18:31:10 +01:00
David Cook b201ee97b8
Bug 41594: Disable access to invoice-files.pl if AcqEnableFiles disabled
This patch makes it so that invoice-files.pl returns 404 if
AcqEnableFiles is disabled

Test plan:
0. Apply the patch
1. koha-plack --restart kohadev
2. Go to /cgi-bin/koha/acqui/invoice-files.pl?invoiceid=999
3. Note that you see a 404 page
4. Change "AcqEnableFiles" syspref to "Do"
5. Go to /cgi-bin/koha/acqui/invoice-files.pl?invoiceid=999
6. Note that you now see a "Files for invoice" page

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 18:31:10 +01:00
David Cook 7302a4d8f2
Bug 41261: Valid inputs to unapi
This change adds data validation to the "unapi" API endpoint.

Test plan:
0. Apply the patch
1. Go to http://localhost:8080/cgi-bin/koha/unapi
2. Note the 400 HTTP response code
3. Go to http://localhost:8080/cgi-bin/koha/unapi?id=bad
4. Note the 400 HTTP response code
5. Go to http://localhost:8080/cgi-bin/koha/unapi?id=koha:biblionumber:1&format=bad
6. Note the XML response listing the available formats for that ID
7. Go to http://localhost:8080//cgi-bin/koha/unapi?id=koha:biblionumber:1
8. Note the XML response listing the available formats for that ID
9. Go to http://localhost:8080//cgi-bin/koha/unapi?format=mods
10. Note the 400 HTTP response code
11. Go to http://localhost:8080//cgi-bin/koha/unapi?id=koha:biblionumber:1&format=mods
12. Note the MODS format returned for biblionumber 1

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 18:31:10 +01:00
Jacob O'Mara 4ccfe35f20
Bug 38426: (RMaint follow-up) update package.json and yarn.lock
@types/mime was resolving differently depending on distro you yarn
install on. This clamps it to the required 1.3.5

Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 17:16:06 +01:00
Martin Renvoize 9cd18e379b
Bug 39781: (RM follow-up) Fix wrong mock_userenv key in test
mock_userenv expects 'branchcode' but the test was passing 'branch',
causing the branchcode to fall through to the 'Branch4T' default and
the branch-specific notice lookup to never match.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit b0df04264e)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-02 16:50:35 +01:00
Martin Renvoize fa67c646a9
Bug 39781: (QA follow-up) Fix crashes, dead code and add tests
- Fix potential crash when C4::Context->userenv returns undef:
  use the established ternary guard pattern used throughout other
  TT plugins (AuthorisedValues, Branches, Desks, etc.)
- Remove dead second argument passed to GetLettersAvailableForALibrary,
  which only accepts one argument; the group_by/columns/order_by
  hashref was silently dropped
- Fix typo "librries" -> "libraries" in GetByModuleForLibrary POD
- Update POD example to use 'add_message' module matching actual usage
- Add test coverage for GetByModuleForLibrary, verifying that a user
  logged in to a branch sees branch-specific and all-libraries notices,
  while users at other branches see only all-libraries notices

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit b18fbab806)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:49:53 +00:00
Andrew Fuerste Henry 0a2ffaae03
Bug 39781: Add POD coverage
Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 5937d40a28)
Signed-off-by: Jacob O'Mara <jacob.omara@openfifth.co.uk>
2026-03-25 08:49:52 +00:00
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