X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FUI%2FWeb.pm;h=e4a9ac1b83afec7ab6e7202497832fc922e24004;hb=4776afec802191dac6dcaffe04c8295b57f01c57;hp=a05a667b36325b2a32fcac704db035122a49c51f;hpb=0dd05e9ff98263d2d42b419b1e278a5a3bc594b2;p=freeside.git diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm index a05a667b3..e4a9ac1b8 100644 --- a/FS/FS/UI/Web.pm +++ b/FS/FS/UI/Web.pm @@ -1,14 +1,18 @@ package FS::UI::Web; use strict; -use vars qw($DEBUG $me); +use vars qw($DEBUG @ISA @EXPORT_OK $me); +use Exporter; use FS::Conf; use FS::Record qw(dbdef); -use Number::Format; +use FS::cust_main; # are sql_balance and sql_date_balance in the right module? #use vars qw(@ISA); #use FS::UI #@ISA = qw( FS::UI ); +@ISA = qw( Exporter ); + +@EXPORT_OK = qw( svc_url ); $DEBUG = 0; $me = '[FS::UID::Web]'; @@ -114,6 +118,7 @@ sub svc_url { $url .= 'svcnum=' if $query =~ /^\d+(;|$)/ or $query eq ''; } + import FS::CGI 'rooturl'; #WTF! why is this necessary my $return = rooturl(). "$opt{action}/$url$query"; $return = qq!! if $opt{ahref}; @@ -144,6 +149,14 @@ sub svc_X_link { "$ahref$x"; } +sub svc_export_links { + my ($m, $part_svc, $cust_svc) = @_ or return ''; + + my $ahref = $cust_svc->export_links; + + join('', @$ahref); +} + sub parse_lt_gt { my($cgi, $field) = @_; @@ -159,7 +172,7 @@ sub parse_lt_gt { warn "checking for ${field}_$op field\n" if $DEBUG; - if ( $cgi->param($field."_$op") =~ /^\s*\$?\s*([\d\,\s]+(\.\d\d)?)\s*$/ ) { + if ( $cgi->param($field."_$op") =~ /^\s*\$?\s*(-?[\d\,\s]+(\.\d\d)?)\s*$/ ) { my $num = $1; $num =~ s/[\,\s]+//g; @@ -176,42 +189,6 @@ sub parse_lt_gt { } -sub bytecount_unexact { - my $bc = shift; - return("$bc bytes") - if ($bc < 1000); - return(sprintf("%.2f Kbytes", $bc/1000)) - if ($bc < 1000000); - return(sprintf("%.2f Mbytes", $bc/1000000)) - if ($bc < 1000000000); - 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 ### @@ -252,7 +229,10 @@ sub cust_header { 'Country' => 'country_full', 'Day phone' => 'daytime', # XXX should use msgcat, but how? 'Night phone' => 'night', # XXX should use msgcat, but how? + 'Fax number' => 'fax', 'Invoicing email(s)' => 'invoicing_list_emailonly_scalar', + 'Payment Type' => 'payby', + 'Current Balance' => 'current_balance', ); my %header2colormethod = ( @@ -328,9 +308,14 @@ sub cust_sql_fields { #inefficientish, but tiny lists and only run once per page push @fields, grep { my $field = $_; grep { $_ eq $field } @cust_fields } - qw( address1 address2 city state zip daytime night ); + qw( address1 address2 city state zip daytime night fax payby ); + + my @extra_fields = (); + if (grep { $_ eq 'current_balance' } @cust_fields) { + push @extra_fields, FS::cust_main->balance_sql . " AS current_balance"; + } - map "cust_main.$_", @fields; + map("cust_main.$_", @fields), @extra_fields; } =item cust_fields OBJECT [ CUST_FIELDS_VALUE ] @@ -442,7 +427,7 @@ use Carp; use Storable qw(nfreeze); use MIME::Base64; use JSON; -use FS::UID; +use FS::UID qw(getotaker); use FS::Record qw(qsearchs); use FS::queue; @@ -515,6 +500,7 @@ sub start_job { push @{$param{$field}}, $value; } } + $param{CurrentUser} = getotaker(); warn "FS::UI::Web::start_job\n". join('', map { if ( ref($param{$_}) ) {