Bugzilla – Attachment 163924 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), 15.14 KB, created by
Lucas Gass (lukeg)
on 2024-03-26 14:35:45 UTC
(
hide
)
Description:
Bug 33478: Save notice format settings
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-03-26 14:35:45 UTC
Size:
15.14 KB
patch
obsolete
>From ddfd4c3e7495e08b9b0759c7ab8a746ca6e687c2 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 18 Apr 2023 04:52:46 +0000 >Subject: [PATCH] Bug 33478: Save notice format settings > >Save format settings for an individual notice, or for all notices >This patch implements a single style field for a slip to allow for advanced CSS customisation of printed notices. There are links to insert selectors as helpers. Styles can be applied for an individual notice, or 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 there is a textarea for CSS, and links to insert helpful selectors for IDs like #receipt and #slip >6. Add some CSS and confirm it saves. >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 CSS settings save successfully >9. The subsequent patches have specific testing plans for each printable notice. For each, confirm that SlipCSS stylesheet changes are applied first. Specific notice styles should be applied last. >10. Test with a non-HTML notice as well, such as RECALL_REQUESTER_DET. Plain (non_HTML) notices have always come with <pre> tags around them so the text is formatted slightly differently but any CSS from SlipCSS or the notice Format should still hold. > >Sponsored-by: Colorado Library Consortium >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > .../bug_33478-add_letter_columns.pl | 18 +++++ > installer/data/mysql/kohastructure.sql | 1 + > .../prog/en/modules/circ/printslip.tt | 1 + > .../prog/en/modules/members/printfeercpt.tt | 1 + > .../prog/en/modules/members/printinvoice.tt | 1 + > .../prog/en/modules/members/printnotice.tt | 1 + > .../prog/en/modules/pos/printreceipt.tt | 1 + > .../prog/en/modules/tools/letter.tt | 69 +++++++++++++++++++ > koha-tmpl/intranet-tmpl/prog/js/letter.js | 20 +++++- > tools/letter.pl | 16 ++++- > 10 files changed, 124 insertions(+), 5 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl b/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl >new file mode 100644 >index 0000000000..91caa66079 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl >@@ -0,0 +1,18 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "33478", >+ description => "Customise the format of notices when they are printed", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ if( !column_exists( 'letter', 'style' ) ) { >+ $dbh->do(q{ >+ ALTER TABLE letter ADD COLUMN `style` mediumtext DEFAULT NULL AFTER `updated_on` >+ }); >+ >+ say $out "Added column 'letter.style'"; >+ } >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 16310f0f44..93130a4492 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -4263,6 +4263,7 @@ CREATE TABLE `letter` ( > `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice', > `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice', > `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', >+ `style` mediumtext DEFAULT NULL COMMENT 'custom styles for this notice', > PRIMARY KEY (`id`), > UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`), > KEY `message_transport_type_fk` (`message_transport_type`), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >index f4d35cf1b1..85157a6d55 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >@@ -29,6 +29,7 @@ > [% IF ( Koha.Preference('SlipCSS') ) %] > <link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" /> > [% END %] >+[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %] > > [% INCLUDE 'slip-print.inc' #printThenClose %] > </head> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt >index 5693c3188c..a2ed265577 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt >@@ -15,6 +15,7 @@ > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > > [% Asset.css("css/printreceiptinvoice.css") | $raw %] >+[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %] > [% INCLUDE 'blocking_errors.inc' %] > </head> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt >index 4fb3442ad8..8a1a3f9505 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt >@@ -15,6 +15,7 @@ > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > > [% Asset.css("css/printreceiptinvoice.css") | $raw %] >+[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %] > [% INCLUDE 'blocking_errors.inc' %] > </head> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >index 85b1660e93..3566bc6d0c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >@@ -18,6 +18,7 @@ > [% IF ( Koha.Preference('SlipCSS') ) %] > <link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" /> > [% END %] >+[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %] > </head> > > <body id="members_printslip" class="member"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt >index 7374498b32..95e2d7d8f9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt >@@ -14,6 +14,7 @@ > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > > [% Asset.css("css/printreceiptinvoice.css") | $raw %] >+[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %] > [% INCLUDE 'blocking_errors.inc' %] > </head> > >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 b24aaf2a32..3c217905aa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -51,6 +51,12 @@ > .panel-group { > margin-top: 3px; > } >+ .css-helper::after { >+ content: " | "; >+ } >+ .css-helper:last-child::after { >+ content: none; >+ } > </style> > [% END %] > </head> >@@ -663,6 +669,43 @@ > </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> >+ <div class="col-md-12"> >+ <ol> >+ <li id="css-helpers"> >+ <label>Insert selectors to apply styles to: </label> >+ <a class="css-helper" id="headings">Headings</a> >+ <a class="css-helper" id="tables">Tables</a> >+ <a class="css-helper" id="text">All text</a> >+ </li> >+ <li> >+ <label for="style">Style (CSS): </label> >+ <textarea id="style" name="style" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea> >+ </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> >+ </fieldset> <!-- /.rows.mtt --> >+ </div> <!-- /.panel-body --> >+ </div> <!-- /.panel-collapse --> >+ </div> <!-- /.panel.panel-default --> >+ > </div> <!-- /.panel-group#lang_lang --> > [% END %] > >@@ -682,6 +725,32 @@ > var new_lettercode = '[% new_lettercode | html %]'; > var new_branchcode = '[% new_branchcode | html %]'; > var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %]; >+ $(document).ready(function(){ >+ $("#headings").click(function(){ >+ $("#style").val(function(i, text) { >+ return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' + >+ '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6 {\n' + >+ '// insert CSS here\n' + >+ '}'; >+ }); >+ }); >+ $("#tables").click(function(){ >+ $("#style").val(function(i, text) { >+ return text + '\nbody, table, th, td, th:last-child, td:last-child {\n' + >+ '// insert CSS here\n' + >+ '}'; >+ }); >+ }); >+ $("#text").click(function(){ >+ $("#style").val(function(i, text) { >+ return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' + >+ '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6,\n' + >+ 'table, th, td, th:last-child, td:last-child {\n' + >+ '// insert CSS here\n' + >+ '}'; >+ }); >+ }); >+ }); > </script> > [% Asset.js("js/letter.js") | $raw %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js >index 8a1894a1f7..5ea32df655 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 0ecab147b0..8f16f37506 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 { >@@ -307,12 +307,20 @@ sub add_validate { > my $oldmodule = $input->param('oldmodule'); > my $code = $input->param('code'); > my $name = $input->param('name'); >+ my $style = $input->param('style'); >+ 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({ style => $style })->store; >+ } >+ } > my $is_html = $input->param("is_html_$mtt\_$lang"); > my $title = shift @title; > my $content = shift @content; >@@ -345,7 +353,8 @@ sub add_validate { > is_html => $is_html || 0, > title => $title, > content => $content, >- lang => $lang >+ lang => $lang, >+ style => $style > } > )->store; > >@@ -360,7 +369,8 @@ sub add_validate { > title => $title, > content => $content, > message_transport_type => $mtt, >- lang => $lang >+ lang => $lang, >+ style => $style > } > )->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