2d37dc89530aa41ad5afc8c2d40c431a2d33be5a
[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 % 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('select-state.html', 'state' => $cust_main->stateid_state,
106                                       'country' => $cust_main->country,
107                                       'prefix'  => 'stateid_',
108                                       'onchange' => $onchange,
109                                       'disabled' => $disabled) %></TD>
110 </TR>
111 % } elsif ( !$pre ) { 
112
113   <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
114   <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
115 % } 
116
117 </TABLE>
118 <%$r%>required fields<BR>
119
120 <%init>
121
122 #my( $cust_main, $pre, $onchange, $disabled, %opt ) = @_;
123 my %opt = @_;
124 my $cust_main = $opt{'cust_main'};
125 my $pre       = $opt{'pre'};
126 my $onchange  = $opt{'onchange'};
127 my $disabled  = $opt{'disabled'};
128
129 my $conf = new FS::Conf;
130
131 foreach (qw(ss stateid)) {
132   $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
133 }
134
135 #false laziness with ship state
136 my $countrydefault = $conf->config('countrydefault') || 'US';
137 $cust_main->set($pre.'country', $countrydefault )
138   unless $cust_main->get($pre.'country');
139
140 my $statedefault = $conf->config('statedefault')
141                    || ($countrydefault eq 'US' ? 'CA' : '');
142 $cust_main->set($pre.'state', $statedefault )
143   unless $cust_main->get($pre.'state')
144          || $cust_main->get($pre.'country') ne $countrydefault;
145
146 $cust_main->set('stateid_state', $cust_main->state )
147   unless $pre || $cust_main->get('stateid_state');
148
149 #my($county_html, $state_html, $country_html) =
150 #  FS::cust_main_county::regionselector( $cust_main->get($pre.'county'),
151 #                                        $cust_main->get($pre.'state'),
152 #                                        $cust_main->get($pre.'country'),
153 #                                        $pre,
154 #                                        $onchange,
155 #                                        $disabled,
156 #                                      );
157
158 my %select_hash = (
159   'county'   => $cust_main->get($pre.'county'),
160   'state'    => $cust_main->get($pre.'state'),
161   'country'  => $cust_main->get($pre.'country'),
162   'prefix'   => $pre,
163   'onchange' => $onchange,
164   'disabled' => $disabled,
165 );
166
167 my @counties = counties( $cust_main->get($pre.'state'),
168                          $cust_main->get($pre.'country'),
169                        );
170 my $county_style = scalar(@counties) > 1 ? '' : 'STYLE="visibility:hidden"';
171
172 my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
173                   ? 'Day Phone'
174                   : FS::Msgcat::_gettext('daytime');
175 my $night_label = FS::Msgcat::_gettext('night') =~/^(night)?$/
176                 ? 'Night Phone'
177                 : FS::Msgcat::_gettext('night') || 'Night Phone';
178 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
179                   ? 'Driver&rsquo;s License'
180                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
181 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
182                         ? 'Driver&rsquo;s License State'
183                         : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';
184
185 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
186
187 </%init>