diff options
author | ivan <ivan> | 2011-05-01 19:27:54 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-05-01 19:27:54 +0000 |
commit | 0a4f210f52ba4ac3f6028dbf20fc047351177cf6 (patch) | |
tree | ccc7ffff95ca9d62683ccf187738f48daef0fb92 /FS | |
parent | 290b6572856ba472cc7f459d8a84bde92819f2b8 (diff) |
cdr reimporting, RT#12181
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Record.pm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index eccabbb7c..1280f08d6 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1630,6 +1630,8 @@ Class method for batch imports. Available params: =item fields - Alternate way to specify import, specifying import fields directly as a listref +=item preinsert_callback + =item postinsert_callback =item params @@ -1664,9 +1666,14 @@ sub batch_import { my( $type, $header, $sep_char, $fixedlength_format, $xml_format, $row_callback, @fields ); + my $postinsert_callback = ''; $postinsert_callback = $param->{'postinsert_callback'} if $param->{'postinsert_callback'}; + my $preinsert_callback = ''; + $preinsert_callback = $param->{'preinsert_callback'} + if $param->{'preinsert_callback'}; + if ( $param->{'format'} ) { my $format = $param->{'format'}; @@ -1914,6 +1921,16 @@ sub batch_import { } next if exists( $param->{skiprow} ); + if ( $preinsert_callback ) { + my $error = &{$postinsert_callback}($record, $param); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "preinsert_callback error". ( $line ? " for $line" : '' ). + ": $error"; + } + next if exists $param->{skiprow} && $param->{skiprow}; + } + my $error = $record->insert; if ( $error ) { |