[freeside-commits] freeside/FS/FS Conf.pm, 1.191, 1.192 part_pkg.pm, 1.57, 1.58 part_svc.pm, 1.30, 1.31 svc_acct.pm, 1.225, 1.226

Jeff Finucane,420,, jeff at wavetail.420.am
Wed Apr 11 20:16:44 PDT 2007


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv7777/FS/FS

Modified Files:
	Conf.pm part_pkg.pm part_svc.pm svc_acct.pm 
Log Message:
input and output on data volume fields specified with k,m,g,or t

Index: part_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_svc.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- part_svc.pm	29 Dec 2006 08:51:32 -0000	1.30
+++ part_svc.pm	12 Apr 2007 03:16:42 -0000	1.31
@@ -145,9 +145,11 @@
     my $flag = $self->getfield($svcdb.'__'.$field.'_flag');
     #if ( uc($flag) =~ /^([DFMAX])$/ ) {
     if ( uc($flag) =~ /^([A-Z])$/ ) { #part_svc_column will test it
+      my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse}
+                   || sub { shift };
       $part_svc_column->setfield('columnflag', $1);
       $part_svc_column->setfield('columnvalue',
-        $self->getfield($svcdb.'__'.$field)
+        &$parser($self->getfield($svcdb.'__'.$field))
       );
       if ( $previous ) {
         $error = $part_svc_column->replace($previous);
@@ -264,9 +266,11 @@
       my $flag = $new->getfield($svcdb.'__'.$field.'_flag');
       #if ( uc($flag) =~ /^([DFMAX])$/ ) {
       if ( uc($flag) =~ /^([A-Z])$/ ) { #part_svc_column will test it
+        my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse}
+                     || sub { shift };
         $part_svc_column->setfield('columnflag', $1);
         $part_svc_column->setfield('columnvalue',
-          $new->getfield($svcdb.'__'.$field)
+          &$parser($new->getfield($svcdb.'__'.$field))
         );
         if ( $previous ) {
           $error = $part_svc_column->replace($previous);

Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- part_pkg.pm	15 Mar 2007 20:54:36 -0000	1.57
+++ part_pkg.pm	12 Apr 2007 03:16:42 -0000	1.58
@@ -817,6 +817,39 @@
   \%plans;
 }
 
+=item format OPTION DATA
+
+Returns data formatted according to the function 'format' described
+in the plan info.  Returns DATA if no such function exists.
+
+=cut
+
+sub format {
+  my ($self, $option, $data) = (shift, shift, shift);
+  if (exists($plans{$self->plan}->{fields}->{$option}{format})) {
+    &{$plans{$self->plan}->{fields}->{$option}{format}}($data);
+  }else{
+    $data;
+  }
+}
+
+=item prase OPTION DATA
+
+Returns data parsed according to the function 'parse' described
+in the plan info.  Returns DATA if no such function exists.
+
+=cut
+
+sub parse {
+  my ($self, $option, $data) = (shift, shift, shift);
+  if (exists($plans{$self->plan}->{fields}->{$option}{parse})) {
+    &{$plans{$self->plan}->{fields}->{$option}{parse}}($data);
+  }else{
+    $data;
+  }
+}
+
+
 =back
 
 =head1 NEW PLAN CLASSES

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- Conf.pm	10 Apr 2007 01:44:57 -0000	1.191
+++ Conf.pm	12 Apr 2007 03:16:42 -0000	1.192
@@ -1755,6 +1755,20 @@
     'type' => 'checkbox',
   },
 
+  {
+    'key'         => 'datavolume-forcemegabytes',
+    'section'     => 'UI',
+    'description' => 'All data volumes are expressed in megabytes',
+    'type'        => 'checkbox',
+  },
+
+  {
+    'key'         => 'datavolume-significantdigits',
+    'section'     => 'UI',
+    'description' => 'number of significant digits to use to represent data volumes',
+    'type'        => 'text',
+  },
+
 );
 
 1;

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -d -r1.225 -r1.226
--- svc_acct.pm	11 Apr 2007 04:28:21 -0000	1.225
+++ svc_acct.pm	12 Apr 2007 03:16:42 -0000	1.226
@@ -273,6 +273,53 @@
                          disable_inventory => 1,
                          disable_select => 1,
                        },
+        'upbytes'   => { label => 'Upload',
+                         type  => 'text',
+                         disable_inventory => 1,
+                         disable_select => 1,
+                         'format' => \&FS::UI::Web::display_bytecount,
+                         'parse' => \&FS::UI::Web::parse_bytecount,
+                       },
+        'downbytes' => { label => 'Download',
+                         type  => 'text',
+                         disable_inventory => 1,
+                         disable_select => 1,
+                         'format' => \&FS::UI::Web::display_bytecount,
+                         'parse' => \&FS::UI::Web::parse_bytecount,
+                       },
+        'totalbytes'=> { label => 'Total up and download',
+                         type  => 'text',
+                         disable_inventory => 1,
+                         disable_select => 1,
+                         'format' => \&FS::UI::Web::display_bytecount,
+                         'parse' => \&FS::UI::Web::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::Web::display_bytecount,
+                                   'parse' => \&FS::UI::Web::parse_bytecount,
+                                 },
+        'downbytes_threshold' => { label => 'Download',
+                                   type  => 'text',
+                                   disable_inventory => 1,
+                                   disable_select => 1,
+                                   'format' => \&FS::UI::Web::display_bytecount,
+                                   'parse' => \&FS::UI::Web::parse_bytecount,
+                                 },
+        'totalbytes_threshold'=> { label => 'Total up and download',
+                                   type  => 'text',
+                                   disable_inventory => 1,
+                                   disable_select => 1,
+                                   'format' => \&FS::UI::Web::display_bytecount,
+                                   'parse' => \&FS::UI::Web::parse_bytecount,
+                                 },
     },
   };
 }



More information about the freeside-commits mailing list