X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=0e10b22122b762a657c421c8a71e5abf8962d1c0;hb=64084bfa6ba2c9167ff4a50683606e57fec62167;hp=940fec968f3c100ed86053010dea6320013205e7;hpb=6ff1674fc7d8e48723efa5a8152ac468c5d4ea58;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 940fec968..0e10b2212 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -46,6 +46,9 @@ use SL::CT; use SL::IC; use SL::IO; +use SL::DB::Language; +use SL::DB::Printer; + require "bin/mozilla/common.pl"; use strict; @@ -1473,9 +1476,24 @@ sub print_form { $extension = 'xls'; } - my $email_extension = (($form->{media} eq 'email') && (-f "$myconfig{templates}/$form->{formname}_email$form->{language}${printer_code}.${extension}")) ? '_email' : ''; + # 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"; - $form->{IN} = "$form->{formname}${email_extension}$form->{language}${printer_code}.${extension}"; + $form->{IN} = undef; + for my $filename (@template_files) { + if (-f "$myconfig{templates}/$filename") { + $form->{IN} = $filename; + last; + } + } + + if (!defined $form->{IN}) { + $::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)); + } delete $form->{OUT}; @@ -1540,6 +1558,16 @@ sub print_form { } # /saving the history + # prepare meta information for template introspection + $form->{template_meta} = { + formname => $form->{formname}, + language => SL::DB::Manager::Language->find_by_or_create(id => $form->{language_id}), + format => $form->{format}, + media => $form->{media}, + extension => $extension, + printer => SL::DB::Manager::Printer->find_by_or_create(id => $form->{printer_id}), + }; + $form->parse_template(\%myconfig); $form->{callback} = "";