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