[freeside-commits] freeside/FS/FS Schema.pm, 1.168.2.12, 1.168.2.13 svc_phone.pm, 1.20.2.1, 1.20.2.2 svc_acct.pm, 1.268.2.9, 1.268.2.10 svc_pbx.pm, 1.1.2.2, 1.1.2.3 svc_Common.pm, 1.51.2.1, 1.51.2.2

Ivan,,, ivan at wavetail.420.am
Mon Jan 25 14:17:31 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv7436/FS/FS

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	Schema.pm svc_phone.pm svc_acct.pm svc_pbx.pm svc_Common.pm 
Log Message:
linking DIDs and users to PBXes, RT#7051

Index: svc_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Common.pm,v
retrieving revision 1.51.2.1
retrieving revision 1.51.2.2
diff -u -d -r1.51.2.1 -r1.51.2.2
--- svc_Common.pm	28 Oct 2009 19:05:11 -0000	1.51.2.1
+++ svc_Common.pm	25 Jan 2010 22:17:28 -0000	1.51.2.2
@@ -586,6 +586,105 @@
 
 }
 
+=item svc_pbx
+
+Returns the FS::svc_pbx record for this service, if any (see L<FS::svc_pbx>).
+
+Only makes sense if the service has a pbxsvc field (currently, svc_phone and
+svc_acct).
+
+=cut
+
+# XXX FS::h_svc_{acct,phone} could have a history-aware svc_pbx override
+
+sub svc_pbx {
+  my $self = shift;
+  return '' unless $self->pbxsvc;
+  qsearchs( 'svc_pbx', { 'svcnum' => $self->pbxsvc } );
+}
+
+=item pbx_title
+
+Returns the title of the FS::svc_pbx record associated with this service, if
+any.
+
+Only makes sense if the service has a pbxsvc field (currently, svc_phone and
+svc_acct).
+
+=cut
+
+sub pbx_title {
+  my $self = shift;
+  my $svc_pbx = $self->svc_pbx or return '';
+  $svc_pbx->title;
+}
+
+=item pbx_select_hash %OPTIONS
+
+Can be called as an object method or a class method.
+
+Returns a hash SVCNUM => TITLE ...  representing the PBXes this customer
+that may be associated with this service.
+
+Currently available options are: I<pkgnum> I<svcpart>
+
+Only makes sense if the service has a pbxsvc field (currently, svc_phone and
+svc_acct).
+
+=cut
+
+#false laziness w/svc_acct::domain_select_hash
+sub pbx_select_hash {
+  my ($self, %options) = @_;
+  my %pbxes = ();
+  my $part_svc;
+  my $cust_pkg;
+
+  if (ref($self)) {
+    $part_svc = $self->part_svc;
+    $cust_pkg = $self->cust_svc->cust_pkg
+      if $self->cust_svc;
+  }
+
+  $part_svc = qsearchs('part_svc', { 'svcpart' => $options{svcpart} })
+    if $options{'svcpart'};
+
+  $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $options{pkgnum} })
+    if $options{'pkgnum'};
+
+  if ($part_svc && ( $part_svc->part_svc_column('pbxsvc')->columnflag eq 'S'
+                  || $part_svc->part_svc_column('pbxsvc')->columnflag eq 'F')) {
+    %pbxes = map { $_->svcnum => $_->title }
+             map { qsearchs('svc_pbx', { 'svcnum' => $_ }) }
+             split(',', $part_svc->part_svc_column('pbxsvc')->columnvalue);
+  } elsif ($cust_pkg) { # && !$conf->exists('svc_acct-alldomains') ) {
+    %pbxes = map { $_->svcnum => $_->title }
+             map { qsearchs('svc_pbx', { 'svcnum' => $_->svcnum }) }
+             map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) }
+             qsearch('cust_pkg', { 'custnum' => $cust_pkg->custnum });
+  } else {
+    #XXX agent-virt
+    warn "hi";
+    %pbxes = map { $_->svcnum => $_->title } qsearch('svc_pbx', {} );
+    warn %pbxes;
+  }
+
+  if ($part_svc && $part_svc->part_svc_column('pbxsvc')->columnflag eq 'D') {
+    my $svc_pbx = qsearchs('svc_pbx',
+      { 'svcnum' => $part_svc->part_svc_column('pbxsvc')->columnvalue } );
+    if ( $svc_pbx ) {
+      $pbxes{$svc_pbx->svcnum}  = $svc_pbx->title;
+    } else {
+      warn "unknown svc_pbx.svcnum for part_svc_column pbxsvc: ".
+           $part_svc->part_svc_column('pbxsvc')->columnvalue;
+
+    }
+  }
+
+  (%pbxes);
+
+}
+
 =item set_auto_inventory
 
 Sets any fields which auto-populate from inventory (see L<FS::part_svc>).

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.168.2.12
retrieving revision 1.168.2.13
diff -u -d -r1.168.2.12 -r1.168.2.13
--- Schema.pm	25 Jan 2010 17:43:57 -0000	1.168.2.12
+++ Schema.pm	25 Jan 2010 22:17:27 -0000	1.168.2.13
@@ -1475,14 +1475,15 @@
         'downbytes_threshold',   'bigint', 'NULL',   '', '', '',
         'totalbytes','bigint', 'NULL',   '', '', '',
         'totalbytes_threshold',   'bigint', 'NULL',   '', '', '',
-        'domsvc',    'int', '',   '', '', '', 
+        'domsvc',    'int',     '', '', '', '', 
+        'pbxsvc',    'int', 'NULL', '', '', '',
         'last_login',  @date_type, '', '', 
         'last_logout', @date_type, '', '', 
       ],
       'primary_key' => 'svcnum',
       #'unique' => [ [ 'username', 'domsvc' ] ],
       'unique' => [],
-      'index' => [ ['username'], ['domsvc'] ],
+      'index' => [ ['username'], ['domsvc'], ['pbxsvc'] ],
     },
 
     'acct_rt_transaction' => {
@@ -2401,10 +2402,11 @@
         'pin',          'varchar', 'NULL', $char_d, '', '',
         'sip_password', 'varchar', 'NULL', $char_d, '', '',
         'phone_name',   'varchar', 'NULL', $char_d, '', '',
+        'pbxsvc',           'int', 'NULL',      '', '', '',
       ],
       'primary_key' => 'svcnum',
       'unique' => [],
-      'index'  => [ [ 'countrycode', 'phonenum' ] ],
+      'index'  => [ [ 'countrycode', 'phonenum' ], ['pbxsvc'] ],
     },
 
     'phone_device' => {

Index: svc_phone.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_phone.pm,v
retrieving revision 1.20.2.1
retrieving revision 1.20.2.2
diff -u -d -r1.20.2.1 -r1.20.2.2
--- svc_phone.pm	17 Jan 2010 02:34:33 -0000	1.20.2.1
+++ svc_phone.pm	25 Jan 2010 22:17:28 -0000	1.20.2.2
@@ -8,6 +8,7 @@
 use FS::svc_Common;
 use FS::part_svc;
 use FS::phone_device;
+use FS::svc_pbx;
 
 @ISA = qw( FS::svc_Common );
 
@@ -67,6 +68,10 @@
 
 =item phone_name
 
+=item pbxsvc
+
+Optional svcnum from svc_pbx
+
 =back
 
 =head1 METHODS
@@ -104,6 +109,11 @@
                           },
         'sip_password' => 'SIP password',
         'phone_name'   => 'Name',
+        'pbxsvc'       => { label => 'PBX',
+                            type  => 'select-svc_pbx.html',
+                            disable_inventory => 1,
+                            disable_select => 1, #UI wonky, pry works otherwise
+                          },
     },
   };
 }
@@ -258,6 +268,7 @@
     || $self->ut_anything('sip_password')
     || $self->ut_numbern('pin')
     || $self->ut_textn('phone_name')
+    || $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' )
   ;
   return $error if $error;
 

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.268.2.9
retrieving revision 1.268.2.10
diff -u -d -r1.268.2.9 -r1.268.2.10
--- svc_acct.pm	25 Jan 2010 00:31:59 -0000	1.268.2.9
+++ svc_acct.pm	25 Jan 2010 22:17:28 -0000	1.268.2.10
@@ -38,6 +38,7 @@
 use FS::svc_acct_pop;
 use FS::cust_main_invoice;
 use FS::svc_domain;
+use FS::svc_pbx;
 use FS::raddb;
 use FS::queue;
 use FS::radius_usergroup;
@@ -161,45 +162,71 @@
 
 =over 4
 
-=item svcnum - primary key (assigned automatcially for new accounts)
+=item svcnum
+
+Primary key (assigned automatcially for new accounts)
 
 =item username
 
-=item _password - generated if blank
+=item _password
 
-=item _password_encoding - plain, crypt, ldap (or empty for autodetection)
+generated if blank
 
-=item sec_phrase - security phrase
+=item _password_encoding
 
-=item popnum - Point of presence (see L<FS::svc_acct_pop>)
+plain, crypt, ldap (or empty for autodetection)
+
+=item sec_phrase
+
+security phrase
+
+=item popnum
+
+Point of presence (see L<FS::svc_acct_pop>)
 
 =item uid
 
 =item gid
 
-=item finger - GECOS
+=item finger
 
-=item dir - set automatically if blank (and uid is not)
+GECOS
+
+=item dir
+
+set automatically if blank (and uid is not)
 
 =item shell
 
-=item quota - (unimplementd)
+=item quota
 
-=item slipip - IP address
+=item slipip
 
-=item seconds - 
+IP address
 
-=item upbytes - 
+=item seconds
 
-=item downbytes - 
+=item upbytes
 
-=item totalbytes - 
+=item downbyte
 
-=item domsvc - svcnum from svc_domain
+=item totalbytes
 
-=item radius_I<Radius_Attribute> - I<Radius-Attribute> (reply)
+=item domsvc
 
-=item rc_I<Radius_Attribute> - I<Radius-Attribute> (check)
+svcnum from svc_domain
+
+=item pbxsvc
+
+Optional svcnum from svc_pbx
+
+=item radius_I<Radius_Attribute>
+
+I<Radius-Attribute> (reply)
+
+=item rc_I<Radius_Attribute>
+
+I<Radius-Attribute> (check)
 
 =back
 
@@ -275,6 +302,20 @@
                          disable_inventory => 1,
 
                        },
+        'domsvc'    => {
+                         label     => 'Domain',
+                         type      => 'select',
+                         select_table => 'svc_domain',
+                         select_key   => 'svcnum',
+                         select_label => 'domain',
+                         disable_inventory => 1,
+
+                       },
+        'pbxsvc'    => { label => 'PBX',
+                         type  => 'select-svc_pbx.html',
+                         disable_inventory => 1,
+                         disable_select => 1, #UI wonky, pry works otherwise
+                       },
         'usergroup' => {
                          label => 'RADIUS groups',
                          type  => 'radius_usergroup_selector',
@@ -1011,7 +1052,8 @@
 
   my $error = $self->ut_numbern('svcnum')
               #|| $self->ut_number('domsvc')
-              || $self->ut_foreign_key('domsvc', 'svc_domain', 'svcnum' )
+              || $self->ut_foreign_key( 'domsvc', 'svc_domain', 'svcnum' )
+              || $self->ut_foreign_keyn('pbxsvc', 'svc_pbx',    'svcnum' )
               || $self->ut_textn('sec_phrase')
               || $self->ut_snumbern('seconds')
               || $self->ut_snumbern('upbytes')

Index: svc_pbx.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_pbx.pm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- svc_pbx.pm	25 Jan 2010 17:36:59 -0000	1.1.2.2
+++ svc_pbx.pm	25 Jan 2010 22:17:28 -0000	1.1.2.3
@@ -37,7 +37,21 @@
 
 =over 4
 
-=item field - description
+=item svcnum
+
+Primary key (assigned automatcially for new accounts)
+
+=item id
+
+(Unique?) number of external record
+
+=item title
+
+PBX name
+
+=item max_extensions
+
+Maximum number of extensions
 
 =back
 



More information about the freeside-commits mailing list