[freeside-commits] branch FREESIDE_4_BRANCH updated. a5374d6ff776a26343e09b84204acd19b7d85e51

Mark Wells mark at 420.am
Mon Nov 30 15:48:21 PST 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  a5374d6ff776a26343e09b84204acd19b7d85e51 (commit)
       via  d57a06db83fe2f6770eb61ec153a4bb216df37b9 (commit)
       via  f3133ea0a9f2d017dbf8f5a156946db504a63e72 (commit)
       via  318f5f84e954d09f7dea2ab98793e812820bef48 (commit)
      from  d1025e8f571644fadeb476f8ec631c4ba7501c85 (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 a5374d6ff776a26343e09b84204acd19b7d85e51
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Nov 30 15:40:03 2015 -0800

    fix contact editing through edit/cust_main.cgi, originally from #23741?

diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 4c09d8c..dcf642b 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -361,9 +361,10 @@ for an "m2" multiple entry field as passed by edit/cust_main.cgi
 sub insert {
   my $self = shift;
   my $cust_pkgs = @_ ? shift : {};
-  my $invoicing_list = $_[0];
-  if ( $invoicing_list and ref($invoicing_list) eq 'ARRAY' ) {
-    shift;
+  my $invoicing_list;
+  if ( $_[0] and ref($_[0]) eq 'ARRAY' ) {
+    warn "cust_main::insert using deprecated invoicing list argument";
+    $invoicing_list = shift;
   }
   my %options = @_;
   warn "$me insert called with options ".
@@ -555,6 +556,25 @@ sub insert {
   warn "  setting contacts\n"
     if $DEBUG > 1;
 
+  $invoicing_list ||= $options{'invoicing_list'};
+  if ( $invoicing_list ) {
+
+    $invoicing_list = join(',', @$invoicing_list) if ref $invoicing_list;
+    my $contact = FS::contact->new({
+      'custnum'       => $self->get('custnum'),
+      'last'          => $self->get('last'),
+      'first'         => $self->get('first'),
+      'emailaddress'  => $invoicing_list,
+      'invoice_dest'  => 'Y',
+    });
+    my $error = $contact->insert;
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error;
+    }
+
+  }
+
   if ( my $contact = delete $options{'contact'} ) {
 
     foreach my $c ( @$contact ) {
@@ -578,27 +598,6 @@ sub insert {
       return $error;
     }
   }
-  
-  if ( $invoicing_list ) {
-    warn "FS::cust_main::insert setting invoice destinations via invoicing_list\n"
-      if $DEBUG;
-
-    # okay, for now we'll still allow setting the contact this way
-    $invoicing_list = join(',', @$invoicing_list) if ref $invoicing_list;
-    my $contact = FS::contact->new({
-      'custnum'       => $self->get('custnum'),
-      'last'          => $self->get('last'),
-      'first'         => $self->get('first'),
-      'emailaddress'  => $invoicing_list,
-      'invoice_dest'  => 'Y',
-    });
-    my $error = $contact->insert;
-    if ( $error ) {
-      $dbh->rollback if $oldAutoCommit;
-      return $error;
-    }
-
-  }
 
   warn "  setting cust_payby\n"
     if $DEBUG > 1;
@@ -1282,12 +1281,21 @@ INVOICING_LIST_ARYREF: If you pass an arrayref to this method, it will be
 set as the contact email address for a default contact with the same name as
 the customer.
 
-Currently available options are: I<tax_exemption>.
+Currently available options are: I<tax_exemption>, I<cust_payby_params>, 
+I<contact_params>, I<invoicing_list>.
 
 The I<tax_exemption> option can be set to an arrayref of tax names or a hashref
 of tax names and exemption numbers.  FS::cust_main_exemption records will be
 deleted and inserted as appropriate.
 
+I<cust_payby_params> and I<contact_params> can be hashrefs of named parameter
+groups (describing the customer's payment methods and contacts, respectively)
+in the style supported by L<FS::o2m_Common/process_o2m>. See L<FS::cust_payby>
+and L<FS::contact> for the fields these can contain.
+
+I<invoicing_list> is a synonym for the INVOICING_LIST_ARYREF parameter, and
+should be used instead if possible.
+
 =cut
 
 sub replace {
@@ -1348,8 +1356,17 @@ sub replace {
     $self->set($l.'num', $new_loc->locationnum);
   } #for $l
 
+  my $invoicing_list;
   if ( @param && ref($param[0]) eq 'ARRAY' ) { # INVOICING_LIST_ARYREF
-    my $invoicing_list = shift @param;
+    warn "cust_main::replace: using deprecated invoicing list argument";
+    $invoicing_list = shift @param;
+  }
+
+  my %options = @param;
+
+  $invoicing_list ||= $options{invoicing_list};
+
+  if ( $invoicing_list ) {
     my $email = '';
     foreach (@$invoicing_list) {
       if ($_ eq 'POST') {
@@ -1438,8 +1455,6 @@ sub replace {
 
   }
 
-  my %options = @param;
-
   my $tax_exemption = delete $options{'tax_exemption'};
   if ( $tax_exemption ) {
 
@@ -1497,6 +1512,24 @@ sub replace {
 
   }
 
+  if ( my $contact_params = delete $options{'contact_params'} ) {
+
+    # this can potentially replace contacts that were created by the
+    # invoicing list argument, but the UI shouldn't allow both of them
+    # to be specified
+
+    my $error = $self->process_o2m(
+      'table'         => 'contact',
+      'fields'        => FS::contact->cgi_contact_fields,
+      'params'        => $contact_params,
+    );
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error;
+    }
+
+  }
+
   unless ( $import || $skip_fuzzyfiles ) {
     $error = $self->queue_fuzzyfiles_update;
     if ( $error ) {
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index a9f7cf4..747de20 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -156,24 +156,23 @@ if ( $curuser->access_right('Edit customer tax exemptions') ) {
   };
 }
 
-$options{'contact_params'} = scalar($cgi->Vars);
 $options{'cust_payby_params'} = scalar($cgi->Vars);
 
-my $email;
-
 if ( $cgi->param('residential_commercial') eq 'Residential' ) {
 
-  $email = $cgi->param('invoice_email') || '';
+  my $email = $cgi->param('invoice_email') || '';
   if ( length($email) == 0 and $conf->exists('cust_main-require_invoicing_list_email', $agentnum) ) {
     $error = 'Email address required';
   }
 
+  $options{'invoicing_list'} = [ $email ];
   # XXX really should include the phone numbers in here also
 
 } else {
 
-  # contact UI is enabled; everything will be passed through via
-  # contact_params
+  # contact UI is enabled
+  $options{'contact_params'} = scalar($cgi->Vars);
+
   if ($conf->exists('cust_main-require_invoicing_list_email', $agentnum)) {
     my $has_email = 0;
     foreach my $prefix (grep /^contactnum\d+$/, $cgi->param) {
@@ -296,7 +295,6 @@ if ( $new->custnum eq '' or $duplicate_of ) {
   else {
     # create the customer
     $error ||= $new->insert( \%hash,
-                             [ $email ],
                              %options,
                              prospectnum => scalar($cgi->param('prospectnum')),
                            );
@@ -334,9 +332,9 @@ if ( $new->custnum eq '' or $duplicate_of ) {
   local($FS::Record::DEBUG)    = $DEBUG if $DEBUG;
 
   local($Data::Dumper::Sortkeys) = 1;
-  warn Dumper({ new => $new, old => $old }) if $DEBUG;
+  warn Dumper({ new => $new, old => $old, options => \%options}) if $DEBUG;
 
-  $error ||= $new->replace( $old, [ $email ], %options );
+  $error ||= $new->replace( $old, %options );
 
   warn "$me returned from replace" if $DEBUG;
   

commit d57a06db83fe2f6770eb61ec153a4bb216df37b9
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Nov 30 15:35:32 2015 -0800

    make cust-email-high-visibility non-optional, and improve display of invoice delivery settings, #28226

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 641f925..eec719a 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5537,13 +5537,6 @@ and customer address. Include units.',
   },
   
   {
-    'key'         => 'cust-email-high-visibility',
-    'section'     => 'UI',
-    'description' => 'Move the invoicing e-mail address field to the top of the billing address section and highlight it.',
-    'type'        => 'checkbox',
-  },
-  
-  {
     'key'         => 'cust-edit-alt-field-order',
     'section'     => 'UI',
     'description' => 'An alternate ordering of fields for the New Customer and Edit Customer screens.',
diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css
index e2feb87..6432293 100644
--- a/httemplate/elements/freeside.css
+++ b/httemplate/elements/freeside.css
@@ -321,6 +321,12 @@ td.label {
   color: #ff0000;
 }
 
+table .error {
+  font-weight: bold;
+  font-size: medium;
+  color: #ff0000;
+}
+
 div#overDiv {
   box-shadow: #333333 1px 1px 2px;
 }
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index 0c9f74a..97b4baf 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -1,6 +1,8 @@
 <FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
 % my $yes = emt('yes');
 % my $no = emt('no');
+% my $allowed = emt('allowed');
+% my $refused = emt('refused');
 
 <TABLE CLASS="fsinnerbox">
 
@@ -162,34 +164,36 @@
 % }
 <TR>
   <TH ALIGN="right"><% mt('Postal mail invoices') |h %></TH>
-  <TD>
-    <% ( grep { $_ eq 'POST' } @invoicing_list )
-         ? $yes. ( $cust_main->invoice_attn
+% if ( $cust_main->postal_invoice ) {
+  <TD><% $yes .  ( $cust_main->invoice_attn
                      ? ', attn: '. $cust_main->invoice_attn
                      : ''
-                 )
-         : $no
-    %>
+                 ) %>
+  </TD>
+% } elsif ( $cust_main->invoice_noemail
+%           or scalar(@invoicing_list) == 0 ) {
+%   # alert the user that this customer has no way to receive an invoice
+  <TD CLASS="error"><% $no %></TD>
+% } else {
+  <TD><% $no %></TD>
+% }
   </TD>
 </TR>
 <TR>
   <TH ALIGN="right"><% mt('Email invoices') |h %></TH>
-  <TD>
-    <% $cust_main->invoice_noemail ? $no : $yes %>
-  </TD>
+% if ( $cust_main->invoice_noemail and ! $cust_main->postal_invoice ) {
+%   # as above, warn if the customer refuses both email and postal invoices
+  <TD CLASS="error"><% $refused %></TD>
+% } else {
+  <TD><% $cust_main->invoice_noemail ? $refused : $allowed %></TD>
+% }
 </TR>
-% unless ( $conf->exists('cust-email-high-visibility')) {
 <TR>
-  <TH ALIGN="right"><% mt('Email address(es)') |h %></TH>
+  <TH ALIGN="right"><% mt('Other email notices') |h %></TH>
   <TD>
-    <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
-%   if ( $cust_main->message_noemail ) {
-    <BR>
-    <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
-%   }
+    <% $cust_main->message_noemail ? $refused : $allowed %>
   </TD>
 </TR>
-% }
 <TR>
   <TH ALIGN="right"><% mt('Invoice terms') |h %></TH>
   <TD>
@@ -272,7 +276,7 @@
 <%init>
 
 my( $cust_main ) = @_;
-my @invoicing_list = $cust_main->invoicing_list;
+my @invoicing_list = $cust_main->invoicing_list_emailonly;
 my $conf = new FS::Conf;
 my $money_char = $conf->config('money_char') || '$';
 
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index e3d5d63..a41a483 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -43,15 +43,36 @@
                     $cust_main->spouse_last, $cust_main->spouse_first) %>
     </TD>
   </TR>
-% }
-%   if ( $conf->exists('cust-email-high-visibility') ) {
+%   }
+%
+%   # invoicing email
+%   if ( scalar(@invoicing_list) == 1 ) { # typical individual user; show here
   <TR>
-    <TH ALIGN="right"><% mt('Email address(es)') |h %></TH>
-    <TD BGCOLOR="#ffff00">
-      <% $cust_main->invoicing_list_emailonly_scalar || $no %>
+    <TH ALIGN="right"><% mt('Email address') |h %></TH>
+    <TD>
+      <% $invoicing_list[0] %>
     </TD>
   </TR>
-%   }
+%   } elsif ( scalar(@invoicing_list) > 1 ) {
+%   # business customer with a contact list
+%   # show nothing here
+%
+%   } else { # there is no invoice email for them
+  <TR>
+    <TH ALIGN="right"><% mt('Email address') |h %></TH>
+%     if ( !$cust_main->postal_invoice or
+%          $conf->exists('cust_main-require_invoicing_list_email',
+%                        $cust_main->agentnum)
+%     ) {
+%       # we need a contact email for this customer (either because that's
+%       # policy, or because otherwise they won't receive invoices) but we
+%       # don't have one.
+    <TD CLASS="error"><% emt('none') %></TD>
+%     } else {
+    <TD><% emt('no') %></TD>
+%     }
+%   } # end of invoicing email
+ 
 %   if ( $cust_main->company ) {
   <TR>
     <TH ALIGN="right"><% mt('Company') |h %></TH>
@@ -195,8 +216,6 @@ my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_st
 
 my $cust_main = shift;
 my $conf = new FS::Conf;
-my @invoicing_list = $cust_main->invoicing_list;
-my $no = emt('no');
+my @invoicing_list = $cust_main->invoicing_list_emailonly;
 
 </%init>
-

commit f3133ea0a9f2d017dbf8f5a156946db504a63e72
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Nov 28 18:28:22 2015 -0800

    debug

diff --git a/httemplate/misc/process/unhold_pkg.html b/httemplate/misc/process/unhold_pkg.html
index 6eec7ee..6940480 100755
--- a/httemplate/misc/process/unhold_pkg.html
+++ b/httemplate/misc/process/unhold_pkg.html
@@ -6,8 +6,6 @@
 </HTML>
 <%init>
 
-warn Dumper +{$cgi->Vars}; # XXX
-
 my $curuser = $FS::CurrentUser::CurrentUser;
 die "access denied"
   unless $curuser->access_right('Unsuspend customer package');
diff --git a/rt/share/html/Elements/ServiceFields b/rt/share/html/Elements/ServiceFields
index 70eea23..0fe5204 100644
--- a/rt/share/html/Elements/ServiceFields
+++ b/rt/share/html/Elements/ServiceFields
@@ -137,12 +137,10 @@ sub svc_location_attribute {
         my $Ticket = shift;
         my @svc_resolvers = ticket_svc_resolvers($Ticket);
         if (@svc_resolvers) {
-          warn '#' . $Ticket->id . ", service attribute $attribute\n";
             foreach my $s (@svc_resolvers) {
                 push @return, $s->ServiceInfo->{$attribute}, '<BR>';
             }
         } else {
-          warn '#' . $Ticket->id . ", customer attribute ship_$attribute\n";
             my @cust_resolvers = map $_->TargetURI->Resolver,
                                  @{ $Ticket->Customers->ItemsArrayRef };
             foreach my $c (@cust_resolvers) {
@@ -156,8 +154,6 @@ sub svc_location_attribute {
 
 </%once>
 <%init>
-use Data::Dumper;
-#warn Dumper(\@service_fields);
 
 my $arg = shift;
 if ( $arg eq 'Names' ) {

commit 318f5f84e954d09f7dea2ab98793e812820bef48
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Nov 28 17:24:47 2015 -0800

    fix display of contacts on customer basics tab, #25536

diff --git a/httemplate/view/cust_main/contacts_new.html b/httemplate/view/cust_main/contacts_new.html
index d55ee3d..a0dd301 100644
--- a/httemplate/view/cust_main/contacts_new.html
+++ b/httemplate/view/cust_main/contacts_new.html
@@ -78,7 +78,6 @@ my @cust_contacts = $cust_main->cust_contact;
 
 # residential customers have a default "invisible" contact, but if they
 # somehow get more than one contact, show them
-my $display = (length($cust_main->residential_commercial) > 0)
-              or ( scalar(@cust_contacts) > 1 );
+my $display = scalar(@cust_contacts) > 1;
 
 </%init>

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

Summary of changes:
 FS/FS/Conf.pm                               |    7 ---
 FS/FS/cust_main.pm                          |   89 ++++++++++++++++++---------
 httemplate/edit/process/cust_main.cgi       |   16 +++--
 httemplate/elements/freeside.css            |    6 ++
 httemplate/misc/process/unhold_pkg.html     |    2 -
 httemplate/view/cust_main/billing.html      |   40 ++++++------
 httemplate/view/cust_main/contacts.html     |   37 ++++++++---
 httemplate/view/cust_main/contacts_new.html |    3 +-
 rt/share/html/Elements/ServiceFields        |    4 --
 9 files changed, 125 insertions(+), 79 deletions(-)




More information about the freeside-commits mailing list