X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Faradial-sftp_and_import;h=668ec49ba18ad0e99b3cb31c94ffbf7df3a14a0b;hp=b0878e277825f9882f9a93502e20f5ccaa79a299;hb=88e9a56677d343392416c262f976f069157b06cb;hpb=abb2295df3d5a81ed6482b1e18f82bf454d242e5 diff --git a/bin/aradial-sftp_and_import b/bin/aradial-sftp_and_import index b0878e277..668ec49ba 100755 --- a/bin/aradial-sftp_and_import +++ b/bin/aradial-sftp_and_import @@ -4,6 +4,7 @@ use strict; use Getopt::Std; +use Date::Parse; use Date::Format; use Text::CSV_XS; use DBI qw( :sql_types ); @@ -65,7 +66,7 @@ our %status_type = ( ### use vars qw( $opt_m $opt_a $opt_b $opt_r $opt_d $opt_v $opt_P ); -getopts('m:abr:dP:v:'); +getopts('m:abr:d:P:v:'); my %options = (); @@ -127,6 +128,8 @@ else { foreach my $filename ( @$ls ) { + next if $opt_d && $filename eq $opt_d; + warn "Downloading $filename\n" if $opt_v; #get the file @@ -160,6 +163,8 @@ foreach my $filename ( @$ls ) { #skip blank records next unless grep defined($_), values %dbhash; + my $date = time2str( '%Y-%m-%d %X', str2time( $hash{'Date'} ) ); + $hash{'Status-Type'} = $status_type{ $hash{'Status-Type'} } if exists $status_type{ $hash{'Status-Type'} }; @@ -167,7 +172,8 @@ foreach my $filename ( @$ls ) { my @extra_values = (); if ( $hash{'Status-Type'} eq 'Start' ) { - $dbhash{'AcctStartTime'} = $hash{'Date'}; + push @keys, 'AcctStartTime'; + $dbhash{'AcctStartTime'} = $date; $sql = 'INSERT INTO radacct ( '. join(',', @keys). ' ) VALUES ( '. join(',', map ' ? ', @keys ). ' )'; @@ -175,7 +181,9 @@ foreach my $filename ( @$ls ) { } elsif ( $hash{'Status-Type'} eq 'Stop' ) { my $AcctSessionId = delete($dbhash{AcctSessionId}); - $dbhash{'AcctStopTime'} = $hash{'Date'}; + + push @keys, 'AcctStopTime'; + $dbhash{'AcctStopTime'} = $date; push @extra_values, $AcctSessionId;