From ee7bb8218d50ca38148427c9b24a8decbd3ace86 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sat, 7 Sep 2013 17:39:00 -0700 Subject: [PATCH] start svc_alarm, RT#23694 --- FS/FS/AccessRight.pm | 1 + FS/FS/Mason.pm | 1 + FS/FS/Schema.pm | 16 ++++++ FS/FS/access_right.pm | 20 +++++-- FS/FS/h_svc_alarm.pm | 32 +++++++++++ FS/FS/svc_alarm.pm | 142 +++++++++++++++++++++++++++++++++++++++++++++++ FS/FS/svc_mailinglist.pm | 2 +- FS/MANIFEST | 2 + FS/t/svc_alarm.t | 5 ++ 9 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 FS/FS/h_svc_alarm.pm create mode 100644 FS/FS/svc_alarm.pm create mode 100644 FS/t/svc_alarm.t diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 019ea2178..2783adac2 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -302,6 +302,7 @@ tie my %rights, 'Tie::IxHash', 'Services: PBXs', 'Services: Ports', 'Services: Mailing lists', + 'Services: Alarm services', 'Services: External services', 'Usage: RADIUS sessions', 'Usage: Call Detail Records (CDRs)', diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 88198dd05..08cce1666 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -352,6 +352,7 @@ if ( -e $addl_handler_use_file ) { use FS::vend_pay; use FS::vend_bill_pay; use FS::sales_pkg_class; + use FS::svc_alarm; # Sammath Naur if ( $FS::Mason::addl_handler_use ) { diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 87a14aac4..66752dab1 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -4250,6 +4250,22 @@ sub tables_hashref { 'index' => [], }, + 'svc_alarm' => { + 'columns' => [ + 'svcnum', 'int', '', '', '', '', + 'alarm_system', 'varchar', '', $char_d, '', '', # dropdowns? + 'alarm_type', 'varchar', '', $char_d, '', '', # + 'acctnum', 'varchar', '', $char_d, '', '', + '_password', 'varchar', '', $char_d, '', '', + 'location', 'varchar', 'NULL', $char_d, '', '', + #cs + #rep + ], + 'primary_key' => 'svcnum', + 'unique' => [], #system/type/acctnum?? + 'index' => [], + }, + 'svc_cable' => { 'columns' => [ 'svcnum', 'int', '', '', '', '', diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index 85334ed1f..289660fa6 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -187,7 +187,8 @@ sub _upgrade_data { # class method my @all_groups = qsearch('access_group', {}); - tie my %onetime, 'Tie::IxHash', + #tie my %onetime, 'Tie::IxHash', + my @onetime = ( 'List customers' => 'List all customers', 'List all customers' => 'Advanced customer search', 'List packages' => 'Summarize packages', @@ -224,6 +225,8 @@ sub _upgrade_data { # class method 'Services: Hardware' => 'Services: Hardware: Advanced search', 'Services: Phone numbers' => 'Services: Phone numbers: Advanced search', + 'Services: Accounts' => 'Services: Alarm services', + 'List rating data' => [ 'Usage: RADIUS sessions', 'Usage: Call Detail Records (CDRs)', 'Usage: Unrateable CDRs', @@ -236,13 +239,18 @@ sub _upgrade_data { # class method 'Services: Accounts' => 'Services: Cable Subscribers', 'Bulk change customer packages' => 'Bulk move customer services', 'Configuration' => 'Edit sales people', -; + ); + +# foreach my $old_acl ( keys %onetime ) { +# +# my @new_acl = ref($onetime{$old_acl}) +# ? @{ $onetime{$old_acl} } +# : ( $onetime{$old_acl} ); - foreach my $old_acl ( keys %onetime ) { + while ( @onetime ) { - my @new_acl = ref($onetime{$old_acl}) - ? @{ $onetime{$old_acl} } - : ( $onetime{$old_acl} ); + my( $old_acl, $new_acl ) = splice(@onetime, 0, 2); + my @new_acl = ref($new_acl) ? @$new_acl : ( $new_acl ); foreach my $new_acl ( @new_acl ) { diff --git a/FS/FS/h_svc_alarm.pm b/FS/FS/h_svc_alarm.pm new file mode 100644 index 000000000..b1bd2362c --- /dev/null +++ b/FS/FS/h_svc_alarm.pm @@ -0,0 +1,32 @@ +package FS::h_svc_alarm; + +use strict; +use vars qw( @ISA ); +use FS::h_Common; +use FS::svc_alarm; + +@ISA = qw( FS::h_Common FS::svc_alarm ); + +sub table { 'h_svc_alarm' }; + +=head1 NAME + +FS::h_svc_alarm - Historical Alarm service objects + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +An FS::h_svc_alarm object represents a historical alarm service subscriber. +FS::h_svc_alarm inherits from FS::h_Common and FS::svc_alarm. + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L + +=cut + +1; + diff --git a/FS/FS/svc_alarm.pm b/FS/FS/svc_alarm.pm new file mode 100644 index 000000000..631891476 --- /dev/null +++ b/FS/FS/svc_alarm.pm @@ -0,0 +1,142 @@ +package FS::svc_alarm; + +use strict; +use base qw( FS::svc_Common ); +use FS::Record; # qw( qsearch qsearchs ); + +=head1 NAME + +FS::svc_alarm - Object methods for svc_alarm records + +=head1 SYNOPSIS + + use FS::svc_alarm; + + $record = new FS::svc_alarm \%hash; + $record = new FS::svc_alarm { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::svc_alarm object represents an alarm service. FS::svc_alarm inherits +from FS::svc_Common. + +The following fields are currently supported: + +=over 4 + +=item svcnum - Primary key + +=item alarm_system - Alarm System + +=item alarm_type = Alarm Type + +=item acctnum - Account number + +=item _password - Password + +=item location - Location on property + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new svc_dish object. + +=cut + +sub table { 'svc_alarm'; } + +sub table_info { + my %opts = ( 'type' => 'text', + #'disable_select' => 1, + 'disable_inventory' => 1, + ); + { + 'name' => 'Alarm service', + 'sorts' => 'acctnum', + 'display_weight' => 80, + 'cancel_weight' => 85, + 'fields' => { + 'svcnum' => { label => 'Service' }, + 'alarm_system' => { label => 'Alarm System', %opts }, + 'alarm_type' => { label => 'Alarm Type', %opts }, + 'acctnum' => { label => 'Account #', %opts }, + '_password' => { label => 'Password', %opts }, + 'location' => { label => 'Location', %opts }, + }, + }; +} + +sub label { + my $self = shift; + $self->acctnum; +} + +sub search_sql { + my($class, $string) = @_; + $class->search_sql_field('acctnum', $string); +} + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=item delete + +Delete this record from the database. + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +# the replace method can be inherited from FS::Record + +=item check + +Checks all fields to make sure this is a valid service. If there is +an error, returns the error, otherwise returns false. Called by the insert +and replace methods. + +=cut + +sub check { + my $self = shift; + + my $x = $self->setfixed; + return $x unless ref $x; + + my $error = + $self->ut_numbern('svcnum') + || $self->ut_text('acctnum') + || $self->ut_numbern('installdate') + || $self->ut_anything('note') + ; + return $error if $error; + + $self->SUPER::check; +} + +=back + +=head1 SEE ALSO + +L, L, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/FS/svc_mailinglist.pm b/FS/FS/svc_mailinglist.pm index ba297eedc..8cab3986d 100644 --- a/FS/FS/svc_mailinglist.pm +++ b/FS/FS/svc_mailinglist.pm @@ -88,7 +88,7 @@ sub table { 'svc_mailinglist'; } sub table_info { { 'name' => 'Mailing list', - 'display_weight' => 80, + 'display_weight' => 31, 'cancel_weight' => 55, 'fields' => { 'username' => { 'label' => 'List address', diff --git a/FS/MANIFEST b/FS/MANIFEST index 1bb5cbd63..eb237c3bb 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -718,3 +718,5 @@ FS/vend_bill_pay.pm t/vend_bill_pay.t FS/sales_pkg_class.pm t/sales_pkg_class.t +FS/svc_alarm.pm +t/svc_alarm.t diff --git a/FS/t/svc_alarm.t b/FS/t/svc_alarm.t new file mode 100644 index 000000000..dbe7712d7 --- /dev/null +++ b/FS/t/svc_alarm.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::svc_alarm; +$loaded=1; +print "ok 1\n"; -- 2.11.0