From: Moritz Bunkus Date: Tue, 18 Feb 2014 10:18:17 +0000 (+0100) Subject: io.pl print_form: CreatePDF zum Auffinden des Templates nutzen X-Git-Tag: release-3.2.0beta~491^2~11 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a0516348e76b315f149bd1014ef68eaf24d7073c;p=kivitendo-erp.git io.pl print_form: CreatePDF zum Auffinden des Templates nutzen --- diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index e10389171..c9f14870b 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -50,6 +50,7 @@ use SL::IO; use SL::DB::Default; use SL::DB::Language; use SL::DB::Printer; +use SL::Helper::CreatePDF; use SL::Helper::Flash; require "bin/mozilla/common.pl"; @@ -1505,18 +1506,20 @@ sub print_form { } # search for the template - my @template_files; - push @template_files, "$form->{formname}_email$form->{language}$printer_code.$extension" if $form->{media} eq 'email'; - push @template_files, "$form->{formname}$form->{language}$printer_code.$extension"; - push @template_files, "$form->{formname}.$extension"; - push @template_files, "default.$extension"; - @template_files = uniq @template_files; - $form->{IN} = first { -f ($defaults->templates . "/$_") } @template_files; - - if (!defined $form->{IN}) { + my ($template_file, @template_files) = SL::Helper::CreatePDF->find_template( + name => $form->{formname}, + email => $form->{media} eq 'email', + language_id => $form->{language_id}, + printer_id => $form->{printer_id}, + extension => $extension, + ); + + if (!defined $template_file) { $::form->error($::locale->text('Cannot find matching template for this print request. Please contact your template maintainer. I tried these: #1.', join ', ', map { "'$_'"} @template_files)); } + $form->{IN} = $template_file; + delete $form->{OUT}; if ($form->{media} eq 'printer') {