use vars qw( @ISA );
use FS::UID qw(dbh);
use FS::Record qw( qsearch qsearchs );
+use FS::Misc qw( csv_from_fixed );
@ISA = qw(FS::Record);
my $imported = 0;
my $dbh = dbh;
+ my @column_lengths = ();
+ my @column_callbacks = ();
+ if ( $format eq 'cch-fixed' || $format eq 'cch-fixed-update' ) {
+ $format =~ s/-fixed//;
+ push @column_lengths, qw( 8 10 3 2 2 10 100 );
+ push @column_lengths, 1 if $format eq 'cch-update';
+ }
+
my $line;
my ( $count, $last, $min_sec ) = (0, time, 5); #progressbar
- if ( $job ) {
- $count++
- while ( defined($line=<$fh>) );
- seek $fh, 0, 0;
+ if ( $job || scalar(@column_lengths) ) {
+ my $error = csv_from_fixed(\$fh, \$count, \@column_lengths);
+ return $error if $error;
}
if ( $format eq 'cch' || $format eq 'cch-update' ) {
- @fields = qw( table name pos number length value description );
+ @fields = qw( table name pos length number value description );
push @fields, 'actionflag' if $format eq 'cch-update';
$hook = sub {
}
delete($hash->{$_})
- for qw( data_vendor table name pos number length value description );
+ for qw( data_vendor table name pos length number value description );
delete($hash->{actionflag}) if exists($hash->{actionflag});
'';
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return "Empty File!" unless $imported;
+ return "Empty File!" unless ($imported || $format eq 'cch-update');
''; #no error