configurable alternate field order for cust edit, RT13102
[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') |h %>" onChange="<% $onchange %>" <%$disabled%> <%$style%>> , 
7     <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') |h %>" onChange="<% $onchange %>" <%$disabled%> <%$style%>>
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 % if ( $conf->exists('cust-email-high-visibility') && !$pre ) {
22     <TR>
23       <TD ALIGN="right" WIDTH="200">
24         <% $conf->exists('cust_main-require_invoicing_list_email') ? $r : '' %>Email address(es)
25       </TD>
26       <TD bgcolor="#FFFF00">
27         <INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>">
28       </TD>
29     </TR>
30 % }
31
32 % unless ( $conf->exists('cust-edit-alt-field-order') ) {
33 <TR>
34   <TD ALIGN="right">Company</TD>
35   <TD COLSPAN=7>
36     <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') |h %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
37   </TD>
38 </TR>
39
40 <% include('/elements/location.html',
41              'prefix'       => $pre,
42              'object'       => $cust_main,
43              'onchange'     => $onchange,
44              'disabled'     => $disabled,
45              'style'        => \@style,
46              'same_checked' => $opt{'same_checked'},
47              'geocode'      => $opt{'geocode'},
48              'censustract'  => $opt{'censustract'},
49           )
50 %>
51
52 <TR>
53   <TD ALIGN="right"><% $daytime_label %></TD>
54   <TD COLSPAN=5>
55     <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
56   </TD>
57 </TR>
58
59 <TR>
60   <TD ALIGN="right"><% $night_label %></TD>
61   <TD COLSPAN=5>
62     <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
63   </TD>
64 </TR>
65
66 <TR>
67   <TD ALIGN="right">Fax</TD>
68   <TD COLSPAN=5>
69     <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
70   </TD>
71 </TR>
72
73 % } else {
74
75 <TR>
76   <TD ALIGN="right"><% $daytime_label %></TD>
77   <TD COLSPAN=5>
78     <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
79   </TD>
80 </TR>
81
82 <TR>
83   <TD ALIGN="right"><% $night_label %></TD>
84   <TD COLSPAN=5>
85     <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
86   </TD>
87 </TR>
88     
89 <% include('/elements/location.html',
90              'prefix'       => $pre,
91              'object'       => $cust_main,
92              'onchange'     => $onchange,
93              'disabled'     => $disabled,
94              'style'        => \@style,
95              'same_checked' => $opt{'same_checked'},
96              'geocode'      => $opt{'geocode'},
97              'censustract'  => $opt{'censustract'},
98           )
99 %>
100
101 <TR>
102   <TD ALIGN="right">Fax</TD>
103   <TD COLSPAN=5>
104     <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
105   </TD>
106 </TR>
107
108 <TR>
109   <TD ALIGN="right">Company</TD>
110   <TD COLSPAN=7>
111     <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') |h %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
112   </TD>
113 </TR>
114
115 % }
116
117 % if ( $conf->exists('show_stateid') && !$pre ) { 
118
119 <TR>
120   <TD ALIGN="right"><% $stateid_label %></TD>
121   <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>></TD>
122   <TD ALIGN="right"><% $stateid_state_label %></TD>
123   <TD><% include('/elements/select-state.html',
124                    'state'    => $cust_main->stateid_state,
125                    'country'  => $cust_main->country,
126                    'prefix'   => 'stateid_',
127                    'onchange' => $onchange,
128                    'disabled' => $disabled,
129                    'style'    => \@style,
130                 )
131       %>
132   </TD>
133 </TR>
134 % } elsif ( !$pre ) { 
135
136   <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
137   <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
138 % } 
139
140 </TABLE>
141 <%$r%>required fields<BR>
142
143 <%init>
144
145 #my( $cust_main, $pre, $onchange, $disabled, %opt ) = @_;
146 my %opt = @_;
147 my $cust_main = $opt{'cust_main'};
148 my $pre       = $opt{'pre'};
149 my $onchange  = $opt{'onchange'};
150 my $disabled  = $opt{'disabled'};
151 my @style     = ( $opt{'style'} ? @{ $opt{'style'} } : () );
152
153 #push @style, 'background-color: #dddddd' if $disabled;
154 my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
155
156 my $conf = new FS::Conf;
157
158 foreach (qw(ss stateid)) {
159   $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
160 }
161
162 #false laziness with ship state
163 my $countrydefault = $conf->config('countrydefault') || 'US';
164 $cust_main->set($pre.'country', $countrydefault )
165   unless $cust_main->get($pre.'country');
166
167 my $statedefault = $conf->config('statedefault')
168                    || ($countrydefault eq 'US' ? 'CA' : '');
169 $cust_main->set($pre.'state', $statedefault )
170   unless $cust_main->get($pre.'state')
171          || $cust_main->get($pre.'country') ne $countrydefault;
172
173 $cust_main->set('stateid_state', $cust_main->state )
174   unless $pre || $cust_main->get('stateid_state');
175
176 $opt{geocode} ||= $cust_main->get('geocode');
177
178 if ( $conf->exists('cust_main-require_censustract') ) {
179   $opt{censustract} ||= $cust_main->censustract;
180 }
181
182 #my($county_html, $state_html, $country_html) =
183 #  FS::cust_main_county::regionselector( $cust_main->get($pre.'county'),
184 #                                        $cust_main->get($pre.'state'),
185 #                                        $cust_main->get($pre.'country'),
186 #                                        $pre,
187 #                                        $onchange,
188 #                                        $disabled,
189 #                                      );
190
191 my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
192                   ? 'Day Phone'
193                   : FS::Msgcat::_gettext('daytime');
194 my $night_label = FS::Msgcat::_gettext('night') =~/^(night)?$/
195                 ? 'Night Phone'
196                 : FS::Msgcat::_gettext('night') || 'Night Phone';
197 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
198                   ? 'Driver&rsquo;s License'
199                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
200 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
201                         ? 'Driver&rsquo;s License State'
202                         : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';
203
204 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
205
206 my @invoicing_list = $cust_main->invoicing_list;
207
208 </%init>