Revision 5a07eafc
Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt
SL/DB/VC.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
require Exporter;
|
|
5 |
use List::MoreUtils qw(uniq);
|
|
6 | 6 |
use SL::DBUtils; |
7 | 7 |
|
8 |
require Exporter; |
|
9 |
|
|
8 | 10 |
our @ISA = qw(Exporter); |
9 |
our @EXPORT = qw(get_credit_remaining); |
|
11 |
our @EXPORT = qw(get_credit_remaining get_all_email_addresses);
|
|
10 | 12 |
|
11 | 13 |
sub get_credit_remaining { |
12 | 14 |
my $vc = shift; |
... | ... | |
50 | 52 |
return $credit_remaining; |
51 | 53 |
} |
52 | 54 |
|
55 |
sub get_all_email_addresses { |
|
56 |
my ($self) = @_; |
|
57 |
|
|
58 |
my $is_sales = ref $self eq 'SL::DB::Customer'; |
|
59 |
|
|
60 |
my @addresses; |
|
61 |
|
|
62 |
# billing address |
|
63 |
push @addresses, $self->$_ for qw(email cc bcc); |
|
64 |
if ($is_sales) { |
|
65 |
push @addresses, $self->$_ for qw(delivery_order_mail invoice_mail); |
|
66 |
} |
|
67 |
|
|
68 |
# additional billing addresses |
|
69 |
if ($is_sales) { |
|
70 |
foreach my $additional_billing_address (@{ $self->additional_billing_addresses }) { |
|
71 |
push @addresses, $additional_billing_address->$_ for qw(email); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
# contacts |
|
76 |
foreach my $contact (@{ $self->contacts }) { |
|
77 |
push @addresses, $contact->$_ for qw(cp_email cp_privatemail); |
|
78 |
} |
|
79 |
|
|
80 |
# shiptos |
|
81 |
foreach my $shipto (@{ $self->shipto }) { |
|
82 |
push @addresses, $shipto->$_ for qw(shiptoemail); |
|
83 |
} |
|
84 |
|
|
85 |
# remove empty ones and duplicates |
|
86 |
@addresses = grep { $_ } @addresses; |
|
87 |
@addresses = uniq @addresses; |
|
88 |
|
|
89 |
|
|
90 |
return \@addresses; |
|
91 |
} |
|
92 |
|
|
53 | 93 |
1; |
Auch abrufbar als: Unified diff
"alle" E-Mail-Adressen per Anhaken als Empfänger hinzufügen können