use SL::DB;
use SL::DBUtils;
use SL::DO;
+use SL::IC;
use SL::IS;
use SL::Mailer;
use SL::Menu;
$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/<br>/g;
$self->show_generic_error($msg);
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,
$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);
$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/) {
$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,