summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2009-03-18 00:30:43 +0000
committerjeff <jeff>2009-03-18 00:30:43 +0000
commit037c3acd250f637182019d0a74361d5420f29c52 (patch)
tree581d910db05d77eb6208e5cd058ae5c1831eed25
parente61679ab66b5e1e2db39791117440d7dfce41045 (diff)
hide unused usage columns
-rw-r--r--FS/FS/part_pkg/flat.pm11
-rw-r--r--FS/FS/svc_acct.pm29
-rwxr-xr-xhttemplate/edit/part_svc.cgi9
3 files changed, 45 insertions, 4 deletions
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index 3ac44c4e2..8fd028650 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -195,12 +195,17 @@ sub is_prepaid {
0; #no, we're postpaid
}
+sub usage_valuehash {
+ my $self = shift;
+ map { $_, $self->option($_) }
+ grep { $self->option($_, 'hush') }
+ qw(seconds upbytes downbytes totalbytes);
+}
+
sub reset_usage {
my($self, $cust_pkg, %opt) = @_;
warn " resetting usage counters" if $opt{debug} > 1;
- my %values = map { $_, $self->option($_) }
- grep { $self->option($_, 'hush') }
- qw(seconds upbytes downbytes totalbytes);
+ my %values = $self->usage_valuehash;
if ($self->option('usage_rollover', 1)) {
$cust_pkg->recharge(\%values);
}else{
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 6f1105148..57ef615f9 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -26,6 +26,7 @@ use FS::Conf;
use FS::Record qw( qsearch qsearchs fields dbh dbdef );
use FS::Msgcat qw(gettext);
use FS::UI::bytecount;
+use FS::part_pkg;
use FS::svc_Common;
use FS::cust_svc;
use FS::part_svc;
@@ -277,6 +278,7 @@ sub table_info {
type => 'text',
disable_inventory => 1,
disable_select => 1,
+ disable_part_svc_column => 1,
},
'upbytes' => { label => 'Upload',
type => 'text',
@@ -284,6 +286,7 @@ sub table_info {
disable_select => 1,
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
+ disable_part_svc_column => 1,
},
'downbytes' => { label => 'Download',
type => 'text',
@@ -291,6 +294,7 @@ sub table_info {
disable_select => 1,
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
+ disable_part_svc_column => 1,
},
'totalbytes'=> { label => 'Total up and download',
type => 'text',
@@ -298,11 +302,13 @@ sub table_info {
disable_select => 1,
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
+ disable_part_svc_column => 1,
},
'seconds_threshold' => { label => 'Seconds threshold',
type => 'text',
disable_inventory => 1,
disable_select => 1,
+ disable_part_svc_column => 1,
},
'upbytes_threshold' => { label => 'Upload threshold',
type => 'text',
@@ -310,6 +316,7 @@ sub table_info {
disable_select => 1,
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
+ disable_part_svc_column => 1,
},
'downbytes_threshold' => { label => 'Download threshold',
type => 'text',
@@ -317,6 +324,7 @@ sub table_info {
disable_select => 1,
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
+ disable_part_svc_column => 1,
},
'totalbytes_threshold'=> { label => 'Total up and download threshold',
type => 'text',
@@ -324,6 +332,7 @@ sub table_info {
disable_select => 1,
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
+ disable_part_svc_column => 1,
},
'last_login'=> {
label => 'Last login',
@@ -503,6 +512,26 @@ sub insert {
$self->svcpart($cust_svc->svcpart);
}
+ # set usage fields and thresholds if unset but set in a package def
+ if ( $self->pkgnum ) {
+ my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
+ my $part_pkg = $cust_pkg->part_pkg if $cust_pkg;
+ if ( $part_pkg && $part_pkg->can('usage_valuehash') ) {
+
+ my %values = $part_pkg->usage_valuehash;
+ my $multiplier = $conf->exists('svc_acct-usage_threshold')
+ ? 1 - $conf->config('svc_acct-usage_threshold')/100
+ : 0.20;
+
+ foreach ( keys %values ) {
+ next if $self->getfield($_);
+ $self->setfield( $_, $values{$_} );
+ $self->setfield( $_. '_threshold', int( $values{$_} * $multiplier ) );
+ }
+
+ }
+ }
+
my @jobnums;
$error = $self->SUPER::insert(
'jobnums' => \@jobnums,
diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi
index e0fb615b1..deb3c80f9 100755
--- a/httemplate/edit/part_svc.cgi
+++ b/httemplate/edit/part_svc.cgi
@@ -131,7 +131,14 @@ that field.
%
% #yucky kludge
% my @fields = defined( dbdef->table($layer) )
-% ? grep { $_ ne 'svcnum' } fields($layer)
+% ? grep {
+% $_ ne 'svcnum' &&
+% ( !FS::part_svc->svc_table_fields($layer)
+% ->{$_}->{disable_part_svc_column} ||
+% $part_svc->part_svc_column($_)->columnflag
+% )
+% }
+% fields($layer)
% : ();
% push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge
% $part_svc->svcpart($clone) if $clone; #haha, undone below