From: levinse Date: Mon, 24 Jan 2011 23:06:49 +0000 (+0000) Subject: CDR reprocess with termination, RT8763 X-Git-Tag: freeside_2_3_0~695 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=c6815d4041610785099c820df097326a70c8ce41 CDR reprocess with termination, RT8763 --- diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index f7402eead..478dcff6b 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -678,6 +678,50 @@ sub invoice_header { $export_names{$format}->{'invoice_header'}; } +=item clear_status + +Clears cdr and any associated cdr_termination statuses - used for +CDR reprocessing. + +=cut + +sub clear_status { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + $self->freesidestatus(''); + my $error = $self->replace; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + my @cdr_termination = qsearch('cdr_termination', + { 'acctid' => $self->acctid } ); + foreach my $cdr_termination ( @cdr_termination ) { + $cdr_termination->status(''); + $error = $cdr_termination->replace; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; +} + =item import_formats Returns an ordered list of key value pairs containing import format names diff --git a/httemplate/misc/cdr.cgi b/httemplate/misc/cdr.cgi index d2ee77364..a344e509f 100644 --- a/httemplate/misc/cdr.cgi +++ b/httemplate/misc/cdr.cgi @@ -33,10 +33,7 @@ if ( $action eq 'new' ) { ) { my $cdr = qsearchs('cdr', { 'acctid' => $acctid }); if ( $action eq 'reprocess selected' && $cdr ) { #new - my %hash = $cdr->hash; - $hash{'freesidestatus'} = ''; - my $new = new FS::cdr \%hash; - my $error = $new->replace($cdr); + my $error = $cdr->clear_status; die $error if $error; } elsif ( $action eq 'delete selected' && $cdr ) { #del my $error = $cdr->delete;