X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Finventory_item.pm;h=3bba1cdda3270b960b3aa20f1380a648fc8360e9;hp=23bacf040d85f0e9738ad6246506fc1045803be0;hb=ad7f49821d40ffd099a45acc32ba91e0e211aede;hpb=6d2cd8e6fc566b4fccd0075156e3e1ddd59fa042 diff --git a/FS/FS/inventory_item.pm b/FS/FS/inventory_item.pm index 23bacf040..3bba1cdda 100644 --- a/FS/FS/inventory_item.pm +++ b/FS/FS/inventory_item.pm @@ -3,10 +3,11 @@ package FS::inventory_item; use strict; use vars qw( @ISA ); use FS::Record qw( dbh qsearch qsearchs ); +use FS::cust_main_Mixin; use FS::inventory_class; use FS::cust_svc; -@ISA = qw(FS::Record); +@ISA = qw( FS::cust_main_Mixin FS::Record ); =head1 NAME @@ -128,61 +129,25 @@ sub cust_svc { =back -=head1 CLASS METHODS +=head1 SUBROUTINES =over 4 -=item batch_import +=item process_batch_import =cut -sub batch_import { - my $param = shift; +sub process_batch_import { + my $job = shift; - my $fh = $param->{filehandle}; + my $opt = { 'table' => 'inventory_item', + #'params' => [ 'itembatch', 'classnum', ], + 'params' => [ 'classnum', ], + 'formats' => { 'default' => [ 'item' ] }, + 'default_csv' => 1, + }; - my $imported = 0; - - 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; - - my $line; - while ( defined($line=<$fh>) ) { - - chomp $line; - - my $inventory_item = new FS::inventory_item { - 'classnum' => $param->{'classnum'}, - 'item' => $line, - }; - - my $error = $inventory_item->insert; - - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error; - - #or just skip? - #next; - } - - $imported++; - } - - $dbh->commit or die $dbh->errstr if $oldAutoCommit; - - #might want to disable this if we skip records for any reason... - return "Empty file!" unless $imported; - - ''; + FS::Record::process_batch_import( $job, $opt, @_ ); }