'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
+
)
</%doc>
'options' => \@location_kind_options,
'labels' => $location_kind_labels,
'curr_value' => scalar($cgi->param('location_kind'))
- || $object->get($pre.'location_kind'),
+ || $object->get('location_kind'),
)
%>
</TD>
NAME = "<%$pre%>zip"
ID = "<%$pre%>zip"
VALUE = "<% $object->get('zip') |h %>"
- SIZE = 10
+ SIZE = 11
onChange = "<% $onchange %>"
<% $disabled %>
<% $style %>
<TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD>
</TR>
+% if ( $opt{enable_coords} ) {
<TR>
- <TD ALIGN="right"><% mt('Latitude') |h %></TH>
+ <TD ALIGN="right"><% mt('Latitude') |h %></TD>
<TD COLSPAN=7>
<INPUT TYPE = "text"
NAME = "<%$pre%>latitude"
>
</TD>
</TR>
+% } else {
+% foreach (qw(latitude longitude)) {
+<INPUT TYPE="hidden" NAME="<% $_ %>" ID="<% $_ %>" VALUE="<% $object->get($_) |h%>">
+% }
+% }
<INPUT TYPE="hidden" NAME="<%$pre%>coord_auto" VALUE="<% $object->coord_auto %>">
<INPUT TYPE="hidden" NAME="<%$pre%>geocode" VALUE="<% $object->geocode %>">
+<INPUT TYPE="hidden" NAME="<%$pre%>censustract" VALUE="<% $object->censustract %>">
<INPUT TYPE="hidden" NAME="<%$pre%>censusyear" VALUE="<% $object->censusyear %>">
-<TR>
% if ( $opt{enable_censustract} ) {
+<TR>
<TD ALIGN="right">Census tract</TD>
<TD COLSPAN=8>
<INPUT TYPE="text" SIZE=15
- NAME="<%$pre%>censustract"
- VALUE="<% $object->censustract %>">
+ NAME="enter_censustract"
+ VALUE="<% $object->censustract |h %>">
<% '(automatic)' %>
</TD>
-% } else {
- <INPUT TYPE="hidden" NAME="<%$pre%>censustract" VALUE="<% $object->censustract %>">
-% }
</TR>
-% if ( $conf->config('tax_district_method') ) {
+% }
+% if ( $opt{enable_district} and $conf->config('tax_district_method') ) {
<TR>
-% if ( $opt{enable_district} ) {
<TD ALIGN="right">Tax district</TD>
<TD COLSPAN=8>
<INPUT TYPE="text" SIZE=15
NAME="<%$pre%>district"
- VALUE="<% $object->district %>">
+ ID="<%$pre%>district"
+ VALUE="<% $object->district |h %>">
<% '(automatic)' %>
</TD>
-% } else {
- <INPUT TYPE="hidden" NAME="<%$pre%>district" VALUE="<% $object->district %>">
-% }
</TR>
+% } else {
+ <INPUT TYPE="hidden" ID="<%$pre%>" NAME="<%$pre%>district" VALUE="<% $object->district %>">
% }
+%# 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 district addr_clean) ) {
+<INPUT TYPE="hidden" NAME="old_<%$pre.$_%>" ID="old_<%$pre.$_%>" VALUE="<% $object->get($_) |h%>">
+% }
+%# Placeholders
+<INPUT TYPE="hidden" NAME="<%$pre%>cachenum" VALUE="">
+<INPUT TYPE="hidden" NAME="<%$pre%>addr_clean" VALUE="">
+
+<SCRIPT TYPE="text/javascript">
+// the strictly correct way to append something to window.onload
+window.addEventListener('load', function() {
+ var clear_coords_ids = [
+ '<%$pre%>latitude',
+ '<%$pre%>longitude',
+ 'enter_censustract',
+ '<%$pre%>district'
+ ];
+ function clear_coords() {
+ for (var i=0; i < clear_coords_ids.length; i++) {
+ var el = document.getElementById(clear_coords_ids[i]);
+ if ( el ) {
+ el.value = '';
+ }
+ }
+ }
+ var clear_coords_on_change = [
+ '<%$pre%>address1',
+ '<%$pre%>address2',
+ '<%$pre%>city',
+ '<%$pre%>state',
+ '<%$pre%>zip',
+ '<%$pre%>country',
+ ];
+ for (var i=0; i < clear_coords_on_change.length; i++) {
+ var el = document.getElementById(clear_coords_on_change[i]);
+ if ( el ) {
+ // because some of these already have onchange triggers
+ el.addEventListener('change', clear_coords);
+ }
+ }
+});
+</SCRIPT>
+
<%init>
my %opt = @_;