X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCommon.pm;h=15f8f7b93f2d94ba9b30ea53a7ec16425207cefe;hb=13aed1fc2af8e71108872823e9a782f0d18e8017;hp=b70378e66c7d795f4f166353aeab15398d9d8c4a;hpb=98b64fe1e380c232428d63cea0eb5f44b1d1a2c3;p=kivitendo-erp.git diff --git a/SL/Common.pm b/SL/Common.pm index b70378e66..15f8f7b93 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -342,6 +342,11 @@ sub get_vc_details { $query = qq|SELECT * FROM shipto WHERE (trans_id = ?)|; $form->{SHIPTO} = selectall_hashref_query($form, $dbh, $query, $vc_id); + if ($vc eq 'customer') { + $query = qq|SELECT * FROM additional_billing_addresses WHERE (customer_id = ?)|; + $form->{ADDITIONAL_BILLING_ADDRESSES} = selectall_hashref_query($form, $dbh, $query, $vc_id); + } + $query = qq|SELECT * FROM contacts WHERE (cp_cv_id = ?)|; $form->{CONTACTS} = selectall_hashref_query($form, $dbh, $query, $vc_id); @@ -539,16 +544,16 @@ sub copy_file_to_webdav_folder { foreach my $item (qw(tmpdir tmpfile type)){ next if $form->{$item}; $::lxdebug->message(LXDebug::WARN(), 'Missing parameter:' . $item); - $::form->error($::locale->text("Missing parameter for WebDAV file copy")); + $::lxdebug->leave_sub(); + return $::locale->text("Missing parameter for WebDAV file copy"); } my ($webdav_folder, $document_name) = get_webdav_folder($form); if (! $webdav_folder){ - $::lxdebug->leave_sub(); $::lxdebug->message(LXDebug::WARN(), 'Cannot check correct WebDAV folder'); - $::form->error($::locale->text("Cannot check correct WebDAV folder")); - return undef; + $::lxdebug->leave_sub(); + return $::locale->text("Cannot check correct WebDAV folder") } $complete_path = File::Spec->catfile($form->{cwd}, $webdav_folder); @@ -562,7 +567,11 @@ sub copy_file_to_webdav_folder { chdir($current_dir); } - opendir my $dh, $complete_path or die "Could not open $complete_path: $!"; + my $dh; + if (!opendir $dh, $complete_path) { + $::lxdebug->leave_sub(); + return "Could not open $complete_path: $!"; + } my ($newest_name, $newest_time); while ( defined( my $file = readdir( $dh ) ) ) { @@ -584,15 +593,19 @@ sub copy_file_to_webdav_folder { return; } + $form->{attachment_filename} ||= $form->generate_attachment_filename; + my $timestamp = get_current_formatted_time(); - my $new_file = File::Spec->catfile($form->{cwd}, $webdav_folder, $form->generate_attachment_filename()); + my $new_file = File::Spec->catfile($form->{cwd}, $webdav_folder, $form->{attachment_filename}); $new_file =~ s{(.*)\.}{$1$timestamp\.}; if (!File::Copy::copy($current_file, $new_file)) { $::lxdebug->message(LXDebug::WARN(), "Copy file from $current_file to $new_file failed: $ERRNO"); - $::form->error($::locale->text("Copy file from #1 to #2 failed: #3", $current_file, $new_file, $ERRNO)); + $::lxdebug->leave_sub(); + return $::locale->text("Copy file from #1 to #2 failed: #3", $current_file, $new_file, $ERRNO); } + return; $::lxdebug->leave_sub(); }