X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=56dc795e14bb25564f70583283b79f9abd854ffa;hb=0b2ca0abb53db0d372bcc51e8093abb30f2aeea6;hp=f5c0a806287884ee135c50439f57f933eff66aa8;hpb=b15682b7a64108cab73f06368203475d7c1777f0;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index f5c0a8062..56dc795e1 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -448,13 +448,23 @@ sub hide_form { $main::lxdebug->leave_sub(); } +sub throw_on_error { + my ($self, $code) = @_; + local $self->{__ERROR_HANDLER} = sub { die({ error => $_[0] }) }; + $code->(); +} + sub error { $main::lxdebug->enter_sub(); $main::lxdebug->show_backtrace(); my ($self, $msg) = @_; - if ($ENV{HTTP_USER_AGENT}) { + + if ($self->{__ERROR_HANDLER}) { + $self->{__ERROR_HANDLER}->($msg); + + } elsif ($ENV{HTTP_USER_AGENT}) { $msg =~ s/\n/
/g; $self->show_generic_error($msg); @@ -866,6 +876,12 @@ sub show_generic_error { my ($self, $error, %params) = @_; + if ($self->{__ERROR_HANDLER}) { + $self->{__ERROR_HANDLER}->($error); + $main::lxdebug->leave_sub(); + return; + } + my $add_params = { 'title_error' => $params{title}, 'label_error' => $error, @@ -3519,7 +3535,7 @@ sub prepare_for_printing { $self->{formname} ||= $self->{type}; $self->{media} ||= 'email'; - die "'media' other than 'email' or 'file' is not supported yet" unless $self->{media} =~ m/^(?:email|file)$/; + die "'media' other than 'email', 'file', 'printer' is not supported yet" unless $self->{media} =~ m/^(?:email|file|printer)$/; # set shipto from billto unless set my $has_shipto = any { $self->{"shipto$_"} } qw(name street zipcode city country contact); @@ -3566,8 +3582,9 @@ sub prepare_for_printing { $extension = 'xls'; } - my $email_extension = '_email' if -f "$self->{templates}/$self->{formname}_email${language}.${extension}"; - $self->{IN} = "$self->{formname}${email_extension}${language}.${extension}"; + my $printer_code = '_' . $self->{printer_code} if $self->{printer_code}; + my $email_extension = '_email' if -f "$self->{templates}/$self->{formname}_email${language}${printer_code}.${extension}"; + $self->{IN} = "$self->{formname}${email_extension}${language}${printer_code}.${extension}"; # Format dates. $self->format_dates($output_dateformat, $output_longdates,