From dbf42dffa01768b3b7b58a50ab824d033396514f Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 8 Nov 2023 17:37:42 +0000 Subject: [PATCH] Bug 35152: Convert RoutingListNote system preference to additional contents This patch moves the RoutingListNote system preference into HTML customizations, making it possible to have language- and library-specific content. To test you should have some content in the RoutingListNote system preference before applying the patch. Apply the patch and run the database update process. - In the staff client, go to Tools -> HTML customizations and verify that the content from RoutingListNote is now stored there. - The HTML customization entry form should offer RoutingListNote as a choice under "Display location." - Update and reinstall active translations (for instance fr-FR): - perl misc/translator/translate update fr-FR - perl misc/translator/translate install fr-FR - Enable the translation if necessary under Administration -> System preferences -> language. - Edit the RoutingListNote HTML customization and add unique content to the "fr-FR" tab. - Go to Serials and create a subscription if necessary. - From the subscription detail page, click "Create routing list" in the left-hand sidebar. - Add one or more recipients to the list and click "Save". - On the "Preview routing list" page click "Save and preview routing slip". - In the pop-up window with the routing list preview you should see the content you added to the RoutingListNote HTML customization. - Switch to your updated translation and confirm that the content you added for your translation shows up correctly. - Go to Administration -> System preferences and search for "RoutingListNote." It should return no results. NOTE: This patch does not keep the default content which was stored by the RoutingListNote system preference. Having a default value for that kind of preference is not standard. Instead I have updated the description of the RoutingSerials preference to add a mention of the RoutingListNote HTML customization option. Signed-off-by: David Nind --- ...-RoutingListNote-to-additional-contents.pl | 41 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../en/includes/html-customization-help.inc | 4 ++ .../en/modules/admin/preferences/serials.pref | 7 +--- .../modules/serials/routing-preview-slip.tt | 14 ++++++- .../en/modules/tools/additional-contents.tt | 2 +- 6 files changed, 60 insertions(+), 9 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-35152-move-RoutingListNote-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-35152-move-RoutingListNote-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-35152-move-RoutingListNote-to-additional-contents.pl new file mode 100755 index 0000000000..81fe414283 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-35152-move-RoutingListNote-to-additional-contents.pl @@ -0,0 +1,41 @@ +use Modern::Perl; + +return { + bug_number => "35152", + description => "Move RoutingListNote to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the RoutingListNote system preference + my ($routinglistnote) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='RoutingListNote'; + | + ); + if ($routinglistnote) { + + # Insert any values found from system preference into additional_contents + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, published_on ) VALUES ('html_customizations', 'RoutingListNote', 'RoutingListNote', NULL, CAST(NOW() AS date) )" + ); + + my ($insert_id) = $dbh->selectrow_array( + "SELECT id FROM additional_contents WHERE category = 'html_customizations' AND code = 'RoutingListNote' AND location = 'RoutingListNote' LIMIT 1", + {} + ); + + $dbh->do( + "INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'RoutingListNote default', ?, 'default' )", + undef, $insert_id, $routinglistnote + ); + + say $out "Added 'RoutingListNote' additional content"; + } + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='RoutingListNote'"); + say $out "Removed system preference 'RoutingListNote'"; + + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b58114d802..ec0e1c4144 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -652,7 +652,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RisExportAdditionalFields', '', NULL , 'Define additional RIS tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea'), ('RoundFinesAtPayment','0', NULL,'If enabled any fines with fractions of a cent will be rounded to the nearest cent when payments are coll ected. e.g. 1.004 will be paid off by a 1.00 payment','YesNo'), ('RoutingListAddReserves','0','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'), -('RoutingListNote','To change this note edit RoutingListNote system preference.','70|10','Define a note to be shown on all routing lists','Textarea'), ('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'), ('SavedSearchFilters', '0', NULL, 'Allow staff with permission to create/edit custom search filters', 'YesNo'), ('SCOAllowCheckin','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc index 9fc3fe5d62..7ffd2c3228 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc @@ -86,6 +86,10 @@ Show the following content on the patron self-registration confirmation page. +
+ Include the following note on all routing list slips. +
+
Show this content on the web-based self checkout screen.
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref index e24ea209a6..dc96b9a637 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref @@ -19,18 +19,13 @@ Serials: choices: 1: Use 0: "Don't use" - - the routing list feature in the serials module. + - the routing list feature in the serials module. A custom message can be shown on routing slips by creating an HTML customization in the RoutingListNote region. - - pref: RoutingListAddReserves choices: 1: Place 0: "Don't place" - received serials on hold if they are on a routing list. - - - - "Include the following note on all routing lists:" - - pref: RoutingListNote - type: textarea - class: code - - Show the - pref: StaffSerialIssueDisplayCount diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt index 2d229d0180..a1bf1c2a4c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE raw %] +[% USE AdditionalContents %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Routing slip preview › Serials › Koha @@ -32,7 +33,18 @@
-

[% Koha.Preference('RoutingListNote') | $raw %]

+ [%- SET RoutingListNote = AdditionalContents.get( location => "RoutingListNote", lang => lang, library => logged_in_user.branchcode ) -%] + + [% IF ( RoutingListNote.content && RoutingListNote.content.count > 0 ) %] +
+ [% FOREACH n IN RoutingListNote.content %] +
+
[% n.content | $raw %]
+
+ [% END %] +
+ [% END %] +

[% routingnotes | html %]

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index 9a686af8d0..e751539749 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -534,7 +534,7 @@ [% END %] [% END %] - [% SET staff_available_options = [ 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] + [% SET staff_available_options = [ 'RoutingListNote', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] [% FOREACH l IN staff_available_options.sort %] [% IF l == location %] -- 2.30.2