enable CardFortress in test database, #71513
[freeside.git] / FS / FS / alarm_type.pm
1 package FS::alarm_type;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record; # qw( qsearch qsearchs );
6 use FS::agent;
7
8 =head1 NAME
9
10 FS::alarm_type - Object methods for alarm_type records
11
12 =head1 SYNOPSIS
13
14   use FS::alarm_type;
15
16   $record = new FS::alarm_type \%hash;
17   $record = new FS::alarm_type { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::alarm_type object represents an alarm system type (number of inputs and
30 outputs).  FS::alarm_type inherits from FS::Record.  The following fields are
31 currently supported:
32
33 =over 4
34
35 =item alarmtypenum
36
37 primary key
38
39 =item agentnum
40
41 agentnum
42
43 =item inputs
44
45 inputs
46
47 =item outputs
48
49 outputs
50
51 =item disabled
52
53 disabled
54
55 =back
56
57 =head1 METHODS
58
59 =over 4
60
61 =item new HASHREF
62
63 Creates a new type.  To add the type 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 { 'alarm_type'; }
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 type.  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('alarmtypenum')
99     || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
100     || $self->ut_number('inputs')
101     || $self->ut_number('outputs')
102     || $self->ut_enum('disabled', ['', 'Y'])
103   ;
104   return $error if $error;
105
106   $self->SUPER::check;
107 }
108
109 =item typename
110
111 inputs x outputs
112
113 =cut
114
115 sub typename {
116   my $self = shift;
117   $self->inputs. 'x'. $self->outputs;
118 }
119
120 =back
121
122 =head1 BUGS
123
124 =head1 SEE ALSO
125
126 L<FS::svc_alarm>, L<FS::Record>
127
128 =cut
129
130 1;
131