@@ -, +, @@
GetPreparedLetter
---
C4/Letters.pm | 25 ++++++++++++++
.../prog/en/modules/members/printfeercpt.tt | 21 ++++++++----
.../prog/en/modules/members/printinvoice.tt | 22 +++++++++----
members/printfeercpt.pl | 33 ++++++++++++-------
members/printinvoice.pl | 31 ++++++++++-------
5 files changed, 98 insertions(+), 34 deletions(-)
--- a/C4/Letters.pm
+++ a/C4/Letters.pm
@@ -31,6 +31,7 @@ use Try::Tiny;
use C4::Members;
use C4::Log;
use C4::SMS;
+use C4::Templates;
use C4::Debug;
use Koha::DateUtils;
use Koha::SMS::Providers;
@@ -784,8 +785,11 @@ sub _parseletter_sth {
# broke things for the rest of us. prepare_cached is a better
# way to cache statement handles anyway.
my $query =
+ ($table eq 'accountlines' ) ? "SELECT * FROM $table WHERE accountlines_id = ?" :
($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" :
($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" :
+ ($table eq 'credits' ) ? "SELECT * FROM accountlines WHERE accountlines_id = ?" :
+ ($table eq 'debits' ) ? "SELECT * FROM accountlines WHERE accountlines_id = ?" :
($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" :
($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" :
($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE itemnumber = ? ORDER BY timestamp DESC LIMIT 1" :
@@ -1520,6 +1524,14 @@ sub _process_tt {
my $loops = $params->{loops};
my $substitute = $params->{substitute} || {};
+ my $htdocs = C4::Context->config('intrahtdocs');
+ my ($theme, $lang, $activethemes)= C4::Templates::themelanguage( $htdocs, 'about.tt', 'intranet');
+ my @includes;
+ foreach (@$activethemes) {
+ push @includes, "$htdocs/$_/$lang/includes";
+ push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en';
+ }
+
my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
my $template = Template->new(
{
@@ -1528,6 +1540,7 @@ sub _process_tt {
PLUGIN_BASE => 'Koha::Template::Plugin',
COMPILE_EXT => $use_template_cache ? '.ttc' : '',
COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '',
+ INCLUDE_PATH => \@includes,
FILTERS => {},
ENCODING => 'UTF-8',
}
@@ -1587,6 +1600,18 @@ sub _get_tt_params {
plural => 'branches',
pk => 'branchcode',
},
+ credits => {
+ module => 'Koha::Account::Lines',
+ singular => 'credit',
+ plural => 'credits',
+ pk => 'accountlines_id',
+ },
+ debits => {
+ module => 'Koha::Account::Lines',
+ singular => 'debit',
+ plural => 'debits',
+ pk => 'accountlines_id',
+ },
items => {
module => 'Koha::Items',
singular => 'item',
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt
@@ -1,16 +1,15 @@
[% USE raw %]
[% USE Asset %]
[% USE Koha %]
-[% USE KohaDates %]
-[% USE Branches %]
-[% USE Price %]
[% SET footerjs = 1 %]
-[% PROCESS 'accounts.inc' %]
-
[% INCLUDE 'doc-head-open.inc' %]
Print receipt for [% patron.cardnumber | html %]
[% INCLUDE 'doc-head-close.inc' %]
+
+
+
+
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
[% INCLUDE 'blocking_errors.inc' %]
@@ -18,7 +17,17 @@
- [% letter.content | $raw | evaltt %]
+ [% IF slip %]
+ [% IF plain %]
+
+ [% slip | html %]
+
+ [% ELSE %]
+ [% slip | $raw %]
+ [% END %]
+ [% ELSE %]
+ No print template found
+ [% END %]
[% MACRO jsinclude BLOCK %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
@@ -1,23 +1,33 @@
[% USE raw %]
[% USE Asset %]
[% USE Koha %]
-[% USE Branches %]
-[% USE KohaDates %]
-[% USE Price %]
[% SET footerjs = 1 %]
-[% PROCESS 'accounts.inc' %]
-
[% INCLUDE 'doc-head-open.inc' %]
Print receipt for [% patron.cardnumber | html %]
[% INCLUDE 'doc-head-close.inc' %]
+
+
+
+
[% Asset.css("css/printreceiptinvoice.css") | $raw %]
+[% INCLUDE 'blocking_errors.inc' %]
- [% letter.content | $raw | evaltt %]
+ [% IF slip %]
+ [% IF plain %]
+
+ [% slip | html %]
+
+ [% ELSE %]
+ [% slip | $raw %]
+ [% END %]
+ [% ELSE %]
+ No print template found
+ [% END %]
[% MACRO jsinclude BLOCK %]
--- a/members/printfeercpt.pl
+++ a/members/printfeercpt.pl
@@ -30,10 +30,10 @@ my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
- template_name => "members/printfeercpt.tt",
- query => $input,
- type => "intranet",
- flagsrequired => {
+ template_name => "members/printfeercpt.tt",
+ query => $input,
+ type => "intranet",
+ flagsrequired => {
borrowers => 'edit_borrowers',
updatecharges => 'remaining_permissions'
}
@@ -55,15 +55,26 @@ output_and_exit_if_error(
}
);
-my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_CREDIT',
- C4::Context::mybranch, 'print', $patron->lang );
+my $letter = C4::Letters::GetPreparedLetter(
+ module => 'circulation',
+ letter_code => 'ACCOUNT_CREDIT',
+ branchcode => C4::Context::mybranch,
+ message_transport_type => 'print',
+ lang => $patron->lang,
+ tables => {
+ credits => $credit_id,
+ borrowers => $patron->borrowernumber
+ },
+ substitute => {
+ tendered => scalar $input->param('tendered'),
+ change => scalar $input->param('change')
+ }
+);
$template->param(
- letter => $letter,
- credit => $credit,
-
- tendered => scalar $input->param('tendered'),
- change => scalar $input->param('change')
+ slip => $letter->{content},
+ plain => !$letter->{is_html},
+ patron => $patron,
);
output_html_with_http_headers $input, $cookie, $template->output;
--- a/members/printinvoice.pl
+++ a/members/printinvoice.pl
@@ -30,10 +30,10 @@ my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
- template_name => "members/printinvoice.tt",
- query => $input,
- type => "intranet",
- flagsrequired => {
+ template_name => "members/printinvoice.tt",
+ query => $input,
+ type => "intranet",
+ flagsrequired => {
borrowers => 'edit_borrowers',
updatecharges => 'remaining_permissions'
}
@@ -41,8 +41,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
my $debit_id = $input->param('accountlines_id');
-my $debit = Koha::Account::Lines->find($debit_id);
-my $patron = $debit->patron;
+my $debit = Koha::Account::Lines->find($debit_id);
+my $patron = $debit->patron;
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
output_and_exit_if_error(
@@ -55,13 +55,22 @@ output_and_exit_if_error(
}
);
-my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_DEBIT',
- C4::Context::mybranch, 'print', $patron->lang );
+my $letter = C4::Letters::GetPreparedLetter(
+ module => 'circulation',
+ letter_code => 'ACCOUNT_DEBIT',
+ branchcode => C4::Context::mybranch,
+ message_transport_type => 'print',
+ lang => $patron->lang,
+ tables => {
+ debits => $debit_id,
+ borrowers => $patron->borrowernumber
+ }
+);
$template->param(
- letter => $letter,
- debit => $debit
-
+ slip => $letter->{content},
+ plain => !$letter->{is_html},
+ patron => $patron,
);
output_html_with_http_headers $input, $cookie, $template->output;
--