fix browse results for selecting counties (resulting from separating tax classes...
[freeside.git] / httemplate / edit / cust_main / contact.html
index e813986..d93d417 100644 (file)
@@ -9,10 +9,10 @@
 % if ( $conf->exists('show_ss') && !$pre ) { 
 
   <TD ALIGN="right">SS#</TD>
-  <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $cust_main->ss %>" SIZE=11></TD>
+  <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $opt{ss} %>" SIZE=11></TD>
 % } elsif ( !$pre ) { 
 
-  <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $cust_main->ss %>"></TD>
+  <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $opt{ss} %>"></TD>
 % } 
 
 
   </TD>
 </TR>
 
+% my $address2_label_style =
+%   ( $disabled
+%     || ! $conf->exists('cust_main-require_address2')
+%     || ( !$pre && !$opt{'same_checked'} )
+%   )
+%     ? 'visibility:hidden'
+%     : '';
+
 <TR>
-  <TD ALIGN="right">&nbsp;</TD>
+  <TD ALIGN="right"><FONT ID="<% $pre %>address2_required" color="#ff0000" STYLE="<% $address2_label_style %>">*</FONT>&nbsp;<FONT ID="<% $pre %>address2_label" STYLE="<% $address2_label_style %>"><B>Unit&nbsp;#</B></FONT></TD>
   <TD COLSPAN=7>
     <INPUT TYPE="text" NAME="<%$pre%>address2" VALUE="<% $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
   </TD>
   </TD>
   <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH>
   <TD>
-    <% include('select-county.html', %select_hash ) %>
+    <% include('/elements/select-county.html', %select_hash ) %>
   </TD>
   <TH ALIGN="right"><%$r%>State</TH>
   <TD>
-    <% include('select-state.html', %select_hash ) %>
+    <% include('/elements/select-state.html', %select_hash ) %>
   </TD>
   <TH><%$r%>Zip</TH>
   <TD>
 
 <TR>
   <TH ALIGN="right"><%$r%>Country</TH>
-  <TD COLSPAN=5><% include('select-country.html', %select_hash ) %></TD>
+  <TD COLSPAN=5><% include('/elements/select-country.html', %select_hash ) %></TD>
+% if ( !$pre ) { 
+  <TD><INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>"></TD>
+% } 
+
 </TR>
 
 <TR>
   </TD>
 </TR>
 
+% if ( $conf->exists('show_stateid') && !$pre ) { 
+
+<TR>
+  <TD ALIGN="right"><% $stateid_label %></TD>
+  <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>></TD>
+  <TD ALIGN="right"><% $stateid_state_label %></TD>
+  <TD><% include('/elements/select-state.html',
+                   'state'    => $cust_main->stateid_state,
+                   'country'  => $cust_main->country,
+                   'prefix'   => 'stateid_',
+                   'onchange' => $onchange,
+                   'disabled' => $disabled,
+                )
+      %>
+  </TD>
+</TR>
+% } elsif ( !$pre ) { 
+
+  <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
+  <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
+% } 
+
 </TABLE>
 <%$r%>required fields<BR>
 
 <%init>
 
-my( $cust_main, $pre, $onchange, $disabled ) = @_;
+#my( $cust_main, $pre, $onchange, $disabled, %opt ) = @_;
+my %opt = @_;
+my $cust_main = $opt{'cust_main'};
+my $pre       = $opt{'pre'};
+my $onchange  = $opt{'onchange'};
+my $disabled  = $opt{'disabled'};
+
 my $conf = new FS::Conf;
 
+foreach (qw(ss stateid)) {
+  $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
+}
+
 #false laziness with ship state
 my $countrydefault = $conf->config('countrydefault') || 'US';
 $cust_main->set($pre.'country', $countrydefault )
@@ -103,6 +147,9 @@ $cust_main->set($pre.'state', $statedefault )
   unless $cust_main->get($pre.'state')
          || $cust_main->get($pre.'country') ne $countrydefault;
 
+$cust_main->set('stateid_state', $cust_main->state )
+  unless $pre || $cust_main->get('stateid_state');
+
 #my($county_html, $state_html, $country_html) =
 #  FS::cust_main_county::regionselector( $cust_main->get($pre.'county'),
 #                                        $cust_main->get($pre.'state'),
@@ -126,8 +173,18 @@ my @counties = counties( $cust_main->get($pre.'state'),
                        );
 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 $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
+                  ? 'Day Phone'
+                  : FS::Msgcat::_gettext('daytime');
+my $night_label = FS::Msgcat::_gettext('night') =~/^(night)?$/
+                ? 'Night Phone'
+                : FS::Msgcat::_gettext('night') || 'Night Phone';
+my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
+                  ? 'Driver&rsquo;s License'
+                  : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
+my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
+                        ? 'Driver&rsquo;s License State'
+                        : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';
 
 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;