RT# 32233 Show unmask widget only if a value exists to unmask
[freeside.git] / httemplate / edit / cust_main / name.html
index 2641ec9..120475b 100644 (file)
@@ -1,48 +1,66 @@
 <%def .namepart>
-% my ($field, $value, $label, $extra) = @_;
-<TD>
+% my ($field, $value, $label, $extra, $unmask_field) = @_;
+<DIV STYLE="display: inline-block" ID="<% $field %>_input">
   <INPUT TYPE="text" NAME="<% $field %>" VALUE="<% $value |h %>" <%$extra%>>
-  <BR><FONT SIZE=-1><% mt($label) %></FONT>
-</TD>
+% if (
+%   $value
+%   && ref $unmask_field
+%   && !$unmask_field->{unmask_ss}
+%   && $FS::CurrentUser::CurrentUser->access_right( $unmask_field->{access_right} )
+% ) {
+  <& /elements/link-replace_element_text.html, {
+      target_id    => $unmask_field->{target_id},
+      replace_text => $unmask_field->{replace_text},
+  } &>
+% }
+  <BR><FONT SIZE="-1" COLOR="#333333"><% emt($label) %></FONT>
+</DIV>
 </%def>
 
 <TR>
-  <TH VALIGN="top" ALIGN="right"><%$r%><% mt('Contact name') |h %></TH>
-  <TD COLSPAN=6>
-    <TABLE CELLSPACING=0 CELLPADDING=0>
-      <TR>
-        <& .namepart, 'last', $cust_main->last, 'Last' &>
-        <TD VALIGN="top"> , </TD>
+  <TH CLASS="required label" ALIGN="right"><% mt('Contact name') |h %></TD>
+  <TD COLSPAN=6 STYLE="vertical-align:top">
+        <& .namepart, 'last', $cust_main->last, 'Last', ',' &>
         <& .namepart, 'first', $cust_main->first, 'First' &>
 % if ( $conf->exists('show_ss') ) {
-        <TD>&nbsp;</TD>
-        <& .namepart, 'ss', $ss, 'SS#', "SIZE=11" &>
+        &nbsp;
+        <& .namepart, 'ss', $ss, 'SS#', "SIZE=11 ID='ss'", {
+          target_id    => 'ss',
+          replace_text => $cust_main->ss,
+          access_right => 'Unmask customer SSN',
+          unmask_ss    => $conf->exists('unmask_ss'),
+        } &>
 % } else  {
         <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>">
 % }
-      </TR>
-    </TABLE>
   </TD>
 </TR>
+% if ( $conf->exists('cust_main-enable_spouse') ) {
+<TR ID="spouse_row">
+  <TH CLASS="label" ALIGN="right"><DIV ID="spouse_label"><% mt('Spouse\'s name') |h %></DIV></TD>
+  <TD COLSPAN=6>
+        <& .namepart, 'spouse_last', $cust_main->spouse_last, 'Last', ',' &>
+        <& .namepart, 'spouse_first', $cust_main->spouse_first, 'First' &>
+  </TD>
+</TR>
+% }
 
-% if ( $conf->exists('cust-email-high-visibility') ) {
 <TR>
-  <TD ALIGN="right">
+  <TH ALIGN="right">
+    <SPAN ID="invoice_email_label" CLASS="
     <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum)
-        ? $r
-        : '' %>Email address(es)
-  </TD>
-  <TD BGCOLOR="#FFFF00">
-    <INPUT TYPE="text" NAME="invoicing_list" 
-           VALUE=<% $cust_main->invoicing_list_emailonly_scalar %>>
+        ? 'required label'
+        : 'label' %>">Email address(es)</SPAN>
+  </TH>
+  <TD COLSPAN=6>
+    <INPUT TYPE="text" NAME="invoice_email"  ID="invoice_email_input" SIZE=40
+           VALUE="<% $cust_main->invoicing_list_emailonly_scalar %>">
   </TD>
 </TR>
-% }
 <%init>
 my $cust_main = shift;
 my $agentnum = $cust_main->agentnum if $cust_main->custnum;
 my $conf = FS::Conf->new;
-my $r = '<font color="#ff0000">*</font>&nbsp;';
 my $ss;
 
 if ( $cgi->param('error') or $conf->exists('unmask_ss') ) {