RT# 32233 Show unmask widget only if a value exists to unmask
[freeside.git] / httemplate / edit / cust_main / stateid.html
1 % if ( $conf->exists('show_stateid') ) {
2 <TR>
3   <TH ALIGN="right"><% $stateid_label %></TH>
4   <TD>
5     <INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12 ID="stateid">
6 % if ( $stateid && $FS::CurrentUser::CurrentUser->access_right( 'Unmask customer DL' )) {
7     <& /elements/link-replace_element_text.html, {target_id => 'stateid', replace_text => $cust_main->stateid} &>
8 % }
9   </TD>
10   <TD><& /elements/select-state.html,
11           state   => $cust_main->stateid_state,
12           country => $cust_main->country, # how does this work on new customer?
13           prefix  => 'stateid_',
14           disable_countyupdate => 1,
15       &></TD>
16 </TR>
17 % } else {
18 <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
19 <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>">
20 % }
21
22 <%init>
23 my $cust_main = shift;
24 my $conf = FS::Conf->new;
25 my $stateid;
26 if ( $cgi->param('error') ) {
27   $stateid = $cust_main->stateid;
28 } elsif ( $cust_main->custnum ) {
29   $stateid = $cust_main->masked('stateid');
30 } else {
31   $stateid = '';
32 }
33 $cust_main->set('stateid_state' => $cust_main->state) 
34   unless $cust_main->stateid_state;
35
36 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
37                   ? 'Driver&rsquo;s License'
38                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
39
40 my $stateid_state_label = 
41                   FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
42                   ? 'Driver&rsquo;s License State'
43                   : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License State';
44 </%init>