summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-03-20 10:30:56 -0700
committerIvan Kohler <ivan@freeside.biz>2017-03-20 10:30:56 -0700
commitb285918ec3ab6c8203e9f8feaf234da306456e5e (patch)
treeeb5d011dbde2e48c94095b04d075abd526018607 /FS/bin
parenta3c0a53cf10a8e2e905710776bd10dfc261c2dfd (diff)
asterisk v12 CDRs, RT#71704
Diffstat (limited to 'FS/bin')
-rwxr-xr-xFS/bin/freeside-cdr-asterisk_sql31
1 files changed, 19 insertions, 12 deletions
diff --git a/FS/bin/freeside-cdr-asterisk_sql b/FS/bin/freeside-cdr-asterisk_sql
index b0f202007..6e63ff008 100755
--- a/FS/bin/freeside-cdr-asterisk_sql
+++ b/FS/bin/freeside-cdr-asterisk_sql
@@ -43,8 +43,8 @@ if ( $engine =~ /^mysql/ ) {
}
my @cols = ();
-if ( $opt{V} > 12 ) {
- push @cols, qw( start answer end );
+if ( $opt{V} >= 12 ) {
+ push @cols, qw( id start answer end );
} else {
push @cols, qw( calldate );
}
@@ -85,11 +85,12 @@ while ( my $row = $sth->fetchrow_hashref ) {
my $cdr = FS::cdr->new($row);
- if ( $opt{V} > 12 ) {
+ if ( $opt{V} >= 12 ) {
$cdr->calldate($cdr->start);
$cdr->startdate(str2time($cdr->start));
$cdr->answerdate(str2time($cdr->answer));
$cdr->enddate(str2time($cdr->end));
+ $cdr->cdrid($cdr->id);
} else {
$cdr->startdate(str2time($cdr->calldate));
}
@@ -100,19 +101,25 @@ while ( my $row = $sth->fetchrow_hashref ) {
if ($error) {
warn "failed import: $error\n";
} else {
+
$imports++;
- if( $dbi->do("UPDATE cdr SET freesidestatus = 'done'
- WHERE calldate = ? AND src = ? AND dst = ?",
- undef,
- $row->{'calldate'},
- $row->{'src'},
- $row->{'dst'},
-
- ) ) {
- $updates++;
+
+ my $where = '';
+ my @args = ();
+ if ( $opt{V} >= 12 ) {
+ $where = 'id = '. $row->{'id'};
+ @args = ( undef );
+ } else {
+ $where = 'calldate = ? AND src = ? AND dst = ?';
+ @args = ( undef, $row->{'calldate'}, $row->{'src'}, $row->{'dst'}, );
+ }
+
+ if ( $dbi->do("UPDATE $table SET freesidestatus = 'done' $where", @args) ) {
+ $updates++;
} else {
warn "failed to set status: ".$dbi->errstr."\n";
}
+
}
}