fix usergroup in edit/part_svc.cgi
[freeside.git] / FS / FS / svc_acct.pm
index 402d729..32ffb76 100644 (file)
@@ -272,6 +272,7 @@ sub table_info {
                          label => 'RADIUS groups',
                          type  => 'radius_usergroup_selector',
                          disable_inventory => 1,
+                         disable_select => 1,
                        },
         'seconds'   => { label => 'Seconds',
                          type  => 'text',
@@ -455,7 +456,7 @@ sub insert {
 
     if (   $conf->exists('emailinvoiceautoalways')
         || $conf->exists('emailinvoiceauto')
-        && $cust_main->invoicing_list_emailonly
+        && $cust_main->invoicing_list_emailonly
        ) {
       my @invoicing_list = $cust_main->invoicing_list;
       push @invoicing_list, $self->email;
@@ -1518,6 +1519,28 @@ sub _op_usage {
 
   my $action = $op2action{$op};
 
+  if ( &{$op2condition{$op}}($self, $column, $amount) ) {
+    foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
+      if ($part_export->option('overlimit_groups')) {
+        my ($new,$old);
+        my $other = new FS::svc_acct $self->hashref;
+        my $groups = &{ $self->_fieldhandlers->{'usergroup'} }
+                       ($self, $part_export->option('overlimit_groups'));
+        $other->usergroup( $groups );
+        if ($action eq 'suspend'){
+          $new = $other; $old = $self;
+        }else{
+          $new = $self; $old = $other;
+        }
+        my $error = $part_export->export_replace($new, $old);
+        if ( $error ) {
+          $dbh->rollback if $oldAutoCommit;
+          return "Error replacing radius groups in export, ${op}: $error";
+        }
+      }
+    }
+  }
+
   if ( $conf->exists("svc_acct-usage_$action")
        && &{$op2condition{$op}}($self, $column, $amount)    ) {
     #my $error = $self->$action();