From 6cd29a0f488daabf8b907aa1890ad2fa78fa6996 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 18 Apr 2023 04:58:29 +0000 Subject: [PATCH] Bug 33478: Save notice format settings Save format settings for an individual notice, or for all notices To test: 1. Apply the patches, install database updates, update schema if needed, and restart services 2. Go to Tools -> Notices and slips 3. Edit any notice 4. Go to the Print tab 5. Confirm format settings now show underneath the notice content box 6. Change some settings and confirm they save correctly 7. Test that 'apply these settings to all notices' option works 8. Add a new notice and confirm format settings save successfully 9. Search for a patron, go to More -> Set permissions 10. Ensure they have all Tools permissions EXCEPT for new format_notices user permission 11. Log into the staff interface as this patron 12. Go to Tools -> Notices and slips 13. Edit a notice 14. Go to the Print tab 15. Confirm the format settings DO NOT show underneath the notice content box Sponsored-by: Colorado Library Consortium --- .../prog/en/modules/tools/letter.tt | 74 +++++++++++++++++++ tools/letter.pl | 46 +++++++++++- 2 files changed, 117 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 910deebfef5..3e01a59a716 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -49,6 +49,23 @@ [% END %] +[% BLOCK translate_justification_types %] + [% SWITCH type %] + [% CASE 'L' %]Left + [% CASE 'C' %]Center + [% CASE 'R' %]Right + [% END %] +[% END %] + +[% BLOCK translate_unit_types %] + [% SWITCH type %] + [% CASE 'POINT' %]PostScript points + [% CASE 'INCH' %]US Inches + [% CASE 'MM' %]SI Millimeters + [% CASE 'CM' %]SI Centimeters + [% END %] +[% END %] + [% WRAPPER 'header.inc' %] [% INCLUDE 'letters-search.inc' %] @@ -643,11 +660,68 @@ [% END %] + [% IF letter.message_transport_type == "print" && CAN_user_tools_format_notices %] + [% SET param = letters.$lang.params %] +
+
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + + Existing format settings will be overwritten. +
  6. +
+
+
+
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
  8. +
+
+ [% END # letter.message_transport_type == "print" && CAN_user_tools_format_notices %] [% END # /FOR mtt %] + [% END %] diff --git a/tools/letter.pl b/tools/letter.pl index c00cc6de3dc..a8ace94d12e 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -49,7 +49,10 @@ use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Letters qw( GetMessageTransportTypes ); use C4::Log qw( logaction ); - +use C4::Creators qw( + get_text_justification_types + get_unit_values +); use Koha::Notice::Templates; use Koha::Patron::Attribute::Types; @@ -228,6 +231,7 @@ sub add_form { content => $letter->{content} // '', tt_error => $letter->{tt_error}, }; + $letters{ $lang }{params} = $letter; } } else { @@ -299,6 +303,8 @@ sub add_form { SQLfieldnames => $field_selection, branchcode => $branchcode, preview_is_available => $preview_is_available, + text_justification_types => get_text_justification_types(), + units => get_unit_values(), ); return; } @@ -310,12 +316,34 @@ sub add_validate { my $oldmodule = $input->param('oldmodule'); my $code = $input->param('code'); my $name = $input->param('name'); + my $text_justify = $input->param('text_justify'); + my $font_size = $input->param('font_size'); + my $units = $input->param('units'); + my $notice_width = $input->param('notice_width'); + my $top_margin = $input->param('top_margin'); + my $left_margin = $input->param('left_margin'); + my $format_all = $input->param('format_all'); my @mtt = $input->multi_param('message_transport_type'); my @title = $input->multi_param('title'); my @content = $input->multi_param('content'); my @lang = $input->multi_param('lang'); for my $mtt ( @mtt ) { my $lang = shift @lang; + if ( $format_all ) { + my @letters = Koha::Notice::Templates->search({ lang => $lang })->as_list; + foreach my $letter ( @letters ) { + $letter->set( + { + text_justify => $text_justify, + font_size => $font_size, + units => $units, + notice_width => $notice_width, + top_margin => $top_margin, + left_margin => $left_margin, + } + )->store; + } + } my $is_html = $input->param("is_html_$mtt\_$lang"); my $title = shift @title; my $content = shift @content; @@ -348,7 +376,13 @@ sub add_validate { is_html => $is_html || 0, title => $title, content => $content, - lang => $lang + lang => $lang, + text_justify => $text_justify, + font_size => $font_size, + units => $units, + notice_width => $notice_width, + top_margin => $top_margin, + left_margin => $left_margin, } )->store; @@ -363,7 +397,13 @@ sub add_validate { title => $title, content => $content, message_transport_type => $mtt, - lang => $lang + lang => $lang, + text_justify => $text_justify, + font_size => $font_size, + units => $units, + notice_width => $notice_width, + top_margin => $top_margin, + left_margin => $left_margin, } )->store; logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content, -- 2.30.2