From: Ivan Kohler Date: Sat, 9 Nov 2013 20:03:52 +0000 (-0800) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=0c04fc78f66d17a5736686757cd8f838715c8380;hp=9545a93c2cb4ee76c4226e0eacf9a6fb9c169adf Merge branch 'master' of git.freeside.biz:/home/git/freeside --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 81669dc65..6b9aab213 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2055,6 +2055,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/Schema.pm b/FS/FS/Schema.pm index 8ba60200e..ae9cb4174 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -4903,7 +4903,7 @@ sub tables_hashref { #currently only u4: # terminating number (as opposed to dialed destination) - 'dst_term', 'varchar', '', $char_d, \"''", '', + 'dst_term', 'varchar', 'NULL', $char_d, '', '', #these don't seem to be logged by most of the SQL cdr_* modules #except tds under sql-illegal names, so; 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/bin/restore-ship_company b/bin/restore-ship_company new file mode 100644 index 000000000..cee700962 --- /dev/null +++ b/bin/restore-ship_company @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +use FS::UID 'adminsuidsetup'; +use FS::Record qw(qsearch qsearchs dbh); +use FS::cust_main; +my $user = shift or die "Usage: + restore-ship_company username [ max-age ] +"; +adminsuidsetup($user); + +$FS::UID::AutoCommit = 1; +local $FS::cust_main::import = 1; + +my $days = shift || 30; +my $time = time - (86400*$days); # by default, only restore within the last + # 30 days +foreach my $cust_main (qsearch('cust_main', { ship_company => '' })) { + my $custnum = $cust_main->custnum; + my $last_h = qsearchs({ + table => 'h_cust_main', + extra_sql => " WHERE custnum = $custnum". + " AND ship_company IS NOT NULL". + " AND history_date >= $time", + order_by => " ORDER BY history_date DESC LIMIT 1", + }); + next if !$last_h; + print "$custnum\t".$last_h->ship_company."\n"; + $cust_main->set('ship_company' => $last_h->ship_company); + my $error = $cust_main->replace; + warn "Error setting service company for customer #$custnum:\n $error\n" + if $error; +} 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
<% $cust_main->company |h %>
<% mt('Company') |h %><% $cust_main->ship_company |h %>
<% mt('Address') |h %>