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