[freeside-commits] freeside/FS/FS XMLRPC.pm, 1.5, 1.6 Schema.pm, 1.220, 1.221 Conf.pm, 1.368, 1.369 Maestro.pm, NONE, 1.1 svc_pbx.pm, 1.6, 1.7

Ivan,,, ivan at wavetail.420.am
Sat Jun 26 02:34:12 PDT 2010


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

Modified Files:
	XMLRPC.pm Schema.pm Conf.pm svc_pbx.pm 
Added Files:
	Maestro.pm 
Log Message:
maestro cust status as reqeusted, RT#8712

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -w -d -r1.220 -r1.221
--- Schema.pm	8 Jun 2010 22:24:59 -0000	1.220
+++ Schema.pm	26 Jun 2010 09:34:09 -0000	1.221
@@ -2803,6 +2803,7 @@
         'id',             'int', 'NULL',      '', '', '', 
         'title',      'varchar', 'NULL', $char_d, '', '', 
         'max_extensions', 'int', 'NULL',      '', '', '',
+        'max_simultaneous', 'int', 'NULL',      '', '', '',
       ],
       'primary_key' => 'svcnum',
       'unique' => [],

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.368
retrieving revision 1.369
diff -u -w -d -r1.368 -r1.369
--- Conf.pm	23 Jun 2010 08:37:46 -0000	1.368
+++ Conf.pm	26 Jun 2010 09:34:09 -0000	1.369
@@ -3578,6 +3578,14 @@
   },
 
   {
+    'key'         => 'mc-outbound_packages',
+    'section'     => '',
+    'description' => "Don't use this.",
+    'type'        => 'select-part_pkg',
+    'multiple'    => 1,
+  },
+
+  {
     'key'         => 'disable-cust-pkg_class',
     'section'     => 'UI',
     'description' => 'Disable the two-step dropdown for selecting package class and package, and return to the classic single dropdown.',

--- NEW FILE: Maestro.pm ---
package FS::Maestro;

use Date::Format;
use FS::Conf;
use FS::Record qw( qsearchs );
use FS::cust_main;

sub customer_status {
  my( $custnum ) = shift; #@_;

  my $cust_main = qsearchs( 'cust_main' => { 'custnum' => $custnum } )
   or return { 'status' => 'E',
               'error'  => "$custnum not found" };

  my @cust_pkg = $cust_main->cust_pkg;

  my @cust_svc = map $_->cust_svc, @cust_pkg;

  ###
  # find $svc_pbx
  ##

  my @cust_svc_pbx =
    grep { my($n,$l,$t) = $_->label; $_->t eq 'svc_pbx' }
    @cust_svc;

  #i tried sofa king hard to explain to them why passing a custnum instead
  #of a conference id was a bad idea, but i can't make them understand...
  if ( ! @cust_svc_pbx ) {
    return { 'status' => 'E',
             'error'  => "customer $custnum has no conference service" };
  } elsif ( scalar(@cust_svc_pbx) > 1 ) {
    return { 'status' => 'E',
             'error'  => "customer $custnum has more than one conference service; there should be a way to specify which one you want",
           }; #maybe list them...  and work with a pkgnum
  }

  my $cust_svc_pbx = $cust_svc_pbx[0];

  my $svc_pbx = $cust_svc_pbx->svc_X;

  ###
  # find "outbound service" y/n
  ###

  my $conf = new FS::Conf;
  my %outbound_pkgs = map { $_=>1 } $conf->config('mc-outbound_packages');
  my $outbound_service =
    scalar( grep $outbound_pkgs{ $_->pkgpart }, @cust_pkg )
    ? 1 : 0;

  ###
  # find "good till" date/time stamp
  ###

  my @active_cust_pkg =
    sort { $a->bill <=> $b->bill }
    grep { !$_->get('cancel') && $_->part_pkg->freq ne '0' }
    @cust_pkg;
  my $good_till =time2str('%c', $active_cust_pkg[0]->bill || time );

  ###
  # return the info
  ###

  { 
    'status' => substr($cust_main->ucfirst_status,0,1), #what they asked for..
    'name'   => $cust_main->name,
    'email'  => $cust_main->invoicing_list_emailonly_scalar,
    'max_lines'        => $svc_pbx->max_extensions,
    'max_simultaneous' => $svc_pbx->max_simultaneous,
    'outbound_service' => $outbound_service,
    'good_till' => $good_till,
    'products'  => [ map $_->pkgpart, grep !$_->get('cancel'), @cust_pkg ],
  };

}

1;

Index: XMLRPC.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/XMLRPC.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- XMLRPC.pm	11 May 2007 18:08:10 -0000	1.5
+++ XMLRPC.pm	26 Jun 2010 09:34:09 -0000	1.6
@@ -1,7 +1,7 @@
 package FS::XMLRPC;
 
 use strict;
-use vars qw( @ISA $DEBUG );
+use vars qw( $DEBUG );
 use Frontier::RPC2;
 
 # Instead of 'use'ing freeside modules on the fly below, just preload them now.
@@ -11,9 +11,9 @@
 use FS::Record;
 use FS::cust_main;
 
-use Data::Dumper;
+use FS::Maestro;
 
- at ISA = qw( );
+use Data::Dumper;
 
 $DEBUG = 0;
 
@@ -131,9 +131,9 @@
 
     }
 
-    warn Dumper(@result) if $DEBUG;
-
-    if (grep { UNIVERSAL::can($_, 'hashref') ? 0 : 1 } @result) {
+    if ( scalar(@result) == 1 && ref($result[0]) eq 'HASH' ) {
+      return $result[0];
+    } elsif (grep { UNIVERSAL::can($_, 'hashref') ? 0 : 1 } @result) {
       #warn "FS::XMLRPC: One or more objects returned from '${fssub}' doesn't " .
       #     "support the 'hashref' method.";
       
@@ -147,8 +147,8 @@
     return [ $FS::VERSION ];
   } # else...
 
-  warn "Unhandle XMLRPC request '${method_name}'";
-  return [];
+  warn "Unhandled XMLRPC request '${method_name}'";
+  return {};
 
 }
 

Index: svc_pbx.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_pbx.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- svc_pbx.pm	26 Jan 2010 10:40:32 -0000	1.6
+++ svc_pbx.pm	26 Jun 2010 09:34:09 -0000	1.7
@@ -55,6 +55,10 @@
 
 Maximum number of extensions
 
+=item max_simultaneous
+
+Maximum number of simultaneous users
+
 =back
 
 =head1 METHODS
@@ -85,6 +89,7 @@
       'id'    => 'ID',
       'title' => 'Name',
       'max_extensions' => 'Maximum number of User Extensions',
+      'max_simultaneous' => 'Maximum number of simultaneous users',
 #      'field'         => 'Description',
 #      'another_field' => { 
 #                           'label'     => 'Description',
@@ -206,15 +211,15 @@
 
 =cut
 
-sub replace {
-  my ( $new, $old ) = ( shift, shift );
-  my $error;
-
-  $error = $new->SUPER::replace($old);
-  return $error if $error;
-
-  '';
-}
+#sub replace {
+#  my ( $new, $old ) = ( shift, shift );
+#  my $error;
+#
+#  $error = $new->SUPER::replace($old);
+#  return $error if $error;
+#
+#  '';
+#}
 
 =item suspend
 



More information about the freeside-commits mailing list