$user && !!trim($user->get_config_value('email'));
} @{ SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]) };
+
+ my $all_partner_email_addresses = $self->order->customervendor->get_all_email_addresses();
+
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 => \@employees_with_email,
+ ALL_PARTNER_EMAIL_ADDRESSES => $all_partner_email_addresses,
);
$self->js
$self->js_reset_order_and_item_ids_after_save;
my $email_form = delete $::form->{email_form};
+
+ if ($email_form->{additional_to}) {
+ $email_form->{to} = join ', ', grep { $_ } $email_form->{to}, @{$email_form->{additional_to}};
+ delete $email_form->{additional_to};
+ }
+
my %field_names = (to => 'email');
$::form->{ $field_names{$_} // $_ } = $email_form->{$_} for keys %{ $email_form };
use strict;
-require Exporter;
+use List::MoreUtils qw(uniq);
use SL::DBUtils;
+require Exporter;
+
our @ISA = qw(Exporter);
-our @EXPORT = qw(get_credit_remaining);
+our @EXPORT = qw(get_credit_remaining get_all_email_addresses);
sub get_credit_remaining {
my $vc = shift;
return $credit_remaining;
}
+sub get_all_email_addresses {
+ my ($self) = @_;
+
+ my $is_sales = ref $self eq 'SL::DB::Customer';
+
+ my @addresses;
+
+ # billing address
+ push @addresses, $self->$_ for qw(email cc bcc);
+ if ($is_sales) {
+ push @addresses, $self->$_ for qw(delivery_order_mail invoice_mail);
+ }
+
+ # additional billing addresses
+ if ($is_sales) {
+ foreach my $additional_billing_address (@{ $self->additional_billing_addresses }) {
+ push @addresses, $additional_billing_address->$_ for qw(email);
+ }
+ }
+
+ # contacts
+ foreach my $contact (@{ $self->contacts }) {
+ push @addresses, $contact->$_ for qw(cp_email cp_privatemail);
+ }
+
+ # shiptos
+ foreach my $shipto (@{ $self->shipto }) {
+ push @addresses, $shipto->$_ for qw(shiptoemail);
+ }
+
+ # remove empty ones and duplicates
+ @addresses = grep { $_ } @addresses;
+ @addresses = uniq @addresses;
+
+
+ return \@addresses;
+}
+
1;
};
my %files = _get_files_for_email_dialog();
+
+ my $all_partner_email_addresses;
+ $all_partner_email_addresses = SL::DB::Customer->load_cached($::form->{vc_id})->get_all_email_addresses() if 'customer' eq $::form->{vc};
+ $all_partner_email_addresses = SL::DB::Vendor ->load_cached($::form->{vc_id})->get_all_email_addresses() if 'vendor' eq $::form->{vc};
+
my $html = $::form->parse_html_template("common/_send_email_dialog", {
email_form => $email_form,
show_bcc => $::auth->assert('email_bcc', 'may fail'),
is_customer => $::form->{vc} eq 'customer',
is_invoice_mail => ($record_email && $::form->{type} eq 'invoice'),
ALL_EMPLOYEES => \@employees_with_email,
+ ALL_PARTNER_EMAIL_ADDRESSES => $all_partner_email_addresses,
});
print $::form->ajax_response_header, $html;
: 'is.pl';
my $email_form = delete $::form->{email_form};
+
+ if ($email_form->{additional_to}) {
+ $email_form->{to} = join ', ', grep { $_ } $email_form->{to}, @{$email_form->{additional_to}};
+ delete $email_form->{additional_to};
+ }
+
my %field_names = (to => 'email');
$::form->{ $field_names{$_} // $_ } = $email_form->{$_} for keys %{ $email_form };
</td>
</tr>
+ [%- IF ALL_PARTNER_EMAIL_ADDRESSES.size %]
+ [%- FOREACH email = ALL_PARTNER_EMAIL_ADDRESSES %]
+ <tr class="hidden" data-toggle-recipients="1">
+ <th align="right" nowrap>
+ [%- IF loop.first %]
+ [% LxERP.t8("Other recipients") %]
+ [%- END %]
+ </th>
+ <td>
+ [% P.checkbox_tag("email_form.additional_to[]", label=email, value=email, checked="0") %]
+ </td>
+ </tr>
+ [%- END %]
+ [%- END %]
+
[%- IF ALL_EMPLOYEES.size %]
<tr class="hidden" data-toggle-recipients="1">
<th align="right" nowrap>[% LxERP.t8("CC to Employee") %]</th>