From: ivan Date: Sat, 26 Jun 2010 09:34:10 +0000 (+0000) Subject: maestro cust status as reqeusted, RT#8712 X-Git-Tag: root_of_svc_elec_features~120 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=40d935c8cd952be7b461405406d9d03f46775baf;hp=368a18b893fef80720277b12342ca6d178a9fd31 maestro cust status as reqeusted, RT#8712 --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 01f88a7c8..99c4876b2 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -3578,6 +3578,14 @@ and customer address. Include units.', }, { + '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.', diff --git a/FS/FS/Maestro.pm b/FS/FS/Maestro.pm new file mode 100644 index 000000000..20dbad607 --- /dev/null +++ b/FS/FS/Maestro.pm @@ -0,0 +1,79 @@ +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; diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 01512f9f6..73392e86c 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2799,10 +2799,11 @@ sub tables_hashref { 'svc_pbx' => { 'columns' => [ - 'svcnum', 'int', '', '', '', '', - 'id', 'int', 'NULL', '', '', '', - 'title', 'varchar', 'NULL', $char_d, '', '', - 'max_extensions', 'int', 'NULL', '', '', '', + 'svcnum', 'int', '', '', '', '', + 'id', 'int', 'NULL', '', '', '', + 'title', 'varchar', 'NULL', $char_d, '', '', + 'max_extensions', 'int', 'NULL', '', '', '', + 'max_simultaneous', 'int', 'NULL', '', '', '', ], 'primary_key' => 'svcnum', 'unique' => [], diff --git a/FS/FS/XMLRPC.pm b/FS/FS/XMLRPC.pm index fb0e5ac74..73ce13f7a 100644 --- a/FS/FS/XMLRPC.pm +++ b/FS/FS/XMLRPC.pm @@ -1,7 +1,7 @@ -package FS::XMLRPC; + 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::Conf; use FS::Record; use FS::cust_main; -use Data::Dumper; +use FS::Maestro; -@ISA = qw( ); +use Data::Dumper; $DEBUG = 0; @@ -131,9 +131,9 @@ sub _serve { #Subroutine, not method } - 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 @@ sub _serve { #Subroutine, not method return [ $FS::VERSION ]; } # else... - warn "Unhandle XMLRPC request '${method_name}'"; - return []; + warn "Unhandled XMLRPC request '${method_name}'"; + return {}; } diff --git a/FS/FS/svc_pbx.pm b/FS/FS/svc_pbx.pm index 6ae04189c..21aaa4e0b 100644 --- a/FS/FS/svc_pbx.pm +++ b/FS/FS/svc_pbx.pm @@ -55,6 +55,10 @@ PBX name Maximum number of extensions +=item max_simultaneous + +Maximum number of simultaneous users + =back =head1 METHODS @@ -85,6 +89,7 @@ sub table_info { '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 @@ returns the error, otherwise returns false. =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 diff --git a/FS/MANIFEST b/FS/MANIFEST index b358c8315..03d56ac58 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -44,6 +44,7 @@ FS/Cron/backup.pm FS/Cron/bill.pm FS/Cron/vacuum.pm FS/Daemon.pm +FS/Maestro.pm FS/Misc.pm FS/Record.pm FS/Report.pm diff --git a/httemplate/misc/xmlrpc.cgi b/httemplate/misc/xmlrpc.cgi index 1d0383f2a..14bf9ef92 100644 --- a/httemplate/misc/xmlrpc.cgi +++ b/httemplate/misc/xmlrpc.cgi @@ -1,18 +1,16 @@ -% -% -% my $request_xml = $cgi->param('POSTDATA'); -% -% #$r->log_error($request_xml); -% -% my $fsxmlrpc = new FS::XMLRPC; -% my ($error, $response_xml) = $fsxmlrpc->serve($request_xml); -% -% #$r->log_error($error) if $error; -% -% http_header('Content-Type' => 'text/xml', -% 'Content-Length' => length($response_xml)); -% -% print $response_xml; -% -% +<% $response_xml %>\ +<%init> +my $request_xml = $cgi->param('POSTDATA'); + +#warn $request_xml; + +my $fsxmlrpc = new FS::XMLRPC; +my ($error, $response_xml) = $fsxmlrpc->serve($request_xml); + +#warn $error; + +http_header('Content-Type' => 'text/xml', + 'Content-Length' => length($response_xml)); + +