Bugzilla – Attachment 157369 Details for
Bug 33478
Customise the format of notices when they are printed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33478: Save notice format settings
Bug-33478-Save-notice-format-settings.patch (text/plain), 11.85 KB, created by
Aleisha Amohia
on 2023-10-19 01:31:22 UTC
(
hide
)
Description:
Bug 33478: Save notice format settings
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-10-19 01:31:22 UTC
Size:
11.85 KB
patch
obsolete
>From 68ad489d7399670f688c277c42a967b4c8998033 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >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 Format tab >5. Confirm format settings are available to edit >6. Change some settings and confirm they save correctly >7. Test that 'apply these settings to all notices' option works. Test the confirmation box appears when this is checked. >8. Add a new notice and confirm format settings save successfully > >Sponsored-by: Colorado Library Consortium >Signed-off-by: Sam Lau <samalau@gmail.com> >--- > .../prog/en/modules/tools/letter.tt | 91 +++++++++++++++++++ > koha-tmpl/intranet-tmpl/prog/js/letter.js | 20 +++- > tools/letter.pl | 40 +++++++- > 3 files changed, 146 insertions(+), 5 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 9d773dd96ac..ed7f083f63b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -55,6 +55,25 @@ > [% END %] > </head> > >+[% text_justification_types = [ 'L','C','R' ] %] >+[% BLOCK translate_justification_types %] >+ [% SWITCH type %] >+ [% CASE 'L' %]<span>Left</span> >+ [% CASE 'C' %]<span>Center</span> >+ [% CASE 'R' %]<span>Right</span> >+ [% END %] >+[% END %] >+ >+[% units = [ 'POINT','INCH','MM','CM' ] %] >+[% BLOCK translate_unit_types %] >+ [% SWITCH type %] >+ [% CASE 'POINT' %]<span>PostScript points</span> >+ [% CASE 'INCH' %]<span>US Inches</span> >+ [% CASE 'MM' %]<span>SI Millimeters</span> >+ [% CASE 'CM' %]<span>SI Centimeters</span> >+ [% END %] >+[% END %] >+ > <body id="tools_letter" class="tools"> > [% WRAPPER 'header.inc' %] > [% INCLUDE 'letters-search.inc' %] >@@ -636,6 +655,78 @@ > </div> <!-- /.panel-collapse --> > </div> <!-- /.panel.panel-default --> > [% END # /FOR mtt %] >+ >+ <div class="panel panel-default"> >+ <div class="panel-heading" role="tab" id="format_[% lang | html %]Heading"> >+ <h3 class="panel-title"> >+ <a role="button" class="collapsed" data-toggle="collapse" data-parent="#group_[% lang | html %]" href="#format_[% lang | html %]" aria-expanded="false" aria-controls="format_[% lang | html %]"> >+ <span>Format</span> >+ </a> >+ </h3> >+ </div> <!-- /.panel-heading --> >+ <div id="format_[% lang | html %]" class="panel-collapse collapse" role="tabpanel" aria-labelledby="format_[% lang | html %]Heading"> >+ <div class="panel-body"> >+ <fieldset class="rows"> >+ <div class="dialog message">These format settings apply when a notice is printed.</div> >+ [% SET param = letters.$lang.params %] >+ <div class="col-md-6"> >+ <ol> >+ <li> >+ <label for="text_justify">Text justification: </label> >+ <select name="text_justify" id="text_justify"> >+ [% FOREACH text_justification_type IN text_justification_types %] >+ [% IF ( text_justification_type == param.text_justify ) %] >+ <option value="[% text_justification_type | html %]" selected="selected">[% PROCESS translate_justification_types type=text_justification_type %]</option> >+ [% ELSE %] >+ <option value="[% text_justification_type | html %]">[% PROCESS translate_justification_types type=text_justification_type %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="font_size">Font size: </label> >+ <input type="text" name="font_size" id="font_size" size="2" value="[% param.font_size | html %]" /> >+ </li> >+ <li> >+ <label for="format_all">Apply format settings to all notices:</label> >+ <input type="checkbox" name="format_all" id="format_all" value="1" /> >+ <span class="hint">Existing format settings will be overwritten.</span> >+ </li> >+ </ol> >+ </div> >+ <div class="col-md-6"> >+ <ol> >+ <li> >+ <label for="units">Units:</label> >+ <select id="units" name="units"> >+ [% FOREACH unit IN units %] >+ [% IF ( unit == param.units ) %] >+ <option value="[% unit | html %]" selected="selected">[% PROCESS translate_unit_types type=unit %]</option> >+ [% ELSE %] >+ <option value="[% unit | html %]">[% PROCESS translate_unit_types type=unit %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="notice_width">Notice width:</label> >+ <input type="text" size="4" name="notice_width" id="notice_width" value="[% param.notice_width | html %]" /> >+ </li> >+ <li> >+ <label for="top_margin">Top margin:</label> >+ <input type="text" size="4" name="top_margin" id="top_margin" value="[% param.top_margin | html %]" /> >+ </li> >+ <li> >+ <label for="left_margin">Left margin:</label> >+ <input type="text" size="4" name="left_margin" id="left_margin" value="[% param.left_margin | html %]" /> >+ </li> >+ </ol> >+ </div> >+ </fieldset> <!-- /.rows.mtt --> >+ </div> <!-- /.panel-body --> >+ </div> <!-- /.panel-collapse --> >+ </div> <!-- /.panel.panel-default --> >+ > </div> <!-- /.panel-group#lang_lang --> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js >index 8a1894a1f79..5ea32df655e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/letter.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js >@@ -48,6 +48,14 @@ function confirmOverwrite( new_lettercode, new_branchcode ){ > } > } > >+function confirmFormatOverwrite( event ) { >+ if ( confirm(__("Existing format settings for all notices will be overwritten by these format settings.")) ) { >+ return true; >+ } else { >+ return false; >+ } >+} >+ > var Sticky; > > $(document).ready(function() { >@@ -85,8 +93,16 @@ $(document).ready(function() { > window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode; > }); > >- $("#submit_form").on("click",function(){ >- $("#add_notice").submit(); >+ $("#submit_form").on("click",function(e){ >+ if ( $("#format_all").is(":checked") ){ >+ if ( confirmFormatOverwrite(e) ) { >+ $("#add_notice").submit(); >+ } else { >+ e.preventDefault(); >+ } >+ } else { >+ $("#add_notice").submit(); >+ } > }); > > $("#add_notice").validate({ >diff --git a/tools/letter.pl b/tools/letter.pl >index c00cc6de3dc..b23e3de2289 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -49,7 +49,6 @@ use C4::Context; > use C4::Output qw( output_html_with_http_headers ); > use C4::Letters qw( GetMessageTransportTypes ); > use C4::Log qw( logaction ); >- > use Koha::Notice::Templates; > use Koha::Patron::Attribute::Types; > >@@ -228,6 +227,7 @@ sub add_form { > content => $letter->{content} // '', > tt_error => $letter->{tt_error}, > }; >+ $letters{ $lang }{params} = $letter; > } > } > else { >@@ -310,12 +310,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 +370,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 +391,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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33478
:
149743
|
149785
|
149786
|
149787
|
149914
|
149915
|
149916
|
149917
|
149918
|
149999
|
150000
|
150001
|
150002
|
150003
|
150004
|
150005
|
150006
|
150007
|
150008
|
150009
|
150010
|
150011
|
150012
|
150265
|
150266
|
150267
|
150268
|
150269
|
150270
|
150271
|
150272
|
150273
|
150274
|
150275
|
150276
|
150277
|
150324
|
150325
|
150326
|
150327
|
150328
|
150329
|
150330
|
150331
|
150332
|
150333
|
150334
|
150335
|
150336
|
150337
|
150338
|
150339
|
150340
|
150341
|
150342
|
150343
|
150344
|
150345
|
151548
|
151580
|
151581
|
151582
|
151583
|
151584
|
151585
|
151586
|
151587
|
151588
|
151589
|
151590
|
151591
|
151592
|
151593
|
156469
|
157368
|
157369
|
157370
|
157371
|
157372
|
157373
|
157374
|
157375
|
157376
|
157377
|
157378
|
157379
|
157380
|
157381
|
157382
|
157387
|
158835
|
158836
|
158837
|
158838
|
158839
|
158840
|
158841
|
158842
|
158843
|
158844
|
158845
|
158846
|
158847
|
158848
|
158849
|
158856
|
162556
|
162557
|
162558
|
162559
|
162560
|
162561
|
162562
|
162563
|
162564
|
162565
|
162566
|
162567
|
162568
|
162569
|
163903
|
163904
|
163905
|
163906
|
163907
|
163908
|
163909
|
163910
|
163911
|
163912
|
163913
|
163914
|
163915
|
163916
|
163924
|
163925
|
163926
|
163927
|
163928
|
163929
|
163930
|
163931
|
163932
|
163933
|
163934
|
163935
|
163936
|
163937
|
163938
|
164719
|
164720
|
164721
|
164722
|
164723
|
164724
|
164725
|
164726
|
164727
|
164728
|
164729
|
164730
|
164731
|
164732
|
164733
|
164741
|
164742
|
164743
|
164744
|
164745
|
164746
|
164747
|
164748
|
164749
|
164750
|
164751
|
164752
|
164753
|
164754
|
164755