X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FForm.pm;h=a3990f9cb19db768b559cd0929cbc7552beedd84;hb=3cae447edd6ab367173b9aca8a168be236f9078c;hp=a11b7adb672b2ed45f7ae455fc6a5b30665c2a2c;hpb=9bf9acdff05a8047d0561c68cdd93b0a03deb568;p=kivitendo-erp.git
diff --git a/SL/Form.pm b/SL/Form.pm
index a11b7adb6..a3990f9cb 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -673,6 +673,7 @@ sub init_template {
'COMPILE_EXT' => '.tcc',
'COMPILE_DIR' => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
'ERROR' => 'templates/webpages/generic/exception.html',
+ 'ENCODING' => 'utf8',
})) || die;
}
@@ -694,7 +695,6 @@ sub show_generic_error {
}
if ($::request->is_ajax) {
- $::lxdebug->message(0, "trying to render AJAX response...");
SL::ClientJS->new
->error($error)
->render(SL::Controller::Base->new);
@@ -1080,8 +1080,9 @@ sub parse_template {
}
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;
@@ -1105,15 +1106,16 @@ sub parse_template {
$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/
\n/g;
- $myconfig->{signature} =~ s/\n/
\n/g;
- $mail->{message} .= "
\n--
\n$myconfig->{signature}\n
";
+ $full_signature =~ s/\n/
\n/g;
+ $mail->{message} .= $full_signature;
open(IN, "<", $self->{tmpfile})
or $self->error($self->cleanup . "$self->{tmpfile} : $!");
@@ -1129,9 +1131,7 @@ sub parse_template {
"name" => $attachment_name }];
}
- $mail->{message} =~ s/\r//g;
- $mail->{message} .= "\n-- \n$myconfig->{signature}";
-
+ $mail->{message} .= $full_signature;
}
my $err = $mail->send();
@@ -1955,8 +1955,8 @@ sub get_duedate {
my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id}) ->load
: $self->{customer_id} ? SL::DB::Customer ->new(id => $self->{customer_id})->load->payment
: $self->{vendor_id} ? SL::DB::Vendor ->new(id => $self->{vendor_id}) ->load->payment
- : croak("Missing field in \$::form: payment_id, customer_id or vendor_id");
-
+ : $self->{invdate} ? undef # no payment terms, therefore invdate == duedate
+ : croak("Missing field in \$::form: payment_id, customer_id, vendor_id or invdate");
my $duedate = $terms ? $terms->calc_date(reference_date => $reference_date)->to_kivitendo : undef;
$main::lxdebug->leave_sub();
@@ -3326,6 +3326,13 @@ sub prepare_for_printing {
# compatibility.
$self->{$_} = $defaults->$_ for qw(company address taxnumber co_ustid duns sepa_creditor_id);
+ $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);
+ }
+
# 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)$/)) {
@@ -3344,6 +3351,10 @@ sub prepare_for_printing {
$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});
@@ -3484,6 +3495,21 @@ sub reformat_numbers {
$::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;