This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / FS / FS / part_svc_column.pm
1 package FS::part_svc_column;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( fields );
6
7 @ISA = qw(FS::Record);
8
9 =head1 NAME
10
11 FS::part_svc_column - Object methods for part_svc_column objects
12
13 =head1 SYNOPSIS
14
15   use FS::part_svc_column;
16
17   $record = new FS::part_svc_column \%hash
18   $record = new FS::part_svc_column { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
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:
33
34 =over 4
35
36 =item columnnum - primary key (assigned automatcially for new records)
37
38 =item svcpart - service definition (see L<FS::part_svc>)
39
40 =item columnname - column name in part_svc.svcdb table
41
42 =item columnvalue - default or fixed value for the column
43
44 =item columnflag - null or empty (no default), `D' for default, `F' for fixed (unchangeable), `S' for selectable choice, `M' for manual selection from inventory, or `A' for automatic selection from inventory.  For virtual fields, can also be 'X' for excluded.
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new column constraint.  To add the column constraint to the database, see L<"insert">.
55
56 =cut
57
58 sub table { 'part_svc_column'; }
59
60 =item insert
61
62 Adds this service definition to the database.  If there is an error, returns
63 the error, otherwise returns false.
64
65 =item delete
66
67 Deletes this record from the database.  If there is an error, returns the
68 error, otherwise returns false.
69
70 =item replace OLD_RECORD
71
72 Replaces OLD_RECORD with this one in the database.  If there is an error,
73 returns the error, otherwise returns false.
74
75 =item check
76
77 Checks all fields to make sure this is a valid record.  If there is an error,
78 returns the error, otherwise returns false.  Called by the insert and replace
79 methods.
80
81 =cut
82
83 sub check {
84   my $self = shift;
85
86   my $error =
87     $self->ut_numbern('columnnum')
88     || $self->ut_number('svcpart')
89     || $self->ut_alpha('columnname')
90     || $self->ut_anything('columnvalue')
91   ;
92   return $error if $error;
93
94   $self->columnflag =~ /^([DFSMAX])$/
95     or return "illegal columnflag ". $self->columnflag;
96   $self->columnflag(uc($1));
97
98   if ( $self->columnflag =~ /^[MA]$/ ) {
99     $error =
100       $self->ut_foreign_key( 'columnvalue', 'inventory_class', 'classnum' );
101     return $error if $error;
102   }
103
104   $self->SUPER::check;
105 }
106
107 =back
108
109 =head1 BUGS
110
111 =head1 SEE ALSO
112
113 L<FS::Record>, L<FS::part_svc>, L<FS::part_pkg>, L<FS::pkg_svc>,
114 L<FS::cust_svc>, L<FS::svc_acct>, L<FS::svc_forward>, L<FS::svc_domain>,
115 schema.html from the base documentation.
116
117 =cut
118
119 1;
120