add cust_main-require_address2 config, reimplement address2-search config ("Unit...
[freeside.git] / httemplate / edit / cust_main / contact.html
1 <% &ntable("#cccccc") %>
2
3 <TR>
4   <TH ALIGN="right"><%$r%>Contact&nbsp;name<BR>(last,&nbsp;first)</TH>
5   <TD COLSPAN=5>
6     <INPUT TYPE="text" NAME="<%$pre%>last" VALUE="<% $cust_main->get($pre.'last') %>" onChange="<% $onchange %>" <%$disabled%>> , 
7     <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') %>" onChange="<% $onchange %>" <%$disabled%>>
8   </TD>
9 % if ( $conf->exists('show_ss') && !$pre ) { 
10
11   <TD ALIGN="right">SS#</TD>
12   <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $opt{ss} %>" SIZE=11></TD>
13 % } elsif ( !$pre ) { 
14
15   <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $opt{ss} %>"></TD>
16 % } 
17
18
19 </TR>
20
21 <TR>
22   <TD ALIGN="right">Company</TD>
23   <TD COLSPAN=7>
24     <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
25   </TD>
26 </TR>
27
28 <TR>
29   <TH ALIGN="right"><%$r%>Address</TH>
30   <TD COLSPAN=7>
31     <INPUT TYPE="text" NAME="<%$pre%>address1" VALUE="<% $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
32   </TD>
33 </TR>
34
35 % my $address2_label_style =
36 %   ( $disabled
37 %     || ! $conf->exists('cust_main-require_address2')
38 %     || ( !$pre && !$opt{'same_checked'} )
39 %   )
40 %     ? 'visibility:hidden'
41 %     : '';
42
43 <TR>
44   <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>
45   <TD COLSPAN=7>
46     <INPUT TYPE="text" NAME="<%$pre%>address2" VALUE="<% $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
47   </TD>
48 </TR>
49
50 <TR>
51   <TH ALIGN="right"><%$r%>City</TH>
52   <TD>
53     <INPUT TYPE="text" NAME="<%$pre%>city" VALUE="<% $cust_main->get($pre.'city') %>" onChange="<% $onchange %>" <%$disabled%>>
54   </TD>
55   <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH>
56   <TD>
57     <% include('select-county.html', %select_hash ) %>
58   </TD>
59   <TH ALIGN="right"><%$r%>State</TH>
60   <TD>
61     <% include('select-state.html', %select_hash ) %>
62   </TD>
63   <TH><%$r%>Zip</TH>
64   <TD>
65     <INPUT TYPE="text" NAME="<%$pre%>zip" VALUE="<% $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<% $onchange %>" <%$disabled%>>
66   </TD>
67 </TR>
68
69 <TR>
70   <TH ALIGN="right"><%$r%>Country</TH>
71   <TD COLSPAN=5><% include('select-country.html', %select_hash ) %></TD>
72 </TR>
73
74 <TR>
75   <TD ALIGN="right"><% $daytime_label %></TD>
76   <TD COLSPAN=5>
77     <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>>
78   </TD>
79 </TR>
80
81 <TR>
82   <TD ALIGN="right"><% $night_label %></TD>
83   <TD COLSPAN=5>
84     <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>>
85   </TD>
86 </TR>
87
88 <TR>
89   <TD ALIGN="right">Fax</TD>
90   <TD COLSPAN=5>
91     <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>>
92   </TD>
93 </TR>
94
95 % if ( $conf->exists('show_stateid') && !$pre ) { 
96
97 <TR>
98   <TD ALIGN="right"><% $stateid_label %></TD>
99   <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>></TD>
100   <TD ALIGN="right"><% $stateid_state_label %></TD>
101   <TD><% include('select-state.html', 'state' => $cust_main->stateid_state,
102                                       'country' => $cust_main->country,
103                                       'prefix'  => 'stateid_',
104                                       'onchange' => $onchange,
105                                       'disabled' => $disabled) %></TD>
106 </TR>
107 % } elsif ( !$pre ) { 
108
109   <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
110   <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
111 % } 
112
113 </TABLE>
114 <%$r%>required fields<BR>
115
116 <%init>
117
118 #my( $cust_main, $pre, $onchange, $disabled, %opt ) = @_;
119 my %opt = @_;
120 my $cust_main = $opt{'cust_main'};
121 my $pre       = $opt{'pre'};
122 my $onchange  = $opt{'onchange'};
123 my $disabled  = $opt{'disabled'};
124
125 my $conf = new FS::Conf;
126
127 foreach (qw(ss stateid)) {
128   $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
129 }
130
131 #false laziness with ship state
132 my $countrydefault = $conf->config('countrydefault') || 'US';
133 $cust_main->set($pre.'country', $countrydefault )
134   unless $cust_main->get($pre.'country');
135
136 my $statedefault = $conf->config('statedefault')
137                    || ($countrydefault eq 'US' ? 'CA' : '');
138 $cust_main->set($pre.'state', $statedefault )
139   unless $cust_main->get($pre.'state')
140          || $cust_main->get($pre.'country') ne $countrydefault;
141
142 $cust_main->set('stateid_state', $cust_main->state )
143   unless $pre || $cust_main->get('stateid_state');
144
145 #my($county_html, $state_html, $country_html) =
146 #  FS::cust_main_county::regionselector( $cust_main->get($pre.'county'),
147 #                                        $cust_main->get($pre.'state'),
148 #                                        $cust_main->get($pre.'country'),
149 #                                        $pre,
150 #                                        $onchange,
151 #                                        $disabled,
152 #                                      );
153
154 my %select_hash = (
155   'county'   => $cust_main->get($pre.'county'),
156   'state'    => $cust_main->get($pre.'state'),
157   'country'  => $cust_main->get($pre.'country'),
158   'prefix'   => $pre,
159   'onchange' => $onchange,
160   'disabled' => $disabled,
161 );
162
163 my @counties = counties( $cust_main->get($pre.'state'),
164                          $cust_main->get($pre.'country'),
165                        );
166 my $county_style = scalar(@counties) > 1 ? '' : 'STYLE="visibility:hidden"';
167
168 my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
169                   ? 'Day Phone'
170                   : FS::Msgcat::_gettext('daytime');
171 my $night_label = FS::Msgcat::_gettext('night') =~/^(night)?$/
172                 ? 'Night Phone'
173                 : FS::Msgcat::_gettext('night') || 'Night Phone';
174 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
175                   ? 'Driver&rsquo;s License'
176                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
177 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
178                         ? 'Driver&rsquo;s License State'
179                         : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';
180
181 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
182
183 </%init>