use FS::Record qw(qsearch dbh);
use FS::part_export;
use FS::phone_avail;
+use Data::Dumper;
@ISA = qw(FS::part_export);
if ( $search->{'statuscode'} == 302200 ) {
return [];
} elsif ( $search->{'statuscode'} != 100 ) {
- my $error = "Error running VoIP Innovations getDIDs: ".
- $search->{'statuscode'}. ': '. $search->{'status'}. "\n";
+
+ my $error = "Error running VoIP Innovations getDIDs: ";
+ if ( $search->{'statuscode'} || $search->{'status'} ) {
+ $error .= $search->{'statuscode'}. ': '. $search->{'status'}. "\n";
+ } else {
+ $error .= Dumper($search);
+ }
warn $error;
die $error;
}
if ( $opt{'svcpart'} ) {
- my $sth = dbh->prepare(
- 'SELECT DISTINCT state FROM phone_avail WHERE svcnum IS NULL'
- ) or die dbh->errstr;
- $sth->execute or die $sth->errstr;
- my %avail_states = map { $_->[0] => 1 } @{ $sth->fetchall_arrayref };
-
- if ( %avail_states ) {
- delete $states{$_} foreach grep ! $avail_states{$_}, keys %states;
+ my $part_svc = qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} } );
+ if ( $part_svc && $part_svc->exporttype eq 'internal_diddb' ) {
+
+ my $sth = dbh->prepare(
+ 'SELECT DISTINCT state FROM phone_avail WHERE svcnum IS NULL'
+ ) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ my %avail_states = map { $_->[0] => 1 } @{ $sth->fetchall_arrayref };
+
+ if ( %avail_states ) {
+ delete $states{$_} foreach grep ! $avail_states{$_}, keys %states;
+ }
+
}
}