eliminate some false laziness in FS::Misc::send_email vs. msg_template/email.pm send_...
[freeside.git] / FS / FS / extension_device.pm
1 package FS::extension_device;
2 use base qw( FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::extension_device - Object methods for extension_device records
10
11 =head1 SYNOPSIS
12
13   use FS::extension_device;
14
15   $record = new FS::extension_device \%hash;
16   $record = new FS::extension_device { '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::extension_device object represents a PBX extension association with a 
29 specific PBX device (SIP phone or ATA).  FS::extension_device inherits from
30 FS::Record.  The following fields are currently supported:
31
32 =over 4
33
34 =item extensiondevicenum
35
36 primary key
37
38 =item extensionnum
39
40 extensionnum
41
42 =item devicenum
43
44 devicenum
45
46
47 =back
48
49 =head1 METHODS
50
51 =over 4
52
53 =item new HASHREF
54
55 Creates a new record.  To add the record to the database, see 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 { 'extension_device'; }
63
64 =item insert
65
66 Adds this record to the database.  If there is an error, returns the error,
67 otherwise returns false.
68
69 =item delete
70
71 Delete this record from the database.
72
73 =item replace OLD_RECORD
74
75 Replaces the OLD_RECORD with this one in the database.  If there is an error,
76 returns the error, otherwise returns false.
77
78 =item check
79
80 Checks all fields to make sure this is a valid record.  If there is
81 an error, returns the error, otherwise returns false.  Called by the insert
82 and replace methods.
83
84 =cut
85
86 sub check {
87   my $self = shift;
88
89   my $error = 
90     $self->ut_numbern('extensiondevicenum')
91     || $self->ut_foreign_keyn('extensionnum', 'pbx_extension', 'extensionnum')
92     || $self->ut_foreign_keyn('devicenum', 'pbx_device', 'devicenum')
93   ;
94   return $error if $error;
95
96   $self->SUPER::check;
97 }
98
99 =back
100
101 =head1 BUGS
102
103 =head1 SEE ALSO
104
105 L<FS::Record>
106
107 =cut
108
109 1;
110