agent-virtualize credit card surcharge percentage, RT#72961
[freeside.git] / FS / FS / alarm_station.pm
1 package FS::alarm_station;
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_station - Object methods for alarm_station records
11
12 =head1 SYNOPSIS
13
14   use FS::alarm_station;
15
16   $record = new FS::alarm_station \%hash;
17   $record = new FS::alarm_station { '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_station object represents an alarm system central station.
30 FS::alarm_station inherits from FS::Record.  The following fields are currently
31 supported:
32
33 =over 4
34
35 =item alarmstationnum
36
37 primary key
38
39 =item agentnum
40
41 agentnum
42
43 =item stationname
44
45 stationname
46
47 =item disabled
48
49 disabled
50
51
52 =back
53
54 =head1 METHODS
55
56 =over 4
57
58 =item new HASHREF
59
60 Creates a new central station.  To add the central station to the database, see
61 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 { 'alarm_station'; }
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 central station.  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('alarmstationnum')
97     || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
98     || $self->ut_text('stationname')
99     || $self->ut_enum('disabled', ['', 'Y'])
100   ;
101   return $error if $error;
102
103   $self->SUPER::check;
104 }
105
106 =back
107
108 =head1 BUGS
109
110 =head1 SEE ALSO
111
112 L<FS::svc_alarm>, L<FS::Record>
113
114 =cut
115
116 1;
117