X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fcdr-voipnow.import;h=c16b00d7c89fd7f5718d76c4fd045a1c705ad590;hp=d9dbd0013e531b85d5f7aa7f034cd8a2ca816de4;hb=f715c23517292a11330ab241fb13221fd89ffc37;hpb=c1cb6d9a3b98cdd6c9066677a87ec9162008c9cf diff --git a/bin/cdr-voipnow.import b/bin/cdr-voipnow.import index d9dbd0013..c16b00d7c 100755 --- a/bin/cdr-voipnow.import +++ b/bin/cdr-voipnow.import @@ -45,7 +45,8 @@ print "Selecting CDRs from $start_id to ".($end_id || 'end')."...\n"; my $table = $opt{T} || 'call_history'; # spelled "disposion" in the table my @cols = ( qw( - id extension_number flow channel partyid start answer duration disposion) ); + id extension_number flow channel partyid start answer duration disposion did + client_client_id ) ); my $sql = 'SELECT '.join(',', @cols). " FROM $table WHERE id >= $start_id"; $sql .= " AND id <= $end_id" if $end_id; $sql .= " ORDER BY id"; @@ -80,18 +81,16 @@ while ( $row = $sth->fetchrow_hashref ) { startdate => str2time($row->{start}), answerdate => str2time($row->{answer}), cdrbatchnum => $cdrbatchnum, + accountcode => $row->{client_client_id}, } ); print $row->{id},"\n" if $opt{v}; - # Since we're finding these records by ID range instead of flagging them - # individually, we can't leave gaps. So rollback and die on any errors - # except for duplicate cdrid. if ( $row->{flow} eq 'out' ) { $cdr->src($row->{'extension_number'}); $cdr->dst($row->{'partyid'}); } elsif ( $row->{flow} eq 'in' ) { - $cdr->dst($row->{'extension_number'}); + $cdr->dst($row->{'did'}); $cdr->src($row->{'partyid'}); } else { @@ -114,6 +113,41 @@ print "Skipped $skipped duplicates.\n" if $skipped; $mysql->disconnect; sub usage { - "Usage: \n cdr-mysql.import\n\t[ -v ]\n\t[ -H host ]\n\t-D database\n\t-U user\n\t-P password\n\tfreesideuser\n"; + "Usage: \n cdr-voipnow.import\n\t[ -H host ]\n\t-D database\n\t-U user\n\t-P password\n\t[ -v ] [ -s start ] [ -e end ]\n\tfreesideuser\n"; } +=head1 NAME + +cdr-voipnow.import - Import call data records (CDRs) from a 4psa VoipNow system + +=head1 SYNOPSIS + + cdr-voipnow.import [ -H host ] -D database -U user -P password + [ -v ] [ -s start ] [ -e end ] freesideuser + +=head1 DESCRIPTION + +Connects to a MySQL database and downloads CDRs from the "call_history" table. +The "id" field maps to "cdrid" in Freeside. Other than that, the following +fields are imported: channel, duration, billsec, startdate, answerdate, +disposition, src, dst. src and dst are inferred from the "extension_number" +and "partyid" fields, with the value of the "flow" field (in or out) deciding +which is the source number and which is the destination. + +Any import errors (except duplicates) will abort and roll back the +transaction. + +=head1 OPTIONS + +-H, -D, -U, -P: parameters to connect to the database: host, database name +user, password. Required, except -H, which defaults to localhost. + +-s: set the lowest CDR id to import. By default, the script will find +the highest existing cdrid and import all CDRs with ids greater than that. +-s overrides this and turns on duplicate checking. + +-e: set the highest CDR id to import. By default, this is unlimited. + +-v: report all CDR ids as they are imported. + +=cut