package FS::svc_alarm;
+use base qw( FS::svc_Common );
use strict;
-use base qw( FS::svc_Common );
use Tie::IxHash;
-use FS::Record qw( qsearchs ); # qw( qsearch qsearchs );
use FS::alarm_system;
use FS::alarm_type;
use FS::alarm_station;
'acctnum' => { label => 'Account #', %opts },
'_password' => { label => 'Password' , %opts },
'location' => { label => 'Location', %opts },
+ 'cs_receiver' => { label => 'CS Receiver #'},
+ 'cs_phonenum' => { label => 'CS Phone #' },
+ 'serialnum' => { label => 'Alarm Serial #' },
'alarmsystemnum' => { label => 'Alarm System Vendor',
type => 'select-alarm_system',
disable_inventory => 1,
my $x = $self->setfixed;
return $x unless ref $x;
- my $error =
+ my $iso3166 = $self->cust_main->ship_location->country();
+
+ my $error =
$self->ut_numbern('svcnum')
|| $self->ut_text('acctnum')
|| $self->ut_alphan('_password')
|| $self->ut_textn('location')
+ || $self->ut_numbern('cs_receiver')
+ || $self->ut_phonen('cs_phonenum', $iso3166)
+ || $self->ut_alphan('serialnum')
|| $self->ut_foreign_key('alarmsystemnum', 'alarm_system', 'systemnum')
|| $self->ut_foreign_key('alarmtypenum', 'alarm_type', 'typenum')
|| $self->ut_foreign_key('alarmstationnum', 'alarm_station', 'stationnum')
;
return $error if $error;
- $self->SUPER::check;
-}
+ #really just an signed int, but to discourage storing other data (e.g. phone)
+ return 'CS Receiver must be 9 digits or less'
+ if $self->cs_receiver =~ /\d{10}/;
-sub alarm_system {
- qsearchs('alarm_system', { alarmsystemnum => shift->alarmsystemnum } );
-}
-sub alarm_type {
- qsearchs('alarm_type', { alarmtypenum => shift->alarmtypenum } );
-}
-sub alarm_station {
- qsearchs('alarm_station', { alarmstationnum => shift->alarmstationnum } );
+ $self->SUPER::check;
}
=back