X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=56dc795e14bb25564f70583283b79f9abd854ffa;hb=0b2ca0abb53db0d372bcc51e8093abb30f2aeea6;hp=39f575f94093de5ea23f5427ee83bb283df0d651;hpb=06ebdd6a611506903b85bc65fe527c9446be0ac6;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 39f575f94..56dc795e1 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -54,6 +54,7 @@ use SL::CVar; use SL::DB; use SL::DBUtils; use SL::DO; +use SL::IC; use SL::IS; use SL::Mailer; use SL::Menu; @@ -447,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); @@ -865,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, @@ -3518,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); @@ -3538,6 +3555,9 @@ sub prepare_for_printing { $output_longdates = 1; } + # Retrieve accounts for tax calculation. + IC->retrieve_accounts(\%::myconfig, $self, map { $_ => $self->{"id_$_"} } 1 .. $self->{rowcount}); + if ($self->{type} =~ /_delivery_order$/) { DO->order_details(); } elsif ($self->{type} =~ /sales_order|sales_quotation|request_quotation|purchase_order/) { @@ -3562,8 +3582,9 @@ sub prepare_for_printing { $extension = 'xls'; } - my $email_extension = '_email' if -f "$::myconfig{templates}/$self->{formname}_email$self->{language}.${extension}"; - $self->{IN} = "$self->{formname}${email_extension}$self->{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,