[freeside-commits] branch FREESIDE_3_BRANCH updated. 61a84d1b2dc076e80dec0b96bc9867ad4215e374

Ivan ivan at 420.am
Mon Dec 9 14:47:18 PST 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  61a84d1b2dc076e80dec0b96bc9867ad4215e374 (commit)
       via  3d1788e9ca966d7cdbc5f2784708cc311b7dac2e (commit)
      from  c641c8c0fe9eddb1690c7243a4f2d0471396ccb2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 61a84d1b2dc076e80dec0b96bc9867ad4215e374
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Dec 9 14:47:16 2013 -0800

    alarm systems, types, central stations, RT#25994

diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 98ba871..0d8795b 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -370,7 +370,10 @@ tie my %rights, 'Tie::IxHash',
 
     { rightname=>'Broadband configuration' },
     { rightname=>'Broadband global configuration', global=>1 },
-    
+
+    { rightname=>'Alarm configuration' },
+    { rightname=>'Alarm global configuration', global=>1 },
+
     { rightname=> 'Configure network monitoring', global=>1 },
 
     #{ rightname=>'Edit employees', global=>1, },
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 289660f..4931c7f 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -239,6 +239,7 @@ sub _upgrade_data { # class method
     'Services: Accounts' => 'Services: Cable Subscribers',
     'Bulk change customer packages' => 'Bulk move customer services',
     'Configuration' => 'Edit sales people',
+    'Configuration' => 'Alarm global configuration',
   );
 
 #  foreach my $old_acl ( keys %onetime ) {
diff --git a/FS/FS/svc_alarm.pm b/FS/FS/svc_alarm.pm
index 6318914..3e910f0 100644
--- a/FS/FS/svc_alarm.pm
+++ b/FS/FS/svc_alarm.pm
@@ -2,7 +2,11 @@ package FS::svc_alarm;
 
 use strict;
 use base qw( FS::svc_Common );
-use FS::Record; # qw( qsearch qsearchs );
+use Tie::IxHash;
+use FS::Record qw( qsearchs ); # qw( qsearch qsearchs );
+use FS::alarm_system;
+use FS::alarm_type;
+use FS::alarm_station;
 
 =head1 NAME
 
@@ -34,9 +38,11 @@ The following fields are currently supported:
 
 =item svcnum - Primary key
 
-=item alarm_system - Alarm System
+=item alarmsystemnum - Alarm System Vendor (see L<FS::alarm_system>)
 
-=item alarm_type = Alarm Type
+=item alarmtypenum - Alarm System Type (inputs/outputs) (see L<FS::alarm_type>)
+
+=item alarmstationnum - Alarm central station (see L<FS::alarm_station>)
 
 =item acctnum - Account number
 
@@ -63,25 +69,50 @@ sub table_info {
                #'disable_select' => 1,
                'disable_inventory' => 1,
              );
+
+  tie my %fields, 'Tie::IxHash',
+    'svcnum'    => { label => 'Service' },
+    'acctnum'         => { label => 'Account #', %opts },
+    '_password'       => { label => 'Password' , %opts },
+    'location'        => { label => 'Location',  %opts },
+    'alarmsystemnum'  => { label => 'Alarm System Vendor',
+                           type  => 'select-alarm_system',
+                           disable_inventory => 1,
+                           value_callback    => sub {
+                             shift->alarm_system->systemname
+                           },
+                         },
+    'alarmtypenum'    => { label => 'Alarm System Type',
+                           type  => 'select-alarm_type',
+                           disable_inventory => 1,
+                           value_callback    => sub {
+                             shift->alarm_type->typename
+                           },
+                         },
+    'alarmstationnum' => { label => 'Alarm Central Station',
+                           type  => 'select-alarm_station',
+                           disable_inventory => 1,
+                           value_callback    => sub {
+                             shift->alarm_station->stationname
+                           },
+                         },
+  ;
+
   {
     '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 },
-    },
+    'fields'         => \%fields,
+
   };
 }
 
 sub label {
   my $self = shift;
-  $self->acctnum;
+  $self->acctnum . '@'. $self->alarm_station->stationname. #?
+    ' ('. $self->alarm_system->systemname. ' '. $self->alarm_type->typename. ')'
+  ;
 }
 
 sub search_sql {
@@ -103,8 +134,6 @@ Delete this record from the database.
 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
@@ -122,14 +151,21 @@ sub check {
   my $error = 
     $self->ut_numbern('svcnum')
     || $self->ut_text('acctnum')
-    || $self->ut_numbern('installdate')
-    || $self->ut_anything('note')
+    || $self->ut_alphan('_password')
+    || $self->ut_textn('location')
+    || $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;
 }
 
+sub alarm_system  { qsearchs('alarm_system', {systemnum =>shift->systemnum } ) }
+sub alarm_type    { qsearchs('alarm_type',   {typenum   =>shift->systemnum } ) }
+sub alarm_station { qsearchs('alarm_station',{stationnum=>shift->stationnum} ) }
+
 =back
 
 =head1 SEE ALSO
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 57233cf..84cd4d5 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -518,6 +518,12 @@ tie my %config_cable, 'Tie::IxHash',
   'Cable modem models' => [ $fsurl.'browse/cable_model.html', '' ],
 ;
 
+tie my %config_alarm, 'Tie::IxHash',
+  'Alarm system vendors'   => [ $fsurl.'browse/alarm_system.html', '' ],
+  'Alarm system types'     => [ $fsurl.'browse/alarm_type.html', '' ],
+  'Alarm central stations' => [ $fsurl.'browse/alarm_station.html', '' ],
+;
+
 tie my %config_export_svc, 'Tie::IxHash', ();
 if ( $curuser->access_right('Configuration') ) {
   $config_export_svc{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ];
@@ -534,6 +540,8 @@ $config_export_svc{'RADIUS'} = [ \%config_radius, '' ]
   if $curuser->access_right('Configuration');
 $config_export_svc{'Cable'} = [ \%config_cable, '' ]
   if $curuser->access_right('Configuration');
+$config_export_svc{'Alarm'} = [ \%config_alarm, '' ]
+  if $curuser->access_right(['Alarm configuration', 'Alarm global configuration']);
 $config_export_svc{'Hardware types'} = [ $fsurl.'browse/hardware_class.html', 'Set up hardware type catalog' ]
   if $curuser->access_right('Configuration');
 
@@ -799,16 +807,19 @@ $menu{'Reports'} = [ \%report_menu, 'Lists, reporting and graphing' ]
 $menu{'Tools'} = [ \%tools_menu, 'Tools' ]
   if keys %tools_menu;
 $menu{'Configuration'} = [ \%config_menu, 'Configuration and setup' ]
-  if $curuser->access_right('Configuration')
-  || $curuser->access_right('Edit package definitions')
-  || $curuser->access_right('Edit global package definitions')
-  || $curuser->access_right('Edit billing events')
-  || $curuser->access_right('Edit global billing events')
-  || $curuser->access_right('Dialup configuration')
-  || $curuser->access_right('Wireless broadband configuration')
-  || $curuser->access_right('Phone configuration')
-  || $curuser->access_right('Edit advertising sources')
-  || $curuser->access_right('Edit global advertising sources');
+  if $curuser->access_right([ 'Configuration',
+                              'Edit package definitions',
+                              'Edit global package definitions',
+                              'Edit billing events',
+                              'Edit global billing events',
+                              'Dialup configuration',
+                              'Wireless broadband configuration',
+                              'Phone configuration',
+                              'Alarm configuration',
+                              'Alarm global configuration',
+                              'Edit advertising sources',
+                              'Edit global advertising sources',
+                           ]);
 $menu{'Help'} = [ \%help_menu, '' ];
 
 

commit 3d1788e9ca966d7cdbc5f2784708cc311b7dac2e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Dec 9 14:46:59 2013 -0800

    alarm systems, types, central stations, RT#25994

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 5d6a47b..2b95ada 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4205,19 +4205,56 @@ sub tables_hashref {
     'svc_alarm' => {
       'columns' => [
         'svcnum',          'int',      '',      '', '', '', 
-        'alarm_system', 'varchar',     '', $char_d, '', '', # dropdowns?
-        'alarm_type',   'varchar',     '', $char_d, '', '', #
+        'alarmsystemnum',  'int',      '',      '', '', '',
+        'alarmtypenum',    'int',      '',      '', '', '',
+        'alarmstationnum', 'int',      '',      '', '', '',
         'acctnum',      'varchar',     '', $char_d, '', '',
         '_password',    'varchar',     '', $char_d, '', '',
         'location',     'varchar', 'NULL', $char_d, '', '',
-        #cs
-        #rep
+        #installer (rep)
       ],
       'primary_key' => 'svcnum',
-      'unique' => [], #system/type/acctnum??
+      'unique' => [],
       'index'  => [],
     },
 
+    'alarm_system' => { #vendors
+      'columns' => [
+        'alarmsystemnum',  'serial',     '',      '', '', '',
+        'agentnum',           'int', 'NULL',      '', '', '',
+        'systemname',     'varchar',     '', $char_d, '', '',
+        'disabled',          'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key' => 'alarmsystemnum',
+      'unique'      => [ ['agentnum', 'systemname'] ],
+      'index'       => [ ['agentnum'], ['disabled'] ],
+    },
+
+    'alarm_type' => { #inputs and outputs
+      'columns' => [
+        'alarmtypenum', 'serial',     '',      '', '', '',
+        'agentnum',        'int', 'NULL',      '', '', '',
+        'inputs',          'int',     '', '', '', '',
+        'outputs',         'int',     '', '', '', '',
+        'disabled',       'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key' => 'alarmtypenum',
+      'unique'      => [ ['agentnum', 'inputs', 'outputs'] ],
+      'index'       => [ ['agentnum'], ['disabled'] ],
+    },
+
+    'alarm_station' => { #central station (where the alarm reports to)
+      'columns' => [
+        'alarmstationnum', 'serial',     '',      '', '', '',
+        'agentnum',           'int', 'NULL',      '', '', '',
+        'stationname',    'varchar',     '', $char_d, '', '',
+        'disabled',          'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key' => 'alarmstationnum',
+      'unique'      => [ ['agentnum', 'stationname'], ],
+      'index'       => [ ['agentnum'], ['disabled'] ],
+    },
+
     'svc_cable' => {
       'columns' => [
         'svcnum',        'int',     '',      '', '', '', 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/AccessRight.pm          |    5 ++-
 FS/FS/Schema.pm               |   47 +++++++++++++++++++++++++---
 FS/FS/access_right.pm         |    1 +
 FS/FS/svc_alarm.pm            |   68 +++++++++++++++++++++++++++++++---------
 httemplate/elements/menu.html |   31 ++++++++++++------
 5 files changed, 120 insertions(+), 32 deletions(-)




More information about the freeside-commits mailing list