4 # cdr.reimport user format filename
8 use FS::UID qw(adminsuidsetup);
9 use FS::Record qw(qsearch);
12 my $user = shift or die &usage;
15 my $format = shift or die &usage;
19 my($new, $rep, $skip) = (0, 0, 0);
21 #this is what makes it a reimport and should probably be moved to cdr.pm
23 my($cdr, $param) = @_;
25 my @exists = qsearch({
27 'hashref' => { 'uniqueid' => $cdr->uniqueid,
29 'startdate' => $cdr->startdate,
33 unless ( scalar(@exists) ) {
37 die "too many matches found!" if scalar(@exists) > 1;
39 my $exists = $exists[0];
40 if ( $exists->freesidestatus ) {
42 $param->{skiprow} = 1;
45 my $error = $exists->delete;
51 my $error = FS::cdr::batch_import( {
54 'batch_namevalue' => $file,
55 'preinsert_callback' => $cb,
59 warn "$skip skipped, $rep replaced, $new new\n";
62 "Usage: \n cdr.reimport user format filename\n";