summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2019-02-05 12:09:46 -0500
committerChristopher Burger <burgerc@freeside.biz>2019-02-05 12:09:46 -0500
commit1fe87434632f2627de487ca2aed6cfadea2c6061 (patch)
tree12070f532ffbde1cf5156433db6fc8b32ac9ae81 /FS/FS
parent9a74b15fe926c37f00added2d034d34bf6c95d7f (diff)
RT# 82094 - updated UI for bulk emailing from advanced customer reports
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/ConfDefaults.pm3
-rw-r--r--FS/FS/UI/Web.pm3
-rw-r--r--FS/FS/cust_main.pm95
3 files changed, 101 insertions, 0 deletions
diff --git a/FS/FS/ConfDefaults.pm b/FS/FS/ConfDefaults.pm
index 2c24b13..bd58934 100644
--- a/FS/FS/ConfDefaults.pm
+++ b/FS/FS/ConfDefaults.pm
@@ -56,6 +56,9 @@ sub cust_fields_avail { (
'Cust# | Cust. Status | Name | Company' =>
'custnum | Status | Last, First | Company',
+ 'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Mobile phone | Fax number | Contact email(s) | Invoices | Messages' =>
+ 'custnum | Status | Last, First | Company | (address) | (all phones) | Contact email(s)',
+
'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Mobile phone | Fax number | Invoicing email(s)' =>
'custnum | Status | Last, First | Company | (address) | (all phones) | Invoicing email(s)',
diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index 5412868..8a1d502 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -343,6 +343,9 @@ sub cust_header {
'(service) Latitude' => 'ship_latitude',
'(service) Longitude' => 'ship_longitude',
'Invoicing email(s)' => 'invoicing_list_emailonly_scalar',
+ 'Contact email(s)' => 'contact_list_emailonly',
+ 'Invoices' => 'contact_list_cust_invoice_only',
+ 'Messages' => 'contact_list_cust_message_only',
# FS::Upgrade::upgrade_config removes this from existing cust-fields settings
# 'Payment Type' => 'cust_payby',
'Current Balance' => 'current_balance',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 061fd69..8647c82 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -3150,6 +3150,101 @@ sub contact_list_email {
@emails;
}
+=item contact_list_email_destinations
+
+Returns a list of emails and whether they receive invoices or messages destinations.
+{ emailaddress => 'email.com', invoice => 'Y', message => '', }
+
+=cut
+
+sub contact_list_email_destinations {
+ my $self = shift;
+ warn "$me contact_list_email_destinations"
+ if $DEBUG;
+ return () if !$self->custnum; # not yet inserted
+ return map { $_ }
+ qsearch({
+ table => 'cust_contact',
+ select => 'emailaddress, cust_contact.invoice_dest as invoice, cust_contact.message_dest as message',
+ addl_from => ' JOIN contact USING (contactnum) '.
+ ' JOIN contact_email USING (contactnum)',
+ hashref => { 'custnum' => $self->custnum, },
+ order_by => 'ORDER BY custcontactnum DESC',
+ extra_sql => '',
+ });
+}
+
+=item contact_list_emailonly
+
+Returns an array of hashes containing the emails. Used for displaying contact email field in advanced customer reports.
+[ { data => 'email.com', }, ]
+
+=cut
+
+sub contact_list_emailonly {
+ my $self = shift;
+ warn "$me contact_list_emailonly called"
+ if $DEBUG;
+ my @emails;
+ foreach ($self->contact_list_email_destinations) {
+ my $data = [
+ {
+ 'data' => $_->emailaddress,
+ },
+ ];
+ push @emails, $data;
+ }
+ return \@emails;
+}
+
+=item contact_list_cust_invoice_only
+
+Returns an array of hashes containing cust_contact.invoice_dest. Does this email receive invoices. Used for displaying email Invoice field in advanced customer reports.
+[ { data => 'Yes', }, ]
+
+=cut
+
+sub contact_list_cust_invoice_only {
+ my $self = shift;
+ warn "$me contact_list_cust_invoice_only called"
+ if $DEBUG;
+ my @emails;
+ foreach ($self->contact_list_email_destinations) {
+ my $invoice = $_->invoice ? 'Yes' : 'No';
+ my $data = [
+ {
+ 'data' => $invoice,
+ },
+ ];
+ push @emails, $data;
+ }
+ return \@emails;
+}
+
+=item contact_list_cust_message_only
+
+Returns an array of hashes containing cust_contact.message_dest. Does this email receive message notifications. Used for displaying email Message field in advanced customer reports.
+[ { data => 'Yes', }, ]
+
+=cut
+
+sub contact_list_cust_message_only {
+ my $self = shift;
+ warn "$me contact_list_cust_message_only called"
+ if $DEBUG;
+ my @emails;
+ foreach ($self->contact_list_email_destinations) {
+ my $message = $_->message ? 'Yes' : 'No';
+ my $data = [
+ {
+ 'data' => $message,
+ },
+ ];
+ push @emails, $data;
+ }
+ return \@emails;
+}
+
=item referral_custnum_cust_main
Returns the customer who referred this customer (or the empty string, if