diff options
author | jeff <jeff> | 2007-04-12 03:16:43 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-04-12 03:16:43 +0000 |
commit | 0dd05e9ff98263d2d42b419b1e278a5a3bc594b2 (patch) | |
tree | ef42a5ed621c73699e3973fd14ef22abdd3a5823 /httemplate | |
parent | b611f02e479f4a7f9840f59f773d282b1c13b62f (diff) |
input and output on data volume fields specified with k,m,g,or t
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 2 | ||||
-rwxr-xr-x | httemplate/browse/part_svc.cgi | 5 | ||||
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 4 | ||||
-rwxr-xr-x | httemplate/edit/part_svc.cgi | 7 | ||||
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 8 | ||||
-rwxr-xr-x | httemplate/edit/process/svc_acct.cgi | 5 | ||||
-rwxr-xr-x | httemplate/edit/svc_acct.cgi | 28 | ||||
-rwxr-xr-x | httemplate/view/svc_acct.cgi | 15 |
8 files changed, 43 insertions, 31 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 6b62ec67b..5acf17ef2 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -189,7 +189,7 @@ push @fields, sub { shift->plan || '(legacy)' }, { 'data' => $1, 'align' => 'right', }, - { 'data' => $2, + { 'data' => $part_pkg->format($1,$2), 'align' => 'left', }, ]; diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 369495571..92c0840b0 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -135,6 +135,9 @@ function part_export_areyousure(href) { % % my($n1)=''; % foreach my $field ( @fields ) { +% my $formatter = +% FS::part_svc->svc_table_fields($svcdb)->{$field}->{format} +% || sub { shift }; % my $flag = $part_svc->part_svc_column($field)->columnflag; % @@ -143,7 +146,7 @@ function part_export_areyousure(href) { <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $flag{$flag} %></TD> <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> -% my $value = $part_svc->part_svc_column($field)->columnvalue; +% my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue); % if ( $flag =~ /^[MA]$/ ) { % $inventory_class{$value} % ||= qsearchs('inventory_class', { 'classnum' => $value } ); diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index ce3e8547f..bdd3f304a 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -323,10 +323,12 @@ Reseller information % % $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>'; % +% my $format = sub { shift }; +% $format = $href->{$field}{'format'} if exists($href->{$field}{'format'}); % if ( ! exists($href->{$field}{'type'}) ) { % $html .= qq!<INPUT TYPE="text" NAME="$field" VALUE="!. % ( exists($plandata{$field}) -% ? $plandata{$field} +% ? &$format($plandata{$field}) % : $href->{$field}{'default'} ). % qq!">!; % } elsif ( $href->{$field}{'type'} eq 'checkbox' ) { diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 6ba9240e3..9432839e7 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -166,12 +166,13 @@ that field. % % foreach my $field (@fields) { % -% my $part_svc_column = $part_svc->part_svc_column($field); -% my $value = $part_svc_column->columnvalue; -% my $flag = $part_svc_column->columnflag; % #my $def = $defs{$layer}{$field}; % my $def = FS::part_svc->svc_table_fields($layer)->{$field}; % my $label = $def->{'def_label'} || $def->{'label'}; +% my $formatter = $def->{'format'} || sub { shift }; +% my $part_svc_column = $part_svc->part_svc_column($field); +% my $value = &$formatter($part_svc_column->columnvalue); +% my $flag = $part_svc_column->columnflag; % % if ( $bgcolor eq $bgcolor1 ) { % $bgcolor = $bgcolor2; diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 1158222b6..5fc59c14d 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -6,11 +6,17 @@ % %my $old = qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart; % +%tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() }; +%my $href = $plans{$cgi->param('plan')}->{'fields'}; +% %#fixup plandata %my $plandata = $cgi->param('plandata'); %my @plandata = split(',', $plandata); %$cgi->param('plandata', -% join('', map { "$_=". join(', ', $cgi->param($_)). "\n" } @plandata ) +% join('', map { my $parser = sub { shift }; +% $parser = $href->{$_}{parse} if exists($href->{$_}{parse}); +% "$_=". join(', ', &$parser($cgi->param($_))). "\n" +% } @plandata ) %); % %foreach (qw( setuptax recurtax disabled )) { diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 30552c846..65ac5c176 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -23,6 +23,11 @@ %#unmunge usergroup %$cgi->param('usergroup', [ $cgi->param('radius_usergroup') ] ); % +%#unmunge bytecounts +%foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) { +% $cgi->param($_, FS::UI::Web::parse_bytecount($cgi->param($_)) ); +%} +% %my %hash = $svcnum ? $old->hash : (); %map { % $hash{$_} = scalar($cgi->param($_)); diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 01f665a45..e0610b22f 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -386,27 +386,27 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> </TR> % } % -% if ( $curuser->access_right('Edit usage') ) { -% my %label = ( seconds => 'Seconds', -% upbytes => 'Upload bytes', -% downbytes => 'Download bytes', -% totalbytes => 'Total bytes', -% ); -% foreach my $uf (keys %label) { -% my $tf = $uf . "_threshold"; -% if ( $svc_acct->$tf ne '' ) { - +% my %label = ( seconds => 'Time', +% upbytes => 'Upload bytes', +% downbytes => 'Download bytes', +% totalbytes => 'Total bytes', +% ); +% foreach my $uf (keys %label) { +% my $tf = $uf . "_threshold"; +% if ( $curuser->access_right('Edit usage') ) { <TR> <TD ALIGN="right"><% $label{$uf} %> remaining</TD> - <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>"></TD> + <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(blank disables)</TD> </TR> <TR> <TD ALIGN="right"><% $label{$uf} %> threshold</TD> - <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(blank or zero disables <% lc($label{$uf}) %> remaining)</TD> + <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(blank disables)</TD> </TR> -% } +% }else{ + <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>"> + <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>"> % } -% } +% } % %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) { % $r =~ /^^r(adius|[cr])_(.+)$/ or next; #? diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 86478681c..2ad9b8ef9 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -245,17 +245,19 @@ Service #<B><% $svcnum %></B> </TD> </TR> % } -% my %ulabel = ( seconds => 'Seconds', +% my %ulabel = ( seconds => 'Time', % upbytes => 'Upload bytes', % downbytes => 'Download bytes', % totalbytes => 'Total bytes', % ); % foreach my $uf ( keys %ulabel ) { % my $tf = $uf . "_threshold"; -% if ( $svc_acct->$tf ne '' ) { +% if ( $svc_acct->$uf ne '' ) { +% my $v = $uf eq 'seconds' ? duration_exact($svc_acct->$uf) +% : FS::UI::Web::display_bytecount($svc_acct->$uf); <TR> <TD ALIGN="right"><% $ulabel{$uf} %> remaining</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->$uf %></TD> + <TD BGCOLOR="#ffffff"><% $v %></TD> </TR> % } @@ -286,13 +288,6 @@ Service #<B><% $svcnum %></B> <TD ALIGN="right">RADIUS groups</TD> <TD BGCOLOR="#ffffff"><% join('<BR>', $svc_acct->radius_groups) %></TD> </TR> -% if ( $svc_acct->seconds =~ /^\d+$/ ) { - - <TR> - <TD ALIGN="right">Prepaid time</TD> - <TD BGCOLOR="#ffffff"><% duration_exact($svc_acct->seconds) %></TD> - </TR> -% } % %# Can this be abstracted further? Maybe a library function like %# widget('HTML', 'view', $svc_acct) ? It would definitely make UI |