X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fsqlradius.pm;h=d1387d6366e9d49d0db52688fa32e1b713c58e36;hb=ec2f19b4484371dff04ec4a5313c7b7d2359cca8;hp=5d84f37ec92ee2b6bf14657aa942f4c45a1e2d1c;hpb=d4e7a23cc00ce65a85c824efbaf569199c40299b;p=freeside.git diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm index 5d84f37ec..d1387d636 100644 --- a/FS/FS/part_export/sqlradius.pm +++ b/FS/FS/part_export/sqlradius.pm @@ -4,7 +4,7 @@ use strict; use vars qw(@ISA @EXPORT_OK $DEBUG %info %options $notes1 $notes2); use Exporter; use Tie::IxHash; -use FS::Record qw( dbh qsearch qsearchs str2time_sql ); +use FS::Record qw( dbh qsearch qsearchs str2time_sql str2time_sql_closing ); use FS::part_export; use FS::svc_acct; use FS::export_svc; @@ -48,7 +48,7 @@ tie %options, 'Tie::IxHash', }, 'show_called_station' => { type => 'checkbox', - label => 'Show the Called-Station-ID on session reports', + label => 'Show the Called-Station-ID on session reports', #as a phone number }, 'overlimit_groups' => { label => 'Radius groups to assign to svc_acct which has exceeded its bandwidth or time limit (if not overridden by overlimit_groups global or per-agent config)', @@ -649,6 +649,8 @@ Returns an arrayref of hashrefs with the following fields: =item acctoutputoctets +=item callingstationid + =item calledstationid =back @@ -687,15 +689,16 @@ sub usage_sessions { qw( datasrc username password ) ); #select a unix time conversion function based on database type - my $str2time = str2time_sql( $dbh->{Driver}->{Name} ); + my $str2time = str2time_sql( $dbh->{Driver}->{Name} ); + my $closing = str2time_sql_closing( $dbh->{Driver}->{Name} ); my @fields = ( qw( username realm framedipaddress acctsessiontime acctinputoctets acctoutputoctets - calledstationid + callingstationid calledstationid ), - "$str2time acctstarttime ) as acctstarttime", - "$str2time acctstoptime ) as acctstoptime", + "$str2time acctstarttime $closing as acctstarttime", + "$str2time acctstoptime $closing as acctstoptime", ); @fields = ( 'username', 'sum(acctsessiontime) as acctsessiontime', 'sum(acctinputoctets) as acctinputoctets', @@ -734,12 +737,12 @@ sub usage_sessions { my $acctstoptime = ''; if ( $opt->{session_status} ne 'open' ) { if ( $start ) { - $acctstoptime .= "$str2time AcctStopTime ) >= ?"; + $acctstoptime .= "$str2time AcctStopTime $closing >= ?"; push @param, $start; $acctstoptime .= ' AND ' if $end; } if ( $end ) { - $acctstoptime .= "$str2time AcctStopTime ) <= ?"; + $acctstoptime .= "$str2time AcctStopTime $closing <= ?"; push @param, $end; } } @@ -753,11 +756,11 @@ sub usage_sessions { push @where, $acctstoptime; if ( $opt->{starttime_start} ) { - push @where, "$str2time AcctStartTime ) >= ?"; + push @where, "$str2time AcctStartTime $closing >= ?"; push @param, $opt->{starttime_start}; } if ( $opt->{starttime_end} ) { - push @where, "$str2time AcctStartTime ) <= ?"; + push @where, "$str2time AcctStartTime $closing <= ?"; push @param, $opt->{starttime_end}; } @@ -796,7 +799,9 @@ sub update_svc { my $dbh = sqlradius_connect( map $self->option($_), qw( datasrc username password ) ); - my $str2time = str2time_sql( $dbh->{Driver}->{Name} ); + my $str2time = str2time_sql( $dbh->{Driver}->{Name} ); + my $closing = str2time_sql_closing( $dbh->{Driver}->{Name} ); + my @fields = qw( radacctid username realm acctsessiontime ); my @param = (); @@ -804,7 +809,7 @@ sub update_svc { my $sth = $dbh->prepare(" SELECT RadAcctId, UserName, Realm, AcctSessionTime, - $str2time AcctStartTime), $str2time AcctStopTime), + $str2time AcctStartTime $closing, $str2time AcctStopTime $closing, AcctInputOctets, AcctOutputOctets FROM radacct WHERE FreesideStatus IS NULL