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