X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/ea5d75b52e043fb3f0d264056df6007049d6a3fd..068f652cd376ffcaa392d2fc32f9d194e17daa44:/SL/Controller/Letter.pm?ds=inline diff --git a/SL/Controller/Letter.pm b/SL/Controller/Letter.pm index f1109d72c..0f1a40f5f 100644 --- a/SL/Controller/Letter.pm +++ b/SL/Controller/Letter.pm @@ -11,6 +11,7 @@ use SL::DB::LetterDraft; use SL::DB::Employee; use SL::Helper::Flash qw(flash); use SL::Helper::CreatePDF; +use SL::Helper::PrintOptions; use SL::Locale::String qw(t8); use SL::IS; use SL::ReportGenerator; @@ -200,17 +201,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); @@ -295,8 +303,6 @@ sub _display { my $letter = $self->letter; - require 'bin/mozilla/io.pl'; - $params{title} ||= t8('Edit Letter'); $::form->{type} = 'letter'; # needed for print_options @@ -313,7 +319,12 @@ sub _display { PCF => [ map { key => $_, value => t8(ucfirst $_) }, PAGE_CREATED_FOR_VALUES() ], letter => $letter, employees => $self->all_employees, - print_options => print_options(inline => 1), + print_options => SL::Helper::PrintOptions->get_print_options ( + options => { no_postscript => 1, + no_opendocument => 1, + no_html => 1, + no_queue => 1 }), + ); } @@ -343,7 +354,7 @@ sub prepare_report { obj_link => sub { $self->url_for(action => 'edit', 'letter.id' => $_[0]->id, callback => $self->models->get_callback) } }, letternumber => { text => t8('Letternumber'), sub => sub { $_[0]->letternumber }, obj_link => sub { $self->url_for(action => 'edit', 'letter.id' => $_[0]->id, callback => $self->models->get_callback) } }, - vc_id => { text => t8('Customer'), sub => sub { $_[0]->customer->displayable_name } }, + vc_id => { text => t8('Customer'), sub => sub { SL::DB::Manager::Customer->find_by_or_create(id => $_[0]->vc_id)->displayable_name } }, contact => { text => t8('Contact'), sub => sub { $_[0]->contact ? $_[0]->contact->full_name : '' } }, ); @@ -531,13 +542,7 @@ sub init_models { SL::Controller::Helper::GetModels->new( controller => $self, model => 'Letter', - sorted => { - _default => { - by => 'letternumber', - dir => 1, - }, - %sort_columns, - }, + sorted => \%sort_columns, with_objects => [ 'contact', 'salesman', 'employee' ], ); }