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