start svc_alarm, RT#23694
[freeside.git] / FS / FS / svc_alarm.pm
1 package FS::svc_alarm;
2
3 use strict;
4 use base qw( FS::svc_Common );
5 use FS::Record; # qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::svc_alarm - Object methods for svc_alarm records
10
11 =head1 SYNOPSIS
12
13   use FS::svc_alarm;
14
15   $record = new FS::svc_alarm \%hash;
16   $record = new FS::svc_alarm { '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::svc_alarm object represents an alarm service.  FS::svc_alarm inherits
29 from FS::svc_Common.
30
31 The following fields are currently supported:
32
33 =over 4
34
35 =item svcnum - Primary key
36
37 =item alarm_system - Alarm System
38
39 =item alarm_type = Alarm Type
40
41 =item acctnum - Account number
42
43 =item _password - Password
44
45 =item location - Location on property
46
47 =back
48
49 =head1 METHODS
50
51 =over 4
52
53 =item new HASHREF
54
55 Creates a new svc_dish object.
56
57 =cut
58
59 sub table { 'svc_alarm'; }
60
61 sub table_info {
62   my %opts = ( 'type' => 'text', 
63                #'disable_select' => 1,
64                'disable_inventory' => 1,
65              );
66   {
67     'name'           => 'Alarm service',
68     'sorts'          => 'acctnum',
69     'display_weight' => 80,
70     'cancel_weight'  => 85,
71     'fields' => {
72       'svcnum'    => { label => 'Service' },
73       'alarm_system'   => { label => 'Alarm System', %opts },
74       'alarm_type'   => { label => 'Alarm Type', %opts },
75       'acctnum'   => { label => 'Account #', %opts },
76       '_password' => { label => 'Password', %opts },
77       'location'  => { label => 'Location', %opts },
78     },
79   };
80 }
81
82 sub label {
83   my $self = shift;
84   $self->acctnum;
85 }
86
87 sub search_sql {
88   my($class, $string) = @_;
89   $class->search_sql_field('acctnum', $string);
90 }
91
92 =item insert
93
94 Adds this record to the database.  If there is an error, returns the error,
95 otherwise returns false.
96
97 =item delete
98
99 Delete this record from the database.
100
101 =item replace OLD_RECORD
102
103 Replaces the OLD_RECORD with this one in the database.  If there is an error,
104 returns the error, otherwise returns false.
105
106 # the replace method can be inherited from FS::Record
107
108 =item check
109
110 Checks all fields to make sure this is a valid service.  If there is
111 an error, returns the error, otherwise returns false.  Called by the insert
112 and replace methods.
113
114 =cut
115
116 sub check {
117   my $self = shift;
118
119   my $x = $self->setfixed;
120   return $x unless ref $x;
121
122   my $error = 
123     $self->ut_numbern('svcnum')
124     || $self->ut_text('acctnum')
125     || $self->ut_numbern('installdate')
126     || $self->ut_anything('note')
127   ;
128   return $error if $error;
129
130   $self->SUPER::check;
131 }
132
133 =back
134
135 =head1 SEE ALSO
136
137 L<FS::Record>, L<FS::svc_Common>, schema.html from the base documentation.
138
139 =cut
140
141 1;
142