[freeside-commits] freeside/FS/FS Maestro.pm,1.8,1.9
Ivan,,,
ivan at wavetail.420.am
Mon Sep 20 20:41:05 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv22644
Modified Files:
Maestro.pm
Log Message:
add service_status call more like we should have in the first place, RT#9905
Index: Maestro.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Maestro.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- Maestro.pm 20 Sep 2010 21:13:16 -0000 1.8
+++ Maestro.pm 21 Sep 2010 03:41:03 -0000 1.9
@@ -8,6 +8,8 @@
use FS::cust_pkg;
use FS::part_svc;
+#i guess this is kind of deprecated in favor of service_status, but keeping it
+#around until they say they don't need it.
sub customer_status {
my( $custnum ) = shift; #@_;
my $svcnum = @_ ? shift : '';
@@ -22,57 +24,14 @@
or return { 'status' => 'E',
'error' => "custnum $custnum not found" };
- my( $svc_pbx, $good_till, $outbound_service ) = ( '', '', '' );
- my %result = ();
- if ( $svcnum ) {
-
- ###
- # reseller scenario to maestro (customer w/ multiple packages)
- ###
-
- # find $svc_pbx
-
- $svc_pbx = qsearchs({
- 'table' => 'svc_pbx',
- 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
- ' LEFT JOIN cust_pkg USING ( pkgnum ) ',
- 'hashref' => { 'svcnum' => $svcnum },
- 'extra_sql' => " AND custnum = $custnum",
- })
- or return { 'status' => 'E',
- 'error' => "svcnum $svcnum not found" };
-
- #status in the reseller scenario
-
- my $cust_pkg = $svc_pbx->cust_svc->cust_pkg;
-
- $result{'status'} = substr($cust_pkg->ucfirst_status,0,1);
-
- # find "outbound service" y/n
-
- #XXX outbound service per-reseller ?
- #my @cust_pkg = $cust_main->cust_pkg;
- #
- #my $conf = new FS::Conf;
- #my %outbound_pkgs = map { $_=>1 } $conf->config('mc-outbound_packages');
- #my $outbound_service =
- # scalar( grep { $outbound_pkgs{ $_->pkgpart }
- # && !$_->get('cancel')
- # }
- # @cust_pkg
- # )
- # ? 1 : 0;
-
- # find "good till" date/time stamp (this package)
-
- $good_till = time2str('%c', $cust_pkg->bill || time );
-
- } else {
+ return service_status($svcnum) if $svcnum;
###
# regular customer to maestro (single package)
###
+ my %result = ();
+
my @cust_pkg = $cust_main->cust_pkg;
#things specific to the non-reseller scenario
@@ -103,13 +62,13 @@
my $cust_svc_pbx = $cust_svc_pbx[0];
- $svc_pbx = $cust_svc_pbx->svc_x;
+ 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');
- $outbound_service =
+ $result{'outbound_service'} =
scalar( grep { $outbound_pkgs{ $_->pkgpart }
&& !$_->get('cancel')
}
@@ -123,19 +82,65 @@
sort { $a->bill <=> $b->bill }
grep { !$_->get('cancel') && $_->part_pkg->freq ne '0' }
@cust_pkg;
- $good_till = time2str('%c', $active_cust_pkg[0]->bill || time );
-
- }
+ $result{'good_till'} = time2str('%c', $active_cust_pkg[0]->bill || time );
return {
'name' => $cust_main->name,
'email' => $cust_main->invoicing_list_emailonly_scalar,
- 'agentnum' => $cust_main->agentnum,
- 'agent' => $cust_main->agent->agent,
+ #'agentnum' => $cust_main->agentnum,
+ #'agent' => $cust_main->agent->agent,
'max_lines' => $svc_pbx ? $svc_pbx->max_extensions : '',
'max_simultaneous' => $svc_pbx ? $svc_pbx->max_simultaneous : '',
- 'outbound_service' => $outbound_service,
- 'good_till' => $good_till,
+ %result,
+ };
+
+}
+
+sub service_status {
+ my $svcnum = shift;
+
+ my $svc_pbx = qsearchs({
+ 'table' => 'svc_pbx',
+ 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
+ ' LEFT JOIN cust_pkg USING ( pkgnum ) ',
+ 'hashref' => { 'svcnum' => $svcnum },
+ #'extra_sql' => " AND custnum = $custnum",
+ })
+ or return { 'status' => 'E',
+ 'error' => "svcnum $svcnum not found" };
+
+ my $cust_pkg = $svc_pbx->cust_svc->cust_pkg;
+ my $cust_main = $cust_pkg->cust_main;
+
+ my %result = ();
+
+ #status in the reseller scenario
+ $result{'status'} = substr($cust_pkg->ucfirst_status,0,1);
+
+ # find "outbound service" y/n
+ my @cust_pkg = $cust_main->cust_pkg;
+ #XXX what about outbound service per-reseller ?
+ my $conf = new FS::Conf;
+ my %outbound_pkgs = map { $_=>1 } $conf->config('mc-outbound_packages');
+ $result{'outbound_service'} =
+ scalar( grep { $outbound_pkgs{ $_->pkgpart }
+ && !$_->get('cancel')
+ }
+ @cust_pkg
+ )
+ ? 1 : 0;
+
+ # find "good till" date/time stamp (this package)
+ $result{'good_till'} = time2str('%c', $cust_pkg->bill || time );
+
+ return {
+ 'custnum' => $cust_main->custnum,
+ 'name' => $cust_main->name,
+ 'email' => $cust_main->invoicing_list_emailonly_scalar,
+ #'agentnum' => $cust_main->agentnum,
+ #'agent' => $cust_main->agent->agent,
+ 'max_lines' => $svc_pbx->max_extensions,
+ 'max_simultaneous' => $svc_pbx->max_simultaneous,
%result,
};
More information about the freeside-commits
mailing list