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