Bug 38666 - Closed stack requests
Summary: Closed stack requests
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature
Assignee: Julian Maurice
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-10 15:12 UTC by Julian Maurice
Modified: 2025-04-11 10:24 UTC (History)
7 users (show)

See Also:
GIT URL:
Change sponsored?: Sponsored
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 38666: Closed stack requests (123.79 KB, patch)
2024-12-10 15:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Closed stack requests (128.51 KB, patch)
2024-12-11 13:06 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: [DO NOT PUSH] Update DBIC schema (2.51 KB, patch)
2024-12-11 13:06 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Flag new columns as boolean (SQL12) (3.09 KB, patch)
2024-12-11 13:06 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Closed stack requests (129.74 KB, patch)
2025-03-05 15:31 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: [DO NOT PUSH] Update DBIC schema (2.51 KB, patch)
2025-03-05 15:31 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Flag new columns as boolean (SQL12) (3.09 KB, patch)
2025-03-05 15:31 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Closed stack requests (129.87 KB, patch)
2025-03-19 09:32 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: [DO NOT PUSH] Update DBIC schema (2.51 KB, patch)
2025-03-19 09:32 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Flag new columns as boolean (SQL12) (3.09 KB, patch)
2025-03-19 09:32 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Closed stack requests (128.43 KB, patch)
2025-04-02 12:30 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: [DO NOT PUSH] Update DBIC schema (2.51 KB, patch)
2025-04-02 12:30 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Flag new columns as boolean (SQL12) (3.09 KB, patch)
2025-04-02 12:30 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Closed stack requests (128.51 KB, patch)
2025-04-02 12:39 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: [DO NOT PUSH] Update DBIC schema (2.51 KB, patch)
2025-04-02 12:39 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Flag new columns as boolean (SQL12) (3.09 KB, patch)
2025-04-02 12:39 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 38666: Closed stack requests (128.44 KB, patch)
2025-04-11 10:00 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 38666: [DO NOT PUSH] Update DBIC schema (2.57 KB, patch)
2025-04-11 10:00 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 38666: Flag new columns as boolean (SQL12) (3.15 KB, patch)
2025-04-11 10:00 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2024-12-10 15:12:52 UTC
A closed stack request is a special kind of hold that can only be placed on a closed stack item.
A closed stack item is an item that is not available publicly in the library but can be made available on demand. When a request is made, a librarian will print a slip then will go retrieve the document and place the slip in place of the document.
Comment 1 Julian Maurice 2024-12-10 15:16:09 UTC Comment hidden (obsolete)
Comment 2 Julian Maurice 2024-12-11 13:06:39 UTC
Created attachment 175371 [details] [review]
Bug 38666: Closed stack requests

A closed stack request is a special kind of hold that can only be placed
on a closed stack item.
A closed stack item is an item that is not available publicly in the
library but can be made available on demand. When a request is made, a
librarian will print a slip then will go retrieve the document and place
the slip in place of the document.

Internally, a closed stack item is an item that is flagged as "closed
stack" (new column items.is_closed_stack). The flag can be modified on
the biblio "Items" tab. The new column can also be mapped to an item
MARC subfield.

An item is available for a closed stack request only if:
- it is flagged as "closed stack"
- there is no holds on it
- it is not checked out
- it is not in transfer

If any of the above conditions is false, it is not available for a
closed stack request but it can be available for a regular hold.
In particular this means that once a closed stack request has been made
on a particular item, this item can now be reserved using regular holds.

Closed stack requests behave like regular holds, with the following
exceptions:
- They can only be placed on a specific item (item-level hold is forced)
- They can be placed on "not for loan" items
- They bypass the "onshelfholds" circulation rule
- They cannot be cancelled from OPAC

There is a new page "Closed stack requests" accessible from the
circulation menu that lists all pending closed stack requests.
From there it is possible to cancel requests or to print a slip (letter
code CLOSED_STACK_SLIP in 'reserves' module)
Once the slip is printed, closed stack requests move to another tab in
the same page.

The patch also adds a template plugin 'GD.Barcode' that allows to
include a barcode image inside a letter. Useful to be able to scan the
printed closed stack request slip.
Example usage:

[% USE GD.Barcode %]
<img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) | html %]">

Test plan:
 1. Apply patch, run updatedatabase.pl and update_dbix_class_files.pl,
    and restart koha
 2. Create a biblio with two items.
 3. On the biblio detail page, click on the "Items" tab
 4. For one of the two items, change the "Closed stack" status from No
    to Yes
 5. Notice there is now a "closed stack requests" tab on the left, and a
    "closed stack request" button in the toolbar
 6. Click on "Place hold" and select a patron. Notice there is only one
    item displayed in the table (the non-"closed stack" item)
 7. Go back to the biblio detail view and click on the "Closed stack
    request" button. Select a patron. Notice there is only one item
    displayed in the table (the "closed stack" item).
 8. Select this item and click on "Place hold". You should be redirected
    to the "Closed stack requests" tab where you can see the request
    that you just made
 9. Try to place a regular hold again. This time you should see both
   items in the table.
10. Go to Tools » Notices and slips
11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
    Add content in the "Print" message.
12. Go to Circulation » Closed stack requests
13. You have two tabs: "Pending" and "Slip printed", you should have one
    request under the pending tab, and zero under the other one.
14. Click on the "Print closed stack request slip" button, in the
    "pending" table. A printer dialog should open, close it.
    The "Closed stack requests" should have been automatically
    refreshed, showing you an empty "pending" tab, while the "Slip
    printed" tab now contains the previously pending request.
15. Cancel the closed stack request.
16. Login to OPAC, find your biblio record and place a closed stack
    request. Like from the staff interface, only the closed stack item
    should be in the items table, and it should not be possible to place
    a biblio-level request
17. In your account page, verify that the closed stack request appear
    under the new tab "Closed stack requests" and that there is no
    "Cancel" button
18. Go back to the staff interface main page. You should see an alert at
    the bottom: "Pending closed stack requests: 1". Clicking on it
    should redirect you to the closed stack requests page seen earlier
    (step 12)
19. Set the closed stack item as "notforloan", either by editing the
    item or its item type. Verify that you can still do closed stack
    requests
20. Change circulation rules to forbid on-shelf holds on the closed
    stack item and verify that you can still do closed stack requests.

Sponsored-by: Université de Lyon 3
Comment 3 Julian Maurice 2024-12-11 13:06:41 UTC
Created attachment 175372 [details] [review]
Bug 38666: [DO NOT PUSH] Update DBIC schema
Comment 4 Julian Maurice 2024-12-11 13:06:43 UTC
Created attachment 175373 [details] [review]
Bug 38666: Flag new columns as boolean (SQL12)
Comment 5 Julian Maurice 2024-12-11 13:12:49 UTC
This isn't ready for QA, as there is no unit tests yet, but it is ready for testing. I'd really like to have some feedback on the feature itself before spending time writing tests.
Comment 6 Thibault Keromnès 2025-01-14 13:57:15 UTC
On step one I ran "dbic",  "updatedatabase" and "restart_all"
On step 2 of the test plan, after creating the  items I have an error when i go back to the biblio details page. The logs read : 
==> /var/log/koha/kohadev/plack-api-error.log <==
[2025/01/14 13:28:29] [WARN] OpenAPI >>> GET api/v1/biblios/272/items [{"message":"Properties not allowed: is_closed_stack.","path":"\/body\/0"},{"message":"Properties not allowed: is_closed_stack.","path":"\/body\/1"},{"message":"Properties not allowed: is_closed_stack.","path":"\/body\/2"}]

==> /var/log/koha/kohadev/plack.log <==
172.18.0.1 - - [14/Jan/2025:13:28:29 +0000] "GET /api/v1/app.pl/api/v1/biblios/272/items?&_page=1&_per_page=20&_match=contains&_order_by= HTTP/1.1" 500 - "http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=272&searchid=scs_1736860462163" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0"

Really interested by what I can see of the feature though.
Comment 7 Julian Maurice 2025-03-05 15:31:23 UTC
Created attachment 178977 [details] [review]
Bug 38666: Closed stack requests

A closed stack request is a special kind of hold that can only be placed
on a closed stack item.
A closed stack item is an item that is not available publicly in the
library but can be made available on demand. When a request is made, a
librarian will print a slip then will go retrieve the document and place
the slip in place of the document.

Internally, a closed stack item is an item that is flagged as "closed
stack" (new column items.is_closed_stack). The flag can be modified on
the biblio "Items" tab. The new column can also be mapped to an item
MARC subfield.

An item is available for a closed stack request only if:
- it is flagged as "closed stack"
- there is no holds on it
- it is not checked out
- it is not in transfer

If any of the above conditions is false, it is not available for a
closed stack request but it can be available for a regular hold.
In particular this means that once a closed stack request has been made
on a particular item, this item can now be reserved using regular holds.

Closed stack requests behave like regular holds, with the following
exceptions:
- They can only be placed on a specific item (item-level hold is forced)
- They can be placed on "not for loan" items
- They bypass the "onshelfholds" circulation rule
- They cannot be cancelled from OPAC

There is a new page "Closed stack requests" accessible from the
circulation menu that lists all pending closed stack requests.
From there it is possible to cancel requests or to print a slip (letter
code CLOSED_STACK_SLIP in 'reserves' module)
Once the slip is printed, closed stack requests move to another tab in
the same page.

The patch also adds a template plugin 'GD.Barcode' that allows to
include a barcode image inside a letter. Useful to be able to scan the
printed closed stack request slip.
Example usage:

[% USE GD.Barcode %]
<img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) | html %]">

Test plan:
 1. Apply patch, run updatedatabase.pl and update_dbix_class_files.pl,
    and restart koha
 2. Create a biblio with two items.
 3. On the biblio detail page, click on the "Items" tab
 4. For one of the two items, change the "Closed stack" status from No
    to Yes
 5. Notice there is now a "closed stack requests" tab on the left, and a
    "closed stack request" button in the toolbar
 6. Click on "Place hold" and select a patron. Notice there is only one
    item displayed in the table (the non-"closed stack" item)
 7. Go back to the biblio detail view and click on the "Closed stack
    request" button. Select a patron. Notice there is only one item
    displayed in the table (the "closed stack" item).
 8. Select this item and click on "Place hold". You should be redirected
    to the "Closed stack requests" tab where you can see the request
    that you just made
 9. Try to place a regular hold again. This time you should see both
   items in the table.
10. Go to Tools » Notices and slips
11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
    Add content in the "Print" message.
12. Go to Circulation » Closed stack requests
13. You have two tabs: "Pending" and "Slip printed", you should have one
    request under the pending tab, and zero under the other one.
14. Click on the "Print closed stack request slip" button, in the
    "pending" table. A printer dialog should open, close it.
    The "Closed stack requests" should have been automatically
    refreshed, showing you an empty "pending" tab, while the "Slip
    printed" tab now contains the previously pending request.
15. Cancel the closed stack request.
16. Login to OPAC, find your biblio record and place a closed stack
    request. Like from the staff interface, only the closed stack item
    should be in the items table, and it should not be possible to place
    a biblio-level request
17. In your account page, verify that the closed stack request appear
    under the new tab "Closed stack requests" and that there is no
    "Cancel" button
18. Go back to the staff interface main page. You should see an alert at
    the bottom: "Pending closed stack requests: 1". Clicking on it
    should redirect you to the closed stack requests page seen earlier
    (step 12)
19. Set the closed stack item as "notforloan", either by editing the
    item or its item type. Verify that you can still do closed stack
    requests
20. Change circulation rules to forbid on-shelf holds on the closed
    stack item and verify that you can still do closed stack requests.

Sponsored-by: Université de Lyon 3
Comment 8 Julian Maurice 2025-03-05 15:31:25 UTC
Created attachment 178978 [details] [review]
Bug 38666: [DO NOT PUSH] Update DBIC schema
Comment 9 Julian Maurice 2025-03-05 15:31:28 UTC
Created attachment 178979 [details] [review]
Bug 38666: Flag new columns as boolean (SQL12)
Comment 10 Julian Maurice 2025-03-05 15:34:33 UTC
Patches rebased on main

(In reply to Thibault Keromnès from comment #6)
> On step one I ran "dbic",  "updatedatabase" and "restart_all"
> On step 2 of the test plan, after creating the  items I have an error when i
> go back to the biblio details page. The logs read : 
> ==> /var/log/koha/kohadev/plack-api-error.log <==
> [2025/01/14 13:28:29] [WARN] OpenAPI >>> GET api/v1/biblios/272/items
> [{"message":"Properties not allowed:
> is_closed_stack.","path":"\/body\/0"},{"message":"Properties not allowed:
> is_closed_stack.","path":"\/body\/1"},{"message":"Properties not allowed:
> is_closed_stack.","path":"\/body\/2"}]

Not sure what was causing that since is_closed_stack is defined in the OpenAPI spec. And I cannot reproduce after the rebase. Can you try again ?
Comment 11 Julian Maurice 2025-03-19 09:32:41 UTC
Created attachment 179466 [details] [review]
Bug 38666: Closed stack requests

A closed stack request is a special kind of hold that can only be placed
on a closed stack item.
A closed stack item is an item that is not available publicly in the
library but can be made available on demand. When a request is made, a
librarian will print a slip then will go retrieve the document and place
the slip in place of the document.

Internally, a closed stack item is an item that is flagged as "closed
stack" (new column items.is_closed_stack). The flag can be modified on
the biblio "Items" tab. The new column can also be mapped to an item
MARC subfield.

An item is available for a closed stack request only if:
- it is flagged as "closed stack"
- there is no holds on it
- it is not checked out
- it is not in transfer

If any of the above conditions is false, it is not available for a
closed stack request but it can be available for a regular hold.
In particular this means that once a closed stack request has been made
on a particular item, this item can now be reserved using regular holds.

Closed stack requests behave like regular holds, with the following
exceptions:
- They can only be placed on a specific item (item-level hold is forced)
- They can be placed on "not for loan" items
- They bypass the "onshelfholds" circulation rule
- They cannot be cancelled from OPAC

There is a new page "Closed stack requests" accessible from the
circulation menu that lists all pending closed stack requests.
From there it is possible to cancel requests or to print a slip (letter
code CLOSED_STACK_SLIP in 'reserves' module)
Once the slip is printed, closed stack requests move to another tab in
the same page.

The patch also adds a template plugin 'GD.Barcode' that allows to
include a barcode image inside a letter. Useful to be able to scan the
printed closed stack request slip.
Example usage:

[% USE GD.Barcode %]
<img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) | html %]">

Test plan:
 1. Apply patch, run updatedatabase.pl and update_dbix_class_files.pl,
    and restart koha
 2. Create a biblio with two items.
 3. On the biblio detail page, click on the "Items" tab
 4. For one of the two items, change the "Closed stack" status from No
    to Yes
 5. Notice there is now a "closed stack requests" tab on the left, and a
    "closed stack request" button in the toolbar
 6. Click on "Place hold" and select a patron. Notice there is only one
    item displayed in the table (the non-"closed stack" item)
 7. Go back to the biblio detail view and click on the "Closed stack
    request" button. Select a patron. Notice there is only one item
    displayed in the table (the "closed stack" item).
 8. Select this item and click on "Place hold". You should be redirected
    to the "Closed stack requests" tab where you can see the request
    that you just made
 9. Try to place a regular hold again. This time you should see both
   items in the table.
10. Go to Tools » Notices and slips
11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
    Add content in the "Print" message.
12. Go to Circulation » Closed stack requests
13. You have two tabs: "Pending" and "Slip printed", you should have one
    request under the pending tab, and zero under the other one.
14. Click on the "Print closed stack request slip" button, in the
    "pending" table. A printer dialog should open, close it.
    The "Closed stack requests" should have been automatically
    refreshed, showing you an empty "pending" tab, while the "Slip
    printed" tab now contains the previously pending request.
15. Cancel the closed stack request.
16. Login to OPAC, find your biblio record and place a closed stack
    request. Like from the staff interface, only the closed stack item
    should be in the items table, and it should not be possible to place
    a biblio-level request
17. In your account page, verify that the closed stack request appear
    under the new tab "Closed stack requests" and that there is no
    "Cancel" button
18. Go back to the staff interface main page. You should see an alert at
    the bottom: "Pending closed stack requests: 1". Clicking on it
    should redirect you to the closed stack requests page seen earlier
    (step 12)
19. Set the closed stack item as "notforloan", either by editing the
    item or its item type. Verify that you can still do closed stack
    requests
20. Change circulation rules to forbid on-shelf holds on the closed
    stack item and verify that you can still do closed stack requests.

Sponsored-by: Université de Lyon 3
Comment 12 Julian Maurice 2025-03-19 09:32:44 UTC
Created attachment 179467 [details] [review]
Bug 38666: [DO NOT PUSH] Update DBIC schema
Comment 13 Julian Maurice 2025-03-19 09:32:46 UTC
Created attachment 179468 [details] [review]
Bug 38666: Flag new columns as boolean (SQL12)
Comment 14 Thibault Keromnès 2025-03-19 09:43:32 UTC
After applying - update_dbix_class_files.pl ends with : 
DBIx::Class::Schema::Loader::make_schema_at(): Checksum mismatch in './/Koha/Schema/Result/Deleteditem.pm', the auto-generated part of the file has been modified outside of this loader.  Aborting.
If you want to overwrite these modifications, set the 'overwrite_modifications' loader option.
Comment 15 Thibault Keromnès 2025-03-19 09:53:48 UTC
When loading a biblio i get an error : Something went wrong when loading the table.
500: Internal Server Error. 
Properties not allowed: is_closed_stack.
Comment 16 Thibault Keromnès 2025-03-19 11:01:10 UTC
Test plan needs an update: no need for update_dbix_class_files.pl. 
Error on comment 14 was solved by running `yarn run api:bundle` and restarting Koha.

On step 12 I get a error when loading closed-stack-requests.pl page. Log reads: Template process failed: file error - columns_settings.inc: not found at /kohadevbox/koha/C4/Templates.pm line 134.
Comment 17 Thibault Keromnès 2025-03-19 14:02:11 UTC
(In reply to Thibault Keromnès from comment #16)
> Test plan needs an update: no need for update_dbix_class_files.pl. 
> Error on comment 14 was solved by running `yarn run api:bundle` and
> restarting Koha.
> 
Made a mistake, sorry : `yarn run api:bundle` solves the comment 15 problem

We still have the dbic issue (comment 14)
Comment 18 Julian Maurice 2025-04-02 12:30:14 UTC
Created attachment 180309 [details] [review]
Bug 38666: Closed stack requests

A closed stack request is a special kind of hold that can only be placed
on a closed stack item.
A closed stack item is an item that is not available publicly in the
library but can be made available on demand. When a request is made, a
librarian will print a slip then will go retrieve the document and place
the slip in place of the document.

Internally, a closed stack item is an item that is flagged as "closed
stack" (new column items.is_closed_stack). The flag can be modified on
the biblio "Items" tab. The new column can also be mapped to an item
MARC subfield.

An item is available for a closed stack request only if:
- it is flagged as "closed stack"
- there is no holds on it
- it is not checked out
- it is not in transfer

If any of the above conditions is false, it is not available for a
closed stack request but it can be available for a regular hold.
In particular this means that once a closed stack request has been made
on a particular item, this item can now be reserved using regular holds.

Closed stack requests behave like regular holds, with the following
exceptions:
- They can only be placed on a specific item (item-level hold is forced)
- They can be placed on "not for loan" items
- They bypass the "onshelfholds" circulation rule
- They cannot be cancelled from OPAC

There is a new page "Closed stack requests" accessible from the
circulation menu that lists all pending closed stack requests.
From there it is possible to cancel requests or to print a slip (letter
code CLOSED_STACK_SLIP in 'reserves' module)
Once the slip is printed, closed stack requests move to another tab in
the same page.

The patch also adds a template plugin 'GD.Barcode' that allows to
include a barcode image inside a letter. Useful to be able to scan the
printed closed stack request slip.
Example usage:

[% USE GD.Barcode %]
<img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) | html %]">

Test plan:
 1. Apply patch, run updatedatabase.pl and update_dbix_class_files.pl,
    and restart koha
 2. Create a biblio with two items.
 3. On the biblio detail page, click on the "Items" tab
 4. For one of the two items, change the "Closed stack" status from No
    to Yes
 5. Notice there is now a "closed stack requests" tab on the left, and a
    "closed stack request" button in the toolbar
 6. Click on "Place hold" and select a patron. Notice there is only one
    item displayed in the table (the non-"closed stack" item)
 7. Go back to the biblio detail view and click on the "Closed stack
    request" button. Select a patron. Notice there is only one item
    displayed in the table (the "closed stack" item).
 8. Select this item and click on "Place hold". You should be redirected
    to the "Closed stack requests" tab where you can see the request
    that you just made
 9. Try to place a regular hold again. This time you should see both
   items in the table.
10. Go to Tools » Notices and slips
11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
    Add content in the "Print" message.
12. Go to Circulation » Closed stack requests
13. You have two tabs: "Pending" and "Slip printed", you should have one
    request under the pending tab, and zero under the other one.
14. Click on the "Print closed stack request slip" button, in the
    "pending" table. A printer dialog should open, close it.
    The "Closed stack requests" should have been automatically
    refreshed, showing you an empty "pending" tab, while the "Slip
    printed" tab now contains the previously pending request.
15. Cancel the closed stack request.
16. Login to OPAC, find your biblio record and place a closed stack
    request. Like from the staff interface, only the closed stack item
    should be in the items table, and it should not be possible to place
    a biblio-level request
17. In your account page, verify that the closed stack request appear
    under the new tab "Closed stack requests" and that there is no
    "Cancel" button
18. Go back to the staff interface main page. You should see an alert at
    the bottom: "Pending closed stack requests: 1". Clicking on it
    should redirect you to the closed stack requests page seen earlier
    (step 12)
19. Set the closed stack item as "notforloan", either by editing the
    item or its item type. Verify that you can still do closed stack
    requests
20. Change circulation rules to forbid on-shelf holds on the closed
    stack item and verify that you can still do closed stack requests.

Sponsored-by: Université de Lyon 3
Comment 19 Julian Maurice 2025-04-02 12:30:17 UTC
Created attachment 180310 [details] [review]
Bug 38666: [DO NOT PUSH] Update DBIC schema
Comment 20 Julian Maurice 2025-04-02 12:30:21 UTC
Created attachment 180311 [details] [review]
Bug 38666: Flag new columns as boolean (SQL12)
Comment 21 Julian Maurice 2025-04-02 12:34:51 UTC
Patches rewritten to use kohaTable instead of KohaTable. This fixes error raised in comment 16.

Error in comment 14 can be ignored by re-generating dbic schema with --force option

So it's ready for testing again.
Comment 22 Julian Maurice 2025-04-02 12:39:02 UTC
Created attachment 180321 [details] [review]
Bug 38666: Closed stack requests

A closed stack request is a special kind of hold that can only be placed
on a closed stack item.
A closed stack item is an item that is not available publicly in the
library but can be made available on demand. When a request is made, a
librarian will print a slip then will go retrieve the document and place
the slip in place of the document.

Internally, a closed stack item is an item that is flagged as "closed
stack" (new column items.is_closed_stack). The flag can be modified on
the biblio "Items" tab. The new column can also be mapped to an item
MARC subfield.

An item is available for a closed stack request only if:
- it is flagged as "closed stack"
- there is no holds on it
- it is not checked out
- it is not in transfer

If any of the above conditions is false, it is not available for a
closed stack request but it can be available for a regular hold.
In particular this means that once a closed stack request has been made
on a particular item, this item can now be reserved using regular holds.

Closed stack requests behave like regular holds, with the following
exceptions:
- They can only be placed on a specific item (item-level hold is forced)
- They can be placed on "not for loan" items
- They bypass the "onshelfholds" circulation rule
- They cannot be cancelled from OPAC

There is a new page "Closed stack requests" accessible from the
circulation menu that lists all pending closed stack requests.
From there it is possible to cancel requests or to print a slip (letter
code CLOSED_STACK_SLIP in 'reserves' module)
Once the slip is printed, closed stack requests move to another tab in
the same page.

The patch also adds a template plugin 'GD.Barcode' that allows to
include a barcode image inside a letter. Useful to be able to scan the
printed closed stack request slip.
Example usage:

[% USE GD.Barcode %]
<img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) | html %]">

Test plan:
 1. Apply the patch:
    a. apply patch,
    b. run updatedatabase.pl and `update_dbix_class_files.pl --force`,
    c. run `yarn run build`,
    d. and finally restart koha
 2. Create a biblio with two items.
 3. On the biblio detail page, click on the "Items" tab
 4. For one of the two items, change the "Closed stack" status from No
    to Yes
 5. Notice there is now a "closed stack requests" tab on the left, and a
    "closed stack request" button in the toolbar
 6. Click on "Place hold" and select a patron. Notice there is only one
    item displayed in the table (the non-"closed stack" item)
 7. Go back to the biblio detail view and click on the "Closed stack
    request" button. Select a patron. Notice there is only one item
    displayed in the table (the "closed stack" item).
 8. Select this item and click on "Place hold". You should be redirected
    to the "Closed stack requests" tab where you can see the request
    that you just made
 9. Try to place a regular hold again. This time you should see both
   items in the table.
10. Go to Tools » Notices and slips
11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
    Add content in the "Print" message.
12. Go to Circulation » Closed stack requests
13. You have two tabs: "Pending" and "Slip printed", you should have one
    request under the pending tab, and zero under the other one.
14. Click on the "Print closed stack request slip" button, in the
    "pending" table. A printer dialog should open, close it.
    The "Closed stack requests" should have been automatically
    refreshed, showing you an empty "pending" tab, while the "Slip
    printed" tab now contains the previously pending request.
15. Cancel the closed stack request.
16. Login to OPAC, find your biblio record and place a closed stack
    request. Like from the staff interface, only the closed stack item
    should be in the items table, and it should not be possible to place
    a biblio-level request
17. In your account page, verify that the closed stack request appear
    under the new tab "Closed stack requests" and that there is no
    "Cancel" button
18. Go back to the staff interface main page. You should see an alert at
    the bottom: "Pending closed stack requests: 1". Clicking on it
    should redirect you to the closed stack requests page seen earlier
    (step 12)
19. Set the closed stack item as "notforloan", either by editing the
    item or its item type. Verify that you can still do closed stack
    requests
20. Change circulation rules to forbid on-shelf holds on the closed
    stack item and verify that you can still do closed stack requests.

Sponsored-by: Université de Lyon 3
Comment 23 Julian Maurice 2025-04-02 12:39:06 UTC
Created attachment 180322 [details] [review]
Bug 38666: [DO NOT PUSH] Update DBIC schema
Comment 24 Julian Maurice 2025-04-02 12:39:10 UTC
Created attachment 180323 [details] [review]
Bug 38666: Flag new columns as boolean (SQL12)
Comment 25 Julian Maurice 2025-04-02 12:40:20 UTC
Re-upload with updated test plan (1st step only)
Comment 26 Amaury GAU 2025-04-02 15:11:24 UTC
(In reply to Julian Maurice from comment #22)
> Created attachment 180321 [details] [review] [review]
> Bug 38666: Closed stack requests
> 
> A closed stack request is a special kind of hold that can only be placed
> on a closed stack item.
> A closed stack item is an item that is not available publicly in the
> library but can be made available on demand. When a request is made, a
> librarian will print a slip then will go retrieve the document and place
> the slip in place of the document.
> 
> Internally, a closed stack item is an item that is flagged as "closed
> stack" (new column items.is_closed_stack). The flag can be modified on
> the biblio "Items" tab. The new column can also be mapped to an item
> MARC subfield.
> 
> An item is available for a closed stack request only if:
> - it is flagged as "closed stack"
> - there is no holds on it
> - it is not checked out
> - it is not in transfer
> 
> If any of the above conditions is false, it is not available for a
> closed stack request but it can be available for a regular hold.
> In particular this means that once a closed stack request has been made
> on a particular item, this item can now be reserved using regular holds.
> 
> Closed stack requests behave like regular holds, with the following
> exceptions:
> - They can only be placed on a specific item (item-level hold is forced)
> - They can be placed on "not for loan" items
> - They bypass the "onshelfholds" circulation rule
> - They cannot be cancelled from OPAC
> 
> There is a new page "Closed stack requests" accessible from the
> circulation menu that lists all pending closed stack requests.
> From there it is possible to cancel requests or to print a slip (letter
> code CLOSED_STACK_SLIP in 'reserves' module)
> Once the slip is printed, closed stack requests move to another tab in
> the same page.
> 
> The patch also adds a template plugin 'GD.Barcode' that allows to
> include a barcode image inside a letter. Useful to be able to scan the
> printed closed stack request slip.
> Example usage:
> 
> [% USE GD.Barcode %]
> <img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) |
> html %]">
> 
> Test plan:
>  1. Apply the patch:
>     a. apply patch,
>     b. run updatedatabase.pl and `update_dbix_class_files.pl --force`,
>     c. run `yarn run build`,
>     d. and finally restart koha
>  2. Create a biblio with two items.
>  3. On the biblio detail page, click on the "Items" tab
>  4. For one of the two items, change the "Closed stack" status from No
>     to Yes
>  5. Notice there is now a "closed stack requests" tab on the left, and a
>     "closed stack request" button in the toolbar
>  6. Click on "Place hold" and select a patron. Notice there is only one
>     item displayed in the table (the non-"closed stack" item)
>  7. Go back to the biblio detail view and click on the "Closed stack
>     request" button. Select a patron. Notice there is only one item
>     displayed in the table (the "closed stack" item).
>  8. Select this item and click on "Place hold". You should be redirected
>     to the "Closed stack requests" tab where you can see the request
>     that you just made
>  9. Try to place a regular hold again. This time you should see both
>    items in the table.
> 10. Go to Tools » Notices and slips
> 11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
>     Add content in the "Print" message.
> 12. Go to Circulation » Closed stack requests
> 13. You have two tabs: "Pending" and "Slip printed", you should have one
>     request under the pending tab, and zero under the other one.
> 14. Click on the "Print closed stack request slip" button, in the
>     "pending" table. A printer dialog should open, close it.
>     The "Closed stack requests" should have been automatically
>     refreshed, showing you an empty "pending" tab, while the "Slip
>     printed" tab now contains the previously pending request.

Why the request can be cancelled as "not found" before printing the slip. I guess this is a user practice to avoid. 


> 15. Cancel the closed stack request.
> 16. Login to OPAC, find your biblio record and place a closed stack
>     request. Like from the staff interface, only the closed stack item
>     should be in the items table, and it should not be possible to place
>     a biblio-level request
> 17. In your account page, verify that the closed stack request appear
>     under the new tab "Closed stack requests" and that there is no
>     "Cancel" button

There is a problem here. If the syspref `SuspendHoldsOpac` is allowed, a button 'Suspend all holds' will appear. I'm pretty sure this is not a wanted behaviour as librarians could be searching for the book while it gets cancelled. 


> 18. Go back to the staff interface main page. You should see an alert at
>     the bottom: "Pending closed stack requests: 1". Clicking on it
>     should redirect you to the closed stack requests page seen earlier
>     (step 12)
> 19. Set the closed stack item as "notforloan", either by editing the
>     item or its item type. Verify that you can still do closed stack
>     requests

It seems weird that a notforloan item can be asked from a patron. The main purpose of a notforloan item, is exactly the contrary. it should not be requestable. Otherwise, it might need a syspref to overrule this behaviour. 
I'd gladly ask other librarians about this.
   
> 20. Change circulation rules to forbid on-shelf holds on the closed
>     stack item and verify that you can still do closed stack requests.
> 
> Sponsored-by: Université de Lyon 3

Thanks for the dev :)
Comment 27 Esther Melander 2025-04-02 15:21:08 UTC
It is exciting to see work on this! The archives I have worked with have all asked for the holds slips to auto print. This development adds a special print holds slip button, which would still be a great benefit. I did file this bug about the auto print holds slip. Bug 35355
Comment 28 Biblibre Sandboxes 2025-04-11 10:00:43 UTC
Created attachment 180822 [details] [review]
Bug 38666: Closed stack requests

A closed stack request is a special kind of hold that can only be placed
on a closed stack item.
A closed stack item is an item that is not available publicly in the
library but can be made available on demand. When a request is made, a
librarian will print a slip then will go retrieve the document and place
the slip in place of the document.

Internally, a closed stack item is an item that is flagged as "closed
stack" (new column items.is_closed_stack). The flag can be modified on
the biblio "Items" tab. The new column can also be mapped to an item
MARC subfield.

An item is available for a closed stack request only if:
- it is flagged as "closed stack"
- there is no holds on it
- it is not checked out
- it is not in transfer

If any of the above conditions is false, it is not available for a
closed stack request but it can be available for a regular hold.
In particular this means that once a closed stack request has been made
on a particular item, this item can now be reserved using regular holds.

Closed stack requests behave like regular holds, with the following
exceptions:
- They can only be placed on a specific item (item-level hold is forced)
- They can be placed on "not for loan" items
- They bypass the "onshelfholds" circulation rule
- They cannot be cancelled from OPAC

There is a new page "Closed stack requests" accessible from the
circulation menu that lists all pending closed stack requests.
From there it is possible to cancel requests or to print a slip (letter
code CLOSED_STACK_SLIP in 'reserves' module)
Once the slip is printed, closed stack requests move to another tab in
the same page.

The patch also adds a template plugin 'GD.Barcode' that allows to
include a barcode image inside a letter. Useful to be able to scan the
printed closed stack request slip.
Example usage:

[% USE GD.Barcode %]
<img src="[% GD.Barcode.create_as_data_url('Code39', hold.item.barcode) | html %]">

Test plan:
 1. Apply the patch:
    a. apply patch,
    b. run updatedatabase.pl and `update_dbix_class_files.pl --force`,
    c. run `yarn run build`,
    d. and finally restart koha
 2. Create a biblio with two items.
 3. On the biblio detail page, click on the "Items" tab
 4. For one of the two items, change the "Closed stack" status from No
    to Yes
 5. Notice there is now a "closed stack requests" tab on the left, and a
    "closed stack request" button in the toolbar
 6. Click on "Place hold" and select a patron. Notice there is only one
    item displayed in the table (the non-"closed stack" item)
 7. Go back to the biblio detail view and click on the "Closed stack
    request" button. Select a patron. Notice there is only one item
    displayed in the table (the "closed stack" item).
 8. Select this item and click on "Place hold". You should be redirected
    to the "Closed stack requests" tab where you can see the request
    that you just made
 9. Try to place a regular hold again. This time you should see both
   items in the table.
10. Go to Tools » Notices and slips
11. Create a new notice in the Holds module with code CLOSED_STACK_SLIP.
    Add content in the "Print" message.
12. Go to Circulation » Closed stack requests
13. You have two tabs: "Pending" and "Slip printed", you should have one
    request under the pending tab, and zero under the other one.
14. Click on the "Print closed stack request slip" button, in the
    "pending" table. A printer dialog should open, close it.
    The "Closed stack requests" should have been automatically
    refreshed, showing you an empty "pending" tab, while the "Slip
    printed" tab now contains the previously pending request.
15. Cancel the closed stack request.
16. Login to OPAC, find your biblio record and place a closed stack
    request. Like from the staff interface, only the closed stack item
    should be in the items table, and it should not be possible to place
    a biblio-level request
17. In your account page, verify that the closed stack request appear
    under the new tab "Closed stack requests" and that there is no
    "Cancel" button
18. Go back to the staff interface main page. You should see an alert at
    the bottom: "Pending closed stack requests: 1". Clicking on it
    should redirect you to the closed stack requests page seen earlier
    (step 12)
19. Set the closed stack item as "notforloan", either by editing the
    item or its item type. Verify that you can still do closed stack
    requests
20. Change circulation rules to forbid on-shelf holds on the closed
    stack item and verify that you can still do closed stack requests.

Sponsored-by: Université de Lyon 3
Signed-off-by: thibault <thibault.keromnes@univ-paris8.fr>
Comment 29 Biblibre Sandboxes 2025-04-11 10:00:46 UTC
Created attachment 180823 [details] [review]
Bug 38666: [DO NOT PUSH] Update DBIC schema

Signed-off-by: thibault <thibault.keromnes@univ-paris8.fr>
Comment 30 Biblibre Sandboxes 2025-04-11 10:00:49 UTC
Created attachment 180824 [details] [review]
Bug 38666: Flag new columns as boolean (SQL12)

Signed-off-by: thibault <thibault.keromnes@univ-paris8.fr>
Comment 31 Thibault Keromnès 2025-04-11 10:07:00 UTC
A few remarks : 
CLOSED_STACK_SLIP : Works with "hungry alligators" variables but I didn't test with Template Toolkit (and I'd love to have a default TT notice;) )

To actually use it I need to be able to batch edit items, so I tested and I can if I first : 
- add it to the Marc framework
- add it to the koha2marclinks
I don't know if it's worth adding to the manual?
Comment 32 Thibault Keromnès 2025-04-11 10:24:25 UTC
(In reply to Amaury GAU from comment #26)
> (In reply to Julian Maurice from comment #22)

> > 19. Set the closed stack item as "notforloan", either by editing the
> >     item or its item type. Verify that you can still do closed stack
> >     requests
> 
> It seems weird that a notforloan item can be asked from a patron. The main
> purpose of a notforloan item, is exactly the contrary. it should not be
> requestable. Otherwise, it might need a syspref to overrule this behaviour. 
> I'd gladly ask other librarians about this.

I think it depends on local setups. 
Part of our collection is not for "loan" but still needs to be requested for local use.
We could use onsite checkouts for it (and i think i will change to that)  but it could make sense to have a notforloan status, for instance if you don't need a library account to ask for the item and don't register the local use as a checkout.