enable CardFortress in test database, #71513
[freeside.git] / FS / FS / part_event_condition_option.pm
1 package FS::part_event_condition_option;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::option_Common;
7 use FS::part_event_condition;
8
9 @ISA = qw( FS::option_Common ); # FS::Record);
10
11 =head1 NAME
12
13 FS::part_event_condition_option - Object methods for part_event_condition_option records
14
15 =head1 SYNOPSIS
16
17   use FS::part_event_condition_option;
18
19   $record = new FS::part_event_condition_option \%hash;
20   $record = new FS::part_event_condition_option { 'column' => 'value' };
21
22   $error = $record->insert;
23
24   $error = $new_record->replace($old_record);
25
26   $error = $record->delete;
27
28   $error = $record->check;
29
30 =head1 DESCRIPTION
31
32 An FS::part_event_condition_option object represents an event condition option.
33 FS::part_event_condition_option inherits from FS::Record.  The following fields
34 are currently supported:
35
36 =over 4
37
38 =item optionnum - primary key
39
40 =item eventconditionnum - Event condition (see L<FS::part_event_condition>)
41
42 =item optionname - Option name
43
44 =item optionvalue - Option value
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new record.  To add the record to the database, see L<"insert">.
55
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to.  You can ask the object for a copy with the I<hash> method.
58
59 =cut
60
61 # the new method can be inherited from FS::Record, if a table method is defined
62
63 sub table { 'part_event_condition_option'; }
64
65 =item insert [ HASHREF | OPTION => VALUE ... ]
66
67 Adds this record to the database.  If there is an error, returns the error,
68 otherwise returns false.
69
70 If a list or hash reference of options is supplied,
71 part_event_condition_option_option records are created (see
72 L<FS::part_event_condition_option_option>).
73
74 =cut
75
76 # the insert method can be inherited from FS::Record
77
78 =item delete
79
80 Delete this record from the database.
81
82 =cut
83
84 # the delete method can be inherited from FS::Record
85
86 =item replace OLD_RECORD [ HASHREF | OPTION => VALUE ... ]
87
88 Replaces the OLD_RECORD with this one in the database.  If there is an error,
89 returns the error, otherwise returns false.
90
91 If a list or hash reference of options is supplied,
92 part_event_condition_option_option records are created or modified (see
93 L<FS::part_event_condition_option_option>).
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 record.  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('optionnum')
115     || $self->ut_foreign_key('eventconditionnum',
116                                'part_event_condition', 'eventconditionnum')
117     || $self->ut_text('optionname')
118     || $self->ut_textn('optionvalue')
119   ;
120   return $error if $error;
121
122   $self->SUPER::check;
123 }
124
125 #this makes the nested options magically show up as perl refs
126 #move it to a mixin class if we need nested options again
127 sub optionvalue {
128   my $self = shift;
129   if ( scalar(@_) ) { #setting, no magic (here, insert takes care of it)
130     $self->set('optionvalue', @_);
131   } else { #getting, magic
132     my $optionvalue = $self->get('optionvalue');
133     if ( $optionvalue eq 'HASH' ) {
134       return { $self->options };
135     } else {
136       $optionvalue;
137     }
138   }
139 }
140
141 =back
142
143 =head1 SEE ALSO
144
145 L<FS::part_event_condition>, L<FS::part_event_condition_option_option>, 
146 L<FS::Record>, schema.html from the base documentation.
147
148 =cut
149
150 1;
151