From 20993efbc44d0ccae27ff32a5f9e3f30a49180c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 3 Feb 2012 18:50:45 +0100 Subject: [PATCH] =?utf8?q?Template=20Metadaten=20und=20default.tex=20Weite?= =?utf8?q?rleitung=20auch=20f=C3=BCr=20Mahnungen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DN.pm | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/SL/DN.pm b/SL/DN.pm index 797588adf..a1db029ca 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -41,6 +41,8 @@ use SL::IS; use SL::Mailer; use SL::MoreCommon; use SL::Template; +use SL::DB::Printer; +use SL::DB::Language; use strict; @@ -403,15 +405,54 @@ sub set_template_options { $form->{printer_code} = "_" . $form->{printer_code}; } - $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html"; - $form->{pdf} = 1; + my $extension = 'html'; + if ($form->{format} eq 'postscript') { + $form->{postscript} = 1; + $extension = 'tex'; - if ($form->{"format"} =~ /opendocument/) { - $form->{IN} =~ s/html$/odt/; - } else { - $form->{IN} =~ s/html$/tex/; + } elsif ($form->{"format"} =~ /pdf/) { + $form->{pdf} = 1; + $extension = $form->{'format'} =~ m/opendocument/i ? 'odt' : 'tex'; + + } elsif ($form->{"format"} =~ /opendocument/) { + $form->{opendocument} = 1; + $extension = 'odt'; + } elsif ($form->{"format"} =~ /excel/) { + $form->{excel} = 1; + $extension = 'xls'; + } + + + # search for the template + my @template_files; + push @template_files, "$form->{formname}_email$form->{language}$form->{printer_code}.$extension" if $form->{media} eq 'email'; + push @template_files, "$form->{formname}$form->{language}$form->{printer_code}.$extension"; + push @template_files, "$form->{formname}.$extension"; + push @template_files, "default.$extension"; + + $form->{IN} = undef; + for my $filename (@template_files) { + if (-f "$form->{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)); + } + + # 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}), + today => DateTime->today, + }; + $main::lxdebug->leave_sub(); } -- 2.20.1