X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fpart_export%2Fsqlradius.pm;fp=FS%2FFS%2Fpart_export%2Fsqlradius.pm;h=db66c39c0ca67839bec6c1f1d361297724b377d5;hb=6bf3df8177a22d2275b1a68045ab5ff2e831af42;hp=18ee3048828ffe78e48e413a272dd5b10b850b5b;hpb=c3d0d1fba9dfc9988f148cbf7bd07de33d5025d8;p=freeside.git diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm index 18ee30488..db66c39c0 100644 --- a/FS/FS/part_export/sqlradius.pm +++ b/FS/FS/part_export/sqlradius.pm @@ -597,7 +597,8 @@ New-style: pass a hashref with the following keys: =item stoptime_end - Upper bound for AcctStopTime, as a UNIX timestamp -=item open_sessions - Only show records with no AcctStopTime (typically used without stoptime_* options and with starttime_* options instead) +=item session_status - 'closed' to only show records with AcctStopTime, +'open' to only show records I AcctStopTime, empty to show both. =item starttime_start - Lower bound for AcctStartTime, as a UNIX timestamp @@ -727,20 +728,23 @@ sub usage_sessions { push @where, " CalledStationID LIKE 'sip:$prefix\%'"; } - if ( $opt->{open_sessions} ) { - push @where, 'AcctStopTime IS NULL'; - } else { - + my $acctstoptime = ''; + if ( $opt->{session_status} ne 'open' ) { if ( $start ) { - push @where, "$str2time AcctStopTime ) >= ?"; + $acctstoptime .= "$str2time AcctStopTime ) >= ?"; push @param, $start; + $acctstoptime .= ' AND ' if $end; } if ( $end ) { - push @where, "$str2time AcctStopTime ) <= ?"; + $acctstoptime .= "$str2time AcctStopTime ) <= ?"; push @param, $end; } - } + if ( $opt->{session_status} ne 'closed' ) { + $acctstoptime = "( $acctstoptime ) OR " if $acctstoptime; + $acctstoptime .= 'AcctStopTime IS NULL'; + } + push @where, $acctstoptime; if ( $opt->{starttime_start} ) { push @where, "$str2time AcctStartTime ) >= ?";