use Carp;
use Data::Dumper;
+use Carp;
use CGI;
use Cwd;
use Encode;
$self->show_generic_error($msg);
} else {
- print STDERR "Error: $msg\n";
- ::end_of_request();
+ confess "Error: $msg\n";
}
$main::lxdebug->leave_sub();
$layout->use_javascript("$_.js") for (qw(
jquery jquery-ui jquery.cookie jquery.checkall jquery.download
- jquery/jquery.form client_js
+ jquery/jquery.form jquery/fixes client_js
common part_selection switchmenuframe autocomplete_part
), "jquery/ui/i18n/jquery.ui.datepicker-$::myconfig{countrycode}");
if (-f "templates/webpages/${file}.html") {
$file = "templates/webpages/${file}.html";
+ } elsif (ref $file eq 'SCALAR') {
+ # file is a scalarref, use inline mode
} else {
my $info = "Web page template '${file}' not found.\n";
+ $::form->header;
print qq|<pre>$info</pre>|;
::end_of_request();
}
'COMPILE_EXT' => '.tcc',
'COMPILE_DIR' => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
'ERROR' => 'templates/webpages/generic/exception.html',
+ 'ENCODING' => 'utf8',
})) || die;
}
}
if ($::request->is_ajax) {
- $::lxdebug->message(0, "trying to render AJAX response...");
SL::ClientJS->new
->error($error)
->render(SL::Controller::Base->new);
file_name => $self->{IN},
form => $self,
myconfig => $myconfig,
- userspath => $userspath);
+ userspath => $userspath,
+ %{ $self->{TEMPLATE_DRIVER_OPTIONS} || {} });
# Copy the notes from the invoice/sales order etc. back to the variable "notes" because that is where most templates expect it to be.
$self->{"notes"} = $self->{ $self->{"formname"} . "notes" };
}
close OUT if $self->{OUT};
-
- my $copy_to_webdav = $::instance_conf->get_webdav && $::instance_conf->get_webdav_documents && !$self->{preview} && $self->{tmpdir} && $self->{tmpfile} && $self->{type};
+ # check only one flag (webdav_documents)
+ # therefore copy to webdav, even if we do not have the webdav feature enabled (just archive)
+ my $copy_to_webdav = $::instance_conf->get_webdav_documents && !$self->{preview} && $self->{tmpdir} && $self->{tmpfile} && $self->{type};
if ($self->{media} eq 'file') {
copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file;
$mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email};
$mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|;
$mail->{fileid} = time() . '.' . $$ . '.';
- $myconfig->{signature} =~ s/\r//g;
+ my $full_signature = $self->create_email_signature();
+ $full_signature =~ s/\r//g;
# if we send html or plain text inline
if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) {
$mail->{contenttype} = "text/html";
$mail->{message} =~ s/\r//g;
$mail->{message} =~ s/\n/<br>\n/g;
- $myconfig->{signature} =~ s/\n/<br>\n/g;
- $mail->{message} .= "<br>\n-- <br>\n$myconfig->{signature}\n<br>";
+ $full_signature =~ s/\n/<br>\n/g;
+ $mail->{message} .= $full_signature;
open(IN, "<", $self->{tmpfile})
or $self->error($self->cleanup . "$self->{tmpfile} : $!");
"name" => $attachment_name }];
}
- $mail->{message} =~ s/\r//g;
- $mail->{message} .= "\n-- \n$myconfig->{signature}";
-
+ $mail->{message} .= $full_signature;
}
my $err = $mail->send();
my $dbh = $self->get_standard_dbh(\%main::myconfig);
my ($sth, $query, $ref);
- my $vc = $self->{"vc"} eq "customer" ? "customer" : "vendor";
- my $vc_id = $self->{"${vc}_id"};
+ my ($vc, $vc_id);
+ if ($params{contacts} || $params{shipto}) {
+ $vc = 'customer' if $self->{"vc"} eq "customer";
+ $vc = 'vendor' if $self->{"vc"} eq "vendor";
+ die "invalid use of get_lists, need 'vc'";
+ $vc_id = $self->{"${vc}_id"};
+ }
if ($params{"contacts"}) {
$self->_get_contacts($dbh, $vc_id, $params{"contacts"});
# compatibility.
$self->{$_} = $defaults->$_ for qw(company address taxnumber co_ustid duns sepa_creditor_id);
- # set shipto from billto unless set
- my $has_shipto = any { $self->{"shipto$_"} } qw(name street zipcode city country contact);
- if (!$has_shipto && ($self->{type} =~ m/^(?:purchase_order|request_quotation)$/)) {
- $self->{shiptoname} = $defaults->company;
- $self->{shiptostreet} = $defaults->address;
+ $self->{"myconfig_${_}"} = $::myconfig{$_} for grep { $_ ne 'dbpasswd' } keys %::myconfig;
+
+ if (!$self->{employee_id}) {
+ $self->{"employee_${_}"} = $::myconfig{$_} for qw(email tel fax name signature);
+ $self->{"employee_${_}"} = $defaults->$_ for qw(address businessnumber co_ustid company duns sepa_creditor_id taxnumber);
+ }
+
+ # Load shipping address from database if shipto_id is set.
+ if ($self->{shipto_id}) {
+ my $shipto = SL::DB::Shipto->new(shipto_id => $self->{shipto_id})->load;
+ $self->{$_} = $shipto->$_ for grep { m{^shipto} } map { $_->name } @{ $shipto->meta->columns };
}
my $language = $self->{language} ? '_' . $self->{language} : '';
$output_longdates = 1;
}
+ $self->{myconfig_output_dateformat} = $output_dateformat;
+ $self->{myconfig_output_longdates} = $output_longdates;
+ $self->{myconfig_output_numberformat} = $output_numberformat;
+
# Retrieve accounts for tax calculation.
IC->retrieve_accounts(\%::myconfig, $self, map { $_ => $self->{"id_$_"} } 1 .. $self->{rowcount});
$::myconfig{numberformat} = $saved_numberformat;
}
+sub create_email_signature {
+
+ my $client_signature = $::instance_conf->get_signature;
+ my $user_signature = $::myconfig{signature};
+
+ my $signature = '';
+ if ( $client_signature or $user_signature ) {
+ $signature = "\n\n-- \n";
+ $signature .= $user_signature . "\n" if $user_signature;
+ $signature .= $client_signature . "\n" if $client_signature;
+ };
+ return $signature;
+
+};
+
sub layout {
my ($self) = @_;
$::lxdebug->enter_sub;