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 (+68 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 657-662 Link Here
657
                [% END %]
663
                [% END %]
658
            [% END # /collapse_item %]
664
            [% END # /collapse_item %]
659
        [% END # /FOR mtt %]
665
        [% END # /FOR mtt %]
666
667
        <div class="panel panel-default">
668
            <div class="panel-heading" role="tab" id="format_[% lang | html %]Heading">
669
                <h3 class="panel-title">
670
                    <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 %]">
671
                        <span>Format</span>
672
                    </a>
673
                </h3>
674
            </div> <!-- /.panel-heading -->
675
            <div id="format_[% lang | html %]" class="panel-collapse collapse" role="tabpanel" aria-labelledby="format_[% lang | html %]Heading">
676
                <div class="panel-body">
677
                    <fieldset class="rows">
678
                    <div class="dialog message">These format settings apply when a notice is printed.</div>
679
                    <div class="col-md-12">
680
                        <ol>
681
                            <li id="css-helpers">
682
                                <label>Insert selectors to apply styles to: </label>
683
                                <a class="css-helper" id="headings">Headings</a>
684
                                <a class="css-helper" id="tables">Tables</a>
685
                                <a class="css-helper" id="text">All text</a>
686
                            </li>
687
                            <li>
688
                                <label for="style">Style (CSS): </label>
689
                                <textarea id="style" name="style" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea>
690
                            </li>
691
                            <li>
692
                                <label for="format_all">Apply format settings to all notices:</label>
693
                                <input type="checkbox" name="format_all" id="format_all" value="1" />
694
                                <span class="hint">Existing format settings will be overwritten.</span>
695
                            </li>
696
                        </ol>
697
                    </div>
698
                    </fieldset> <!-- /.rows.mtt -->
699
                </div> <!-- /.panel-body -->
700
            </div> <!-- /.panel-collapse -->
701
        </div> <!-- /.panel.panel-default -->
660
    [% END # /WRAPPER accordion %]
702
    [% END # /WRAPPER accordion %]
661
[% END %]
703
[% END %]
662
704
Lines 676-681 Link Here
676
        var new_lettercode = '[% new_lettercode | html %]';
718
        var new_lettercode = '[% new_lettercode | html %]';
677
        var new_branchcode = '[% new_branchcode | html %]';
719
        var new_branchcode = '[% new_branchcode | html %]';
678
        var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %];
720
        var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %];
721
        $(document).ready(function(){
722
            $("#headings").click(function(){
723
                $("#style").val(function(i, text) {
724
                    return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' +
725
                    '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6 {\n' +
726
                    '// insert CSS here\n' +
727
                    '}';
728
                });
729
            });
730
            $("#tables").click(function(){
731
                $("#style").val(function(i, text) {
732
                    return text + '\nbody, table, th, td, th:last-child, td:last-child {\n' +
733
                    '// insert CSS here\n' +
734
                    '}';
735
                });
736
            });
737
            $("#text").click(function(){
738
                $("#style").val(function(i, text) {
739
                    return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' +
740
                    '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6,\n' +
741
                    'table, th, td, th:last-child, td:last-child {\n' +
742
                    '// insert CSS here\n' +
743
                    '}';
744
                });
745
            });
746
        });
679
     </script>
747
     </script>
680
    [% Asset.js("js/letter.js") | $raw %]
748
    [% Asset.js("js/letter.js") | $raw %]
681
[% END %]
749
[% 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