diff options
author | ivan <ivan> | 2006-12-27 02:37:17 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-12-27 02:37:17 +0000 |
commit | 3c8870ee619416f126a65c93d5ef7a2f2e24bc96 (patch) | |
tree | 728873036ac4ae84b649923605176a875588167e /httemplate/edit/cust_main | |
parent | 14ee9d25605ce139bad4655987575508c06f7f7e (diff) |
Add a (magically appearing and disappearing) label on the county selector. confusing when labeled "state"
Diffstat (limited to 'httemplate/edit/cust_main')
-rw-r--r-- | httemplate/edit/cust_main/contact.html | 100 | ||||
-rw-r--r-- | httemplate/edit/cust_main/select-county.html | 15 |
2 files changed, 58 insertions, 57 deletions
diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html index a001634a2..e813986cd 100644 --- a/httemplate/edit/cust_main/contact.html +++ b/httemplate/edit/cust_main/contact.html @@ -1,50 +1,8 @@ -% -% -%my( $cust_main, $pre, $onchange, $disabled ) = @_; -%my $conf = new FS::Conf; -% -%#false laziness with ship state -%my $countrydefault = $conf->config('countrydefault') || 'US'; -%$cust_main->set($pre.'country', $countrydefault ) -% unless $cust_main->get($pre.'country'); -% -%my $statedefault = $conf->config('statedefault') -% || ($countrydefault eq 'US' ? 'CA' : ''); -%$cust_main->set($pre.'state', $statedefault ) -% unless $cust_main->get($pre.'state') -% || $cust_main->get($pre.'country') ne $countrydefault; -% -%#my($county_html, $state_html, $country_html) = -%# FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), -%# $cust_main->get($pre.'state'), -%# $cust_main->get($pre.'country'), -%# $pre, -%# $onchange, -%# $disabled, -%# ); -% -%my %select_hash = ( -% 'county' => $cust_main->get($pre.'county'), -% 'state' => $cust_main->get($pre.'state'), -% 'country' => $cust_main->get($pre.'country'), -% 'prefix' => $pre, -% 'onchange' => $onchange, -% 'disabled' => $disabled, -%); -% -%my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; -%my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; -% -%my $r = qq!<font color="#ff0000">*</font> !; -% -% - - <% &ntable("#cccccc") %> <TR> <TH ALIGN="right"><%$r%>Contact name<BR>(last, first)</TH> - <TD COLSPAN=3> + <TD COLSPAN=5> <INPUT TYPE="text" NAME="<%$pre%>last" VALUE="<% $cust_main->get($pre.'last') %>" onChange="<% $onchange %>" <%$disabled%>> , <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') %>" onChange="<% $onchange %>" <%$disabled%>> </TD> @@ -62,21 +20,21 @@ <TR> <TD ALIGN="right">Company</TD> - <TD COLSPAN=5> + <TD COLSPAN=7> <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> <TH ALIGN="right"><%$r%>Address</TH> - <TD COLSPAN=5> + <TD COLSPAN=7> <INPUT TYPE="text" NAME="<%$pre%>address1" VALUE="<% $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> <TD ALIGN="right"> </TD> - <TD COLSPAN=5> + <TD COLSPAN=7> <INPUT TYPE="text" NAME="<%$pre%>address2" VALUE="<% $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> @@ -86,9 +44,12 @@ <TD> <INPUT TYPE="text" NAME="<%$pre%>city" VALUE="<% $cust_main->get($pre.'city') %>" onChange="<% $onchange %>" <%$disabled%>> </TD> - <TH ALIGN="right"><%$r%>State</TH> + <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH> <TD> <% include('select-county.html', %select_hash ) %> + </TD> + <TH ALIGN="right"><%$r%>State</TH> + <TD> <% include('select-state.html', %select_hash ) %> </TD> <TH><%$r%>Zip</TH> @@ -126,3 +87,48 @@ </TABLE> <%$r%>required fields<BR> +<%init> + +my( $cust_main, $pre, $onchange, $disabled ) = @_; +my $conf = new FS::Conf; + +#false laziness with ship state +my $countrydefault = $conf->config('countrydefault') || 'US'; +$cust_main->set($pre.'country', $countrydefault ) + unless $cust_main->get($pre.'country'); + +my $statedefault = $conf->config('statedefault') + || ($countrydefault eq 'US' ? 'CA' : ''); +$cust_main->set($pre.'state', $statedefault ) + unless $cust_main->get($pre.'state') + || $cust_main->get($pre.'country') ne $countrydefault; + +#my($county_html, $state_html, $country_html) = +# FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), +# $cust_main->get($pre.'state'), +# $cust_main->get($pre.'country'), +# $pre, +# $onchange, +# $disabled, +# ); + +my %select_hash = ( + 'county' => $cust_main->get($pre.'county'), + 'state' => $cust_main->get($pre.'state'), + 'country' => $cust_main->get($pre.'country'), + 'prefix' => $pre, + 'onchange' => $onchange, + 'disabled' => $disabled, +); + +my @counties = counties( $cust_main->get($pre.'state'), + $cust_main->get($pre.'country'), + ); +my $county_style = scalar(@counties) > 1 ? '' : 'STYLE="visibility:hidden"'; + +my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; +my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; + +my $r = qq!<font color="#ff0000">*</font> !; + +</%init> diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html index 5b068214e..0dc826896 100644 --- a/httemplate/edit/cust_main/select-county.html +++ b/httemplate/edit/cust_main/select-county.html @@ -34,10 +34,14 @@ opt(what.form.<% $opt{'prefix'} %>county, countiesArray[s], countyLabel); } + var countyFormLabel = document.getElementById('<% $opt{'prefix'} %>countylabel'); + if ( countiesArray.length > 1 ) { what.form.<% $opt{'prefix'} %>county.style.display = ''; + countyFormLabel.style.visibility = 'visible'; } else { what.form.<% $opt{'prefix'} %>county.style.display = 'none'; + countyFormLabel.style.visibility = 'hidden'; } //run the callback @@ -84,16 +88,7 @@ foreach my $opt (qw( county state country prefix onchange disabled )) { my @counties = (); if ( $countyflag ) { - @counties = - sort - map { $_->county } - qsearch( { - 'select' => 'DISTINCT county', - 'table' => 'cust_main_county', - 'hashref' => { 'state' => $opt{'state'}, - 'country' => $opt{'country'}, - }, - } ); + @counties = counties( $opt{'state'}, $opt{'country'} ); # this is very hacky unless ( scalar(@counties) > 1 ) { |