tower for svc_acct, RT#15538
authorivan <ivan>
Mon, 19 Dec 2011 01:59:16 +0000 (01:59 +0000)
committerivan <ivan>
Mon, 19 Dec 2011 01:59:16 +0000 (01:59 +0000)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/svc_Tower_Mixin.pm [new file with mode: 0644]
FS/FS/svc_acct.pm
FS/FS/svc_broadband.pm
httemplate/edit/svc_acct.cgi
httemplate/view/svc_acct/basics.html

index 94669ff..36852ea 100644 (file)
@@ -4720,13 +4720,17 @@ and customer address. Include units.',
   {
     'key'         => 'translate-auto-insert',
     'section'     => '',
-    'description' => 'Auto-insert untranslated strings for selected non-en_US locales with their default/en_US values. DO NOT TURN THIS ON.',
-    'type'        => 'select-sub',
+    'description' => 'Auto-insert untranslated strings for selected non-en_US locales with their default/en_US values.  Do not turn this on unless translating the interface into a new language.',
+    'type'        => 'select',
     'multiple'    => 1,
-    'options_sub' => sub { map { $_ => '' } 
-                            grep { $_ ne 'en_US' } FS::Locales::locales;
-                                    },
-    'option_sub'  => sub { ''; },
+    'select_enum' => [ grep { $_ ne 'en_US' } FS::Locales::locales ],
+  },
+
+  {
+    'key'         => 'svc_acct-tower_sector',
+    'section'     => '',
+    'description' => 'Track tower and sector for svc_acct (account) services.',
+    'type'        => 'checkbox',
   },
 
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index 321065f..bd708a7 100644 (file)
@@ -1895,6 +1895,7 @@ sub tables_hashref {
         '_password_encoding', 'varchar', 'NULL', $char_d, '', '',
         'sec_phrase', 'varchar',  'NULL',   $char_d, '', '', 
         'popnum',    'int',    'NULL',   '', '', '', 
+        'sectornum', 'int', 'NULL',      '', '', '',
         'uid',       'int', 'NULL',   '', '', '', 
         'gid',       'int', 'NULL',   '', '', '', 
         'finger',    'varchar',   'NULL',   2*$char_d, '', '', 
@@ -2537,6 +2538,10 @@ sub tables_hashref {
         #'agentnum',      'int', 'NULL',      '', '', '',
         'towername', 'varchar',     '', $char_d, '', '',
         'disabled',     'char', 'NULL',       1, '', '',
+        'latitude', 'decimal', 'NULL',   '10,7', '', '', 
+        'longitude','decimal', 'NULL',   '10,7', '', '', 
+        'altitude', 'decimal', 'NULL',       '', '', '', 
+        'coord_auto',  'char', 'NULL',        1, '', '',
       ],
       'primary_key' => 'towernum',
       'unique'      => [ [ 'towername' ] ], # , 'agentnum' ] ],
diff --git a/FS/FS/svc_Tower_Mixin.pm b/FS/FS/svc_Tower_Mixin.pm
new file mode 100644 (file)
index 0000000..8caef6d
--- /dev/null
@@ -0,0 +1,17 @@
+package FS::svc_Tower_Mixin;
+
+use strict;
+use FS::Record qw(qsearchs); #qsearch;
+use FS::tower_sector;
+
+=item tower_sector
+
+=cut
+
+sub tower_sector {
+  my $self = shift;
+  return '' unless $self->sectornum;
+  qsearchs('tower_sector', { sectornum => $self->sectornum });
+}
+
+1;
index 64f2c35..3bb7af4 100644 (file)
@@ -5,6 +5,7 @@ use base qw( FS::svc_Domain_Mixin
              FS::svc_CGP_Mixin
              FS::svc_CGPRule_Mixin
              FS::svc_Radius_Mixin
+             FS::svc_Tower_Mixin
              FS::svc_Common );
 use vars qw( $DEBUG $me $conf $skip_fuzzyfiles
              $dir_prefix @shells $usernamemin
@@ -53,6 +54,7 @@ use FS::svc_forward;
 use FS::svc_www;
 use FS::cdr;
 use FS::acct_snarf;
+use FS::tower_sector;
 
 $DEBUG = 0;
 $me = '[FS::svc_acct]';
@@ -338,6 +340,7 @@ sub table_info {
                          disable_inventory => 1,
                          disable_select => 1, #UI wonky, pry works otherwise
                        },
+        'sectornum' => 'Tower sector',
         'usergroup' => {
                          label => 'RADIUS groups',
                          type  => 'select-radius_group.html',
@@ -1122,6 +1125,7 @@ sub check {
               #|| $self->ut_number('domsvc')
               || $self->ut_foreign_key( 'domsvc', 'svc_domain', 'svcnum' )
               || $self->ut_foreign_keyn('pbxsvc', 'svc_pbx',    'svcnum' )
+              || $self->ut_foreign_keyn('sectornum','tower_sector','sectornum')
               || $self->ut_textn('sec_phrase')
               || $self->ut_snumbern('seconds')
               || $self->ut_snumbern('upbytes')
index edcb4bc..1d1fa76 100755 (executable)
@@ -10,7 +10,7 @@ use FS::addr_block;
 use FS::part_svc_router;
 use FS::tower_sector;
 
-@ISA = qw( FS::svc_Radius_Mixin FS::svc_Common );
+@ISA = qw( FS::svc_Radius_Mixin FS::svc_Tower_Mixin FS::svc_Common );
 
 $FS::UID::callback{'FS::svc_broadband'} = sub { 
   $conf = new FS::Conf;
@@ -488,16 +488,6 @@ sub NetAddr {
   new NetAddr::IP ($self->ip_addr);
 }
 
-=item tower_sector
-
-=cut
-
-sub tower_sector {
-  my $self = shift;
-  return '' unless $self->sectornum;
-  qsearchs('tower_sector', { sectornum => $self->sectornum });
-}
-
 =item addr_block
 
 Returns the FS::addr_block record (i.e. the address block) for this broadband service.
index 52fbd37..38567ef 100755 (executable)
@@ -160,6 +160,19 @@ function randomPass() {
     <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
   </TR>
 % } 
+
+%#tower (huh)
+%if ( $conf->exists('svc_acct-tower_sector')
+%     && $part_svc->part_svc_column('sectornum')->columnflag ne 'F' ) {
+    <& /elements/tr-select-tower_sector.html,
+         'curr_value' => $svc_acct->sectornum,
+         #'part_svc'   => $part_svc,
+         #'cust_pkg'   => $cust_pkg,
+    &>
+%} else {
+    <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
+%}
+
 % #uid/gid 
 % foreach my $xid (qw( uid gid )) { 
 %
index 6adebc6..8f180b6 100644 (file)
     <& /view/elements/tr.html, label=>mt('Access number'), value=>$svc_acct_pop->text &>
 % } 
 
+% if ( $svc_acct->sectornum && $conf->exists('svc_acct-tower_sector') ) {
+%   my $tower_sector = $svc_acct->tower_sector;
+%   my $link = $tower_sector->ip_addr
+%                ? '<A HREF="http://'. $tower_sector->ip_addr. '">'
+%                : '';
+    <& /view/elements/tr.html,
+        label => mt('Tower sector'),
+        value => $link. $tower_sector->description. ($link ? '</A>' : ''),
+    &>
+% }
+
 % if ($svc_acct->uid ne '') { 
   <& /view/elements/tr.html, label=>mt('UID'), value=>$svc_acct->uid &>
 % }