X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-cdr-portaone-import;h=dfd130bbb1c518011d1175eb59bf6d33ebdf49c5;hp=9a02a72593b179dc5896da978196df114dfacdef;hb=772656864b377bbd2ef2febd40891ef1206b5be0;hpb=4350b9742f567ac32089d57df42e08339f944a66 diff --git a/FS/bin/freeside-cdr-portaone-import b/FS/bin/freeside-cdr-portaone-import old mode 100644 new mode 100755 index 9a02a7259..dfd130bbb --- a/FS/bin/freeside-cdr-portaone-import +++ b/FS/bin/freeside-cdr-portaone-import @@ -5,7 +5,7 @@ use strict; use Date::Format 'time2str'; use Date::Parse 'str2time'; use Getopt::Long; -use JSON; +use Cpanel::JSON::XS; use Net::HTTPS::Any qw(https_post); use Time::Local; @@ -16,12 +16,14 @@ use FS::cdr_batch; sub usage { "Usage: +freeside-cdr-portaone-import -x exportnum [-s startdate] [-e enddate] [-v] freesideuser + freeside-cdr-portaone-import -h 'your.domain.com:443' -u switchusername -p switchpass [-s startdate] [-e enddate] [-v] freesideuser "; } -my ($host,$username,$password,$startdate,$enddate,$verbose); +my ($host,$username,$password,$startdate,$enddate,$verbose,$exportnum); GetOptions( "enddate=s" => \$enddate, "host=s" => \$host, @@ -29,11 +31,12 @@ GetOptions( "startdate=s" => \$startdate, "username=s" => \$username, "verbose" => \$verbose, + "x=s" => \$exportnum, ); my $fsuser = $ARGV[-1]; -die usage() unless $host && $password && $username && $fsuser; +die usage() unless $fsuser; adminsuidsetup($fsuser); @@ -43,6 +46,19 @@ if ($host =~ /^(.*)\:(.*)$/) { $port = $2; } +if ($exportnum) { + my $export = qsearchs('part_export', { 'exportnum' => $exportnum }); + die "Export not found" unless $export; + $host = $export->machine; + $port = $export->option('port'); + $username = $export->option('username'); + $password = $export->option('password'); + die "Auth info not fully specified in export" + unless $host && $port && $username && $password; +} + +die usage() unless $host && $password && $username; + if ($startdate) { $startdate = str2time($startdate) or die "Can't parse startdate $startdate"; $startdate = time2str("%Y-%m-%d %H:%M:%S",$startdate); @@ -53,7 +69,7 @@ unless ($startdate) { 'hashref' => { 'cdrbatch' => {op=>'like', value=>'portaone-import%'}}, 'order_by' => 'ORDER BY _date DESC LIMIT 1', }); - $startdate = time2str("%Y-%m-%d %H:%M:%S", $lastbatch->_date + 1) if $lastbatch; + $startdate = time2str("%Y-%m-%d %H:%M:%S", $lastbatch->_date) if $lastbatch; } $startdate ||= '2010-01-01 00:00:00'; #seems decently in the past