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