RT# 81961 Repair broken links in POD documentation
[freeside.git] / FS / FS / hardware_type.pm
1 package FS::hardware_type;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::hardware_type - Object methods for hardware_type records
10
11 =head1 SYNOPSIS
12
13   use FS::hardware_type;
14
15   $record = new FS::hardware_type \%hash;
16   $record = new FS::hardware_type { '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::hardware_type object represents a device type (a model name or 
29 number) assignable as a hardware service (L<FS::svc_hardware>).
30 FS::hardware_type inherits from FS::Record.  The following fields are 
31 currently supported:
32
33 =over 4
34
35 =item typenum - primary key
36
37 =item classnum - key to an L<FS::hardware_class> record defining the class 
38 to which this device type belongs.
39
40 =item model - descriptive model name or number
41
42 =item revision - revision name/number, subordinate to model
43
44 =back
45
46 =head1 METHODS
47
48 =over 4
49
50 =item new HASHREF
51
52 Creates a new record.  To add the record to the database, see L<"insert">.
53
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to.  You can ask the object for a copy with the I<hash> method.
56
57 =cut
58
59 # the new method can be inherited from FS::Record, if a table method is defined
60
61 sub table { 'hardware_type'; }
62
63 =item insert
64
65 Adds this record to the database.  If there is an error, returns the error,
66 otherwise returns false.
67
68 =cut
69
70 # the insert method can be inherited from FS::Record
71
72 =item delete
73
74 Delete this record from the database.
75
76 =cut
77
78 # the delete method can be inherited from FS::Record
79
80 =item replace OLD_RECORD
81
82 Replaces the OLD_RECORD with this one in the database.  If there is an error,
83 returns the error, otherwise returns false.
84
85 =cut
86
87 # the replace method can be inherited from FS::Record
88
89 =item check
90
91 Checks all fields to make sure this is a valid hardware type.  If there is
92 an error, returns the error, otherwise returns false.  Called by the insert
93 and replace methods.
94
95 =cut
96
97 # the check method should currently be supplied - FS::Record contains some
98 # data checking routines
99
100 sub check {
101   my $self = shift;
102
103   my $error = 
104     $self->ut_numbern('typenum')
105     || $self->ut_foreign_key('classnum', 'hardware_class', 'classnum')
106     || $self->ut_text('model')
107     || $self->ut_textn('revision')
108   ;
109   return $error if $error;
110
111   $self->SUPER::check;
112 }
113
114 =item hardware_class
115
116 Returns the L<FS::hardware_class> associated with this device.
117
118 =cut
119
120 sub hardware_class {
121   my $self = shift;
122   return qsearchs('hardware_class', { 'classnum' => $self->classnum });
123 }
124
125 =item description
126
127 Returns the model and revision number.
128
129 =cut
130
131 sub description {
132   my $self = shift;
133   $self->model . ($self->revision ? ' '.$self->revision : '');
134 }
135
136 =back
137
138 =head1 SEE ALSO
139
140 L<FS::svc_hardware>, L<FS::Record>, schema.html from the base documentation.
141
142 =cut
143
144 1;
145