From 80f544165a03820e9de87c85052eab89729e0328 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 18 Jan 2016 16:20:34 +0100 Subject: [PATCH] =?utf8?q?Letter:=20Aussagekr=C3=A4ftigere=20Fehlermeldung?= =?utf8?q?,=20wenn=20Vorlage=20nicht=20gefunden=20wird.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Letter.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/SL/Controller/Letter.pm b/SL/Controller/Letter.pm index f1109d72c..994b3c001 100644 --- a/SL/Controller/Letter.pm +++ b/SL/Controller/Letter.pm @@ -200,17 +200,24 @@ sub action_print_letter { $::form->get_employee_data('prefix' => 'employee', 'id' => $letter->{employee_id}); $::form->get_employee_data('prefix' => 'salesman', 'id' => $letter->{salesman_id}); + my ($template_file, @template_files) = SL::Helper::CreatePDF->find_template( + name => 'letter', + printer_id => $::form->{printer_id}, + language_id => $::form->{language_id}, + formname => 'letter', + format => 'pdf', + ); + + 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)); + } + my %create_params = ( - template => scalar(SL::Helper::CreatePDF->find_template( - name => 'letter', - printer_id => $::form->{printer_id}, - language_id => $::form->{language_id}, - formname => 'letter', - format => 'pdf', - )), + template => $template_file, variables => $::form, return => 'file_name', ); + my $pdf_file_name; eval { $pdf_file_name = SL::Helper::CreatePDF->create_pdf(%create_params); -- 2.20.1