optional better visibility for invoicing email field, RT12944
[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') ? $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 <TR>
33   <TD ALIGN="right"><% mt('Company') |h %></TD>
34   <TD COLSPAN=7>
35     <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') |h %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
36   </TD>
37 </TR>
38
39 <& /elements/location.html,
40              'prefix'       => $pre,
41              'object'       => $cust_main,
42              'onchange'     => $onchange,
43              'disabled'     => $disabled,
44              'style'        => \@style,
45              'same_checked' => $opt{'same_checked'},
46              'geocode'      => $opt{'geocode'},
47              'censustract'  => $opt{'censustract'},
48 &>
49
50 <TR>
51   <TD ALIGN="right"><% $daytime_label %></TD>
52   <TD COLSPAN=5>
53     <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
54   </TD>
55 </TR>
56
57 <TR>
58   <TD ALIGN="right"><% $night_label %></TD>
59   <TD COLSPAN=5>
60     <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
61   </TD>
62 </TR>
63
64 <TR>
65   <TD ALIGN="right"><% mt('Fax') |h %></TD>
66   <TD COLSPAN=5>
67     <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
68   </TD>
69 </TR>
70
71 % if ( $conf->exists('show_stateid') && !$pre ) { 
72
73 <TR>
74   <TD ALIGN="right"><% $stateid_label %></TD>
75   <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>></TD>
76   <TD ALIGN="right"><% $stateid_state_label %></TD>
77   <TD><& /elements/select-state.html,
78                    'state'    => $cust_main->stateid_state,
79                    'country'  => $cust_main->country,
80                    'prefix'   => 'stateid_',
81                    'onchange' => $onchange,
82                    'disabled' => $disabled,
83                    'style'    => \@style,
84       &>
85   </TD>
86 </TR>
87 % } elsif ( !$pre ) { 
88
89   <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
90   <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
91 % } 
92
93 </TABLE>
94 <%$r%><% mt('required fields') |h %><BR>
95
96 <%init>
97
98 my %opt = @_;
99 my $cust_main = $opt{'cust_main'};
100 my $pre       = $opt{'pre'};
101 my $onchange  = $opt{'onchange'};
102 my $disabled  = $opt{'disabled'};
103 my @style     = ( $opt{'style'} ? @{ $opt{'style'} } : () );
104
105 my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
106
107 my $conf = new FS::Conf;
108
109 foreach (qw(ss stateid)) {
110   $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
111 }
112
113 #false laziness with ship state
114 my $countrydefault = $conf->config('countrydefault') || 'US';
115 $cust_main->set($pre.'country', $countrydefault )
116   unless $cust_main->get($pre.'country');
117
118 my $statedefault = $conf->config('statedefault')
119                    || ($countrydefault eq 'US' ? 'CA' : '');
120 $cust_main->set($pre.'state', $statedefault )
121   unless $cust_main->get($pre.'state')
122          || $cust_main->get($pre.'country') ne $countrydefault;
123
124 $cust_main->set('stateid_state', $cust_main->state )
125   unless $pre || $cust_main->get('stateid_state');
126
127 $opt{geocode} ||= $cust_main->get('geocode');
128
129 if ( $conf->exists('cust_main-require_censustract') ) {
130   $opt{censustract} ||= $cust_main->censustract;
131 }
132
133 my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
134                   ? 'Day Phone'
135                   : FS::Msgcat::_gettext('daytime');
136 my $night_label = FS::Msgcat::_gettext('night') =~/^(night)?$/
137                 ? 'Night Phone'
138                 : FS::Msgcat::_gettext('night') || 'Night Phone';
139 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
140                   ? 'Driver&rsquo;s License'
141                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
142 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
143                         ? 'Driver&rsquo;s License State'
144                         : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';
145
146 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
147
148 my @invoicing_list = $cust_main->invoicing_list;
149
150 </%init>