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

(-)a/C4/Letters.pm (-1 / +29 lines)
Lines 31-36 use Try::Tiny; Link Here
31
use C4::Members;
31
use C4::Members;
32
use C4::Log;
32
use C4::Log;
33
use C4::SMS;
33
use C4::SMS;
34
use C4::Templates;
34
use C4::Debug;
35
use C4::Debug;
35
use Koha::DateUtils;
36
use Koha::DateUtils;
36
use Koha::SMS::Providers;
37
use Koha::SMS::Providers;
Lines 627-639 sub GetPreparedLetter { Link Here
627
    my %params = @_;
628
    my %params = @_;
628
629
629
    my $letter = $params{letter};
630
    my $letter = $params{letter};
631
    my $lang   = $params{lang} || 'default';
630
632
631
    unless ( $letter ) {
633
    unless ( $letter ) {
632
        my $module      = $params{module} or croak "No module";
634
        my $module      = $params{module} or croak "No module";
633
        my $letter_code = $params{letter_code} or croak "No letter_code";
635
        my $letter_code = $params{letter_code} or croak "No letter_code";
634
        my $branchcode  = $params{branchcode} || '';
636
        my $branchcode  = $params{branchcode} || '';
635
        my $mtt         = $params{message_transport_type} || 'email';
637
        my $mtt         = $params{message_transport_type} || 'email';
636
        my $lang        = $params{lang} || 'default';
637
638
638
        $letter = getletter( $module, $letter_code, $branchcode, $mtt, $lang );
639
        $letter = getletter( $module, $letter_code, $branchcode, $mtt, $lang );
639
640
Lines 728-733 sub GetPreparedLetter { Link Here
728
            tables  => $tables,
729
            tables  => $tables,
729
            loops  => $loops,
730
            loops  => $loops,
730
            substitute => $substitute,
731
            substitute => $substitute,
732
            lang => $lang
731
        }
733
        }
732
    );
734
    );
733
735
Lines 784-791 sub _parseletter_sth { Link Here
784
    #       broke things for the rest of us. prepare_cached is a better
786
    #       broke things for the rest of us. prepare_cached is a better
785
    #       way to cache statement handles anyway.
787
    #       way to cache statement handles anyway.
786
    my $query = 
788
    my $query = 
789
    ($table eq 'accountlines' )    ? "SELECT * FROM $table WHERE   accountlines_id = ?"                               :
787
    ($table eq 'biblio'       )    ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
790
    ($table eq 'biblio'       )    ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
788
    ($table eq 'biblioitems'  )    ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
791
    ($table eq 'biblioitems'  )    ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
792
    ($table eq 'credits'      )    ? "SELECT * FROM accountlines WHERE   accountlines_id = ?"                         :
793
    ($table eq 'debits'       )    ? "SELECT * FROM accountlines WHERE   accountlines_id = ?"                         :
789
    ($table eq 'items'        )    ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
794
    ($table eq 'items'        )    ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
790
    ($table eq 'issues'       )    ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
795
    ($table eq 'issues'       )    ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
791
    ($table eq 'old_issues'   )    ? "SELECT * FROM $table WHERE     itemnumber = ? ORDER BY timestamp DESC LIMIT 1"  :
796
    ($table eq 'old_issues'   )    ? "SELECT * FROM $table WHERE     itemnumber = ? ORDER BY timestamp DESC LIMIT 1"  :
Lines 1518-1523 sub _process_tt { Link Here
1518
    my $tables = $params->{tables};
1523
    my $tables = $params->{tables};
1519
    my $loops = $params->{loops};
1524
    my $loops = $params->{loops};
1520
    my $substitute = $params->{substitute} || {};
1525
    my $substitute = $params->{substitute} || {};
1526
    my $lang = defined($params->{lang}) && $params->{lang} ne 'default' ? $params->{lang} : 'en';
1527
    my ($theme, $activethemes);
1528
1529
    my $htdocs = C4::Context->config('intrahtdocs');
1530
    ($theme, $lang, $activethemes)= C4::Templates::activethemes( $htdocs, 'about.tt', 'intranet', $lang);
1531
    my @includes;
1532
    foreach (@$activethemes) {
1533
        push @includes, "$htdocs/$_/$lang/includes";
1534
        push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en';
1535
    }
1521
1536
1522
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1537
    my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
1523
    my $template           = Template->new(
1538
    my $template           = Template->new(
Lines 1527-1532 sub _process_tt { Link Here
1527
            PLUGIN_BASE  => 'Koha::Template::Plugin',
1542
            PLUGIN_BASE  => 'Koha::Template::Plugin',
1528
            COMPILE_EXT  => $use_template_cache ? '.ttc' : '',
1543
            COMPILE_EXT  => $use_template_cache ? '.ttc' : '',
1529
            COMPILE_DIR  => $use_template_cache ? C4::Context->config('template_cache_dir') : '',
1544
            COMPILE_DIR  => $use_template_cache ? C4::Context->config('template_cache_dir') : '',
1545
            INCLUDE_PATH => \@includes,
1530
            FILTERS      => {},
1546
            FILTERS      => {},
1531
            ENCODING     => 'UTF-8',
1547
            ENCODING     => 'UTF-8',
1532
        }
1548
        }
Lines 1586-1591 sub _get_tt_params { Link Here
1586
            plural   => 'branches',
1602
            plural   => 'branches',
1587
            pk       => 'branchcode',
1603
            pk       => 'branchcode',
1588
        },
1604
        },
1605
        credits => {
1606
            module => 'Koha::Account::Lines',
1607
            singular => 'credit',
1608
            plural => 'credits',
1609
            pk => 'accountlines_id',
1610
        },
1611
        debits => {
1612
            module => 'Koha::Account::Lines',
1613
            singular => 'debit',
1614
            plural => 'debits',
1615
            pk => 'accountlines_id',
1616
        },
1589
        items => {
1617
        items => {
1590
            module   => 'Koha::Items',
1618
            module   => 'Koha::Items',
1591
            singular => 'item',
1619
            singular => 'item',
(-)a/C4/Templates.pm (-1 / +6 lines)
Lines 268-273 sub themelanguage { Link Here
268
    # Select a language based on cookie, syspref available languages & browser
268
    # Select a language based on cookie, syspref available languages & browser
269
    my $lang = C4::Languages::getlanguage($query);
269
    my $lang = C4::Languages::getlanguage($query);
270
270
271
    return activethemes($htdocs, $tmpl, $interface, $lang); 
272
}
273
274
sub activethemes {
275
    my ($htdocs, $tmpl, $interface, $lang) = @_;
276
271
    # Get theme
277
    # Get theme
272
    my @themes;
278
    my @themes;
273
    my $theme_syspref    = ($interface eq 'intranet') ? 'template' : 'opacthemes';
279
    my $theme_syspref    = ($interface eq 'intranet') ? 'template' : 'opacthemes';
Lines 303-309 sub themelanguage { Link Here
303
    }
309
    }
304
}
310
}
305
311
306
307
sub setlanguagecookie {
312
sub setlanguagecookie {
308
    my ( $query, $language, $uri ) = @_;
313
    my ( $query, $language, $uri ) = @_;
309
314
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt (-6 / +15 lines)
Lines 1-16 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE Branches %]
6
[% USE Price %]
7
[% SET footerjs = 1 %]
4
[% SET footerjs = 1 %]
8
5
9
[% PROCESS 'accounts.inc' %]
10
11
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
12
<title>Print receipt for [% patron.cardnumber | html %]</title>
7
<title>Print receipt for [% patron.cardnumber | html %]</title>
13
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
9
10
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
12
14
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
13
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
15
[% INCLUDE 'blocking_errors.inc' %]
14
[% INCLUDE 'blocking_errors.inc' %]
16
</head>
15
</head>
Lines 18-24 Link Here
18
<body id="pat_printfeercpt" class="pat">
17
<body id="pat_printfeercpt" class="pat">
19
18
20
<div id="receipt">
19
<div id="receipt">
21
    [% letter.content | $raw | evaltt %]
20
  [% IF slip %]
21
    [% IF plain %]
22
    <pre>
23
      [% slip | html %]
24
    </pre>
25
    [% ELSE %]
26
      [% slip | $raw %]
27
    [% END %]
28
  [% ELSE %]
29
    No print template found
30
  [% END %]
22
</div>
31
</div>
23
32
24
[% MACRO jsinclude BLOCK %]
33
[% MACRO jsinclude BLOCK %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt (-6 / +16 lines)
Lines 1-23 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE Branches %]
5
[% USE KohaDates %]
6
[% USE Price %]
7
[% SET footerjs = 1 %]
4
[% SET footerjs = 1 %]
8
5
9
[% PROCESS 'accounts.inc' %]
10
11
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
12
<title>Print receipt for [% patron.cardnumber | html %]</title>
7
<title>Print receipt for [% patron.cardnumber | html %]</title>
13
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
9
10
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" />
12
14
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
13
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
14
[% INCLUDE 'blocking_errors.inc' %]
15
</head>
15
</head>
16
16
17
<body id="printinvoice" class="pat">
17
<body id="printinvoice" class="pat">
18
18
19
<div id="receipt">
19
<div id="receipt">
20
    [% letter.content | $raw | evaltt %]
20
  [% IF slip %]
21
    [% IF plain %]
22
    <pre>
23
      [% slip | html %]
24
    </pre>
25
    [% ELSE %]
26
      [% slip | $raw %]
27
    [% END %]
28
  [% ELSE %]
29
    No print template found
30
  [% END %]
21
</div>
31
</div>
22
32
23
[% MACRO jsinclude BLOCK %]
33
[% MACRO jsinclude BLOCK %]
(-)a/members/printfeercpt.pl (-11 / +22 lines)
Lines 30-39 my $input = CGI->new; Link Here
30
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
32
    {
33
        template_name   => "members/printfeercpt.tt",
33
        template_name => "members/printfeercpt.tt",
34
        query           => $input,
34
        query         => $input,
35
        type            => "intranet",
35
        type          => "intranet",
36
        flagsrequired   => {
36
        flagsrequired => {
37
            borrowers     => 'edit_borrowers',
37
            borrowers     => 'edit_borrowers',
38
            updatecharges => 'remaining_permissions'
38
            updatecharges => 'remaining_permissions'
39
        }
39
        }
Lines 55-69 output_and_exit_if_error( Link Here
55
    }
55
    }
56
);
56
);
57
57
58
my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_CREDIT',
58
my $letter = C4::Letters::GetPreparedLetter(
59
    C4::Context::mybranch, 'print', $patron->lang );
59
    module                 => 'circulation',
60
    letter_code            => 'ACCOUNT_CREDIT',
61
    branchcode             => C4::Context::mybranch,
62
    message_transport_type => 'print',
63
    lang                   => $patron->lang,
64
    tables                 => {
65
        credits   => $credit_id,
66
        borrowers => $patron->borrowernumber
67
    },
68
    substitute => {
69
        tendered => scalar $input->param('tendered'),
70
        change   => scalar $input->param('change')
71
    }
72
);
60
73
61
$template->param(
74
$template->param(
62
    letter => $letter,
75
    slip   => $letter->{content},
63
    credit => $credit,
76
    plain  => !$letter->{is_html},
64
77
    patron => $patron,
65
    tendered => scalar $input->param('tendered'),
66
    change   => scalar $input->param('change')
67
);
78
);
68
79
69
output_html_with_http_headers $input, $cookie, $template->output;
80
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/printinvoice.pl (-12 / +20 lines)
Lines 30-39 my $input = CGI->new; Link Here
30
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
32
    {
33
        template_name   => "members/printinvoice.tt",
33
        template_name => "members/printinvoice.tt",
34
        query           => $input,
34
        query         => $input,
35
        type            => "intranet",
35
        type          => "intranet",
36
        flagsrequired   => {
36
        flagsrequired => {
37
            borrowers     => 'edit_borrowers',
37
            borrowers     => 'edit_borrowers',
38
            updatecharges => 'remaining_permissions'
38
            updatecharges => 'remaining_permissions'
39
        }
39
        }
Lines 41-48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
41
);
41
);
42
42
43
my $debit_id = $input->param('accountlines_id');
43
my $debit_id = $input->param('accountlines_id');
44
my $debit = Koha::Account::Lines->find($debit_id);
44
my $debit    = Koha::Account::Lines->find($debit_id);
45
my $patron = $debit->patron;
45
my $patron   = $debit->patron;
46
46
47
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
47
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
48
output_and_exit_if_error(
48
output_and_exit_if_error(
Lines 55-67 output_and_exit_if_error( Link Here
55
    }
55
    }
56
);
56
);
57
57
58
my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_DEBIT',
58
my $letter = C4::Letters::GetPreparedLetter(
59
    C4::Context::mybranch, 'print', $patron->lang );
59
    module                 => 'circulation',
60
    letter_code            => 'ACCOUNT_DEBIT',
61
    branchcode             => C4::Context::mybranch,
62
    message_transport_type => 'print',
63
    lang                   => $patron->lang,
64
    tables                 => {
65
        debits    => $debit_id,
66
        borrowers => $patron->borrowernumber
67
    }
68
);
60
69
61
$template->param(
70
$template->param(
62
    letter  => $letter,
71
    slip   => $letter->{content},
63
    debit   => $debit
72
    plain  => !$letter->{is_html},
64
73
    patron => $patron,
65
);
74
);
66
75
67
output_html_with_http_headers $input, $cookie, $template->output;
76
output_html_with_http_headers $input, $cookie, $template->output;
68
- 

Return to bug 26734