break _bytecount subroutines out of FS::UI::Web
[freeside.git] / FS / FS / svc_acct.pm
index 1ef2119..1e34ff0 100644 (file)
@@ -24,6 +24,7 @@ use FS::UID qw( datasrc );
 use FS::Conf;
 use FS::Record qw( qsearch qsearchs fields dbh dbdef );
 use FS::Msgcat qw(gettext);
 use FS::Conf;
 use FS::Record qw( qsearch qsearchs fields dbh dbdef );
 use FS::Msgcat qw(gettext);
+use FS::UI::bytecount;
 use FS::svc_Common;
 use FS::cust_svc;
 use FS::part_svc;
 use FS::svc_Common;
 use FS::cust_svc;
 use FS::part_svc;
@@ -273,6 +274,53 @@ sub table_info {
                          disable_inventory => 1,
                          disable_select => 1,
                        },
                          disable_inventory => 1,
                          disable_select => 1,
                        },
+        'upbytes'   => { label => 'Upload',
+                         type  => 'text',
+                         disable_inventory => 1,
+                         disable_select => 1,
+                         'format' => \&FS::UI::bytecount::display_bytecount,
+                         'parse' => \&FS::UI::bytecount::parse_bytecount,
+                       },
+        'downbytes' => { label => 'Download',
+                         type  => 'text',
+                         disable_inventory => 1,
+                         disable_select => 1,
+                         'format' => \&FS::UI::bytecount::display_bytecount,
+                         'parse' => \&FS::UI::bytecount::parse_bytecount,
+                       },
+        'totalbytes'=> { label => 'Total up and download',
+                         type  => 'text',
+                         disable_inventory => 1,
+                         disable_select => 1,
+                         'format' => \&FS::UI::bytecount::display_bytecount,
+                         'parse' => \&FS::UI::bytecount::parse_bytecount,
+                       },
+        'seconds_threshold'   => { label => 'Seconds',
+                                   type  => 'text',
+                                   disable_inventory => 1,
+                                   disable_select => 1,
+                                 },
+        'upbytes_threshold'   => { label => 'Upload',
+                                   type  => 'text',
+                                   disable_inventory => 1,
+                                   disable_select => 1,
+                                   'format' => \&FS::UI::bytecount::display_bytecount,
+                                   'parse' => \&FS::UI::bytecount::parse_bytecount,
+                                 },
+        'downbytes_threshold' => { label => 'Download',
+                                   type  => 'text',
+                                   disable_inventory => 1,
+                                   disable_select => 1,
+                                   'format' => \&FS::UI::bytecount::display_bytecount,
+                                   'parse' => \&FS::UI::bytecount::parse_bytecount,
+                                 },
+        'totalbytes_threshold'=> { label => 'Total up and download',
+                                   type  => 'text',
+                                   disable_inventory => 1,
+                                   disable_select => 1,
+                                   'format' => \&FS::UI::bytecount::display_bytecount,
+                                   'parse' => \&FS::UI::bytecount::parse_bytecount,
+                                 },
     },
   };
 }
     },
   };
 }
@@ -1590,7 +1638,7 @@ sub _op_usage {
 
   if ( &{$op2condition{$op}}($self, $column, $amount) ) {
     foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
 
   if ( &{$op2condition{$op}}($self, $column, $amount) ) {
     foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
-      if ($part_export->option('overlimit_groups'), 1) {
+      if ($part_export->option('overlimit_groups')) {
         my ($new,$old);
         my $other = new FS::svc_acct $self->hashref;
         my $groups = &{ $self->_fieldhandlers->{'usergroup'} }
         my ($new,$old);
         my $other = new FS::svc_acct $self->hashref;
         my $groups = &{ $self->_fieldhandlers->{'usergroup'} }
@@ -1713,7 +1761,7 @@ sub set_usage {
     my $error = $self->overlimit('unsuspend');
 
     foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
     my $error = $self->overlimit('unsuspend');
 
     foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
-      if ($part_export->option('overlimit_groups'), 1) {
+      if ($part_export->option('overlimit_groups')) {
         my $old = new FS::svc_acct $self->hashref;
         my $groups = &{ $self->_fieldhandlers->{'usergroup'} }
                        ($self, $part_export->option('overlimit_groups'));
         my $old = new FS::svc_acct $self->hashref;
         my $groups = &{ $self->_fieldhandlers->{'usergroup'} }
                        ($self, $part_export->option('overlimit_groups'));