From 37ac9c4f5754a1398b7bc354db716be828f04253 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 8 Nov 2013 16:47:27 -0800 Subject: [PATCH] option to make ship_company field available again, #25782 --- 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 + httemplate/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 diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index eed84fc52..b368c8fbc 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 840df7558..2314c02c1 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 d768f8406..5126fea6b 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1662,7 +1662,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' }; @@ -1724,6 +1724,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') @@ -1741,11 +1742,13 @@ sub check { || $self->ut_currencyn('currency') ; - 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 16db71271..215fdc2bc 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 d597d0bc2..8a3d6f918 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -73,6 +73,7 @@ ><% mt('same as billing address') |h %>
+ <& 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 000000000..badb5e8cd --- /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; + diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html index 8fe3a9ebb..294b7babb 100644 --- a/httemplate/view/cust_main/contacts.html +++ b/httemplate/view/cust_main/contacts.html @@ -41,7 +41,14 @@ % } -% } # if $this eq 'bill' +% } elsif ( $this eq 'ship' ) { +% if ( $cust_main->ship_company ) { # mostly obsolete these days... + + + + +% } +% } % # now the actual address -- 2.11.0
<% $cust_main->company |h %>
<% mt('Company') |h %><% $cust_main->ship_company |h %>
<% mt('Address') |h %>