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