X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Faradial-sftp_and_import;h=e7639633a0f83381a0d3771024956bb92a8279a3;hp=53357033c78b24057ee1669e6607412c3fa4a8aa;hb=5f0388ca15d79d964b1c6197d0841d8f5c708d15;hpb=cbcd29b65e7899f487e962a301435a32dba001e2 diff --git a/bin/aradial-sftp_and_import b/bin/aradial-sftp_and_import index 53357033c..e7639633a 100755 --- a/bin/aradial-sftp_and_import +++ b/bin/aradial-sftp_and_import @@ -4,9 +4,11 @@ use strict; use Getopt::Std; +use Date::Parse; use Date::Format; use Text::CSV_XS; use DBI qw( :sql_types ); +use FS::DBI; use Net::SFTP::Foreign; #use FS::UID qw( adminsuidsetup datasrc ); @@ -80,8 +82,8 @@ mkdir $cachedir unless -d $cachedir; my $servername = shift or die &usage; my( $datasrc, $db_user, $db_pass ) = ( shift, shift, shift ); -my $dbh = DBI->connect( $datasrc, $db_user, $db_pass) - or die "can't connect: $DBI::errstr\n"; +my $dbh = FS::DBI->connect( $datasrc, $db_user, $db_pass) + or die "can't connect: $FS::DBI::errstr\n"; my $csv = Text::CSV_XS->new; @@ -162,6 +164,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'} }; @@ -170,7 +174,7 @@ foreach my $filename ( @$ls ) { if ( $hash{'Status-Type'} eq 'Start' ) { push @keys, 'AcctStartTime'; - $dbhash{'AcctStartTime'} = $hash{'Date'}; + $dbhash{'AcctStartTime'} = $date; $sql = 'INSERT INTO radacct ( '. join(',', @keys). ' ) VALUES ( '. join(',', map ' ? ', @keys ). ' )'; @@ -180,7 +184,7 @@ foreach my $filename ( @$ls ) { my $AcctSessionId = delete($dbhash{AcctSessionId}); push @keys, 'AcctStopTime'; - $dbhash{'AcctStopTime'} = $hash{'Date'}; + $dbhash{'AcctStopTime'} = $date; push @extra_values, $AcctSessionId;