summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2002-11-05 23:29:38 +0000
committerivan <ivan>2002-11-05 23:29:38 +0000
commit548a47b0ec1040320e56f17cfac71f716785cb95 (patch)
treea17d59c3aed4149285c47bcfddf6b041950cf6ca /httemplate
parentfc3b6024fcf0bf0394e6239639cbe31786b0cad8 (diff)
bandwidth charges from sqlradius
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/part_pkg.cgi29
-rwxr-xr-xhttemplate/view/svc_acct.cgi18
2 files changed, 40 insertions, 7 deletions
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 187578a35..6141c0083 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -356,7 +356,7 @@ tie my %plans, 'Tie::IxHash',
},
'sqlradacct_hour' => {
- 'name' => 'Base charge plus charge per-hour from an external sqlradius radacct table',
+ 'name' => 'Base charge plus charge per-hour (and for data) from an external sqlradius radacct table',
'fields' => {
'setup_fee' => { 'name' => 'Setup fee for this package',
'default' => 0,
@@ -370,13 +370,34 @@ tie my %plans, 'Tie::IxHash',
'recur_hourly_charge' => { 'name' => 'Additional charge per hour',
'default' => 0,
},
+ 'recur_included_input' => { 'name' => 'Input megabytes included',
+ 'default' => 0,
+ },
+ 'recur_input_charge' => { 'name' =>
+ 'Additional charge per input megabyte',
+ 'default' => 0,
+ },
+ 'recur_included_output' => { 'name' => 'Output megabytes included',
+ 'default' => 0,
+ },
+ 'recur_output_charge' => { 'name' =>
+ 'Additional charge per output megabyte',
+ 'default' => 0,
+ },
+ 'recur_included_total' => { 'name' =>
+ 'Total input+output megabytes included',
+ 'default' => 0,
+ },
+ 'recur_total_charge' => { 'name' =>
+ 'Additional charge per input+output megabyte',
+ 'default' => 0,
+ },
},
- 'fieldorder' => [ 'setup_fee', 'recur_flat', 'recur_included_hours', 'recur_hourly_charge' ],
+ 'fieldorder' => [qw( setup_fee recur_flat recur_included_hours recur_hourly_charge recur_included_input recur_input_charge recur_included_input recur_output_charge recur_included_total recur_total_charge )],
'setup' => 'what.setup_fee.value',
- 'recur' => '\'my $hours = $cust_pkg->seconds_since_sqlradacct($cust_pkg->last_bill, $sdate ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
+ 'recur' => '\'my $last_bill = $cust_pkg->last_bill; my $hours = $cust_pkg->seconds_since_sqlradacct($last_bill, $sdate ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; my $input = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, "Acct-Input-Octets" ) / 1048576; my $output = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, "Acct-Output-Octets" ) / 1048576; my $total = $input + $output - \' + what.recur_included_total.value + \'; $total = 0 if $total < 0; my $input = $input - \' + what.recur_included_input.value + \'; $input = 0 if $input < 0; my $output = $output - \' + what.recur_included_output.value + \'; $output = 0 if $output < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours + \' + what.recur_input_charge + \' * $input + \' + what.recur_output_charge + \' * $output + \' + what.recur_total_charge + \' * $total ;\'',
},
-
;
my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi
index e86d43f30..7295f577d 100755
--- a/httemplate/view/svc_acct.cgi
+++ b/httemplate/view/svc_acct.cgi
@@ -78,6 +78,13 @@ if ( $part_svc->part_export('sqlradius') ) {
my $m = int( ($seconds%3600) / 60 );
my $s = $seconds%60;
+ my $input = $svc_acct->attribute_since_sqlradacct(
+ $last_bill, time, 'Acct-Input-Octets'
+ ) / 1048576;
+ my $output = $svc_acct->attribute_since_sqlradacct(
+ $last_bill, time, 'Acct-Output-Octets'
+ ) / 1048576;
+
if ( $seconds ) {
print "Online <B>$h</B>h <B>$m</B>m <B>$s</B>s";
} else {
@@ -86,11 +93,16 @@ if ( $part_svc->part_export('sqlradius') ) {
if ( $cust_pkg ) {
print ' this billing cycle (since '. time2str("%C", $last_bill). ') - '.
- $plandata{recur_included_hours}. ' total hours in plan<BR><BR>';
+ $plandata{recur_included_hours}. ' total hours in plan<BR>';
} else {
- print ' (no billing cycle available for unaudited account)<BR><BR>';
+ print ' (no billing cycle available for unaudited account)<BR>';
}
+ print 'Input: <B>'. sprintf("%.3f", $input). ' megabytes<BR>';
+ print 'Output: <B>'. sprintf("%.3f", $output). ' megabytes<BR>';
+
+ print '<BR>';
+
}
#print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!;
@@ -183,7 +195,7 @@ print '<TR><TD ALIGN="right">RADIUS groups</TD><TD BGCOLOR="#ffffff">'.
print '</TABLE></TD></TR></TABLE><BR><BR>';
-print join("\n", $conf->config('svc_acct-notes') ). '<BR><BR>'.
+print join("\n", $conf->config('svc_acct-notes') ). '<BR><BR>'.
joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>';
%>