From c07c575934e2d0eeaa757035153d43c27825a242 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 13 Jan 2025 17:10:43 +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. Sponsored-by: Athens County Public Libraries Signed-off-by: David Nind Signed-off-by: Jonathan Druart --- ...-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 00000000000..81fe4142839 --- /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 ede2d4d2755..b5bbea63aaf 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -694,7 +694,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 d33c36cc8d6..15bf876fc68 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 @@ -90,6 +90,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 5bea1b16ae2..800a1748136 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 @@ -20,18 +20,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 dbcadf40bc7..9ed4b94dad0 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,6 +1,7 @@ [% USE raw %] [% USE Koha %] [% PROCESS 'i18n.inc' %] +[% USE AdditionalContents %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] [% FILTER collapse %] @@ -39,7 +40,18 @@ </div> <!-- /.page-section --> <div id="routingnotes"> - <p id="generalroutingnote">[% Koha.Preference('RoutingListNote') | $raw %]</p> + [%- SET RoutingListNote = AdditionalContents.get( location => "RoutingListNote", lang => lang, library => logged_in_user.branchcode ) -%] + + [% IF ( RoutingListNote.content && RoutingListNote.content.count > 0 ) %] + <div id="[% RoutingListNote.location | html %]"> + [% FOREACH n IN RoutingListNote.content %] + <div class="[% n.lang | html %]_item"> + <div class="[% n.lang | html %]_body">[% n.content | $raw %]</div> + </div> + [% END %] + </div> + [% END %] + <p id="routingnote">[% routingnotes | html %]</p> </div> 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 512dff30cdb..0468cfe9a5f 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 @@ -538,7 +538,7 @@ [% END %] [% END %] </optgroup> - [% SET staff_available_options = [ 'IntranetmainUserblock', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] + [% SET staff_available_options = [ 'IntranetmainUserblock', 'RoutingListNote', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] <optgroup label="Staff interface"> [% FOREACH l IN staff_available_options.sort %] [% IF l == location %] -- 2.34.1