have the UI use full country names, and state names outside the US...
[freeside.git] / httemplate / edit / cust_main / select-country.html
index 014effd..3941f2f 100644 (file)
@@ -26,7 +26,7 @@
 
   function <%= $opt{'prefix'} %>country_changed(what, callback) {
 
-    country = what.options[what.selectedIndex].text;
+    country = what.options[what.selectedIndex].value;
 
     function <%= $opt{'prefix'} %>update_states(states) {
 
@@ -36,8 +36,8 @@
 
       // add the new states
       var statesArray = eval('(' + states + ')' );
-      for ( var s = 0; s < statesArray.length; s++ ) {
-          var stateLabel = statesArray[s];
+      for ( var s = 0; s < statesArray.length; s=s+2 ) {
+          var stateLabel = statesArray[s+1];
           if ( stateLabel == "" )
               stateLabel = '(n/a)';
           opt(what.form.<%= $opt{'prefix'} %>state, statesArray[s], stateLabel);
 <SELECT NAME="<%= $opt{'prefix'} %>country" onChange="<%= $opt{'prefix'} %>country_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>>
 
 <% foreach my $country (
-     sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b }
+     sort {    ($b eq $countrydefault) <=> ($a eq $countrydefault)
+            or code2country($a) cmp code2country($b) }
      map { $_->country }
      qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', )
    ) {
 %>
 
-  <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= $country %>
+  <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= code2country($country). " ($country)" %>
 
 <% } %>