X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main%2Fchoose_tax_location.html;h=be93a5de8ff997cb5117c8295325ad2b91460a2d;hb=55f003404af6a2416571138356d11c5ad3755e58;hp=23fdbf282116833c4afaf3059869006087bad3a6;hpb=4e77f6927631e226e13da84082be66867b71330f;p=freeside.git diff --git a/httemplate/edit/cust_main/choose_tax_location.html b/httemplate/edit/cust_main/choose_tax_location.html index 23fdbf282..be93a5de8 100644 --- a/httemplate/edit/cust_main/choose_tax_location.html +++ b/httemplate/edit/cust_main/choose_tax_location.html @@ -4,17 +4,21 @@

- - + +
@@ -34,23 +38,27 @@ my $conf = new FS::Conf; my $have_selected = 0; -my ($data_vendor) = $cgi->param('data_vendor') =~ /^([-\w]+)$/; -my ($city) = $cgi->param('city') =~ /^([\w ]+)$/; -my ($state) = $cgi->param('state') =~ /^(\w+)$/; -my ($zip) = $cgi->param('zip') =~ /^([-\w]+)$/; +my %location = (); -my($zip5, $zip4) = split('-', $zip); +($location{data_vendor}) = $cgi->param('data_vendor') =~ /^([-\w]+)$/; +($location{city}) = $cgi->param('city') =~ /^([\w ]+)$/; +($location{state}) = $cgi->param('state') =~ /^(\w+)$/; +($location{zip}) = $cgi->param('zip') =~ /^([-\w ]+)$/; +($location{country}) = $cgi->param('country') =~ /^([\w ]+)$/; -my $hashref = { data_vendor => $data_vendor, - #city => $city, - #state => $state, - zip => $zip5, - }; -#my @keys = qw ( city state zip ); -my @keys = qw ( zip ); +my($zip5, $zip4) = split('-', $location{zip}); + +#only support US & CA +my $hashref = { 'data_vendor' => $location{data_vendor} }; +$hashref->{zip} = $location{country} eq 'CA' ? substr($zip5,0,1) : $zip5, + +my @keys = keys(%$hashref); my @cust_tax_location = (); until ( @cust_tax_location ) { - @cust_tax_location = qsearch( 'cust_tax_location', $hashref ); + @cust_tax_location = qsearch({ table => 'cust_tax_location', + hashref => $hashref, + order_by => 'LIMIT 50', + }); last unless scalar(@keys); delete $hashref->{ shift @keys }; } @@ -62,7 +70,10 @@ foreach my $location (@cust_tax_location) { $max{$_} = ($length > $max{$_}) ? $length : $max{$_}; } } -$max{$_}++ foreach qw( city county state ); +foreach ( qw( city county state ) ) { + $max{$_} = $location{$_} if $location{$_} > $max{$_}; + $max{$_}++; +} my $header = '  '; $header .= $_. ' ' x ( $max{lc($_)} - length($_) )