radius attributes & default/fixed values should work again now
authorivan <ivan>
Tue, 11 Sep 2001 23:44:01 +0000 (23:44 +0000)
committerivan <ivan>
Tue, 11 Sep 2001 23:44:01 +0000 (23:44 +0000)
FS/FS/part_svc.pm
httemplate/edit/svc_acct.cgi
httemplate/edit/svc_acct_sm.cgi
httemplate/edit/svc_domain.cgi
httemplate/edit/svc_forward.cgi
httemplate/view/svc_acct.cgi

index f1e71ad..6f66ef9 100644 (file)
@@ -40,10 +40,6 @@ FS::Record.  The following fields are currently supported:
 =item svcdb - table used for this service.  See L<FS::svc_acct>,
 L<FS::svc_domain>, and L<FS::svc_forward>, among others.
 
-=item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
-
-=item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null, `D' for default, or `F' for fixed
-
 =back
 
 =head1 METHODS
@@ -63,6 +59,7 @@ sub table { 'part_svc'; }
 
 Adds this service definition to the database.  If there is an error, returns
 the error, otherwise returns false.
+
 =item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
 
 =item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null, `D' for default, or `F' for fixed
@@ -285,11 +282,20 @@ sub part_svc_column {
                                };
 }
 
+=item all_part_svc_column
+
+=cut
+
+sub all_part_svc_column {
+  my $self = shift;
+  qsearch('part_svc_column', { 'svcpart' => $self->svcpart } );
+}
+
 =back
 
 =head1 VERSION
 
-$Id: part_svc.pm,v 1.4 2001-09-11 00:08:18 ivan Exp $
+$Id: part_svc.pm,v 1.5 2001-09-11 23:44:01 ivan Exp $
 
 =head1 BUGS
 
index 8a2cb80..f594bd2 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: svc_acct.cgi,v 1.6 2001-09-04 14:44:06 ivan Exp $ -->
+#<!-- $Id: svc_acct.cgi,v 1.7 2001-09-11 23:44:01 ivan Exp $ -->
 
 use strict;
 use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
@@ -13,6 +13,7 @@ use FS::CGI qw(header popurl);
 use FS::Record qw(qsearch qsearchs fields);
 use FS::svc_acct;
 use FS::Conf;
+use FS::raddb;
 
 $cgi = new CGI;
 &cgisuidsetup($cgi);
@@ -68,11 +69,12 @@ if ( $cgi->param('error') ) {
     }
 
     #set fixed and default fields from part_svc
-    my($field);
-    foreach $field ( fields('svc_acct') ) {
-      if ( $part_svc->getfield('svc_acct__'. $field. '_flag') ne '' ) {
-        $svc_acct->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
-      }
+    foreach my $part_svc_column (
+      grep { $_->columnflag } $part_svc->all_part_svc_column
+    ) {
+      $svc_acct->setfield( $part_svc_column->columnname,
+                           $part_svc_column->columnvalue,
+                         );
     }
 
   }
@@ -118,18 +120,19 @@ END
 
 #domain
 $domsvc = $svc_acct->domsvc || 0;
-if ( $part_svc->svc_acct__domsvc_flag eq 'F' ) {
+if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
   print qq!<INPUT TYPE="hidden" NAME="domsvc" VALUE="$domsvc">!;
 } else { 
   my @svc_domain = ();
-  if ( $part_svc->svc_acct__domsvc_flag eq 'D' ) {
-    my $svc_domain =
-      qsearchs('svc_domain', { 'svcnum' => $part_svc->svc_acct__domsvc } );
+  if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'D' ) {
+    my $svc_domain = qsearchs('svc_domain', {
+      'svcnum' => $part_svc->part_svc_column('domsvc')->columnvalue,
+    } );
     if ( $svc_domain ) {
       push @svc_domain, $svc_domain;
     } else {
-      warn "unknown svc_domain.svcnum for part_svc.svc_acct__domsvc: ".
-           $part_svc->svc_acct__domsvc;
+      warn "unknown svc_domain.svcnum for part_svc_column domsvc: ".
+           $part_svc->part_svc_column('domsvc')->columnvalue;
     }
   }
   my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
@@ -157,7 +160,7 @@ if ( $part_svc->svc_acct__domsvc_flag eq 'F' ) {
 
 #pop
 $popnum = $svc_acct->popnum || 0;
-if ( $part_svc->svc_acct__popnum_flag eq "F" ) {
+if ( $part_svc->part_svc_column('popnum')->columnflag eq "F" ) {
   print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$popnum">!;
 } else { 
   print qq!<BR>POP: <SELECT NAME="popnum" SIZE=1><OPTION>\n!;
@@ -189,7 +192,7 @@ print <<END;
 END
 
 $shell = $svc_acct->shell;
-if ( $part_svc->svc_acct__shell_flag eq "F" ) {
+if ( $part_svc->part_svc_column('shell')->columnflag eq "F" ) {
   print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
 } else {
   print qq!<BR>Shell: <SELECT NAME="shell" SIZE=1>!;
@@ -208,12 +211,24 @@ if ( $part_svc->svc_acct__shell_flag eq "F" ) {
 
 print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!;
 
-if ( $part_svc->svc_acct__slipip_flag eq "F" ) {
+if ( $part_svc->part_svc_column('slipip')->columnflag eq "F" ) {
   print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!;
 } else {
   print qq!<BR>IP: <INPUT TYPE="text" NAME="slipip" VALUE="$slipip">!;
 }
 
+foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
+  $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
+  my $a = $2;
+  if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) {
+    print qq!<INPUT TYPE="hidden" NAME="$r" VALUE="!.
+          $svc_acct->getfield($r). '">';
+  } else {
+    print qq!<BR>$FS::raddb::attrib{$a}: <INPUT TYPE="text" NAME="$r" VALUE="!.
+          $svc_acct->getfield($r). '">';
+  }
+}
+
 #submit
 print qq!<P><INPUT TYPE="submit" VALUE="Submit">!; 
 
index 4eb3d83..21bd6a9 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: svc_acct_sm.cgi,v 1.3 2001-09-11 20:59:32 ivan Exp $ -->
+#<!-- $Id: svc_acct_sm.cgi,v 1.4 2001-09-11 23:44:01 ivan Exp $ -->
 
 use strict;
 use vars qw( $conf $cgi $mydomain $action $svcnum $svc_acct_sm $pkgnum $svcpart
@@ -57,11 +57,12 @@ if ( $cgi->param('error') ) {
     $svcnum='';
 
     #set fixed and default fields from part_svc
-    my($field);
-    foreach $field ( fields('svc_acct_sm') ) {
-      if ( $part_svc->getfield('svc_acct_sm__'. $field. '_flag') ne '' ) {
-        $svc_acct_sm->setfield($field,$part_svc->getfield('svc_acct_sm__'. $field) );
-      }
+    foreach my $part_svc_column (
+      grep { $_->columnflag } $part_svc->all_part_svc_column
+    ) {
+      $svc_acct_sm->setfield( $part_svc_column->columnname,
+                              $part_svc_column->columnvalue,
+                            );
     }
 
   }
index 8ffc9d7..7033c11 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: svc_domain.cgi,v 1.2 2001-08-21 02:31:56 ivan Exp $ -->
+#<!-- $Id: svc_domain.cgi,v 1.3 2001-09-11 23:44:01 ivan Exp $ -->
 
 use strict;
 use vars qw( $cgi $action $svcnum $svc_domain $pkgnum $svcpart $part_svc
@@ -57,13 +57,15 @@ if ( $cgi->param('error') ) {
     $svcnum='';
 
     #set fixed and default fields from part_svc
-    my($field);
-    foreach $field ( fields('svc_domain') ) {
-      if ( $part_svc->getfield('svc_domain__'. $field. '_flag') ne '' ) {
-        $svc_domain->setfield($field,$part_svc->getfield('svc_domain__'. $field) );
-      }
+    foreach my $part_svc_column (
+      grep { $_->columnflag } $part_svc->all_part_svc_column
+    ) {
+      $svc_domain->setfield( $part_svc_column->columnname,
+                             $part_svc_column->columnvalue,
+                           );
     }
 
+
   }
 }
 $action = $svcnum ? 'Edit' : 'Add';
index de4c8cb..287833e 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-# <!-- $Id: svc_forward.cgi,v 1.3 2001-08-21 10:27:11 ivan Exp $ -->
+# <!-- $Id: svc_forward.cgi,v 1.4 2001-09-11 23:44:01 ivan Exp $ -->
 
 use strict;
 use vars qw( $conf $cgi $mydomain $action $svcnum $svc_forward $pkgnum $svcpart
@@ -57,13 +57,15 @@ if ( $cgi->param('error') ) {
     $svcnum='';
 
     #set fixed and default fields from part_svc
-    my($field);
-    foreach $field ( fields('svc_forward') ) {
-      if ( $part_svc->getfield('svc_forward__'. $field. '_flag') ne '' ) {
-        $svc_forward->setfield($field,$part_svc->getfield('svc_forward__'. $field) );
-      }
+    foreach my $part_svc_column (
+      grep { $_->columnflag } $part_svc->all_part_svc_column
+    ) {
+      $svc_forward->setfield( $part_svc_column->columnname,
+                              $part_svc_column->columnvalue,
+                            );
     }
 
+
   }
 }
 $action = $svc_forward->svcnum ? 'Edit' : 'Add';
index 3a22271..ad7e653 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-# <!-- $Id: svc_acct.cgi,v 1.3 2001-08-21 02:31:57 ivan Exp $ -->
+# <!-- $Id: svc_acct.cgi,v 1.4 2001-09-11 23:44:01 ivan Exp $ -->
 
 use strict;
 use vars qw( $conf $cgi $svc_domain $query $svcnum $svc_acct $cust_svc $pkgnum
@@ -15,6 +15,7 @@ use FS::cust_svc;
 use FS::cust_pkg;
 use FS::part_svc;
 use FS::svc_acct_pop;
+use FS::raddb;
 
 $cgi = new CGI;
 &cgisuidsetup($cgi);
@@ -101,9 +102,14 @@ if ($svc_acct->slipip) {
   foreach $attribute ( grep /^radius_/, fields('svc_acct') ) {
     #warn $attribute;
     $attribute =~ /^radius_(.*)$/;
-    my($pattribute) = ($1);
-    $pattribute =~ s/_/-/g;
-    print "<BR>Radius $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
+    my $pattribute = $FS::raddb::attrib{$1};
+    print "<BR>Radius (reply) $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
+  }
+  foreach $attribute ( grep /^rc_/, fields('svc_acct') ) {
+    #warn $attribute;
+    $attribute =~ /^rc_(.*)$/;
+    my $pattribute = $FS::raddb::attrib{$1};
+    print "<BR>Radius (check) $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
   }
 } else {
   print "<BR><BR>(No SLIP/PPP account)";