Bug 37661

Summary: Disable/Enable Bookings
Product: Koha Reporter: Catrina Berka <catrina>
Component: CirculationAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew, baptiste.wojtkowski, dcook, esther.melander, gmcharlt, heather, hebah, kebliss, kyle, lucas, martin.renvoize, mathsabypro, michael.adamyk, mteal
Version: 24.05   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Medium patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function: Bookings
Bug Depends on: 29002    
Bug Blocks:    
Attachments: [24.11] Bug 37661: Add a new syspref EnableBooking
[24.11] Bug 37661: Have 29002 depend on EnableBooking
[24.11] Bug 37661: Have 37736 depend on Enable booking
[24.11] Bug 37661: Have 37737 depend on EnableBooking
Bu 37661: Have 36428 depend on EnableBooking
[24.11] Bug 37661: Have 36428 depend on EnableBooking
Bug 37661: Add a new syspref EnableBooking
Bug 37661: Have 29002 depend on EnableBooking
Bug 37661: Have 37736 depend on Enable booking
Bug 37661: Have 37737 depend on EnableBooking
Bug 37661: Have 36428 depend on EnableBooking
Bug 37661: Add a new syspref EnableBooking
Bug 37661: Have 29002 depend on EnableBooking
Bug 37661: Have 37736 depend on Enable booking
Bug 37661: Have 37737 depend on EnableBooking
Bug 37661: Have 36428 depend on EnableBooking
Bug 37661: Add a new syspref EnableBooking
Bug 37661: Have 29002 depend on EnableBooking
Bug 37661: Have 37737 depend on EnableBooking
Bug 37661: Have 36428 depend on EnableBooking
Bug 37661: Have 37736 depend on Enable booking
Bug 37661: Tidy
Bug 37661: Add a new syspref EnableBooking
Bug 37661: [squash me] Have 29002 depend on EnableBooking
Bug 37661: [squash me] Have 33737 depend on EnableBooking
Bug 37661: [squash me] Have 36428 depend on EnableBooking
Bug 37661: [squash me] Have 33736 depend on Enable booking
Bug 37661: [squash me] Tidy
Bug 37661: (follow-up) [squash me] remove useless lines

Description Catrina Berka 2024-08-16 18:39:41 UTC
If libraries are not planning to use the bookings feature, there's no way to hide this option. Even if staff don’t have the manage_bookings permission, they can still set an item as bookable, but the “place booking” button won’t appear for them.

It would be nice if the bookings feature could be set to enable/disable via a system preference, similar to EnablePointOfSale, EnableItemGroups, HouseboundModule, ERMModule, ILLModule, and PreservationModule.
Comment 1 Martin Renvoize (ashimema) 2024-10-16 14:50:31 UTC
*** Bug 38017 has been marked as a duplicate of this bug. ***
Comment 2 Heather Rommens 2025-03-17 19:12:52 UTC
It would be nice if this Disable/Enable option also applied to the Bookings tab in the patron account. I have received several requests from libraries to hide this tab since they aren't using the Bookings feature.
Comment 3 hebah 2025-04-24 17:13:03 UTC
24.11 bug 33736 brought 'bookings to pull' into the circ module - it would be nice if this global on/off could turn it off as well.
Comment 4 Baptiste Wojtkowski (bwoj) 2025-07-23 15:11:42 UTC
Created attachment 184558 [details] [review]
[24.11] Bug 37661: Add a new syspref EnableBooking

This patch makes the Booking module dependant of a new YesNo syspref: EnableBooking

To do this, I tried and get all changes using the graph of Bug 29002 and
got interrested in every tt change to make changes on this depend on the
new syspref. File inside the booking module should not be amended.

Here are the files I found relevant for each patch
Bug 37737:
- koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
Bug 37736:
- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt
Bug 29002:
- koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt
Comment 5 Baptiste Wojtkowski (bwoj) 2025-07-23 15:11:45 UTC
Created attachment 184559 [details] [review]
[24.11] Bug 37661: Have 29002 depend on EnableBooking
Comment 6 Baptiste Wojtkowski (bwoj) 2025-07-23 15:11:47 UTC
Created attachment 184560 [details] [review]
[24.11] Bug 37661: Have 37736 depend on Enable booking
Comment 7 Baptiste Wojtkowski (bwoj) 2025-07-23 15:11:50 UTC
Created attachment 184561 [details] [review]
[24.11] Bug 37661: Have 37737 depend on EnableBooking
Comment 8 Baptiste Wojtkowski (bwoj) 2025-07-23 15:50:48 UTC Comment hidden (obsolete)
Comment 9 Baptiste Wojtkowski (bwoj) 2025-07-23 15:51:44 UTC
Created attachment 184566 [details] [review]
[24.11] Bug 37661: Have 36428 depend on EnableBooking
Comment 10 Baptiste Wojtkowski (bwoj) 2025-07-24 09:13:27 UTC
Created attachment 184578 [details] [review]
Bug 37661: Add a new syspref EnableBooking

This patch makes the Booking module dependant of a new YesNo syspref: EnableBooking

To do this, I tried and get all changes using the graph of Bug 29002 and
got interrested in every tt change to make changes on this depend on the
new syspref. File inside the booking module should not be amended.

Here are the files I found relevant for each patch
Bug 37737:
- koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
Bug 37736:
- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt
Bug 29002:
- koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt

TEST PLAN:
1 -  Set "Bookable = 1" on a given item
2 - Make sure you know where are located
    - The field bookable on exemplaries
    - The button "Place booking" in item toolbae
    - The link "Bookings (0)" in item menu
3 - Apply patch and update database
4 - Check that every field listed in 2 - is still present
5 - Set the syspref "EnableBooking" to "Disable"
6 - Check that every field listed in 2 - is still present
7 - Browse Norme, ISBD, Marc, Items tabs + pages imageviewer.pl, labeledMARCdetail.pl and check that nothing is broken
Comment 11 Baptiste Wojtkowski (bwoj) 2025-07-24 09:13:30 UTC
Created attachment 184579 [details] [review]
Bug 37661: Have 29002 depend on EnableBooking
Comment 12 Baptiste Wojtkowski (bwoj) 2025-07-24 09:13:33 UTC
Created attachment 184580 [details] [review]
Bug 37661: Have 37736 depend on Enable booking
Comment 13 Baptiste Wojtkowski (bwoj) 2025-07-24 09:13:36 UTC
Created attachment 184581 [details] [review]
Bug 37661: Have 37737 depend on EnableBooking
Comment 14 Baptiste Wojtkowski (bwoj) 2025-07-24 09:13:38 UTC
Created attachment 184582 [details] [review]
Bug 37661: Have 36428 depend on EnableBooking
Comment 15 Esther Melander 2025-07-24 15:52:53 UTC
I received an error when trying to apply the patch to KTD. I'm not sure if I am missing a step?

Error message:
Applying: Bug 37661: Add a new syspref EnableBooking
error: sha1 information is lacking or useless (installer/data/mysql/mandatory/sysprefs.sql).
error: could not build fake ancestor
Patch failed at 0001 Bug 37661: Add a new syspref EnableBooking
Comment 16 Baptiste Wojtkowski (bwoj) 2025-07-25 09:15:24 UTC
Hum, I just tried and reapply on the last main on top of "20313df192 Bug 40298: define select2 parent in patron search modal" and it seems working. Is your git repository up to date ?
Comment 17 Esther Melander 2025-07-25 17:00:01 UTC
That may have been it. I have updated and the patch applied correctly.

After applying the patch and updating the database, the fields in step 2 were not present. The EnableBooking system preference came in disabled, which would explain why they were not present. I flipped the system preference to Enabled and the fields appeared as they should.

The system preference appears to enable/disable Bookings.

I did notice, the system preference overrides the Bookings checkbox in the item type configuration. If EnableBooking is enabled, it enables bookings for everything and does not reference the Item Type configuration checkbox. I would expect the system preference to reference the Item Type configuration.
Comment 18 Baptiste Wojtkowski (bwoj) 2025-07-28 09:33:52 UTC
I don't get your last point, do you think you should still be able to manage the attribute "booking" while EnableBookings is disabled ?
Comment 19 Esther Melander 2025-07-28 14:50:23 UTC
I would expect the EnableBookings to enable the feature, but the item type attribute should actually controls whether bookings are available or not, if that makes sense.

This patch turns on bookings for all item types, overriding the item type attribute.
Comment 20 Andrew Fuerste-Henry 2025-08-06 12:12:09 UTC
Created attachment 185150 [details] [review]
Bug 37661: Add a new syspref EnableBooking

This patch makes the Booking module dependant of a new YesNo syspref: EnableBooking

To do this, I tried and get all changes using the graph of Bug 29002 and
got interrested in every tt change to make changes on this depend on the
new syspref. File inside the booking module should not be amended.

Here are the files I found relevant for each patch
Bug 37737:
- koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
Bug 37736:
- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt
Bug 29002:
- koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt

TEST PLAN:
1 -  Set "Bookable = 1" on a given item
2 - Make sure you know where are located
    - The field bookable on exemplaries
    - The button "Place booking" in item toolbae
    - The link "Bookings (0)" in item menu
3 - Apply patch and update database
4 - Check that every field listed in 2 - is still present
5 - Set the syspref "EnableBooking" to "Disable"
6 - Check that every field listed in 2 - is still present
7 - Browse Norme, ISBD, Marc, Items tabs + pages imageviewer.pl, labeledMARCdetail.pl and check that nothing is broken

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 21 Andrew Fuerste-Henry 2025-08-06 12:12:13 UTC
Created attachment 185151 [details] [review]
Bug 37661: Have 29002 depend on EnableBooking

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 22 Andrew Fuerste-Henry 2025-08-06 12:12:16 UTC
Created attachment 185152 [details] [review]
Bug 37661: Have 37736 depend on Enable booking

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 23 Andrew Fuerste-Henry 2025-08-06 12:12:20 UTC
Created attachment 185153 [details] [review]
Bug 37661: Have 37737 depend on EnableBooking

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 24 Andrew Fuerste-Henry 2025-08-06 12:12:23 UTC
Created attachment 185154 [details] [review]
Bug 37661: Have 36428 depend on EnableBooking

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Comment 25 Andrew Fuerste-Henry 2025-08-06 12:15:40 UTC
(In reply to Esther Melander from comment #19)
> I would expect the EnableBookings to enable the feature, but the item type
> attribute should actually controls whether bookings are available or not, if
> that makes sense.
> 
> This patch turns on bookings for all item types, overriding the item type
> attribute.

I wasn't able to recreate this. With the system preference set to Enabled, I was only able to place bookings where the itemtype was set to bookable=1 or the individual item was set to bookable=1.
Comment 26 Esther Melander 2025-08-08 18:52:38 UTC
1. Find an item record and ensure it is not set to be bookable.
2. Verify the item type for the item is not set to be bookable.
3. Apply patch
4. Notice the system preference came in enabled by default.
5. Double check the item and see if it is now bookable - it should not be. Check others items with the same item type to make sure they are not bookable. Check other item types - they should not be bookable.
6. Enable the individual item as bookable. Run checks in step 5. Only the one item should be bookable.
7. Enable the item type as bookable. Check multiple items of the item type. They should all be bookable.
8. Select an item and mark it as not bookable.

Notice the individual item should now not be bookable but the place booking link is still available and I can place a booking.

I'm guessing this is set to be enabled by default so as not to disable any bookings with an upgrade.
Comment 27 Andrew Fuerste-Henry 2025-08-08 19:27:16 UTC
(In reply to Esther Melander from comment #26)
> 8. Select an item and mark it as not bookable.
> 
> Notice the individual item should now not be bookable but the place booking
> link is still available and I can place a booking.

I cannot recreate what you've documented here.
I have the patch applied and EnableBookings set to Enable. 
I have the BOOK itemtype set to be bookable.
Biblio 344 has 3 books attached. I have them set to bookable Yes, No, and Follow Itemtype, respectively. 
When I place a booking, I can place it for Any item, the item with bookable=yes, or the item with bookable following the itemtype.
I cannot place a booking for the item marked bookable:no
Comment 28 Esther Melander 2025-08-08 20:05:36 UTC
I  must have had something wrong with my KTD. I shut it down and restarted and it worked as you described.
Comment 29 Owen Leonard 2025-08-11 11:10:52 UTC
There are a lot of qa tool errors to be corrected, and merge markers in circulation-home.tt.
Comment 30 Baptiste Wojtkowski (bwoj) 2025-08-12 13:57:53 UTC
Created attachment 185325 [details] [review]
Bug 37661: Add a new syspref EnableBooking

This patch makes the Booking module dependant of a new YesNo syspref: EnableBooking

To do this, I tried and get all changes using the graph of Bug 29002 and
got interrested in every tt change to make changes on this depend on the
new syspref. File inside the booking module should not be amended.

Here are the files I found relevant for each patch
Bug 37737:
- koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
Bug 37736:
- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt
Bug 29002:
- koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt

TEST PLAN:
1 -  Set "Bookable = 1" on a given item
2 - Make sure you know where are located
    - The field bookable on exemplaries
    - The button "Place booking" in item toolbae
    - The link "Bookings (0)" in item menu
3 - Apply patch and update database
4 - Check that every field listed in 2 - is still present
5 - Set the syspref "EnableBooking" to "Disable"
6 - Check that every field listed in 2 - is still present
7 - Browse Norme, ISBD, Marc, Items tabs + pages imageviewer.pl, labeledMARCdetail.pl and check that nothing is broken
Comment 31 Baptiste Wojtkowski (bwoj) 2025-08-12 13:57:56 UTC
Created attachment 185326 [details] [review]
Bug 37661: Have 29002 depend on EnableBooking
Comment 32 Baptiste Wojtkowski (bwoj) 2025-08-12 13:57:59 UTC
Created attachment 185327 [details] [review]
Bug 37661: Have 37737 depend on EnableBooking
Comment 33 Baptiste Wojtkowski (bwoj) 2025-08-12 13:58:02 UTC
Created attachment 185329 [details] [review]
Bug 37661: Have 36428 depend on EnableBooking
Comment 34 Baptiste Wojtkowski (bwoj) 2025-08-12 13:58:05 UTC
Created attachment 185331 [details] [review]
Bug 37661: Have 37736 depend on Enable booking
Comment 35 Baptiste Wojtkowski (bwoj) 2025-08-12 13:58:08 UTC
Created attachment 185333 [details] [review]
Bug 37661: Tidy
Comment 36 Baptiste Wojtkowski (bwoj) 2025-08-12 13:59:55 UTC
Note for QA/Release manager, the names are in order to better isolate if some patch are not covered by this revert, but please squash it before pushing :)
Comment 37 David Cook 2025-08-22 01:53:25 UTC
I think this is an important change to make, as I don't think bug 29002 should've been pushed without a system preference.

But what is going on with these patches? It looks like a lot of these should be on the bugs they're named after. There shouldn't need to be a "Tidy" patch these days either.
Comment 38 David Cook 2025-08-22 01:56:58 UTC
Comment on attachment 185326 [details] [review]
Bug 37661: Have 29002 depend on EnableBooking

Review of attachment 185326 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
@@ +82,4 @@
>      <script>
>          dayjs.extend(window.dayjs_plugin_isSameOrBefore);
>      </script>
> +    <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script>

This looks like a merge error of some kind?
Comment 39 David Cook 2025-08-22 02:00:30 UTC
(In reply to David Cook from comment #37)
> But what is going on with these patches? It looks like a lot of these should
> be on the bugs they're named after. There shouldn't need to be a "Tidy"
> patch these days either.

Actually, it looks like some of those bug numbers are totally wrong.

Bug 37737 - Users with 'execute_reports' permission can create reports 23.11 and lower 
Bug 37736 - installing koha on wsl debian 

So not sure what's going on there either...
Comment 40 Baptiste Wojtkowski (bwoj) 2025-08-22 11:50:02 UTC
Hi, thank you for your attention to the patch :)
As I mentioned in Comment 36, I have split the patch into multiple patches in order to better check which bugs have been "reverted", and how they have been reverted. Once PQA I'll squash everything.

There is an issue that I was pretty sure I had fixed with the name of some commits, which are 33737 and 33737
Comment 41 Baptiste Wojtkowski (bwoj) 2025-08-22 11:50:53 UTC
(In reply to David Cook from comment #38)
> Comment on attachment 185326 [details] [review] [review]
> Bug 37661: Have 29002 depend on EnableBooking
> 
> Review of attachment 185326 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
> @@ +82,4 @@
> >      <script>
> >          dayjs.extend(window.dayjs_plugin_isSameOrBefore);
> >      </script>
> > +    <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script>
> 
> This looks like a merge error of some kind?

Hum.. I don't know how this happened O.o
Comment 42 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:29 UTC
Created attachment 185710 [details] [review]
Bug 37661: Add a new syspref EnableBooking

This patch makes the Booking module dependant of a new YesNo syspref: EnableBooking

To do this, I tried and get all changes using the graph of Bug 29002 and
got interrested in every tt change to make changes on this depend on the
new syspref. File inside the booking module should not be amended.

Here are the files I found relevant for each patch
Bug 37737:
- koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
Bug 37736:
- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt
Bug 29002:
- koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt
- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt

TEST PLAN:
1 -  Set "Bookable = 1" on a given item
2 - Make sure you know where are located
    - The field bookable on exemplaries
    - The button "Place booking" in item toolbae
    - The link "Bookings (0)" in item menu
3 - Apply patch and update database
4 - Check that every field listed in 2 - is still present
5 - Set the syspref "EnableBooking" to "Disable"
6 - Check that every field listed in 2 - is still present
7 - Browse Norme, ISBD, Marc, Items tabs + pages imageviewer.pl, labeledMARCdetail.pl and check that nothing is broken
Comment 43 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:32 UTC
Created attachment 185711 [details] [review]
Bug 37661: [squash me] Have 29002 depend on EnableBooking
Comment 44 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:36 UTC
Created attachment 185712 [details] [review]
Bug 37661: [squash me] Have 33737 depend on EnableBooking
Comment 45 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:39 UTC
Created attachment 185713 [details] [review]
Bug 37661: [squash me] Have 36428 depend on EnableBooking
Comment 46 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:42 UTC
Created attachment 185714 [details] [review]
Bug 37661: [squash me] Have 33736 depend on Enable booking
Comment 47 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:46 UTC
Created attachment 185715 [details] [review]
Bug 37661: [squash me] Tidy
Comment 48 Baptiste Wojtkowski (bwoj) 2025-08-22 12:16:49 UTC
Created attachment 185716 [details] [review]
Bug 37661: (follow-up) [squash me] remove useless lines