Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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( qsearch qsearchs );
6 use FS::cust_svc;
7 use FS::part_export_machine;
8
9 =head1 NAME
10
11 FS::svc_export_machine - Object methods for svc_export_machine records
12
13 =head1 SYNOPSIS
14
15   use FS::svc_export_machine;
16
17   $record = new FS::svc_export_machine \%hash;
18   $record = new FS::svc_export_machine { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::svc_export_machine object represents a customer service export
31 hostname.  FS::svc_export_machine inherits from FS::Record.  The following
32 fields are currently supported:
33
34 =over 4
35
36 =item svcexportmachinenum
37
38 primary key
39
40 =item svcnum
41
42 Customer service, see L<FS::cust_svc>
43
44 =item machinenum
45
46 Export hostname, see L<FS::part_export_machine>
47
48 =back
49
50 =head1 METHODS
51
52 =over 4
53
54 =item new HASHREF
55
56 Creates a new record.  To add the record to the database, see L<"insert">.
57
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to.  You can ask the object for a copy with the I<hash> method.
60
61 =cut
62
63 sub table { 'svc_export_machine'; }
64
65 =item insert
66
67 Adds this record to the database.  If there is an error, returns the error,
68 otherwise returns false.
69
70 =item delete
71
72 Delete this record from the database.
73
74 =item replace OLD_RECORD
75
76 Replaces the OLD_RECORD with this one in the database.  If there is an error,
77 returns the error, otherwise returns false.
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   my $error = 
91     $self->ut_numbern('svcexportmachinenum')
92     || $self->ut_foreign_key('svcnum', 'cust_svc', 'svcnum')
93     || $self->ut_foreign_key('machinenum', 'part_export_machine', 'machinenum' )
94   ;
95   return $error if $error;
96
97   $self->SUPER::check;
98 }
99
100 =back
101
102 =head1 BUGS
103
104 =head1 SEE ALSO
105
106 L<FS::cust_svc>, L<FS::part_export_machine>, L<FS::Record>
107
108 =cut
109
110 1;
111