E-Mail-Versand: CC: nur kivi-Benutzer mit hinterlegter E-Mail-Adresse anzeigen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 12 Nov 2021 11:09:18 +0000 (12:09 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 12 Nov 2021 11:22:07 +0000 (12:22 +0100)
SL/Controller/Order.pm
bin/mozilla/io.pl

index cdae561..55c037d 100644 (file)
@@ -14,6 +14,7 @@ use SL::MIME;
 use SL::Util qw(trim);
 use SL::YAML;
 use SL::DB::AdditionalBillingAddress;
+use SL::DB::AuthUser;
 use SL::DB::History;
 use SL::DB::Order;
 use SL::DB::Default;
@@ -426,13 +427,17 @@ sub action_save_and_show_email_dialog {
 
   my %files = $self->get_files_for_email_dialog();
 
-  $self->{all_employees} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
+  my @employees_with_email = grep {
+    my $user = SL::DB::Manager::AuthUser->find_by(login => $_->login);
+    $user && !!trim($user->get_config_value('email'));
+  } @{ SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]) };
+
   my $dialog_html = $self->render('common/_send_email_dialog', { output => 0 },
                                   email_form    => $email_form,
                                   show_bcc      => $::auth->assert('email_bcc', 'may fail'),
                                   FILES         => \%files,
                                   is_customer   => $self->cv eq 'customer',
-                                  ALL_EMPLOYEES => $self->{all_employees},
+                                  ALL_EMPLOYEES => \@employees_with_email,
   );
 
   $self->js
index 1ce4c18..d0e1f57 100644 (file)
@@ -54,7 +54,9 @@ use SL::IO;
 use SL::File;
 use SL::PriceSource;
 use SL::Presenter::Part;
+use SL::Util qw(trim);
 
+use SL::DB::AuthUser;
 use SL::DB::Contact;
 use SL::DB::Currency;
 use SL::DB::Customer;
@@ -2113,7 +2115,10 @@ sub show_sales_purchase_email_dialog {
     $body_params{fallback_translation_type} = "preset_text_invoice";
   }
 
-  $::form->{all_employees} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
+  my @employees_with_email = grep {
+    my $user = SL::DB::Manager::AuthUser->find_by(login => $_->login);
+    $user && !!trim($user->get_config_value('email'));
+  } @{ SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]) };
 
   my $email_form = {
     to                  => $email,
@@ -2131,7 +2136,7 @@ sub show_sales_purchase_email_dialog {
     FILES           => \%files,
     is_customer     => $::form->{vc} eq 'customer',
     is_invoice_mail => ($record_email && $::form->{type} eq 'invoice'),
-    ALL_EMPLOYEES   => $::form->{all_employees},
+    ALL_EMPLOYEES   => \@employees_with_email,
   });
 
   print $::form->ajax_response_header, $html;