View | Details | Raw Unified | Return to bug 33478
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl (+18 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "33478",
5
    description => "Customise the format of notices when they are printed",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        if( !column_exists( 'letter', 'style' ) ) {
11
          $dbh->do(q{
12
              ALTER TABLE letter ADD COLUMN `style` mediumtext DEFAULT NULL AFTER `updated_on`
13
          });
14
15
          say $out "Added column 'letter.style'";
16
        }
17
    },
18
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 4263-4268 CREATE TABLE `letter` ( Link Here
4263
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice',
4263
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice',
4264
  `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice',
4264
  `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice',
4265
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
4265
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
4266
  `style` mediumtext DEFAULT NULL COMMENT 'custom styles for this notice',
4266
  PRIMARY KEY (`id`),
4267
  PRIMARY KEY (`id`),
4267
  UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`),
4268
  UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`),
4268
  KEY `message_transport_type_fk` (`message_transport_type`),
4269
  KEY `message_transport_type_fk` (`message_transport_type`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt (+1 lines)
Lines 29-34 Link Here
29
[% IF ( Koha.Preference('SlipCSS') ) %]
29
[% IF ( Koha.Preference('SlipCSS') ) %]
30
<link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" />
30
<link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" />
31
[% END %]
31
[% END %]
32
[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %]
32
33
33
[% INCLUDE 'slip-print.inc' #printThenClose %]
34
[% INCLUDE 'slip-print.inc' #printThenClose %]
34
</head>
35
</head>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt (+1 lines)
Lines 15-20 Link Here
15
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
15
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
16
16
17
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
17
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
18
[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %]
18
[% INCLUDE 'blocking_errors.inc' %]
19
[% INCLUDE 'blocking_errors.inc' %]
19
</head>
20
</head>
20
21
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt (+1 lines)
Lines 15-20 Link Here
15
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
15
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
16
16
17
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
17
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
18
[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %]
18
[% INCLUDE 'blocking_errors.inc' %]
19
[% INCLUDE 'blocking_errors.inc' %]
19
</head>
20
</head>
20
21
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt (+1 lines)
Lines 18-23 Link Here
18
[% IF ( Koha.Preference('SlipCSS') ) %]
18
[% IF ( Koha.Preference('SlipCSS') ) %]
19
<link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" />
19
<link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" />
20
[% END %]
20
[% END %]
21
[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %]
21
</head>
22
</head>
22
23
23
<body id="members_printslip" class="member">
24
<body id="members_printslip" class="member">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt (+1 lines)
Lines 14-19 Link Here
14
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
14
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
15
15
16
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
16
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
17
[% IF slip.style %]<style>[% slip.style | $raw %]</style>[% END %]
17
[% INCLUDE 'blocking_errors.inc' %]
18
[% INCLUDE 'blocking_errors.inc' %]
18
</head>
19
</head>
19
20
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt (+69 lines)
Lines 51-56 Link Here
51
        .panel-group {
51
        .panel-group {
52
            margin-top: 3px;
52
            margin-top: 3px;
53
        }
53
        }
54
        .css-helper::after {
55
            content: " | ";
56
        }
57
        .css-helper:last-child::after {
58
            content: none;
59
        }
54
    </style>
60
    </style>
55
[% END %]
61
[% END %]
56
</head>
62
</head>
Lines 658-663 Link Here
658
                </div> <!-- /.panel-collapse -->
664
                </div> <!-- /.panel-collapse -->
659
            </div> <!-- /.panel.panel-default -->
665
            </div> <!-- /.panel.panel-default -->
660
        [% END # /FOR mtt %]
666
        [% END # /FOR mtt %]
667
668
        <div class="panel panel-default">
669
            <div class="panel-heading" role="tab" id="format_[% lang | html %]Heading">
670
                <h3 class="panel-title">
671
                    <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 %]">
672
                        <span>Format</span>
673
                    </a>
674
                </h3>
675
            </div> <!-- /.panel-heading -->
676
            <div id="format_[% lang | html %]" class="panel-collapse collapse" role="tabpanel" aria-labelledby="format_[% lang | html %]Heading">
677
                <div class="panel-body">
678
                    <fieldset class="rows">
679
                    <div class="dialog message">These format settings apply when a notice is printed.</div>
680
                    <div class="col-md-12">
681
                        <ol>
682
                            <li id="css-helpers">
683
                                <label>Insert selectors to apply styles to: </label>
684
                                <a class="css-helper" id="headings">Headings</a>
685
                                <a class="css-helper" id="tables">Tables</a>
686
                                <a class="css-helper" id="text">All text</a>
687
                            </li>
688
                            <li>
689
                                <label for="style">Style (CSS): </label>
690
                                <textarea id="style" name="style" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea>
691
                            </li>
692
                            <li>
693
                                <label for="format_all">Apply format settings to all notices:</label>
694
                                <input type="checkbox" name="format_all" id="format_all" value="1" />
695
                                <span class="hint">Existing format settings will be overwritten.</span>
696
                            </li>
697
                        </ol>
698
                    </div>
699
                    </fieldset> <!-- /.rows.mtt -->
700
                </div> <!-- /.panel-body -->
701
            </div> <!-- /.panel-collapse -->
702
        </div> <!-- /.panel.panel-default -->
703
661
    </div> <!-- /.panel-group#lang_lang -->
704
    </div> <!-- /.panel-group#lang_lang -->
662
[% END %]
705
[% END %]
663
706
Lines 677-682 Link Here
677
        var new_lettercode = '[% new_lettercode | html %]';
720
        var new_lettercode = '[% new_lettercode | html %]';
678
        var new_branchcode = '[% new_branchcode | html %]';
721
        var new_branchcode = '[% new_branchcode | html %]';
679
        var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %];
722
        var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %];
723
        $(document).ready(function(){
724
            $("#headings").click(function(){
725
                $("#style").val(function(i, text) {
726
                    return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' +
727
                    '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6 {\n' +
728
                    '// insert CSS here\n' +
729
                    '}';
730
                });
731
            });
732
            $("#tables").click(function(){
733
                $("#style").val(function(i, text) {
734
                    return text + '\nbody, table, th, td, th:last-child, td:last-child {\n' +
735
                    '// insert CSS here\n' +
736
                    '}';
737
                });
738
            });
739
            $("#text").click(function(){
740
                $("#style").val(function(i, text) {
741
                    return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' +
742
                    '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6,\n' +
743
                    'table, th, td, th:last-child, td:last-child {\n' +
744
                    '// insert CSS here\n' +
745
                    '}';
746
                });
747
            });
748
        });
680
     </script>
749
     </script>
681
    [% Asset.js("js/letter.js") | $raw %]
750
    [% Asset.js("js/letter.js") | $raw %]
682
[% END %]
751
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/letter.js (-2 / +18 lines)
Lines 48-53 function confirmOverwrite( new_lettercode, new_branchcode ){ Link Here
48
    }
48
    }
49
}
49
}
50
50
51
function confirmFormatOverwrite( event ) {
52
    if ( confirm(__("Existing format settings for all notices will be overwritten by these format settings.")) ) {
53
        return true;
54
    } else {
55
        return false;
56
    }
57
}
58
51
var Sticky;
59
var Sticky;
52
60
53
$(document).ready(function() {
61
$(document).ready(function() {
Lines 85-92 $(document).ready(function() { Link Here
85
        window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode;
93
        window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode;
86
    });
94
    });
87
95
88
    $("#submit_form").on("click",function(){
96
    $("#submit_form").on("click",function(e){
89
        $("#add_notice").submit();
97
        if ( $("#format_all").is(":checked") ){
98
            if ( confirmFormatOverwrite(e) ) {
99
                $("#add_notice").submit();
100
            } else {
101
                e.preventDefault();
102
            }
103
        } else {
104
            $("#add_notice").submit();
105
        }
90
    });
106
    });
91
107
92
    $("#add_notice").validate({
108
    $("#add_notice").validate({
(-)a/tools/letter.pl (-4 / +13 lines)
Lines 49-55 use C4::Context; Link Here
49
use C4::Output qw( output_html_with_http_headers );
49
use C4::Output qw( output_html_with_http_headers );
50
use C4::Letters qw( GetMessageTransportTypes );
50
use C4::Letters qw( GetMessageTransportTypes );
51
use C4::Log qw( logaction );
51
use C4::Log qw( logaction );
52
53
use Koha::Notice::Templates;
52
use Koha::Notice::Templates;
54
use Koha::Patron::Attribute::Types;
53
use Koha::Patron::Attribute::Types;
55
54
Lines 228-233 sub add_form { Link Here
228
                content    => $letter->{content} // '',
227
                content    => $letter->{content} // '',
229
                tt_error   => $letter->{tt_error},
228
                tt_error   => $letter->{tt_error},
230
            };
229
            };
230
            $letters{ $lang }{params} = $letter;
231
        }
231
        }
232
    }
232
    }
233
    else {
233
    else {
Lines 307-318 sub add_validate { Link Here
307
    my $oldmodule     = $input->param('oldmodule');
307
    my $oldmodule     = $input->param('oldmodule');
308
    my $code          = $input->param('code');
308
    my $code          = $input->param('code');
309
    my $name          = $input->param('name');
309
    my $name          = $input->param('name');
310
    my $style         = $input->param('style');
311
    my $format_all    = $input->param('format_all');
310
    my @mtt           = $input->multi_param('message_transport_type');
312
    my @mtt           = $input->multi_param('message_transport_type');
311
    my @title         = $input->multi_param('title');
313
    my @title         = $input->multi_param('title');
312
    my @content       = $input->multi_param('content');
314
    my @content       = $input->multi_param('content');
313
    my @lang          = $input->multi_param('lang');
315
    my @lang          = $input->multi_param('lang');
314
    for my $mtt ( @mtt ) {
316
    for my $mtt ( @mtt ) {
315
        my $lang = shift @lang;
317
        my $lang = shift @lang;
318
        if ( $format_all ) {
319
            my @letters = Koha::Notice::Templates->search({ lang => $lang })->as_list;
320
            foreach my $letter ( @letters ) {
321
                $letter->set({ style => $style })->store;
322
            }
323
        }
316
        my $is_html = $input->param("is_html_$mtt\_$lang");
324
        my $is_html = $input->param("is_html_$mtt\_$lang");
317
        my $title   = shift @title;
325
        my $title   = shift @title;
318
        my $content = shift @content;
326
        my $content = shift @content;
Lines 345-351 sub add_validate { Link Here
345
                    is_html    => $is_html || 0,
353
                    is_html    => $is_html || 0,
346
                    title      => $title,
354
                    title      => $title,
347
                    content    => $content,
355
                    content    => $content,
348
                    lang       => $lang
356
                    lang       => $lang,
357
                    style      => $style
349
                }
358
                }
350
            )->store;
359
            )->store;
351
360
Lines 360-366 sub add_validate { Link Here
360
                    title                  => $title,
369
                    title                  => $title,
361
                    content                => $content,
370
                    content                => $content,
362
                    message_transport_type => $mtt,
371
                    message_transport_type => $mtt,
363
                    lang                   => $lang
372
                    lang                   => $lang,
373
                    style                  => $style
364
                }
374
                }
365
            )->store;
375
            )->store;
366
            logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content,
376
            logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content,
367
- 

Return to bug 33478