communigate (phase 2): rules. RT#7514
[freeside.git] / FS / FS / cgp_rule.pm
1 package FS::cgp_rule;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::cgp_rule - Object methods for cgp_rule records
10
11 =head1 SYNOPSIS
12
13   use FS::cgp_rule;
14
15   $record = new FS::cgp_rule \%hash;
16   $record = new FS::cgp_rule { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::cgp_rule object represents an example.  FS::cgp_rule inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item rulenum
34
35 primary key
36
37 =item name
38
39 name
40
41 =item comment
42
43 comment
44
45 =item svcnum
46
47 svcnum
48
49 =item priority
50
51 priority
52
53
54 =back
55
56 =head1 METHODS
57
58 =over 4
59
60 =item new HASHREF
61
62 Creates a new example.  To add the example to the database, see L<"insert">.
63
64 Note that this stores the hash reference, not a distinct copy of the hash it
65 points to.  You can ask the object for a copy with the I<hash> method.
66
67 =cut
68
69 # the new method can be inherited from FS::Record, if a table method is defined
70
71 sub table { 'cgp_rule'; }
72
73 =item insert
74
75 Adds this record to the database.  If there is an error, returns the error,
76 otherwise returns false.
77
78 =cut
79
80 # the insert method can be inherited from FS::Record
81
82 =item delete
83
84 Delete this record from the database.
85
86 =cut
87
88 # the delete method can be inherited from FS::Record
89
90 =item replace OLD_RECORD
91
92 Replaces the OLD_RECORD with this one in the database.  If there is an error,
93 returns the error, otherwise returns false.
94
95 =cut
96
97 # the replace method can be inherited from FS::Record
98
99 =item check
100
101 Checks all fields to make sure this is a valid example.  If there is
102 an error, returns the error, otherwise returns false.  Called by the insert
103 and replace methods.
104
105 =cut
106
107 # the check method should currently be supplied - FS::Record contains some
108 # data checking routines
109
110 sub check {
111   my $self = shift;
112
113   my $error = 
114     $self->ut_numbern('rulenum')
115     || $self->ut_text('name')
116     || $self->ut_text('comment')
117     || $self->ut_number('svcnum')
118     || $self->ut_number('priority')
119   ;
120   return $error if $error;
121
122   $self->SUPER::check;
123 }
124
125 =back
126
127 =head1 BUGS
128
129 The author forgot to customize this manpage.
130
131 =head1 SEE ALSO
132
133 L<FS::Record>, schema.html from the base documentation.
134
135 =cut
136
137 1;
138