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