[freeside-commits] branch master updated. 9427fea032c131bc2c000515853d4f1462b7deff

Christopher Burger burgerc at freeside.biz
Wed Feb 13 08:59:07 PST 2019


The branch, master has been updated
       via  9427fea032c131bc2c000515853d4f1462b7deff (commit)
       via  5ea21368e57b35d34f20f876e6b93f16975afb78 (commit)
       via  acb5db886076201922167d39d76fd9b3e9e54c9c (commit)
       via  1fe87434632f2627de487ca2aed6cfadea2c6061 (commit)
      from  9ad0cdfb307e346add9e3496cf3cbdc1eee4e7d8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9427fea032c131bc2c000515853d4f1462b7deff
Merge: 5ea21368e 9ad0cdfb3
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Feb 13 11:57:58 2019 -0500

    Merge branch 'master' of ssh://git.freeside.biz/home/git/freeside


commit 5ea21368e57b35d34f20f876e6b93f16975afb78
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Feb 13 11:57:15 2019 -0500

    RT# 82087 - added logging for decode json error

diff --git a/FS/FS/part_export/saisei.pm b/FS/FS/part_export/saisei.pm
index db42f6107..190f1ef33 100644
--- a/FS/FS/part_export/saisei.pm
+++ b/FS/FS/part_export/saisei.pm
@@ -371,7 +371,7 @@ sub get_rateplan_name {
   my $service_name = $svc_name ? $svc_name : $service_part->{Hash}->{svc};
 
   my $rateplan_name = $service_name . " " . $svc_broadband->{Hash}->{speed_down} . "-" . $svc_broadband->{Hash}->{speed_up};
-  $rateplan_name =~ s/\s/_/g;
+  $rateplan_name =~ s/\s/_/g; $rateplan_name =~ s/[^A-Za-z0-9\-_]//g;
 
   return $rateplan_name;
 }
@@ -410,37 +410,39 @@ sub api_call {
   $client->setHost('http://'.$self->{Hash}->{machine}.':'.$self->option('port'));
   $client->$method('/rest/top/configurations/running'.$path, $data, { "Content-type" => 'application/json'});
 
-  warn "Response Code is ".$client->responseCode()."\n" if $self->option('debug');
+  warn "Saisei Response Code is ".$client->responseCode()."\n" if $self->option('debug');
 
   my $result;
 
   if ($client->responseCode() eq '200' || $client->responseCode() eq '201') {
     eval { $result = decode_json($client->responseContent()) };
     unless ($result) {
-      $self->{'__saisei_error'} = "Error decoding json: $@";
+      $self->{'__saisei_error'} = "Error decoding json from Saisei";
+      warn "Saisei RC 201 Response Content is not json\n".$client->responseContent()."\n" if $self->option('debug');
       return;
     }
   }
   elsif ($client->responseCode() eq '404') {
     eval { $result = decode_json($client->responseContent()) };
     unless ($result) {
-      $self->{'__saisei_error'} = "Error decoding json: $@";
+      $self->{'__saisei_error'} = "Error decoding json from Saisei";
+      warn "Saisei RC 404 Response Content is not json\n".$client->responseContent()."\n" if $self->option('debug');
       return;
     }
     ## check if message is for empty hash.
     my($does_not_exist) = $result->{message} =~ /'(.*)' does not exist$/;
     $self->{'__saisei_error'} = "Error ".$result->{message} unless $does_not_exist;
-    warn "Response Content is\n".$client->responseContent."\n" if ($self->option('debug') && !$does_not_exist);
+    warn "Saisei Response Content is\n".$client->responseContent."\n" if ($self->option('debug') && !$does_not_exist);
     return;
   }
   elsif ($client->responseCode() eq '500') {
     $self->{'__saisei_error'} = "Can't connect to host during $method , received responce code: " . $client->responseCode() . " and message: " . $client->responseContent();
-    warn "Response Content is\n".$client->responseContent."\n" if $self->option('debug');
+    warn "Saisei Response Content is\n".$client->responseContent."\n" if $self->option('debug');
     return;
   }
   else {
     $self->{'__saisei_error'} = "Bad response from server during $method , received responce code: " . $client->responseCode() . " and message: " . $client->responseContent();
-    warn "Response Content is\n".$client->responseContent."\n" if $self->option('debug');
+    warn "Saisei Response Content is\n".$client->responseContent."\n" if $self->option('debug');
     return; 
   }
 

commit acb5db886076201922167d39d76fd9b3e9e54c9c
Merge: 1fe874346 d276a88f9
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Feb 12 15:15:37 2019 -0500

    Merge branch 'master' of ssh://git.freeside.biz/home/git/freeside


commit 1fe87434632f2627de487ca2aed6cfadea2c6061
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Feb 5 12:09:46 2019 -0500

    RT# 82094 - updated UI for bulk emailing from advanced customer reports

diff --git a/FS/FS/ConfDefaults.pm b/FS/FS/ConfDefaults.pm
index 2c24b137b..bd5893439 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 54128682e..8a1d50236 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 061fd69a3..8647c829a 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
diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html
index b631165dc..cf3ab1b48 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -372,6 +372,15 @@ if ( !$cgi->param('preview') ) {
     $body ||= $content->body;
   }
 
+  my $sql_query = "FS::$table"->search(\%search);
+  my $count_query = delete($sql_query->{'count_query'});
+  my $count_sth = dbh->prepare($count_query)
+    or die "Error preparing $count_query: ". dbh->errstr;
+  $count_sth->execute
+    or die "Error executing $count_query: ". $count_sth->errstr;
+  my $count_arrayref = $count_sth->fetchrow_arrayref;
+  $num_cust = $count_arrayref->[0];
+
 } else {
 
   my @checked_email_dest;
@@ -520,8 +529,8 @@ if ( my @in_classnums = $cgi->param('classnums') ) {
 $dest_ischecked{message} = 1 unless %dest_ischecked;
 
 my @optin_checkboxes = (
-  [ 'message' => { label => 'Message recipients' } ],
-  [ 'invoice' => { label => 'Invoice recipients' } ],
+  [ 'message' => { label => 'Message recipients', desc => 'send this notice to all message recipients for the '.$num_cust.' selected customers.' } ],
+  [ 'invoice' => { label => 'Invoice recipients', desc => 'send this notice to all invoice recipients for the '.$num_cust.' selected customers.' } ],
 );
 my @classnum_checkboxes = (
   [ '0' => { label => '(None)' }],
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index f6c6c62d8..4c7fa14aa 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -155,9 +155,10 @@ if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') )
   $uri->query_form( \%query_hash );
   my $query = $uri->query;
 
-  push @$menubar, emt('Email a notice to these customers') =>
-                    "${p}misc/email-customers.html?table=cust_main&$query",
-
+  push @$menubar, emt('Email a notice to these customers message recipients') =>
+                    "${p}misc/email-customers.html?table=cust_main&classnums=message&$query";
+  push @$menubar, emt('Email a notice to these customers invoice recipients') =>
+                    "${p}misc/email-customers.html?table=cust_main&classnums=invoice&$query";
 }
 
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ConfDefaults.pm                |  3 ++
 FS/FS/UI/Web.pm                      |  3 ++
 FS/FS/cust_main.pm                   | 95 ++++++++++++++++++++++++++++++++++++
 FS/FS/part_export/saisei.pm          | 16 +++---
 httemplate/misc/email-customers.html | 13 ++++-
 httemplate/search/cust_main.html     |  7 +--
 6 files changed, 125 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list