eliminate some false laziness in FS::Misc::send_email vs. msg_template/email.pm send_...
[freeside.git] / FS / FS / vend_class.pm
1 package FS::vend_class;
2
3 use strict;
4 use base qw( FS::class_Common );
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::vend_class - Object methods for vend_class records
10
11 =head1 SYNOPSIS
12
13   use FS::vend_class;
14
15   $record = new FS::vend_class \%hash;
16   $record = new FS::vend_class { '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::vend_class object represents a vendor class.  FS::vend_class inherits
29 from FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item classnum
34
35 primary key
36
37 =item classname
38
39 classname
40
41 =item disabled
42
43 disabled
44
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new vendor class.  To add the vendor class to the database, see
55 L<"insert">.
56
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to.  You can ask the object for a copy with the I<hash> method.
59
60 =cut
61
62 sub table { 'vend_class'; }
63
64 sub _target_table { 'vend_main'; }
65
66 =item insert
67
68 Adds this record to the database.  If there is an error, returns the error,
69 otherwise returns false.
70
71 =item delete
72
73 Delete this record from the database.
74
75 =item replace OLD_RECORD
76
77 Replaces the OLD_RECORD with this one in the database.  If there is an error,
78 returns the error, otherwise returns false.
79
80 =item check
81
82 Checks all fields to make sure this is a valid vendor class.  If there is
83 an error, returns the error, otherwise returns false.  Called by the insert
84 and replace methods.
85
86 =cut
87
88 sub check {
89   my $self = shift;
90
91   my $error = 
92     $self->ut_numbern('classnum')
93     || $self->ut_text('classname')
94     || $self->ut_enum('disabled', [ '', 'Y' ])
95   ;
96   return $error if $error;
97
98   $self->SUPER::check;
99 }
100
101 =back
102
103 =head1 BUGS
104
105 =head1 SEE ALSO
106
107 L<FS::Record>, schema.html from the base documentation.
108
109 =cut
110
111 1;
112