summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cdr.pm44
-rw-r--r--httemplate/misc/cdr.cgi5
2 files changed, 45 insertions, 4 deletions
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;