1 package FS::part_svc_column;
5 use FS::Record qw( fields );
11 FS::part_svc_column - Object methods for part_svc_column objects
15 use FS::part_svc_column;
17 $record = new FS::part_svc_column \%hash
18 $record = new FS::part_svc_column { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::part_svc_column record represents a service definition column
31 constraint. FS::part_svc_column inherits from FS::Record. The following
32 fields are currently supported:
36 =item columnnum - primary key (assigned automatcially for new records)
38 =item svcpart - service definition (see L<FS::part_svc>)
40 =item columnname - column name in part_svc.svcdb table
42 =item columnlabel - label for the column
44 =item columnvalue - default or fixed value for the column
46 =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.
48 =item required - column value expected to be true
58 Creates a new column constraint. To add the column constraint to the database, see L<"insert">.
62 sub table { 'part_svc_column'; }
66 Adds this service definition to the database. If there is an error, returns
67 the error, otherwise returns false.
71 Deletes this record from the database. If there is an error, returns the
72 error, otherwise returns false.
74 =item replace OLD_RECORD
76 Replaces OLD_RECORD with this one in the database. If there is an error,
77 returns the error, otherwise returns false.
81 Checks all fields to make sure this is a valid record. If there is an error,
82 returns the error, otherwise returns false. Called by the insert and replace
91 $self->ut_numbern('columnnum')
92 || $self->ut_number('svcpart')
93 || $self->ut_alpha('columnname')
94 || $self->ut_textn('columnlabel')
95 || $self->ut_anything('columnvalue')
96 || $self->ut_flag('required')
98 return $error if $error;
100 $self->columnflag =~ /^([DFSMAHXP]?)$/
101 or return "illegal columnflag ". $self->columnflag;
102 $self->columnflag(uc($1));
104 if ( $self->columnflag =~ /^[MA]$/ ) {
105 # split, check all values independently, and normalize
106 my @classnums = split(/\s*,\s*/, $self->columnvalue);
107 foreach (@classnums) {
108 $self->set('columnvalue', $_);
109 $error = $self->ut_foreign_key( 'columnvalue', 'inventory_class', 'classnum' );
110 return $error if $error;
112 $self->set('columnvalue', join(',', @classnums));
114 if ( $self->columnflag eq 'H' ) {
116 $self->ut_foreign_key( 'columnvalue', 'hardware_class', 'classnum' );
118 return $error if $error;
129 L<FS::Record>, L<FS::part_svc>, L<FS::part_pkg>, L<FS::pkg_svc>,
130 L<FS::cust_svc>, L<FS::svc_acct>, L<FS::svc_forward>, L<FS::svc_domain>,
131 schema.html from the base documentation.