summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2006-04-03 09:46:57 +0000
committerivan <ivan>2006-04-03 09:46:57 +0000
commit929f432c766bbe3bdeed5b80818a12ddf6ec6339 (patch)
tree8129b16aa927db1e4182fcaaeea0c5ee9f050fd4 /httemplate
parent36693c42cbaca86f6957d5ed6794624810018bb3 (diff)
have the UI use full country names, and state names outside the US...
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/cust_main/contact.html2
-rw-r--r--httemplate/edit/cust_main/select-country.html11
-rw-r--r--httemplate/edit/cust_main/select-state.html13
-rw-r--r--httemplate/misc/states.cgi14
-rw-r--r--httemplate/view/cust_main/contacts.html4
5 files changed, 14 insertions, 30 deletions
diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html
index e0cd06f56..6e4f08957 100644
--- a/httemplate/edit/cust_main/contact.html
+++ b/httemplate/edit/cust_main/contact.html
@@ -96,7 +96,7 @@ my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
<TR>
<TH ALIGN="right"><%=$r%>Country</TH>
- <TD><%= include('select-country.html', %select_hash ) %></TD>
+ <TD COLSPAN=5><%= include('select-country.html', %select_hash ) %></TD>
</TR>
<TR>
diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html
index 014effd66..3941f2f93 100644
--- a/httemplate/edit/cust_main/select-country.html
+++ b/httemplate/edit/cust_main/select-country.html
@@ -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);
@@ -58,13 +58,14 @@
<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)" %>
<% } %>
diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html
index 98e685ab8..64da36ba7 100644
--- a/httemplate/edit/cust_main/select-state.html
+++ b/httemplate/edit/cust_main/select-state.html
@@ -9,17 +9,10 @@
<SELECT NAME="<%= $opt{'prefix'} %>state" onChange="<%= $opt{'prefix'} %>state_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>>
-<% foreach my $state (
- sort
- map { $_->state }
- qsearch( 'cust_main_county',
- { 'country' => $opt{'country'} },
- 'DISTINCT ON ( state ) *',
- )
- ) {
-%>
+<% tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); %>
+<% foreach my $state ( keys %states ) { %>
- <OPTION VALUE="<%= $state %>"<%= $state eq $opt{'state'} ? ' SELECTED' : '' %>><%= $state || '(n/a)' %>
+ <OPTION VALUE="<%= $state %>"<%= $state eq $opt{'state'} ? ' SELECTED' : '' %>><%= $states{$state} || '(n/a)' %>
<% } %>
diff --git a/httemplate/misc/states.cgi b/httemplate/misc/states.cgi
index cff2c9774..63c494d15 100644
--- a/httemplate/misc/states.cgi
+++ b/httemplate/misc/states.cgi
@@ -1,16 +1,6 @@
<%
my $country = $cgi->param('arg');
+ my @output = states_hash($country);
- my @states =
- sort
- map { s/[\n\r]//g; $_; }
- map { $_->state; }
- qsearch( 'cust_main_county',
- { 'country' => $country },
- 'DISTINCT ON ( state ) *',
- )
- ;
-
-
-%>[ <%= join(', ', map { qq("$_") } @states) %> ]
+%>[ <%= join(', ', map { qq("$_") } @output) %> ]
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 89926ea64..7aba11813 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -33,13 +33,13 @@ Billing address
<TD ALIGN="right">City</TD>
<TD BGCOLOR="#ffffff"><%= $cust_main->city %></TD>
<TD ALIGN="right">State</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->state %></TD>
+ <TD BGCOLOR="#ffffff"><%= state_label($cust_main->state, $cust_main->country) %></TD>
<TD ALIGN="right">Zip</TD>
<TD BGCOLOR="#ffffff"><%= $cust_main->zip %></TD>
</TR>
<TR>
<TD ALIGN="right">Country</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->country %></TD>
+ <TD BGCOLOR="#ffffff"><%= code2country($cust_main->country) %></TD>
</TR>
<%
my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/