RT# 80488 Live look up of WA state tax district
[freeside.git] / httemplate / elements / tr-select-cust_location.html
index 47a917d..1e6cf5b 100644 (file)
@@ -2,24 +2,23 @@
 
 Example:
 
-  include('/elements/tr-select-cust_location.html',
-            'cgi'       => $cgi,
+  <& /elements/tr-select-cust_location.html,
+         'cgi'           => $cgi,
 
-            'cust_main'     => $cust_main,
-            #or
-            'prospect_main' => $prospect_main,
+         'cust_main'     => $cust_main,
+         #or
+         'prospect_main' => $prospect_main,
 
-            #optional
-            'empty_label'   => '(default service address)',
-         )
+         #optional
+         'empty_label'   => '(default service address)',
+  &>
 
 </%doc>
 
-<% include('/elements/xmlhttp.html',
-              'url'  => $p.'misc/location.cgi',
-              'subs' => [ 'get_location' ],
-           )
-%>
+<& /elements/xmlhttp.html,
+     'url'  => $p.'misc/location.cgi',
+     'subs' => [ 'get_location' ],
+&>
 
 <SCRIPT TYPE="text/javascript">
 
@@ -194,20 +193,33 @@ Example:
   </TD>
 </TR>
 
-<% include('/elements/location.html',
-             'object'       => $cust_location,
-             #'onchange' ?  probably not
-             'disabled'     => $disabled,
-             'no_asterisks' => 1,
-             'no_bold'      => $opt{'no_bold'},
-             'alt_format'   => $opt{'alt_format'},
-             'enable_coords'=> 1,
-             'enable_censustract' => 1,
-          )
-%>
+<& /elements/location.html,
+     'object'             => $cust_location,
+     #'onchange' ?  probably not
+     'disabled'           => $disabled,
+     'no_asterisks'       => 1,
+     'no_bold'            => $opt{'no_bold'},
+     'alt_format'         => $opt{'alt_format'},
+     'enable_coords'      => 1,
+     'enable_censustract' => 1,
+     'enable_district'    => $conf->exists('tax_district_method') ? 1 : 0,
+&>
+
 <SCRIPT TYPE="text/javascript">
-  locationnum_changed(document.getElementById('locationnum'));
+% if ( $prospect_main ) { # && ! $opt{is_optional} ) {
+
+    changeSelect(document.getElementById('country'), <% $cust_location->country || $countrydefault |js_string %>);
+
+    country_changed( document.getElementById('country'),
+                     fix_state_factory( <% $cust_location->state || $statedefault |js_string %>,
+                                        ''
+                                      )
+                   );
+% } elsif ( $locationnum != -1 ) {
+    locationnum_changed(document.getElementById('locationnum'));
+% }
 </SCRIPT>
+
 <%init>
 
 my $conf = new FS::Conf;
@@ -288,7 +300,7 @@ push @cust_location, $cust_location
 @cust_location = sort $location_sort grep !$_->disabled, @cust_location;
 
 $cust_location = $cust_location[0]
-  if ( $prospect_main )
+  if $prospect_main
   && !$opt{'is_optional'}
   && @cust_location;