this should process default usergroup as well as fixed now
[freeside.git] / httemplate / edit / svc_acct.cgi
index e74d84d..8d50aed 100755 (executable)
@@ -68,18 +68,13 @@ unless ( $svcnum || $cgi->param('error') ) { #adding
     }
   }
 
-  #set fixed and default fields from part_svc
-  foreach my $part_svc_column (
-    grep { $_->columnflag } $part_svc->all_part_svc_column
-  ) {
-    if ( $part_svc_column->columnname eq 'usergroup' ) {
-      @groups = split(',', $part_svc_column->columnvalue);
-    } else {
-      $svc_acct->setfield( $part_svc_column->columnname,
-                           $part_svc_column->columnvalue,
-                         );
-    }
-  }
+  $svc_acct->set_default_and_fixed( {
+    #false laziness w/svc-acct::_fieldhandlers
+    'usergroup' => sub { return $_[0] if ref($_[0]) eq 'ARRAY';
+                         @groups = split(/\s*,\s*/, shift );
+                         \@groups;
+                       },
+  } );
 
 }
 
@@ -119,7 +114,7 @@ my $p1 = popurl(1);
 
 %>
 
-<%= header("$action $svc account") %>
+<%= include("/elements/header.html","$action $svc account") %>
 
 <% if ( $cgi->param('error') ) { %>
   <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
@@ -274,7 +269,7 @@ if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
 <% foreach my $xid (qw( uid gid )) { %>
 
   <%
-  if ( $part_svc->part_svc_column($xid)->columnflag eq 'F'
+  if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
        || ! $conf->exists("svc_acct-edit_$xid")
      ) {
   %>
@@ -376,7 +371,7 @@ if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
 <% } %>
 
 
-<% if ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) { %>
+<% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { %>
 
   <INPUT TYPE="hidden" NAME="slipip" VALUE="<%= $svc_acct->slipip %>">
 
@@ -396,7 +391,7 @@ foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
   my $a = $2;
 %>
 
-  <% if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) { %>
+  <% if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) { %>
 
     <INPUT TYPE="hidden" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>">