[freeside-commits] freeside/FS/FS/UI Web.pm,1.26,1.26.2.1
Jeff Finucane,420,,
jeff at wavetail.420.am
Wed Apr 11 20:18:26 PDT 2007
- Previous message: [freeside-commits] freeside/httemplate/edit part_pkg.cgi, 1.68, 1.69 part_svc.cgi, 1.57, 1.58 svc_acct.cgi, 1.46, 1.47
- Next message: [freeside-commits] freeside/FS/FS Conf.pm, 1.180.2.4, 1.180.2.5 part_pkg.pm, 1.56.2.1, 1.56.2.2 part_svc.pm, 1.30, 1.30.2.1 svc_acct.pm, 1.217.2.5, 1.217.2.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS/UI
In directory wavetail:/tmp/cvs-serv8008/FS/FS/UI
Modified Files:
Tag: FREESIDE_1_7_BRANCH
Web.pm
Log Message:
input and output on data volume fields specified with k,m,g,or t (backport)
Index: Web.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/UI/Web.pm,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -d -r1.26 -r1.26.2.1
--- Web.pm 14 Feb 2007 08:48:36 -0000 1.26
+++ Web.pm 12 Apr 2007 03:18:24 -0000 1.26.2.1
@@ -4,6 +4,7 @@
use vars qw($DEBUG $me);
use FS::Conf;
use FS::Record qw(dbdef);
+use Number::Format;
#use vars qw(@ISA);
#use FS::UI
@@ -186,6 +187,31 @@
return(sprintf("%.2f Gbytes", $bc/1000000000));
}
+sub parse_bytecount {
+ my $bc = shift;
+ return $bc if (($bc =~ tr/.//) > 1);
+ $bc =~ /^\s*([\d.]*)\s*([kKmMgGtT]?)[bB]?\s*$/ or return $bc;
+ my $base = $1;
+ return $bc unless length $base;
+ my $exponent = index ' kmgt', lc($2);
+ return $bc if ($exponent < 0 && $2);
+ $exponent = 0 if ($exponent < 0);
+ return $base * 1024 ** $exponent;
+}
+
+sub display_bytecount {
+ my $bc = shift;
+ return $bc unless ($bc =~ /^(\d+)$/);
+ my $conf = new FS::Conf;
+ my $f = new Number::Format;
+ my $precision = $conf->exists('datavolume-significantdigits')
+ ? $conf->config('datavolume-significantdigits')
+ : 3;
+ my $unit = $conf->exists('datavolume-forcemegabytes') ? 'M' : 'A';
+
+ return $f->format_bytes($bc, precision => $precision, unit => $unit);
+}
+
###
# cust_main report subroutines
###
- Previous message: [freeside-commits] freeside/httemplate/edit part_pkg.cgi, 1.68, 1.69 part_svc.cgi, 1.57, 1.58 svc_acct.cgi, 1.46, 1.47
- Next message: [freeside-commits] freeside/FS/FS Conf.pm, 1.180.2.4, 1.180.2.5 part_pkg.pm, 1.56.2.1, 1.56.2.2 part_svc.pm, 1.30, 1.30.2.1 svc_acct.pm, 1.217.2.5, 1.217.2.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list