import torrus 1.0.9
[freeside.git] / httemplate / edit / cust_main / contact.html
index 7b88ccb..99bc558 100644 (file)
-<%
-
-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 $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone';
-my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone';
-
-my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
-
-%>
-
-<%= &itable("#cccccc") %>
+<% &ntable("#cccccc") %>
 
 <TR>
-  <TH ALIGN="right"><%=$r%>Contact&nbsp;name<BR>(last,&nbsp;first)</TH>
-  <TD COLSPAN=3>
-    <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%>>
+  <TH ALIGN="right"><%$r%>Contact&nbsp;name<BR>(last,&nbsp;first)</TH>
+  <TD COLSPAN=5>
+    <INPUT TYPE="text" NAME="<%$pre%>last" VALUE="<% $cust_main->get($pre.'last') |h %>" onChange="<% $onchange %>" <%$disabled%> <%$style%>> , 
+    <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') |h %>" onChange="<% $onchange %>" <%$disabled%> <%$style%>>
   </TD>
+% if ( $conf->exists('show_ss') && !$pre ) { 
 
-<% if ( $conf->exists('show_ss') && !$pre ) { %>
   <TD ALIGN="right">SS#</TD>
-  <TD><INPUT TYPE="text" NAME="ss" VALUE="<%= $cust_main->ss %>" SIZE=11></TD>
-<% } else { %>
-  <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<%= $cust_main->ss %>"></TD>
-<% } %>
+  <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $opt{ss} %>" SIZE=11></TD>
+% } elsif ( !$pre ) { 
+
+  <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $opt{ss} %>"></TD>
+% } 
+
 
 </TR>
 
 <TR>
   <TD ALIGN="right">Company</TD>
-  <TD COLSPAN=5>
-    <INPUT TYPE="text" NAME="<%=$pre%>company" VALUE="<%= $cust_main->get($pre.'company') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+  <TD COLSPAN=7>
+    <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') |h %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
   </TD>
 </TR>
 
-<TR>
-  <TH ALIGN="right"><%=$r%>Address</TH>
-  <TD COLSPAN=5>
-    <INPUT TYPE="text" NAME="<%=$pre%>address1" VALUE="<%= $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
-  </TD>
-</TR>
+<% include('/elements/location.html',
+             'prefix'       => $pre,
+             'object'       => $cust_main,
+             'onchange'     => $onchange,
+             'disabled'     => $disabled,
+             'style'        => \@style,
+             'same_checked' => $opt{'same_checked'},
+             'geocode'      => $opt{'geocode'},
+             'censustract'  => $opt{'censustract'},
+          )
+%>
 
 <TR>
-  <TD ALIGN="right">&nbsp;</TD>
+  <TD ALIGN="right"><% $daytime_label %></TD>
   <TD COLSPAN=5>
-    <INPUT TYPE="text" NAME="<%=$pre%>address2" VALUE="<%= $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
-  </TD>
-</TR>
-
-<TR>
-  <TH ALIGN="right"><%=$r%>City</TH>
-  <TD>
-    <INPUT TYPE="text" NAME="<%=$pre%>city" VALUE="<%= $cust_main->get($pre.'city') %>" onChange="<%= $onchange %>" <%=$disabled%>>
+    <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
   </TD>
-  <TH ALIGN="right"><%=$r%>State</TH>
-  <TD><%= $county_html. $state_html %></TD>
-  <TH><%=$r%>Zip</TH>
-  <TD>
-    <INPUT TYPE="text" NAME="<%=$pre%>zip" VALUE="<%= $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<%= $onchange %>" <%=$disabled%>>
-  </TD>
-</TR>
-
-<TR>
-  <TH ALIGN="right"><%=$r%>Country</TH>
-  <TD><%= $country_html %></TD>
 </TR>
 
 <TR>
-  <TD ALIGN="right"><%= $daytime_label %></TD>
+  <TD ALIGN="right"><% $night_label %></TD>
   <TD COLSPAN=5>
-    <INPUT TYPE="text" NAME="<%=$pre%>daytime" VALUE="<%= $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>>
+    <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
   </TD>
 </TR>
 
 <TR>
-  <TD ALIGN="right"><%= $night_label %></TD>
+  <TD ALIGN="right">Fax</TD>
   <TD COLSPAN=5>
-    <INPUT TYPE="text" NAME="<%=$pre%>night" VALUE="<%= $cust_main->get($pre.'night') %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>>
+    <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
   </TD>
 </TR>
 
+% if ( $conf->exists('show_stateid') && !$pre ) { 
+
 <TR>
-  <TD ALIGN="right">Fax</TD>
-  <TD COLSPAN=5>
-    <INPUT TYPE="text" NAME="<%=$pre%>fax" VALUE="<%= $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<%= $onchange %>" <%=$disabled%>>
+  <TD ALIGN="right"><% $stateid_label %></TD>
+  <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>></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,
+                   'style'    => \@style,
+                )
+      %>
   </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>
+<%$r%>required fields<BR>
+
+<%init>
+
+#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 @style     = ( $opt{'style'} ? @{ $opt{'style'} } : () );
+
+#push @style, 'background-color: #dddddd' if $disabled;
+my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
+
+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 )
+  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;
+
+$cust_main->set('stateid_state', $cust_main->state )
+  unless $pre || $cust_main->get('stateid_state');
+
+$opt{geocode} ||= $cust_main->get('geocode');
+
+if ( $conf->exists('cust_main-require_censustract') ) {
+  $opt{censustract} ||= $cust_main->censustract;
+}
+
+#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 $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;!;
 
+</%init>