svc_pbx devices, for RT#24968
[freeside.git] / FS / FS / pbx_device.pm
1 package FS::pbx_device;
2 use base qw( FS::MAC_Mixin FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::pbx_device - Object methods for pbx_device records
10
11 =head1 SYNOPSIS
12
13   use FS::pbx_device;
14
15   $record = new FS::pbx_device \%hash;
16   $record = new FS::pbx_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::pbx_device object represents a specific customer phone device, such
29 as a SIP phone or ATA.  FS::pbx_device inherits from FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item devicenum
34
35 primary key
36
37 =item devicepart
38
39 devicepart
40
41 =item svcnum
42
43 svcnum
44
45 =item mac_addr
46
47 mac_addr
48
49
50 =back
51
52 =head1 METHODS
53
54 =over 4
55
56 =item new HASHREF
57
58 Creates a new record.  To add the record to the database, see L<"insert">.
59
60 Note that this stores the hash reference, not a distinct copy of the hash it
61 points to.  You can ask the object for a copy with the I<hash> method.
62
63 =cut
64
65 sub table { 'pbx_device'; }
66
67 =item insert
68
69 Adds this record to the database.  If there is an error, returns the error,
70 otherwise returns false.
71
72 =item delete
73
74 Delete this record from the database.
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 =item check
82
83 Checks all fields to make sure this is a valid record.  If there is
84 an error, returns the error, otherwise returns false.  Called by the insert
85 and replace methods.
86
87 =cut
88
89 sub check {
90   my $self = shift;
91
92   my $error = 
93     $self->ut_numbern('devicenum')
94     || $self->ut_foreign_key('devicepart', 'part_device', 'devicepart')
95     || $self->ut_foreign_key('svcnum', 'svc_pbx', 'svcnum')
96     || $self->ut_mac_addr('mac_addr')
97   ;
98   return $error if $error;
99
100   $self->SUPER::check;
101 }
102
103 =back
104
105 =head1 BUGS
106
107 =head1 SEE ALSO
108
109 L<FS::Record>
110
111 =cut
112
113 1;
114