diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-05-15 11:41:24 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-05-15 11:41:24 -0700 |
commit | 7898193bb13ad215d1cc95983dbd092fbd2ba799 (patch) | |
tree | e913ea045c088bdbbd0d3f87efd6f348b0bd2e2f | |
parent | 742413b38cee4b7991643368dc9796500857298c (diff) | |
parent | 230e099f92541bc3bc0e2a08e81932ee17909fa0 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
-rw-r--r-- | FS/FS/ClientAPI.pm | 2 | ||||
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 42 | ||||
-rw-r--r-- | FS/FS/svc_pbx.pm | 25 | ||||
-rw-r--r-- | FS/FS/svc_phone.pm | 5 | ||||
-rwxr-xr-x | debian/rules | 15 | ||||
-rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 2 | ||||
-rw-r--r-- | fs_selfservice/FS-SelfService/cgi/view_usage.html | 24 |
7 files changed, 73 insertions, 42 deletions
diff --git a/FS/FS/ClientAPI.pm b/FS/FS/ClientAPI.pm index 1fea28c67..e4031b26e 100644 --- a/FS/FS/ClientAPI.pm +++ b/FS/FS/ClientAPI.pm @@ -6,7 +6,7 @@ use vars qw( @EXPORT_OK %handler $domain $DEBUG $me ); @EXPORT_OK = qw( load_clientapi_modules ); -$DEBUG = 0; +$DEBUG = 1; $me = '[FS::ClientAPI]'; %handler = (); diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index e2f859527..c89b7bb3f 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -1857,18 +1857,20 @@ sub list_svcs { } # no usage to hide here - } elsif ( $svcdb eq 'svc_phone' ) { + } elsif ( $svcdb eq 'svc_phone' or $svcdb eq 'svc_pbx' ) { if (!$hide_usage) { # could potentially show lots of things... $hash{'outbound'} = 1; $hash{'inbound'} = 0; - if ( $part_pkg->plan eq 'voip_inbound' ) { - $hash{'outbound'} = 0; - $hash{'inbound'} = 1; - } elsif ( $part_pkg->option('selfservice_inbound_format') - or $conf->config('selfservice-default_inbound_cdr_format') - ) { - $hash{'inbound'} = 1; + if ( $svcdb eq 'svc_phone' ) { + if ( $part_pkg->plan eq 'voip_inbound' ) { + $hash{'outbound'} = 0; + $hash{'inbound'} = 1; + } elsif ( $part_pkg->option('selfservice_inbound_format') + or $conf->config('selfservice-default_inbound_cdr_format') + ) { + $hash{'inbound'} = 1; + } } foreach (qw(inbound outbound)) { # hmm...we can't filter by status here, because there might @@ -2163,11 +2165,11 @@ sub _list_cdr_usage { # XXX CDR type support... # XXX any way to do a paged search on this? # we have to return the results all at once... - my($svc_phone, $begin, $end, %opt) = @_; + my($svc_x, $begin, $end, %opt) = @_; map [ $_->downstream_csv(%opt, 'keeparray' => 1) ], - $svc_phone->get_cdrs( - 'begin'=>$begin, - 'end'=>$end, + $svc_x->get_cdrs( + 'begin' => $begin, + 'end' => $end, 'disable_charged_party' => 1, %opt ); @@ -2175,9 +2177,7 @@ sub _list_cdr_usage { sub list_cdr_usage { my $p = shift; - _usage_details( \&_list_cdr_usage, $p, - 'svcdb' => 'svc_phone', - ); + _usage_details( \&_list_cdr_usage, $p ); } sub _usage_details { @@ -2194,17 +2194,17 @@ sub _usage_details { my $search = { 'svcnum' => $p->{'svcnum'} }; $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent'; - my $svcdb = $opt{'svcdb'} || 'svc_acct'; - - my $svc_x = qsearchs( $svcdb, $search ); + my $cust_svc = qsearchs( 'cust_svc', $search ); return { 'error' => 'No service selected in list_svc_usage' } - unless $svc_x; + unless $cust_svc; - my $cust_pkg = $svc_x->cust_svc->cust_pkg; + my $svc_x = $cust_svc->svc_x; + my $svcdb = $svc_x->table; + my $cust_pkg = $cust_svc->cust_pkg; my $freq = $cust_pkg->part_pkg->freq; my %callback_opt; my $header = []; - if ( $svcdb eq 'svc_phone' ) { + if ( $svcdb eq 'svc_phone' or $svcdb eq 'svc_pbx' ) { my $format = ''; if ( $p->{inbound} ) { $format = $cust_pkg->part_pkg->option('selfservice_inbound_format') diff --git a/FS/FS/svc_pbx.pm b/FS/FS/svc_pbx.pm index e19dc88dd..b28f0573d 100644 --- a/FS/FS/svc_pbx.pm +++ b/FS/FS/svc_pbx.pm @@ -386,6 +386,31 @@ sub get_cdrs { qsearch ( $psearch->{query} ) } +=item sum_cdrs + +Takes the same options as psearch_cdrs, but returns a single row containing +"count" (the number of CDRs) and the sums of the following fields: duration, +billsec, rated_price, rated_seconds, rated_minutes. + +Note that if any calls are not rated, their rated_* fields will be null. +If you want to use those fields, pass the 'status' option to limit to +calls that have been rated. This is intentional; please don't "fix" it. + +=cut + +sub sum_cdrs { + my $self = shift; + my $psearch = $self->psearch_cdrs(@_); + $psearch->{query}->{'select'} = join(',', + 'COUNT(*) AS count', + map { "SUM($_) AS $_" } + qw(duration billsec rated_price rated_seconds rated_minutes) + ); + # hack + $psearch->{query}->{'extra_sql'} =~ s/ ORDER BY.*$//; + qsearchs ( $psearch->{query} ); +} + =back =head1 BUGS diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 326c0be30..fc903652f 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -201,9 +201,10 @@ sub table_info { }, 'circuit_svcnum' => { label => 'Circuit', type => 'select', - select_table => 'svc_domain', + select_table => 'svc_circuit', select_key => 'svcnum', - select_label => 'circuit_label', + select_label => 'label', + select_allow_empty=> 1, disable_inventory => 1, }, diff --git a/debian/rules b/debian/rules index 348720f3c..85f6a6147 100755 --- a/debian/rules +++ b/debian/rules @@ -47,7 +47,8 @@ export DIST_CONF = ${FREESIDE_CONF}/default_conf export MASON_HANDLER=$(TMP)-webui/usr/local/etc/freeside/handler.pl #export FREESIDE_DOCUMENT_ROOT = /usr/share/freeside/www -export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/var/www/freeside +export APACHE_DOCUMENT_ROOT := $(shell [ ${APACHE_VERSION} = '2.4' ] && echo '/var/www/html' || echo '/var/www') +export FREESIDE_DOCUMENT_ROOT = $(TMP)$(APACHE_DOCUMENT_ROOT)/freeside export INIT_FILE = $(TMP).init export INIT_INSTALL = /bin/true export HTTPD_RESTART = /bin/true @@ -215,15 +216,15 @@ install-stamp: build-stamp chown -R freeside ${TMP}-selfservice-lib/usr/local/freeside chmod 600 ${TMP}-selfservice-lib/usr/local/freeside/selfservice_socket - install -d -o freeside -g freeside ${TMP}-selfservice-ui/var/www/ - cp -R fs_selfservice/FS-SelfService/cgi ${TMP}-selfservice-ui/var/www/selfservice-DIST - chown freeside.freeside ${TMP}-selfservice-ui/var/www/selfservice-DIST/*.cgi ${TMP}-selfservice-ui/var/www/selfservice-DIST/*/*.cgi; - chmod 755 ${TMP}-selfservice-ui/var/www/selfservice-DIST/*.cgi ${TMP}-selfservice-ui/var/www/selfservice-DIST/*/*.cgi + install -d -o freeside -g freeside ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/ + cp -R fs_selfservice/FS-SelfService/cgi ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST + chown freeside.freeside ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*.cgi ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*/*.cgi; + chmod 755 ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*.cgi ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*/*.cgi # NG-selfservice - install -d ${TMP}-ng-selfservice/var/www/ - cp -R ng_selfservice ${TMP}-ng-selfservice/var/www/ng_selfservice-DIST/ + install -d ${TMP}-ng-selfservice$(APACHE_DOCUMENT_ROOT)/ + cp -R ng_selfservice ${TMP}-ng-selfservice$(APACHE_DOCUMENT_ROOT)/ng_selfservice-DIST/ #RT Config diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 2337fb51e..8fec01121 100755 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -957,7 +957,7 @@ sub delete_svc { sub view_usage { my $res = list_svcs( 'session_id' => $session_id, - 'svcdb' => [ 'svc_acct', 'svc_phone', 'svc_port', ], + 'svcdb' => [ 'svc_acct', 'svc_phone', 'svc_port', 'svc_pbx' ], 'ncancelled' => 1, ); if ($res->{hide_usage}) { diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html index 2aa7c1efb..4099a57f5 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_usage.html +++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html @@ -3,6 +3,7 @@ @svc_acct = (); @svc_phone = (); @svc_port = (); + @svc_pbx = (); foreach (@svcs) { $by_pkg_label{ $_->{pkg_label} } ||= []; @@ -13,6 +14,8 @@ push @svc_phone, $_; } elsif ( $_->{svcdb} eq 'svc_port' ) { push @svc_port, $_; + } elsif ( $_->{svcdb} eq 'svc_pbx' ) { + push @svc_pbx, $_; } } ''; @@ -74,10 +77,10 @@ <%= scalar(@svc_acct) ? '</TABLE><BR><BR>' : '' %> -<%= if ( @svc_phone ) { +<%= if ( @svc_phone or @svc_pbx ) { %any = (); for my $dir (qw(outbound inbound)) { - $any{$dir} = grep { $_->{$dir} } @svc_phone; + $any{$dir} = grep { $_->{$dir} } (@svc_phone, @svc_pbx); } $OUT.= '<FONT SIZE="4">Call usage</FONT><BR><BR> <TABLE BGCOLOR="#cccccc" STYLE="display:inline-block"> @@ -97,21 +100,22 @@ } %> -<%= foreach my $svc_phone ( @svc_phone ) { - my $link = "${url}view_cdr_details;". - "svcnum=$svc_phone->{'svcnum'};beginning=0;ending=0"; - $OUT .= '<TR><TD>'. $svc_phone->{'label'}. ': '. $svc_phone->{'value'}; +<%= foreach my $svc_x ( @svc_phone, @svc_pbx ) { + my $link = $url . 'view_cdr_details;' . + 'svcnum='.$svc_x->{'svcnum'}. + ';beginning=0;ending=0'; + $OUT .= '<TR><TD>'. $svc_x->{'label'}. ': '. $svc_x->{'value'}; $OUT .= '</TD>'; # usage summary w/ links for my $dir (qw(outbound inbound)) { if ( $dir eq 'inbound' ) { $link .= ';inbound=1'; } - if ( $svc_phone->{$dir} ) { + if ( $svc_x->{$dir} ) { $OUT .= '<TD ALIGN="right">'.qq!<A HREF="$link">! . sprintf('%d calls (%.0f minutes)', - $svc_phone->{$dir}->{'count'}, - $svc_phone->{$dir}->{'duration'} / 60 + $svc_x->{$dir}->{'count'}, + $svc_x->{$dir}->{'duration'} / 60 ) . '</A></TD>'; } elsif ( $any{$dir} ) { @@ -154,7 +158,7 @@ '<TD COLSPAN=4>* shared among all your phone plans</TD></TR>'; } } -if ( scalar(@svc_phone) or scalar(@usage_pools) ) { +if ( @svc_phone or @svc_pbx or @usage_pools ) { $OUT .= '</TABLE><BR><BR>'; } ''; |