fix browse results for selecting counties (resulting from separating tax classes...
[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('/elements/select-county.html', %select_hash ) %>
58   </TD>
59   <TH ALIGN="right"><%$r%>State</TH>
60   <TD>
61     <% include('/elements/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('/elements/select-country.html', %select_hash ) %></TD>
72 % if ( !$pre ) { 
73   <TD><INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>"></TD>
74 % } 
75
76 </TR>
77
78 <TR>
79   <TD ALIGN="right"><% $daytime_label %></TD>
80   <TD COLSPAN=5>
81     <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>>
82   </TD>
83 </TR>
84
85 <TR>
86   <TD ALIGN="right"><% $night_label %></TD>
87   <TD COLSPAN=5>
88     <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>>
89   </TD>
90 </TR>
91
92 <TR>
93   <TD ALIGN="right">Fax</TD>
94   <TD COLSPAN=5>
95     <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>>
96   </TD>
97 </TR>
98
99 % if ( $conf->exists('show_stateid') && !$pre ) { 
100
101 <TR>
102   <TD ALIGN="right"><% $stateid_label %></TD>
103   <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>></TD>
104   <TD ALIGN="right"><% $stateid_state_label %></TD>
105   <TD><% include('/elements/select-state.html',
106                    'state'    => $cust_main->stateid_state,
107                    'country'  => $cust_main->country,
108                    'prefix'   => 'stateid_',
109                    'onchange' => $onchange,
110                    'disabled' => $disabled,
111                 )
112       %>
113   </TD>
114 </TR>
115 % } elsif ( !$pre ) { 
116
117   <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
118   <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
119 % } 
120
121 </TABLE>
122 <%$r%>required fields<BR>
123
124 <%init>
125
126 #my( $cust_main, $pre, $onchange, $disabled, %opt ) = @_;
127 my %opt = @_;
128 my $cust_main = $opt{'cust_main'};
129 my $pre       = $opt{'pre'};
130 my $onchange  = $opt{'onchange'};
131 my $disabled  = $opt{'disabled'};
132
133 my $conf = new FS::Conf;
134
135 foreach (qw(ss stateid)) {
136   $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
137 }
138
139 #false laziness with ship state
140 my $countrydefault = $conf->config('countrydefault') || 'US';
141 $cust_main->set($pre.'country', $countrydefault )
142   unless $cust_main->get($pre.'country');
143
144 my $statedefault = $conf->config('statedefault')
145                    || ($countrydefault eq 'US' ? 'CA' : '');
146 $cust_main->set($pre.'state', $statedefault )
147   unless $cust_main->get($pre.'state')
148          || $cust_main->get($pre.'country') ne $countrydefault;
149
150 $cust_main->set('stateid_state', $cust_main->state )
151   unless $pre || $cust_main->get('stateid_state');
152
153 #my($county_html, $state_html, $country_html) =
154 #  FS::cust_main_county::regionselector( $cust_main->get($pre.'county'),
155 #                                        $cust_main->get($pre.'state'),
156 #                                        $cust_main->get($pre.'country'),
157 #                                        $pre,
158 #                                        $onchange,
159 #                                        $disabled,
160 #                                      );
161
162 my %select_hash = (
163   'county'   => $cust_main->get($pre.'county'),
164   'state'    => $cust_main->get($pre.'state'),
165   'country'  => $cust_main->get($pre.'country'),
166   'prefix'   => $pre,
167   'onchange' => $onchange,
168   'disabled' => $disabled,
169 );
170
171 my @counties = counties( $cust_main->get($pre.'state'),
172                          $cust_main->get($pre.'country'),
173                        );
174 my $county_style = scalar(@counties) > 1 ? '' : 'STYLE="visibility:hidden"';
175
176 my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
177                   ? 'Day Phone'
178                   : FS::Msgcat::_gettext('daytime');
179 my $night_label = FS::Msgcat::_gettext('night') =~/^(night)?$/
180                 ? 'Night Phone'
181                 : FS::Msgcat::_gettext('night') || 'Night Phone';
182 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
183                   ? 'Driver&rsquo;s License'
184                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
185 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
186                         ? 'Driver&rsquo;s License State'
187                         : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';
188
189 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
190
191 </%init>