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