X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Flocation.html;h=873fe16213fac3538d8729527a418e9c4bd70ac7;hb=a72a10f754f7465121d6137bb3dcee0a21ea6443;hp=c606523f0eaa505edc075cc010772d7a18e74dfa;hpb=65befdb357c410bd24bf411551cd9d091d82b10d;p=freeside.git diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html index c606523f0..873fe1621 100644 --- a/httemplate/elements/location.html +++ b/httemplate/elements/location.html @@ -3,16 +3,18 @@ Example: include( '/elements/location.html', - 'object' => $cust_main, # or $cust_location - 'prefix' => $pre, #only for cust_main objects + 'object' => $cust_location + 'prefix' => $pre, # prefixed to form field names 'onchange' => $javascript, - 'disabled' => $disabled, - 'same_checked' => $same_checked, 'geocode' => $geocode, #passed through 'censustract' => $censustract, #passed through 'no_asterisks' => 0, #set true to disable the red asterisks next #to required fields 'address1_label' => 'Address', #label for address + 'enable_coords' => 1, #show latitude/longitude fields + 'enable_district' => 1, #show tax district field + 'enable_censustract' => 1, #show censustract field + ) @@ -31,7 +33,7 @@ Example: 'options' => \@location_kind_options, 'labels' => $location_kind_labels, 'curr_value' => scalar($cgi->param('location_kind')) - || $object->get($pre.'location_kind'), + || $object->get('location_kind'), ) %> @@ -40,12 +42,12 @@ Example: % } - <<%$th%> ALIGN="right"><%$r%><% $opt{'address1_label'} || emt('Address') %>> + <<%$th%> STYLE="width:16ex" ALIGN="right"><%$r%><% $opt{'address1_label'} || emt('Address') %>> @@ -62,7 +64,7 @@ Example: @@ -75,7 +77,7 @@ Example: @@ -83,7 +85,7 @@ Example: % my $location_type = scalar($cgi->param('location_type')) -% || $object->get($pre.'location_type'); +% || $object->get('location_type'); % #my $location_number = scalar($cgi->param('location_number')) % # || $object->get($pre.'location_number'); % @@ -130,7 +132,7 @@ Example: <% $style %> @@ -161,8 +163,8 @@ Example: <% $style %> @@ -175,13 +177,14 @@ Example: <% include('/elements/select-country.html', %select_hash ) %> +% if ( $opt{enable_coords} ) { - <% mt('Latitude') |h %> + <% mt('Latitude') |h %> <% $style %> > @@ -189,37 +192,59 @@ Example: <% $style %> > - - -% if ( !$pre ) { - % } else { -% if ( $pre eq 'ship_' && $conf->exists('cust_main-require_censustract') ) { - <<%$th%> ALIGN="right">Census tract
(automatic)> - - - - - -% } else { - -% } -% if ( $conf->config('tax_district_method') or $object->get('district') ) { - - <<%$th%> ALIGN="right">Tax district
(automatic)> - - - - +% foreach (qw(latitude longitude)) { + % } -% } +% } + + + + +% if ( $opt{enable_censustract} ) { + + Census tract + + + <% '(automatic)' %> + + +% } +% if ( $conf->config('tax_district_method') ) { +% if ( $opt{enable_district} ) { + + Tax district + + + <% '(automatic)' %> + + +% } else { + +% } +% } + +%# For address standardization: +%# keep a clean copy of the address so we know if we need +%# to re-standardize +% foreach (qw(address1 city state country zip latitude +% longitude censustract addr_clean) ) { + +% } +%# Placeholders + + <%init> my %opt = @_; @@ -233,16 +258,13 @@ my $conf = new FS::Conf; my $r = $opt{'no_asterisks'} ? '' : qq!* !; -#false laziness with ship state my $countrydefault = $conf->config('countrydefault') || 'US'; -$object->set($pre.'country', $countrydefault ) - unless $object->get($pre.'country'); - -my $statedefault = $conf->config('statedefault') +my $statedefault = $conf->config('statedefault') || ($countrydefault eq 'US' ? 'CA' : ''); -$object->set($pre.'state', $statedefault ) - unless $object->get($pre.'state') - || $object->get($pre.'country') ne $countrydefault; +$object ||= FS::cust_location->new({ + 'country' => $countrydefault, + 'state' => $statedefault, +}); my $alt_err = ($opt{'alt_format'} && !$disabled) ? $object->alternize : ''; @@ -255,8 +277,8 @@ push @address2_label_style, 'visibility:hidden' || ! $conf->exists('cust_main-require_address2') || ( !$pre && !$opt{'same_checked'} ); -my @counties = counties( $object->get($pre.'state'), - $object->get($pre.'country'), +my @counties = counties( $object->get('state'), + $object->get('country'), ); my @county_style = (); push @county_style, 'display:none' # 'visibility:hidden' @@ -276,10 +298,10 @@ my $county_style = : ''; my %select_hash = ( - 'city' => $object->get($pre.'city'), - 'county' => $object->get($pre.'county'), - 'state' => $object->get($pre.'state'), - 'country' => $object->get($pre.'country'), + 'city' => $object->get('city'), + 'county' => $object->get('county'), + 'state' => $object->get('state'), + 'country' => $object->get('country'), 'prefix' => $pre, 'onchange' => $onchange, 'disabled' => $disabled,