fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / part_export_option.pm
1 package FS::part_export_option;
2 use base qw(FS::Record);
3
4 use strict;
5 use FS::Record qw( qsearchs ); #qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::part_export_option - Object methods for part_export_option records
10
11 =head1 SYNOPSIS
12
13   use FS::part_export_option;
14
15   $record = new FS::part_export_option \%hash;
16   $record = new FS::part_export_option { '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::part_export_option object represents an export option.
29 FS::part_export_option inherits from FS::Record.  The following fields are
30 currently supported:
31
32 =over 4
33
34 =item optionnum - primary key
35
36 =item exportnum - export (see L<FS::part_export>)
37
38 =item optionname - option name
39
40 =item optionvalue - option value
41
42 =back
43
44 =head1 METHODS
45
46 =over 4
47
48 =item new HASHREF
49
50 Creates a new export option.  To add the export option to the database, see
51 L<"insert">.
52
53 Note that this stores the hash reference, not a distinct copy of the hash it
54 points to.  You can ask the object for a copy with the I<hash> method.
55
56 =cut
57
58 # the new method can be inherited from FS::Record, if a table method is defined
59
60 sub table { 'part_export_option'; }
61
62 =item insert
63
64 Adds this record to the database.  If there is an error, returns the error,
65 otherwise returns false.
66
67 =cut
68
69 # the insert method can be inherited from FS::Record
70
71 =item delete
72
73 Delete this record from the database.
74
75 =cut
76
77 # the delete method can be inherited from FS::Record
78
79 =item replace OLD_RECORD
80
81 Replaces the OLD_RECORD with this one in the database.  If there is an error,
82 returns the error, otherwise returns false.
83
84 =cut
85
86 # the replace method can be inherited from FS::Record
87
88 =item check
89
90 Checks all fields to make sure this is a valid export option.  If there is
91 an error, returns the error, otherwise returns false.  Called by the insert
92 and replace methods.
93
94 =cut
95
96 # the check method should currently be supplied - FS::Record contains some
97 # data checking routines
98
99 sub check {
100   my $self = shift;
101
102   my $error = 
103     $self->ut_numbern('optionnum')
104     || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
105     || $self->ut_alpha('optionname')
106     || $self->ut_anything('optionvalue')
107   ;
108   return $error if $error;
109
110   return "Unknown exportnum: ". $self->exportnum
111     unless qsearchs('part_export', { 'exportnum' => $self->exportnum } );
112
113   #check options & values?
114
115   $self->SUPER::check;
116 }
117
118 =back
119
120 =head1 BUGS
121
122 Possibly.
123
124 =head1 SEE ALSO
125
126 L<FS::part_export>, L<FS::Record>, schema.html from the base documentation.
127
128 =cut
129
130 1;
131