fix 'Can't call method "setup" on an undefined value' error when using into rates...
[freeside.git] / FS / FS / part_svc_column.pm
index 37e841e..d467516 100644 (file)
@@ -39,9 +39,11 @@ fields are currently supported:
 
 =item columnname - column name in part_svc.svcdb table
 
+=item columnlabel - label for the column
+
 =item columnvalue - default or fixed value for the column
 
-=item columnflag - null, D or F
+=item columnflag - null or empty (no default), `D' for default, `F' for fixed (unchangeable), `S' for selectable choice, `M' for manual selection from inventory, `A' for automatic selection from inventory, or `H' for selection from a hardware class.  For virtual fields, can also be 'X' for excluded.
 
 =back
 
@@ -87,23 +89,30 @@ sub check {
     $self->ut_numbern('columnnum')
     || $self->ut_number('svcpart')
     || $self->ut_alpha('columnname')
+    || $self->ut_textn('columnlabel')
     || $self->ut_anything('columnvalue')
   ;
   return $error if $error;
 
-  $self->columnflag =~ /^([DF])$/
+  $self->columnflag =~ /^([DFSMAHX]?)$/
     or return "illegal columnflag ". $self->columnflag;
   $self->columnflag(uc($1));
 
-  ''; #no error
+  if ( $self->columnflag =~ /^[MA]$/ ) {
+    $error =
+      $self->ut_foreign_key( 'columnvalue', 'inventory_class', 'classnum' );
+  }
+  if ( $self->columnflag eq 'H' ) {
+    $error = 
+      $self->ut_foreign_key( 'columnvalue', 'hardware_class', 'classnum' );
+  }
+  return $error if $error;
+
+  $self->SUPER::check;
 }
 
 =back
 
-=head1 VERSION
-
-$Id: part_svc_column.pm,v 1.1 2001-09-07 20:49:15 ivan Exp $
-
 =head1 BUGS
 
 =head1 SEE ALSO