[freeside-commits] branch FREESIDE_3_BRANCH updated. 3b172c8a7b7ca97bd71671dc358f29c5116948da

Mark Wells mark at 420.am
Fri Nov 8 16:47:32 PST 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  3b172c8a7b7ca97bd71671dc358f29c5116948da (commit)
      from  8adb2ffe88bff5cc7e9a62c113ff81c2662ae0eb (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 3b172c8a7b7ca97bd71671dc358f29c5116948da
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Nov 8 16:47:13 2013 -0800

    option to make ship_company field available again, #25782

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 0db674a..1fcb7ec 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2040,6 +2040,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'show_ship_company',
+    'section'     => 'UI',
+    'description' => 'Turns on display/collection of a "service company name" field for customers.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'show_ss',
     'section'     => 'UI',
     'description' => 'Turns on display/collection of social security numbers in the web interface.  Sometimes required by electronic check (ACH) processors.',
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 840df75..2314c02 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -581,11 +581,14 @@ sub print_generic {
   my $countrydefault = $conf->config('countrydefault') || 'US';
   foreach ( qw( address1 address2 city state zip country fax) ){
     my $method = 'ship_'.$_;
-    $invoice_data{"ship_$_"} = _latex_escape($cust_main->$method);
+    $invoice_data{"ship_$_"} = $escape_function->($cust_main->$method);
   }
-  foreach ( qw( contact company ) ) { #compatibility
-    $invoice_data{"ship_$_"} = _latex_escape($cust_main->$_);
+  if ( length($cust_main->ship_company) ) {
+    $invoice_data{'ship_company'} = $escape_function->($cust_main->ship_company);
+  } else {
+    $invoice_data{'ship_company'} = $escape_function->($cust_main->company);
   }
+  $invoice_data{'ship_contact'} = $escape_function->($cust_main->contact);
   $invoice_data{'ship_country'} = ''
     if ( $invoice_data{'ship_country'} eq $countrydefault );
   
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 4fe79a9..ed64cde 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1696,7 +1696,7 @@ sub queue_fuzzyfiles_update {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  foreach my $field ( 'first', 'last', 'company' ) {
+  foreach my $field ( 'first', 'last', 'company', 'ship_company' ) {
     my $queue = new FS::queue { 
       'job' => 'FS::cust_main::Search::append_fuzzyfiles_fuzzyfield'
     };
@@ -1758,6 +1758,7 @@ sub check {
     || $self->ut_snumbern('spouse_birthdate')
     || $self->ut_snumbern('anniversary_date')
     || $self->ut_textn('company')
+    || $self->ut_textn('ship_company')
     || $self->ut_anything('comments')
     || $self->ut_numbern('referral_custnum')
     || $self->ut_textn('stateid')
@@ -1774,11 +1775,13 @@ sub check {
     || $self->ut_enum('locale', [ '', FS::Locales->locales ])
   ;
 
-  my $company = $self->company;
-  $company =~ s/^\s+//; 
-  $company =~ s/\s+$//; 
-  $company =~ s/\s+/ /g;
-  $self->company($company);
+  foreach (qw(company ship_company)) {
+    my $company = $self->get($_);
+    $company =~ s/^\s+//; 
+    $company =~ s/\s+$//; 
+    $company =~ s/\s+/ /g;
+    $self->set($_, $company);
+  }
 
   #barf.  need message catalogs.  i18n.  etc.
   $error .= "Please select an advertising source."
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 16db712..215fdc2 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -21,6 +21,7 @@ $me = '[FS::cust_main::Search]';
 
 @fuzzyfields = (
   'cust_main.first', 'cust_main.last', 'cust_main.company', 
+  'cust_main.ship_company', # if you're using it
   'cust_location.address1',
   'contact.first',   'contact.last',
 );
@@ -321,6 +322,7 @@ sub smart_search {
     $sql .= " (    LOWER(cust_main.first)         = $q_value
                 OR LOWER(cust_main.last)          = $q_value
                 OR LOWER(cust_main.company)       = $q_value
+                OR LOWER(cust_main.ship_company)  = $q_value
             ";
 
     #address1 (yes, it's a kludge)
@@ -358,6 +360,7 @@ sub smart_search {
 
       my @hashrefs = (
         { 'company'      => { op=>'ILIKE', value=>"%$value%" }, },
+        { 'ship_company' => { op=>'ILIKE', value=>"%$value%" }, },
       );
 
       if ( $first && $last ) {
@@ -439,7 +442,7 @@ sub smart_search {
           %fuzopts
         );
      }
-      foreach my $field ( 'first', 'last', 'company' ) {
+      foreach my $field ( 'first', 'last', 'company', 'ship_company' ) {
         push @cust_main, FS::cust_main::Search->fuzzy_search(
           { $field => $value },
           %fuzopts
@@ -1193,6 +1196,7 @@ sub append_fuzzyfiles {
   #foreach my $fuzzy (@fuzzyfields) {
   foreach my $fuzzy ( 'cust_main.first', 'cust_main.last', 'cust_main.company', 
                       'cust_location.address1',
+                      'cust_main.ship_company',
                     ) {
 
     append_fuzzyfiles_fuzzyfield($fuzzy, shift);
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 2908848..0e33c15 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -73,6 +73,7 @@
     ><% mt('same as billing address') |h %>
     <DIV CLASS="fsinnerbox">
       <TABLE ID="table_ship_location" WIDTH="100%">
+      <& cust_main/before_ship_location.html, $cust_main &>
       <& /elements/location.html,
           object => $cust_main->ship_location,
           prefix => 'ship_',
diff --git a/httemplate/edit/cust_main/before_ship_location.html b/httemplate/edit/cust_main/before_ship_location.html
new file mode 100644
index 0000000..badb5e8
--- /dev/null
+++ b/httemplate/edit/cust_main/before_ship_location.html
@@ -0,0 +1,13 @@
+% if ( length($cust_main->ship_company) or
+%      $conf->exists('show_ship_company') ) {
+  <& /elements/tr-input-text.html,
+      label       => mt('Company'),
+      field       => 'ship_company',
+      curr_value  => $cust_main->ship_company,
+      colspan     => 6,
+  &>
+% }
+<%init>
+my $cust_main = shift;
+my $conf = FS::Conf->new;
+</%init>
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 8fe3a9e..294b7ba 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -41,7 +41,14 @@
     <TD COLSPAN=7 BGCOLOR="#ffffff"><% $cust_main->company |h %></TD>
   </TR>
 %   }
-% } # if $this eq 'bill'
+% } elsif ( $this eq 'ship' ) {
+%   if ( $cust_main->ship_company ) { # mostly obsolete these days...
+  <TR>
+    <TD ALIGN="right"><% mt('Company') |h %></TD>
+    <TD COLSPAN=7 BGCOLOR="#ffffff"><% $cust_main->ship_company |h %></TD>
+  </TR>
+%   }
+% }
 % # now the actual address
 <TR>
   <TD ALIGN="right"><% mt('Address') |h %></TD>

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

Summary of changes:
 FS/FS/Conf.pm                                      |    7 +++++++
 FS/FS/Template_Mixin.pm                            |    9 ++++++---
 FS/FS/cust_main.pm                                 |   15 +++++++++------
 FS/FS/cust_main/Search.pm                          |    6 +++++-
 httemplate/edit/cust_main.cgi                      |    1 +
 .../edit/cust_main/before_ship_location.html       |   13 +++++++++++++
 httemplate/view/cust_main/contacts.html            |    9 ++++++++-
 7 files changed, 49 insertions(+), 11 deletions(-)
 create mode 100644 httemplate/edit/cust_main/before_ship_location.html




More information about the freeside-commits mailing list