invoice_sections_with_taxes per-agent, RT#79636
[freeside.git] / httemplate / edit / svc_acct.cgi
index 574fb51..27ea3c5 100755 (executable)
@@ -30,8 +30,9 @@
   <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD>
 </TR>
 
-<TR>
-  <TD ALIGN="right"><% mt('Username') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('username')->columnlabel || mt('Username'),
+     'required' => $part_svc->part_svc_column('username')->required ) %>
 % if ( $svcnum && $conf->exists('svc_acct-no_edit_username') ) {
     <TD BGCOLOR="#eeeeee"><% $svc_acct->username() %></TD>
     <INPUT TYPE="hidden" NAME="username" VALUE="<% $username %>">
 </TR>
 
 %if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) {
-<TR>
 % #XXX eventually should require "Edit Password" ACL
-  <TD ALIGN="right"><% mt('Password') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('_password')->columnlabel || mt('Password'),
+     'required' => $part_svc->part_svc_column('_password')->required ) %>
   <TD>
     <INPUT TYPE="text" ID="clear_password" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
-    <& /elements/random_pass.html, 'clear_password' &>
+    <& /elements/random_pass.html, 'clear_password' &><BR>
+    <DIV ID="clear_password_result" STYLE="font-size: smaller"></DIV>
+    <& '/elements/validate_password.html', 
+         'fieldid' => 'clear_password',
+         'svcnum' => $svcnum 
+    &>
   </TD>
 </TR>
 %}else{
@@ -60,8 +67,9 @@
 %if ( $conf->exists('security_phrase') 
 %  && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
 
-  <TR>
-    <TD ALIGN="right"><% mt('Security phrase') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('sec_phrase')->columnlabel || mt('Security phrase'),
+     'required' => $part_svc->part_svc_column('sec_phrase')->required ) %>
     <TD>
       <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
       (<% mt('for forgotten passwords') |h %>)
 %                                                )
 %                );
 
-  <TR>
-    <TD ALIGN="right"><% mt('Domain') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('domsvc')->columnlabel || mt('Domain'),
+     'required' => $part_svc->part_svc_column('domsvc')->required ) %>
     <TD>
       <SELECT NAME="domsvc" SIZE=1>
 % foreach my $svcnum (
              'curr_value' => $svc_acct->pbxsvc,
              'part_svc'   => $part_svc,
              'cust_pkg'   => $cust_pkg,
+             'label'      => $part_svc->part_svc_column('pbxsvc')->columnlabel || 'PBX',
 &>
 
 %#pop
   <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
 % } else { 
 
-  <TR>
-    <TD ALIGN="right"><% mt('Access number') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('popnum')->columnlabel || mt('Access number'),
+     'required' => $part_svc->part_svc_column('popnum')->required ) %>
     <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
   </TR>
 % } 
          'curr_value' => $svc_acct->sectornum,
          #'part_svc'   => $part_svc,
          #'cust_pkg'   => $cust_pkg,
+         'required'   => $part_svc->part_svc_column('sectornum')->required,
+         'label'       => $part_svc->part_svc_column('sectornum')->columnlabel || mt('Tower sector'),
     &>
 %} else {
     <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
 %  
 % if ( length($svc_acct->$xid()) ) { 
 
-      <TR>
-        <TD ALIGN="right"><% uc($xid) %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column($xid)->columnlabel || uc($xid),
+     'required' => $part_svc->part_svc_column($xid)->required ) %>
+%#      <TR>
+%#        <TD ALIGN="right"><% uc($xid) %></TD>
           <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
         <TD>
         </TD>
     <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
 % } else { 
   
-    <TR>
-      <TD ALIGN="right"><% uc($xid) %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column($xid)->columnlabel || uc($xid),
+     'required' => $part_svc->part_svc_column($xid)->required ) %>
       <TD>
         <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
       </TD>
 % } else { 
 
 
-  <TR>
-    <TD ALIGN="right"><% mt('Real Name') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('finger')->columnlabel || mt('Real Name'),
+     'required' => $part_svc->part_svc_column('finger')->required ) %>
     <TD>
       <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
     </TD>
 % } else {
 
 
-  <TR>
-    <TD ALIGN="right"><% mt('Home directory') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('dir')->columnlabel || mt('Home directory'),
+     'required' => $part_svc->part_svc_column('dir')->required ) %>
     <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
   </TR>
 % } 
 % } else { 
 
 
-  <TR>
-    <TD ALIGN="right"><% mt('Shell') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('shell')->columnlabel || mt('Shell'),
+     'required' => $part_svc->part_svc_column('shell')->required ) %>
     <TD>
       <SELECT NAME="shell" SIZE=1>
 %
 %   # (should we show this if slipip is fixed?)
 <& /elements/tr-select-router_block_ip.html, 
   'object' => $svc_acct,
-  'ip_field' => 'slipip'
+  'ip_field' => 'slipip',
+  'required' => $part_svc->part_svc_column('routernum')->required,
+  'label'    => $part_svc->part_svc_column('routernum')->columnlabel,
+  'ip_addr_required' => $part_svc->part_svc_column('slipip')->required,
+  'ip_addr_label' => $part_svc->part_svc_column('slipip')->columnlabel,
 &>
 % } else {
 %   # don't expose these to the user--they're only useful in the other case
 %   if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { 
     <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
 %   } else { 
-    <TR>
-      <TD ALIGN="right"><% mt('IP') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('slipip')->columnlabel || mt('IP'),
+     'required' => $part_svc->part_svc_column('slipip')->required ) %>
       <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
     </TR>
 %   }
 % }
 
-% my %label = ( seconds => 'Time',
-%               upbytes => 'Upload bytes',
-%               downbytes => 'Download bytes',
-%               totalbytes => 'Total bytes',
-%             );
+% tie my %label, 'Tie::IxHash', seconds    => 'Time',
+%                               upbytes    => 'Upload bytes',
+%                               downbytes  => 'Download bytes',
+%                               totalbytes => 'Total bytes',
+% ;
 % foreach my $uf (keys %label) {
 %   my $tf = $uf . "_threshold";
 %   if ( $curuser->access_right('Edit usage') ) { 
 % } 
 
 
-<TR>
-  <TD ALIGN="right"><% mt('RADIUS groups') |h %></TD>
+<% include('/elements/tr-td-label.html',
+     'label'    => $part_svc->part_svc_column('usergroup')->columnlabel || mt('RADIUS groups'),
+     'required' => $part_svc->part_svc_column('usergroup')->required ) %>
 % if ( $part_svc_usergroup->columnflag eq 'F' ) { 
     <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
 % } else { 
 % } 
 
 </TR>
+
+% if ( $part_svc->has_router ) {
+<& /elements/hidden.html,
+    field => 'router_routernum',
+    curr_value => $svc_acct->router_routernum
+&>
+<& /elements/tr-input-text.html,
+    label => 'Attached router name',
+    field => 'router_routername',
+    size  => 32,
+    curr_value => $svc_acct->router_routername
+&>
+<& /elements/tr-select-table.html,
+    label         => 'Attached address block',
+    field         => 'router_blocknum',
+    table         => 'addr_block',
+    hashref       => { 'routernum' => '0' },
+    extra_sql     => ($svc_acct->router_routernum ?
+                        ' OR routernum = '.$svc_acct->router_routernum : ''),
+    agent_virt    => 1,
+    agent_null    => 1,
+    name_col      => 'cidr',
+    order_by      => 'ORDER BY ip_gateway, ip_netmask',
+    empty_label   => '(none)',
+    disable_empty => 0,
+    curr_value    => $svc_acct->router_blocknum
+&>
+% }
+
 % foreach my $field ($svc_acct->virtual_fields) { 
 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields. 
 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { 
@@ -502,7 +557,7 @@ my $ulen =
   : dbdef->table('svc_acct')->column('username')->length;
 my $ulen2 = $ulen+2;
 
-my $pmax = max($conf->config('passwordmax') || 13);
+my $pmax = max($conf->config('passwordmax') || 12);
 my $pmax2 = $pmax+2;
 
 my $p1 = popurl(1);
@@ -525,4 +580,21 @@ if ( $export_google ) {
   } #if $error
 }
 
+if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
+  if ( $svcnum ) {
+    my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
+    if ( $router ) {
+      $svc_acct->set("router_$_", $router->get($_))
+        foreach ('routername', 'routernum');
+      my ($block) = $router->addr_block;
+      $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
+    }
+  }
+  foreach (qw(router_routername router_routernum router_blocknum)) {
+    if ( $cgi->param($_) =~ /^(\w+)$/ ) {
+      $svc_acct->set($_, $1);
+    }
+  }
+}
+
 </%init>