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

(-)a/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl (-43 / +3 lines)
Lines 7-58 return { Link Here
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
9
10
        if( !column_exists( 'letter', 'font_size' ) ) {
10
        if( !column_exists( 'letter', 'style' ) ) {
11
          $dbh->do(q{
11
          $dbh->do(q{
12
              ALTER TABLE letter ADD COLUMN `font_size` int(4) NOT NULL DEFAULT 14 AFTER `updated_on`
12
              ALTER TABLE letter ADD COLUMN `style` mediumtext DEFAULT NULL AFTER `updated_on`
13
          });
13
          });
14
14
15
          say $out "Added column 'letter.font_size'";
15
          say $out "Added column 'letter.style'";
16
        }
17
18
        if( !column_exists( 'letter', 'text_justify' ) ) {
19
          $dbh->do(q{
20
              ALTER TABLE letter ADD COLUMN `text_justify` enum('L','C','R') NOT NULL DEFAULT 'L' AFTER `font_size`
21
          });
22
23
          say $out "Added column 'letter.text_justify'";
24
        }
25
26
        if( !column_exists( 'letter', 'units' ) ) {
27
          $dbh->do(q{
28
              ALTER TABLE letter ADD COLUMN `units` enum('POINT','INCH','MM','CM') NOT NULL DEFAULT 'INCH' AFTER `text_justify`
29
          });
30
31
          say $out "Added column 'letter.units'";
32
        }
33
34
        if( !column_exists( 'letter', 'notice_width' ) ) {
35
          $dbh->do(q{
36
              ALTER TABLE letter ADD COLUMN `notice_width` float NOT NULL DEFAULT 8.5 AFTER `units`
37
          });
38
39
          say $out "Added column 'letter.notice_width'";
40
        }
41
42
        if( !column_exists( 'letter', 'top_margin' ) ) {
43
          $dbh->do(q{
44
              ALTER TABLE letter ADD COLUMN `top_margin` float NOT NULL DEFAULT 0 AFTER `notice_width`
45
          });
46
47
          say $out "Added column 'letter.top_margin'";
48
        }
49
50
        if( !column_exists( 'letter', 'left_margin' ) ) {
51
          $dbh->do(q{
52
              ALTER TABLE letter ADD COLUMN `left_margin` float NOT NULL DEFAULT 0 AFTER `top_margin`
53
          });
54
55
          say $out "Added column 'letter.left_margin'";
56
        }
16
        }
57
    },
17
    },
58
};
18
};
(-)a/installer/data/mysql/kohastructure.sql (-6 / +1 lines)
Lines 3959-3970 CREATE TABLE `letter` ( Link Here
3959
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice',
3959
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice',
3960
  `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice',
3960
  `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice',
3961
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
3961
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
3962
  `font_size` int(4) NOT NULL DEFAULT 14 COMMENT 'font size used when notice is printed',
3962
  `style` mediumtext DEFAULT NULL COMMENT 'custom styles for this notice',
3963
  `text_justify` enum('L','C','R') NOT NULL DEFAULT 'L' COMMENT 'text justification used when notice is printed',
3964
  `units` enum('POINT','INCH','MM','CM') NOT NULL DEFAULT 'INCH' COMMENT 'units to use for print measurements',
3965
  `notice_width` float NOT NULL DEFAULT 8.5 COMMENT 'width of notice',
3966
  `top_margin` float NOT NULL DEFAULT 0 COMMENT 'top margin for notice',
3967
  `left_margin` float NOT NULL DEFAULT 0 COMMENT 'left margin for notice',
3968
  PRIMARY KEY (`id`),
3963
  PRIMARY KEY (`id`),
3969
  UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`),
3964
  UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`),
3970
  KEY `message_transport_type_fk` (`message_transport_type`),
3965
  KEY `message_transport_type_fk` (`message_transport_type`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/notice_format_translations.inc (-16 lines)
Lines 1-16 Link Here
1
[% BLOCK translate_justification_types %]
2
    [%  SWITCH type %]
3
        [%   CASE 'L' %]left
4
        [%   CASE 'C' %]center
5
        [%   CASE 'R' %]right
6
    [%  END %]
7
[% END %]
8
9
[% BLOCK translate_unit_types %]
10
    [% SWITCH type %]
11
        [%   CASE 'POINT' %]pt
12
        [%   CASE 'INCH' %]in
13
        [%   CASE 'MM' %]mm
14
        [%   CASE 'CM' %]cm
15
    [% END %]
16
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/slip_content.inc (-15 lines)
Lines 1-18 Link Here
1
<style>
2
    #slip, #receipt {
3
        text-align:[% PROCESS translate_justification_types type=notice.text_justify | trim %];
4
        font-size:[% notice.font_size %]px;
5
        width:[% notice.notice_width %][% PROCESS translate_unit_types type=notice.units | trim %];
6
        margin-top:[% notice.top_margin %][% PROCESS translate_unit_types type=notice.units | trim %];
7
        margin-left:[% notice.left_margin %][% PROCESS translate_unit_types type=notice.units | trim %];
8
    }
9
10
    h3, h4, th, td, th:last-child, td:last-child {
11
        text-align:[% PROCESS translate_justification_types type=notice.text_justify | trim %];
12
        font-size:[% notice.font_size %]px;
13
    }
14
</style>
15
16
[% IF notice.is_html %]
1
[% IF notice.is_html %]
17
    [% notice.content | $raw %]
2
    [% notice.content | $raw %]
18
[% ELSE %]
3
[% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt (-2 / +1 lines)
Lines 29-40 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>
35
36
36
[% PROCESS 'notice_format_translations.inc' %]
37
38
<body id="circ_printslip" class="circ">
37
<body id="circ_printslip" class="circ">
39
<div id="receipt">
38
<div id="receipt">
40
    [% IF ( slip ) %]
39
    [% IF ( slip ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt (-2 / +1 lines)
Lines 15-25 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
21
[% PROCESS 'notice_format_translations.inc' %]
22
23
<body id="pat_printfeercpt" class="pat">
22
<body id="pat_printfeercpt" class="pat">
24
<div id="receipt">
23
<div id="receipt">
25
    [% IF ( slip ) %]
24
    [% IF ( slip ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt (-2 / +1 lines)
Lines 15-25 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
21
[% PROCESS 'notice_format_translations.inc' %]
22
23
<body id="printinvoice" class="pat">
22
<body id="printinvoice" class="pat">
24
<div id="receipt">
23
<div id="receipt">
25
    [% IF ( slip ) %]
24
    [% IF ( slip ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt (-2 / +1 lines)
Lines 18-27 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
[% PROCESS 'notice_format_translations.inc' %]
24
25
<body id="members_printslip" class="member">
24
<body id="members_printslip" class="member">
26
<div id="slip">
25
<div id="slip">
27
    [% IF ( slip ) %]
26
    [% IF ( slip ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt (-2 / +1 lines)
Lines 14-24 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
20
[% PROCESS 'notice_format_translations.inc' %]
21
22
<body id="pat_printfeercpt" class="pat">
21
<body id="pat_printfeercpt" class="pat">
23
<div id="receipt">
22
<div id="receipt">
24
    [% IF ( slip ) %]
23
    [% IF ( slip ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt (-73 / +51 lines)
Lines 51-79 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>
57
63
58
[% text_justification_types = [ 'L','C','R' ] %]
59
[% BLOCK translate_justification_types %]
60
    [%  SWITCH type %]
61
        [%   CASE 'L' %]<span>Left</span>
62
        [%   CASE 'C' %]<span>Center</span>
63
        [%   CASE 'R' %]<span>Right</span>
64
    [%  END %]
65
[% END %]
66
67
[% units = [ 'POINT','INCH','MM','CM' ] %]
68
[% BLOCK translate_unit_types %]
69
    [% SWITCH type %]
70
        [%   CASE 'POINT' %]<span>PostScript points</span>
71
        [%   CASE 'INCH' %]<span>US Inches</span>
72
        [%   CASE 'MM' %]<span>SI Millimeters</span>
73
        [%   CASE 'CM' %]<span>SI Centimeters</span>
74
    [% END %]
75
[% END %]
76
77
<body id="tools_letter" class="tools">
64
<body id="tools_letter" class="tools">
78
    [% WRAPPER 'header.inc' %]
65
    [% WRAPPER 'header.inc' %]
79
    [% INCLUDE 'letters-search.inc' %]
66
    [% INCLUDE 'letters-search.inc' %]
Lines 668-727 Link Here
668
                <div class="panel-body">
655
                <div class="panel-body">
669
                    <fieldset class="rows">
656
                    <fieldset class="rows">
670
                    <div class="dialog message">These format settings apply when a notice is printed.</div>
657
                    <div class="dialog message">These format settings apply when a notice is printed.</div>
671
                        [% SET param = letters.$lang.params %]
658
                    <div class="col-md-12">
672
                        <div class="col-md-6">
659
                        <ol>
673
                            <ol>
660
                            <li id="css-helpers">
674
                                <li>
661
                                <label>Insert selectors to apply styles to: </label>
675
                                    <label for="text_justify">Text justification: </label>
662
                                <a class="css-helper" id="headings">Headings</a>
676
                                    <select name="text_justify" id="text_justify">
663
                                <a class="css-helper" id="tables">Tables</a>
677
                                        [% FOREACH text_justification_type IN text_justification_types %]
664
                                <a class="css-helper" id="text">All text</a>
678
                                            [% IF ( text_justification_type == param.text_justify ) %]
665
                            </li>
679
                                            <option value="[% text_justification_type | html %]" selected="selected">[% PROCESS translate_justification_types type=text_justification_type %]</option>
666
                            <li>
680
                                            [% ELSE %]
667
                                <label for="style">Style (CSS): </label>
681
                                            <option value="[% text_justification_type | html %]">[% PROCESS translate_justification_types type=text_justification_type %]</option>
668
                                <textarea id="style" name="style" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea>
682
                                            [% END %]
669
                            </li>
683
                                        [% END %]
670
                            <li>
684
                                    </select>
671
                                <label for="format_all">Apply format settings to all notices:</label>
685
                                </li>
672
                                <input type="checkbox" name="format_all" id="format_all" value="1" />
686
                                <li>
673
                                <span class="hint">Existing format settings will be overwritten.</span>
687
                                    <label for="font_size">Font size: </label>
674
                            </li>
688
                                    <input type="text" name="font_size" id="font_size" size="2" value="[% param.font_size | html %]" />
675
                        </ol>
689
                                </li>
676
                    </div>
690
                                <li>
691
                                    <label for="format_all">Apply format settings to all notices:</label>
692
                                    <input type="checkbox" name="format_all" id="format_all" value="1" />
693
                                    <span class="hint">Existing format settings will be overwritten.</span>
694
                                </li>
695
                            </ol>
696
                        </div>
697
                        <div class="col-md-6">
698
                            <ol>
699
                                <li>
700
                                    <label for="units">Units:</label>
701
                                    <select id="units" name="units">
702
                                        [% FOREACH unit IN units %]
703
                                            [% IF ( unit == param.units ) %]
704
                                            <option value="[% unit | html %]" selected="selected">[% PROCESS translate_unit_types type=unit %]</option>
705
                                            [% ELSE %]
706
                                            <option value="[% unit | html %]">[% PROCESS translate_unit_types type=unit %]</option>
707
                                            [% END %]
708
                                        [% END %]
709
                                    </select>
710
                                </li>
711
                                <li>
712
                                    <label for="notice_width">Notice width:</label>
713
                                    <input type="text" size="4" name="notice_width" id="notice_width" value="[% param.notice_width | html %]" />
714
                                </li>
715
                                <li>
716
                                    <label for="top_margin">Top margin:</label>
717
                                    <input type="text" size="4" name="top_margin" id="top_margin" value="[% param.top_margin | html %]" />
718
                                </li>
719
                                <li>
720
                                    <label for="left_margin">Left margin:</label>
721
                                    <input type="text" size="4" name="left_margin" id="left_margin" value="[% param.left_margin | html %]" />
722
                                </li>
723
                            </ol>
724
                        </div>
725
                    </fieldset> <!-- /.rows.mtt -->
677
                    </fieldset> <!-- /.rows.mtt -->
726
                </div> <!-- /.panel-body -->
678
                </div> <!-- /.panel-body -->
727
            </div> <!-- /.panel-collapse -->
679
            </div> <!-- /.panel-collapse -->
Lines 746-751 Link Here
746
        var new_lettercode = '[% new_lettercode | html %]';
698
        var new_lettercode = '[% new_lettercode | html %]';
747
        var new_branchcode = '[% new_branchcode | html %]';
699
        var new_branchcode = '[% new_branchcode | html %]';
748
        var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %];
700
        var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %];
701
        $(document).ready(function(){
702
            $("#headings").click(function(){
703
                $("#style").val(function(i, text) {
704
                    return text + '\nbody, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' +
705
                    '#receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6 {\n' +
706
                    '// insert CSS here\n' +
707
                    '}';
708
                });
709
            });
710
            $("#tables").click(function(){
711
                $("#style").val(function(i, text) {
712
                    return text + '\nbody, table, th, td, th:last-child, td:last-child {\n' +
713
                    '// insert CSS here\n' +
714
                    '}';
715
                });
716
            });
717
            $("#text").click(function(){
718
                $("#style").val(function(i, text) {
719
                    return text + '\nbody, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' +
720
                    '#receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6,\n' +
721
                    'table, th, td, th:last-child, td:last-child {\n' +
722
                    '// insert CSS here\n' +
723
                    '}';
724
                });
725
            });
726
        });
749
     </script>
727
     </script>
750
    [% Asset.js("js/letter.js") | $raw %]
728
    [% Asset.js("js/letter.js") | $raw %]
751
[% END %]
729
[% END %]
(-)a/tools/letter.pl (-29 / +4 lines)
Lines 310-321 sub add_validate { Link Here
310
    my $oldmodule     = $input->param('oldmodule');
310
    my $oldmodule     = $input->param('oldmodule');
311
    my $code          = $input->param('code');
311
    my $code          = $input->param('code');
312
    my $name          = $input->param('name');
312
    my $name          = $input->param('name');
313
    my $text_justify  = $input->param('text_justify');
313
    my $style         = $input->param('style');
314
    my $font_size     = $input->param('font_size');
315
    my $units         = $input->param('units');
316
    my $notice_width  = $input->param('notice_width');
317
    my $top_margin    = $input->param('top_margin');
318
    my $left_margin   = $input->param('left_margin');
319
    my $format_all    = $input->param('format_all');
314
    my $format_all    = $input->param('format_all');
320
    my @mtt           = $input->multi_param('message_transport_type');
315
    my @mtt           = $input->multi_param('message_transport_type');
321
    my @title         = $input->multi_param('title');
316
    my @title         = $input->multi_param('title');
Lines 326-341 sub add_validate { Link Here
326
        if ( $format_all ) {
321
        if ( $format_all ) {
327
            my @letters = Koha::Notice::Templates->search({ lang => $lang })->as_list;
322
            my @letters = Koha::Notice::Templates->search({ lang => $lang })->as_list;
328
            foreach my $letter ( @letters ) {
323
            foreach my $letter ( @letters ) {
329
                $letter->set(
324
                $letter->set({ style => $style })->store;
330
                    {
331
                        text_justify  => $text_justify,
332
                        font_size  => $font_size,
333
                        units      => $units,
334
                        notice_width  => $notice_width,
335
                        top_margin    => $top_margin,
336
                        left_margin   => $left_margin,
337
                    }
338
                )->store;
339
            }
325
            }
340
        }
326
        }
341
        my $is_html = $input->param("is_html_$mtt\_$lang");
327
        my $is_html = $input->param("is_html_$mtt\_$lang");
Lines 371-382 sub add_validate { Link Here
371
                    title      => $title,
357
                    title      => $title,
372
                    content    => $content,
358
                    content    => $content,
373
                    lang       => $lang,
359
                    lang       => $lang,
374
                    text_justify  => $text_justify,
360
                    style      => $style
375
                    font_size  => $font_size,
376
                    units      => $units,
377
                    notice_width  => $notice_width,
378
                    top_margin    => $top_margin,
379
                    left_margin   => $left_margin,
380
                }
361
                }
381
            )->store;
362
            )->store;
382
363
Lines 392-403 sub add_validate { Link Here
392
                    content                => $content,
373
                    content                => $content,
393
                    message_transport_type => $mtt,
374
                    message_transport_type => $mtt,
394
                    lang                   => $lang,
375
                    lang                   => $lang,
395
                    text_justify  => $text_justify,
376
                    style                  => $style
396
                    font_size  => $font_size,
397
                    units      => $units,
398
                    notice_width  => $notice_width,
399
                    top_margin    => $top_margin,
400
                    left_margin   => $left_margin,
401
                }
377
                }
402
            )->store;
378
            )->store;
403
            logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content,
379
            logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content,
404
- 

Return to bug 33478