allow svc_acct password field to be disabled, #39528, fixing fallout from #29354...
[freeside.git] / httemplate / view / svc_acct / basics.html
index 1cdf776..1b7d56b 100644 (file)
@@ -20,7 +20,7 @@
 % if ( $password =~ /^\*\w+\* (.*)$/ ) {
 %   $password = $1;
 %   $show_pw .= '<I>('. mt('login disabled') .')</I> ';
-% } 
+% }
 % if ( ! $password
 %      && $svc_acct->_password_encryption ne 'plain'
 %      && $svc_acct->_password
 % {
 %   $show_pw .= '<I>('. uc($svc_acct->_password_encryption). ' '.mt('encrypted').')</I>';
 % } elsif ( $conf->exists('showpasswords') ) { 
-%   $show_pw .= '<PRE>'. encode_entities($password). '</PRE>';
+%   $show_pw .= '<SPAN >'. encode_entities($password). '</PRE>';
 % } else { 
+%   $password = '';
 %   $show_pw .= '<I>('. mt('hidden') .')</I>';
-% } 
-% $password = ''; 
-<& /view/elements/tr.html, label=>mt('Password'), value=>$show_pw &>
-
+% }
+% my $psc = $part_svc->part_svc_column('_password');
+% if ( $psc->columnflag eq 'F' and $psc->columnvalue eq '' ) {
+%   # show nothing
+% } else {
+<TR>
+  <TD ALIGN="right"><% mt('Password') %></TD>
+  <TD STYLE="background-color: #ffffff; white-space: nowrap">
+  <% $show_pw %>
+%   my $curuser = $FS::CurrentUser::CurrentUser;
+%   if ( $curuser->access_right('Provision customer service') or
+%       ($curuser->access_right('Edit password') and
+%       ! $part_svc->restrict_edit_password)
+%        and $psc->columnflag ne 'F'
+%      )
+%   {
+  <& /elements/change_password.html,
+      'svc_acct'    => $svc_acct,
+      'curr_value'  => $password,
+  &>
+%   }
+  </TD>
+</TR>
+% }
 
 % if ( $conf->exists('security_phrase') ) {
   <& /view/elements/tr.html, label=>mt('Security phrase'), value=>$svc_acct->sec_phrase &>
 
 % }
 
+<%perl>
+# minor false laziness w/ view/svc_broadband.cgi
+sub slipip {
+  my $svc_acct = shift;
+  my $out = $svc_acct->slipip or return '';
+  if ( $out eq '0.0.0.0' or $out eq '0e0' ) {
+    return '<I>('.mt('Dynamic').'</I>';
+  }
+  $out .= ' ('.
+          include('/elements/popup_link-ping.html', ip => $svc_acct->slipip).
+          ')';
+  if ( my $addr_block = $svc_acct->addr_block ) {
+    $out .= '<br>Netmask: ' . $addr_block->NetAddr->mask .
+            '<br>Gateway: ' . $addr_block->ip_gateway;
+  }
+  $out;
+}
+</%perl>
+
 % if ($svc_acct->slipip) { 
   <& /view/elements/tr.html,
        label=>mt('IP address'),
-       value=> ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' )
-                 ? "<I>(".mt('Dynamic').")</I>"
-                 : $svc_acct->slipip. ' '.
-                   include('/elements/popup_link-ping.html',
-                             'ip'=>$svc_acct->slipip,
-                          )
+       value=> slipip($svc_acct)
   &>
 % } 
 
 <& /view/elements/tr.html, label=>mt('RADIUS groups'),
     value=>join('<BR>', $svc_acct->radius_groups('long_description')) &>
 
+<& router.html, 'svc_acct' => $svc_acct &>
+
 %# Can this be abstracted further?  Maybe a library function like
 %# widget('HTML', 'view', $svc_acct) ?  It would definitely make UI 
 %# style management easier.