summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-05-31 23:53:17 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-06-01 18:53:42 -0500
commitf13e22aab920cd6fab70319acc1291c083d0f151 (patch)
tree59072cfec8dab6c96b37e79e11a2cdec934d428d /FS
parentca77b09b2249f23725dd494472323e730d21ba33 (diff)
RT#42380: Show usage for broadband services in selfservice portal
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm14
-rw-r--r--FS/FS/cust_svc.pm12
2 files changed, 19 insertions, 7 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index ecac223da..986306524 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1856,6 +1856,20 @@ sub list_svcs {
# would it make sense to put this in a svc_* method?
+ if (!$hide_usage and grep(/^$svcdb$/, qw(svc_acct svc_broadband)) and $part_svc->part_export_usage) {
+ my $last_bill = $cust_pkg->last_bill || 0;
+ my $now = time;
+ my $up_used = $cust_svc->attribute_since_sqlradacct($last_bill,$now,'AcctInputOctets');
+ my $down_used = $cust_svc->attribute_since_sqlradacct($last_bill,$now,'AcctOutputOctets');
+ %hash = (
+ %hash,
+ 'seconds_used' => $cust_svc->seconds_since_sqlradacct($last_bill,$now),
+ 'upbytes_used' => display_bytecount($up_used),
+ 'downbytes_used' => display_bytecount($down_used),
+ 'totalbytes_used' => display_bytecount($up_used + $down_used)
+ );
+ }
+
if ( $svcdb eq 'svc_acct' ) {
foreach (qw(username email finger seconds)) {
$hash{$_} = $svc_x->$_;
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index 9d9ecdd50..3f7348321 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -823,13 +823,12 @@ sub seconds_since { 'internal session db deprecated'; };
=item seconds_since_sqlradacct TIMESTAMP_START TIMESTAMP_END
-See L<FS::svc_acct/seconds_since_sqlradacct>. Equivalent to
-$cust_svc->svc_x->seconds_since_sqlradacct, but more efficient. Meaningless
-for records where B<svcdb> is not "svc_acct".
+Equivalent to $cust_svc->svc_x->seconds_since_sqlradacct, but
+more efficient. Meaningless for records where B<svcdb> is not
+svc_acct or svc_broadband.
=cut
-#note: implementation here, POD in FS::svc_acct
sub seconds_since_sqlradacct {
my($self, $start, $end) = @_;
@@ -968,12 +967,11 @@ sub seconds_since_sqlradacct {
=item attribute_since_sqlradacct TIMESTAMP_START TIMESTAMP_END ATTRIBUTE
See L<FS::svc_acct/attribute_since_sqlradacct>. Equivalent to
-$cust_svc->svc_x->attribute_since_sqlradacct, but more efficient. Meaningless
-for records where B<svcdb> is not "svc_acct".
+$cust_svc->svc_x->attribute_since_sqlradacct, but more efficient.
+Meaningless for records where B<svcdb> is not svc_acct or svc_broadband.
=cut
-#note: implementation here, POD in FS::svc_acct
#(false laziness w/seconds_since_sqlradacct above)
sub attribute_since_sqlradacct {
my($self, $start, $end, $attrib) = @_;