From ed32f5fa66246fc03b7a7fc394eed4399c1dadf8 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 23 Jul 2025 15:39:03 +0200 Subject: [PATCH] Bug 37661: [24.11.x] 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: Martin Renvoize Signed-off-by: Lucas Gass --- .../bug_37661-EnableBooking_syspref.pl | 17 +++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/includes/biblio-view-menu.inc | 2 +- .../prog/en/includes/cat-toolbar.inc | 2 +- .../prog/en/includes/patron-detail-tabs.inc | 4 ++++ .../modules/admin/preferences/circulation.pref | 8 ++++++++ .../prog/en/modules/catalogue/ISBDdetail.tt | 10 +++++++--- .../prog/en/modules/catalogue/MARCdetail.tt | 10 +++++++--- .../prog/en/modules/catalogue/detail.tt | 11 ++++++++--- .../prog/en/modules/catalogue/imageviewer.tt | 10 +++++++--- .../en/modules/catalogue/labeledMARCdetail.tt | 10 +++++++--- .../prog/en/modules/catalogue/moredetail.tt | 13 ++++++++++--- .../prog/en/modules/circ/circulation-home.tt | 4 +++- .../prog/en/modules/members/moremember.tt | 10 +++++++--- 14 files changed, 88 insertions(+), 24 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_37661-EnableBooking_syspref.pl diff --git a/installer/data/mysql/atomicupdate/bug_37661-EnableBooking_syspref.pl b/installer/data/mysql/atomicupdate/bug_37661-EnableBooking_syspref.pl new file mode 100755 index 00000000000..1fd8bb1796b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37661-EnableBooking_syspref.pl @@ -0,0 +1,17 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "37661", + description => "Add a way to enable/disable bookings", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('EnableBooking','1',NULL,'If enabled, activate every functionalities related with Bookings module','YesNo')} + ); + + say_success( $out, "Added new system preference 'EnableBooking'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index de6f70ed6fc..f940022abbf 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -246,6 +246,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'), ('EmailSMSSendDriverFromAddress', '', '', 'Email SMS send driver from address override', 'Free'), ('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'), +('EnableBooking','1',NULL,'If enabled, activate every functionnalities related with Bookings module','YesNo'), ('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'), ('EnableExpiredPasswordReset', '0', NULL, 'Enable ability for patrons with expired password to reset their password directly', 'YesNo'), ('EnableItemGroupHolds','0','','Enable item groups holds feature','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 3e5625eff0a..98310cf2b80 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -50,7 +50,7 @@ Items - [% IF ( CAN_user_circulate_manage_bookings && biblio.items.filter_by_bookable.count ) %] + [% IF ( Koha.Preference('EnableBooking') && CAN_user_circulate_manage_bookings && biblio.items.filter_by_bookable.count ) %] [%- IF ( bookingsview ) -%]
  • [%- ELSE -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 41b07daa093..ce2822cb08f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -273,7 +273,7 @@ [% END %] [% END %] -[% IF ( CAN_user_circulate_manage_bookings && biblio.items.filter_by_bookable.count ) %] +[% IF ( Koha.Preference('EnableBooking') && CAN_user_circulate_manage_bookings && biblio.items.filter_by_bookable.count ) %]
    [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc index 45567cb972f..71181ac6042 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc @@ -23,11 +23,13 @@ [% WRAPPER tab_item tabname= "holds" %] Holds ([% holds_count || 0 | html %]) [% END %] + [% IF Koha.Preference('EnableBooking') %] [% WRAPPER tab_item tabname="bookings" %] [% SET bookings_count = patron.bookings.filter_by_active.count %] [% SET expired_bookings_count = patron.bookings.count - bookings_count %] Bookings ([% bookings_count || 0 | html %]) [% END %] + [% END %] [% END %] [% IF Koha.Preference('UseRecalls') %] @@ -215,6 +217,7 @@ [% END %] [% END # /tab_panel#holds %] + [% IF Koha.Preference('EnableBooking') %] [% WRAPPER tab_panel tabname="bookings" %] [% IF ( bookings_count ) %]
    @@ -230,6 +233,7 @@

    Patron has nothing booked.

    [% END %] [% END %] + [% END %] [% END %] [% IF Koha.Preference('UseRecalls') %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index e6169464f6e..3841418bee4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -1515,3 +1515,11 @@ Circulation: 1: Enable 0: Disable - "the curbside pickup module." + + Booking module: + - + - pref: EnableBooking + choices: + 1: Enable + 0: Disable + - "the booking module." diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt index 4beb9846405..3e5819e7ed5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt @@ -91,10 +91,14 @@ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] - [% INCLUDE 'calendar.inc' %] - [% INCLUDE 'select2.inc' %] [% Asset.js("js/catalog.js") | $raw %] - [% Asset.js("js/modals/place_booking.js") | $raw %] + + [% IF Koha.Preference('EnableBooking') %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] + [% Asset.js("js/modals/place_booking.js") | $raw %] + [% END %] + [% Asset.js("js/browser.js") | $raw %] [% IF ( Koha.Preference('CatalogConcerns') ) %] - [% INCLUDE 'calendar.inc' %] - [% INCLUDE 'select2.inc' %] [% Asset.js("js/catalog.js") | $raw %] - [% Asset.js("js/modals/place_booking.js") | $raw %] + + [% IF Koha.Preference('EnableBooking') %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] + [% Asset.js("js/modals/place_booking.js") | $raw %] + [% END %] + [% Asset.js("js/browser.js") | $raw %] [% IF ( Koha.Preference('CatalogConcerns') ) %] - [% INCLUDE 'calendar.inc' %] - [% INCLUDE 'select2.inc' %] [% Asset.js("js/catalog.js") | $raw %] - [% Asset.js("js/modals/place_booking.js") | $raw %] + + [% IF Koha.Preference('EnableBooking') %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] + [% Asset.js("js/modals/place_booking.js") | $raw %] + [% END %] + [% IF ( Koha.Preference('CatalogConcerns') ) %] - [% INCLUDE 'calendar.inc' %] - [% INCLUDE 'select2.inc' %] [% Asset.js("js/catalog.js") | $raw %] - [% Asset.js("js/modals/place_booking.js") | $raw %] [% Asset.js("js/browser.js") | $raw %] + + [% IF Koha.Preference('EnableBooking') %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] + [% Asset.js("js/modals/place_booking.js") | $raw %] + [% END %] + [% IF ( Koha.Preference('CatalogConcerns') ) %] [% INCLUDE 'js-patron-format.inc' %] - [% INCLUDE 'calendar.inc' %] - [% INCLUDE 'select2.inc' %] [% Asset.js("js/catalog.js") | $raw %] - [% Asset.js("js/modals/place_booking.js") | $raw %] [% Asset.js("js/browser.js") | $raw %] [% Asset.js("js/checkout_renewals_modal.js") | $raw %] + + [% IF Koha.Preference('EnableBooking') %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] + [% Asset.js("js/modals/place_booking.js") | $raw %] + [% END %] + [% IF ( Koha.Preference('CatalogConcerns') ) %] [% Asset.js("js/checkouts.js") | $raw %] - [% Asset.js("js/tables/bookings.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] -- 2.43.0