X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fcdr-netsapiens.import;fp=bin%2Fcdr-netsapiens.import;h=649ade62b8d4efef7c23f40c9715b4fd9aa4eccc;hp=80922556aaa57b415db9708bc35a3609a8b148e0;hb=4637ede67752c7fc635bfb0c78c40458af218a72;hpb=87b5a2f15b23247a68fd29f8c0fb5cd81ab406ba diff --git a/bin/cdr-netsapiens.import b/bin/cdr-netsapiens.import index 80922556a..649ade62b 100755 --- a/bin/cdr-netsapiens.import +++ b/bin/cdr-netsapiens.import @@ -4,8 +4,9 @@ use strict; use vars qw( $DEBUG ); +use Date::Format; use REST::Client; -use FS::UID qw(adminsuidsetup); +use FS::UID qw(adminsuidsetup dbh); use FS::Record qw(qsearchs); use FS::part_export; use FS::cdr; @@ -19,56 +20,69 @@ my $exportnum = shift or die &usage; my $part_export = qsearchs('part_export', { 'exportnum' => $exportnum } ) or die "unknown exportnum $exportnum\n"; -#find max time_release -#SELECT MAX( -#2009-02-19 20:17:37 -my $time_release = '2009-01-01 00:00:00'; +my $cdrs = 0; -#retreive CDRs >= this time -#XXX (in pages, this tops out at 20) _start=>0, _limit=>20 +do { -my $ns = $part_export->ns_command( 'GET', '/cdr/', - 'time_release' => '$time_release,', - '_sort' => '+time_release', - ); + #find max time_release + my $sth = dbh->prepare('SELECT MAX(enddate) FROM cdr') #XXX and imported from this netsapens switch + or die dbh->errstr; -#loop over them, double check duplicates, insert the rest + $sth->execute or die $sth->errstr; + my $time_relase = time2str('%Y-%m-%d %x', $sth->fetchrow_arrayref->[0]); + #2009-02-19 20:17:37 + #my $time_release = '2009-01-01 00:00:00'; -my $content = $ns->responseContent; + #retreive CDRs >= this time -#20090219201719000016@SkyNet360.Com -#